minmin
minmin

Reputation: 53

How to send JavaScript errors to sentry?

I'm trying to send all JavaScript's errors to Sentry.

I read Sentry's Installation docs(https://docs.sentry.io/clients/javascript/install/) and chose So for example:

<script src="jquery.js"></script>
<script src="https://cdn.ravenjs.com/3.17.0/raven.min.js" crossorigin="anonymous"></script>
<script>Raven.config('https://[code]@sentry.io/[code]').install();</script>
<script src="app.js"></script>

I checked that raven.js was loaded and overwrided window.onerror.

error log in Google Chrome Console raven js code

I could send notifications if I use Manually Reporting Errors like this.

try {
  doSomething(a[0])
} catch(e) {
  Raven.captureException(e)
}

But I couldn't capture any uncaught exception if I don't use Manually Reporting Errors.

What should I do? Thanks!

Upvotes: 0

Views: 4232

Answers (1)

Matt
Matt

Reputation: 4117

You need to give Sentry a context within which to work. Otherwise it wont know where to look.

Take a look at the top of the docs here: https://docs.sentry.io/clients/node/usage/

So wrap the code in a sentry context and you should be good to go.

Upvotes: 1

Related Questions