11angular . module ( 'exceptionless' , [ ] )
2- . constant ( 'ExceptionlessClient' , Exceptionless . ExceptionlessClient . default )
2+ . constant ( '$ ExceptionlessClient' , Exceptionless . ExceptionlessClient . default )
33 . factory ( 'exceptionlessHttpInterceptor' , [ '$q' , 'ExceptionlessClient' , function ( $q , ExceptionlessClient ) {
44 return {
55 responseError : function responseError ( rejection ) {
@@ -11,14 +11,12 @@ angular.module('exceptionless', [])
1111 . setProperty ( 'config' , rejection . config )
1212 . submit ( ) ;
1313 }
14-
1514 return $q . reject ( rejection ) ;
1615 }
1716 } ;
1817 } ] )
19- . config ( [ '$httpProvider' , '$provide' , 'ExceptionlessClient' , function ( $httpProvider , $provide , ExceptionlessClient ) {
18+ . config ( [ '$httpProvider' , '$provide' , 'ExceptionlessClient' , function ( $httpProvider , $provide , ExceptionlessClient ) {
2019 $httpProvider . interceptors . push ( 'exceptionlessHttpInterceptor' ) ;
21-
2220 $provide . decorator ( '$exceptionHandler' , [ '$delegate' , function ( $delegate ) {
2321 return function ( exception , cause ) {
2422 $delegate ( exception , cause ) ;
@@ -28,19 +26,67 @@ angular.module('exceptionless', [])
2826 $provide . decorator ( '$log' , [ '$delegate' , function ( $delegate ) {
2927 function decorateRegularCall ( property , logLevel ) {
3028 var previousFn = $delegate [ property ] ;
31- $delegate [ property ] = function ( ) {
29+ return $delegate [ property ] = function ( ) {
3230 previousFn . call ( null , arguments ) ;
3331 ExceptionlessClient . submitLog ( 'Angular' , arguments [ 0 ] , logLevel ) ;
3432 } ;
3533 }
36-
3734 $delegate . log = decorateRegularCall ( 'log' , 'Trace' ) ;
3835 $delegate . info = decorateRegularCall ( 'info' , 'Info' ) ;
3936 $delegate . warn = decorateRegularCall ( 'warn' , 'Warn' ) ;
4037 $delegate . debug = decorateRegularCall ( 'debug' , 'Debug' ) ;
4138 $delegate . error = decorateRegularCall ( 'error' , 'Error' ) ;
4239 return $delegate ;
4340 } ] ) ;
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+ } ) ;
4490 } ] ) ;
4591
4692declare var Exceptionless ;
0 commit comments