Skip to content

Commit 11f9d67

Browse files
committed
Fix angular plugin
1 parent d2ab38b commit 11f9d67

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

plugins/angular.js

+21-24
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,30 @@ var angular = window.angular,
1212
// quit if angular isn't on the page
1313
if (!(angular && Raven)) return;
1414

15-
// Angular plugin doesn't go through the normal `Raven.addPlugin`
16-
// since this bootstraps the `install()` automatically.
17-
18-
function ngRavenProvider($provide) {
19-
$provide.decorator('$exceptionHandler', [
20-
'RavenConfig', '$delegate',
21-
ngRavenExceptionHandler
22-
]);
23-
}
24-
25-
function ngRavenExceptionHandler(RavenConfig, $delegate) {
26-
if (!RavenConfig)
27-
throw new Error('RavenConfig must be set before using this');
15+
Raven.addPlugin(function () {
16+
function RavenProvider() {
17+
this.$get = ['$window', function($window, $log) {
18+
return $window.Raven;
19+
}];
20+
}
2821

29-
if (RavenConfig.debug !== void 0) {
30-
Raven.debug = RavenConfig.debug;
22+
function ExceptionHandlerProvider($provide) {
23+
$provide.decorator('$exceptionHandler',
24+
['Raven', '$delegate', exceptionHandler]);
3125
}
3226

33-
Raven.config(RavenConfig.dsn, RavenConfig.config).install();
34-
return function angularExceptionHandler(ex, cause) {
35-
$delegate(ex, cause);
36-
Raven.captureException(ex, {extra: {cause: cause}});
37-
};
38-
}
27+
function exceptionHandler(Raven, $delegate) {
28+
return function (ex, cause) {
29+
Raven.captureException(ex, {
30+
extra: { cause: cause }
31+
});
32+
$delegate(ex, cause);
33+
};
34+
}
3935

40-
angular.module('ngRaven', [])
41-
.config(['$provide', ngRavenProvider])
42-
.value('Raven', Raven);
36+
angular.module('ngRaven', [])
37+
.provider('Raven', RavenProvider)
38+
.config(['$provide', ExceptionHandlerProvider]);
39+
});
4340

4441
}(typeof window !== 'undefined' ? window : this));

0 commit comments

Comments
 (0)