Sentry and JQuery's .on

I’m using Sentry for the Javascript frontend (require + Backbone) of a large project. I noticed that Raven doesn’t seem to pick up errors caused by callbacks. I’ve mostly experimented with .on, but chances are it affects our JQuery XHR calls and other things too. Here’s a JSFiddle that shows what’s going on:

What’s the best way for me to get Raven to pick up errors that are the results of functions called by Jquery event callbacks? I’d really rather not go throughout my entire code base and surround every callback with Raven.context if I can help it.


Hey @JoeDuncko, you have to call .install in order for global handlers to be attached.
You can verify that by adding this snipped at the top of your script tag and seeing console logs.

Raven.config('', {
  dataCallback: function (data) {
    return data
  shouldSendCallback: function () {
    return false

Whoah, totally missed that! But that ended up not being my problem - while I neglected to run ‘.install()’ in my example, in my actual code base it was running.

Turns out that our issue was caused by us running jquery 1.12.4. You can see in the following example that when we have an ajax call that has errors in its callbacks, those errors aren’t caught by raven:

But when we run jquery 3.3.1 errors in ajax callbacks are caught just fine:

So that solves that!