1
1
angular . module ( 'exceptionless' , [ ] )
2
- . constant ( 'ExceptionlessClient' , Exceptionless . ExceptionlessClient . default )
2
+ . constant ( '$ ExceptionlessClient' , Exceptionless . ExceptionlessClient . default )
3
3
. factory ( 'exceptionlessHttpInterceptor' , [ '$q' , 'ExceptionlessClient' , function ( $q , ExceptionlessClient ) {
4
4
return {
5
5
responseError : function responseError ( rejection ) {
@@ -11,14 +11,12 @@ angular.module('exceptionless', [])
11
11
. setProperty ( 'config' , rejection . config )
12
12
. submit ( ) ;
13
13
}
14
-
15
14
return $q . reject ( rejection ) ;
16
15
}
17
16
} ;
18
17
} ] )
19
- . config ( [ '$httpProvider' , '$provide' , 'ExceptionlessClient' , function ( $httpProvider , $provide , ExceptionlessClient ) {
18
+ . config ( [ '$httpProvider' , '$provide' , 'ExceptionlessClient' , function ( $httpProvider , $provide , ExceptionlessClient ) {
20
19
$httpProvider . interceptors . push ( 'exceptionlessHttpInterceptor' ) ;
21
-
22
20
$provide . decorator ( '$exceptionHandler' , [ '$delegate' , function ( $delegate ) {
23
21
return function ( exception , cause ) {
24
22
$delegate ( exception , cause ) ;
@@ -28,19 +26,67 @@ angular.module('exceptionless', [])
28
26
$provide . decorator ( '$log' , [ '$delegate' , function ( $delegate ) {
29
27
function decorateRegularCall ( property , logLevel ) {
30
28
var previousFn = $delegate [ property ] ;
31
- $delegate [ property ] = function ( ) {
29
+ return $delegate [ property ] = function ( ) {
32
30
previousFn . call ( null , arguments ) ;
33
31
ExceptionlessClient . submitLog ( 'Angular' , arguments [ 0 ] , logLevel ) ;
34
32
} ;
35
33
}
36
-
37
34
$delegate . log = decorateRegularCall ( 'log' , 'Trace' ) ;
38
35
$delegate . info = decorateRegularCall ( 'info' , 'Info' ) ;
39
36
$delegate . warn = decorateRegularCall ( 'warn' , 'Warn' ) ;
40
37
$delegate . debug = decorateRegularCall ( 'debug' , 'Debug' ) ;
41
38
$delegate . error = decorateRegularCall ( 'error' , 'Error' ) ;
42
39
return $delegate ;
43
40
} ] ) ;
41
+ } ] )
42
+ . run ( [ '$rootScope' , 'ExceptionlessClient' , function ( $rootScope , ExceptionlessClient ) {
43
+ $rootScope . $on ( '$routeChangeSuccess' , function ( event , next , current ) {
44
+ ExceptionlessClient . createFeatureUsage ( current . name )
45
+ . setProperty ( 'next' , next )
46
+ . setProperty ( 'current' , current )
47
+ . submit ( ) ;
48
+ } ) ;
49
+
50
+ $rootScope . $on ( '$routeChangeError' , function ( event , current , previous , rejection ) {
51
+ ExceptionlessClient . createUnhandledException ( new Error ( rejection ) , '$routeChangeError' )
52
+ . setProperty ( 'current' , current )
53
+ . setProperty ( 'previous' , previous )
54
+ . submit ( ) ;
55
+ } ) ;
56
+
57
+ $rootScope . $on ( '$stateChangeSuccess' , function ( event , toState , toParams , fromState , fromParams ) {
58
+ if ( toState . name === 'otherwise' ) {
59
+ return ;
60
+ }
61
+
62
+ ExceptionlessClient . createFeatureUsage ( toState . controller || toState . name )
63
+ . setProperty ( 'toState' , toState )
64
+ . setProperty ( 'toParams' , toParams )
65
+ . setProperty ( 'fromState' , fromState )
66
+ . setProperty ( 'fromParams' , fromParams )
67
+ . submit ( ) ;
68
+ } ) ;
69
+
70
+ $rootScope . $on ( '$stateNotFound' , function ( event , unfoundState , fromState , fromParams ) {
71
+ ExceptionlessClient . createNotFound ( unfoundState . to )
72
+ . setProperty ( 'unfoundState' , unfoundState )
73
+ . setProperty ( 'fromState' , fromState )
74
+ . setProperty ( 'fromParams' , fromParams )
75
+ . submit ( ) ;
76
+ } ) ;
77
+
78
+ $rootScope . $on ( '$stateChangeError' , function ( event , toState , toParams , fromState , fromParams , error ) {
79
+ if ( ! error ) {
80
+ return ;
81
+ }
82
+
83
+ ExceptionlessClient . createUnhandledException ( error , '$stateChangeError' )
84
+ . setProperty ( 'toState' , toState )
85
+ . setProperty ( 'toParams' , toParams )
86
+ . setProperty ( 'fromState' , fromState )
87
+ . setProperty ( 'fromParams' , fromParams )
88
+ . submit ( ) ;
89
+ } ) ;
44
90
} ] ) ;
45
91
46
92
declare var Exceptionless ;
0 commit comments