@@ -12,33 +12,30 @@ var angular = window.angular,
12
12
// quit if angular isn't on the page
13
13
if ( ! ( angular && Raven ) ) return ;
14
14
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
+ }
28
21
29
- if ( RavenConfig . debug !== void 0 ) {
30
- Raven . debug = RavenConfig . debug ;
22
+ function ExceptionHandlerProvider ( $provide ) {
23
+ $provide . decorator ( '$exceptionHandler' ,
24
+ [ 'Raven' , '$delegate' , exceptionHandler ] ) ;
31
25
}
32
26
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
+ }
39
35
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
+ } ) ;
43
40
44
41
} ( typeof window !== 'undefined' ? window : this ) ) ;
0 commit comments