Last active
November 16, 2015 04:25
-
-
Save jico/e4d14ae301ed93132823 to your computer and use it in GitHub Desktop.
Raven JS integration. https://medium.com/@jico/the-fine-art-of-javascript-error-tracking-bc031f24c659
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Log Angular exceptions to Sentry | |
$provide.decorator('$exceptionHandler', function($delegate) { | |
return function(exception, cause) { | |
$delegate(exception, cause); | |
Raven.captureException(exception, { | |
extra: { | |
cause: cause, | |
member_email: member.email | |
} | |
}); | |
} | |
}); | |
// Log HTTP response errors to Sentry | |
$provide.factory('ravenHttpInterceptor', function($q) { | |
return { | |
responseError: function(rejection) { | |
var err = new Error('HTTP response error'); | |
Raven.captureException(err, { | |
extra: { | |
config: rejection.config, | |
status: rejection.status, | |
data: rejection.data, | |
member_email: member.email | |
} | |
}); | |
$q.reject(rejection); | |
} | |
} | |
}); | |
$httpProvider.interceptors.push('ravenHttpInterceptor'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment