2
0
forked from Wavyzz/dolibarr

New Added client-side Sentry logging

Using Raven.js allows logging client-side javascript errors to the
configured Sentry server.
This commit is contained in:
Raphaël Doursenaud
2015-08-31 17:21:03 +02:00
parent 7ef5cbfb96
commit a6ef289470
47 changed files with 7872 additions and 9 deletions

View File

@@ -0,0 +1,36 @@
/**
* Angular.js plugin
*
* Provides an $exceptionHandler for Angular.js
*/
;(function(Raven, angular) {
'use strict';
// quit if angular isn't on the page
if (!angular) {
return;
}
function ngRavenProvider($provide) {
$provide.decorator('$exceptionHandler', [
'RavenConfig', '$delegate',
ngRavenExceptionHandler
]);
}
function ngRavenExceptionHandler(RavenConfig, $delegate) {
if (!RavenConfig)
throw new Error('RavenConfig must be set before using this');
Raven.config(RavenConfig.dsn, RavenConfig.config).install();
return function angularExceptionHandler(ex, cause) {
$delegate(ex, cause);
Raven.captureException(ex, {extra: {cause: cause}});
};
}
angular.module('ngRaven', [])
.config(['$provide', ngRavenProvider])
.value('Raven', Raven);
})(window.Raven, window.angular);