Skip to content

Commit d606641

Browse files
committed
Added angular feature usage / 404's and errors based on route changes.
1 parent 51cf643 commit d606641

File tree

7 files changed

+108
-17
lines changed

7 files changed

+108
-17
lines changed

dist/exceptionless.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export declare class NodeBootstrapper implements IBootstrapper {
399399
export declare class WebErrorParser implements IErrorParser {
400400
parse(context: EventPluginContext, exception: Error): Promise<IError>;
401401
private processError(context, exception, stackFrames);
402-
private onParseError(context);
402+
private onParseError(error, context);
403403
private getStackFrames(context, stackFrames);
404404
}
405405
export declare class WebModuleCollector implements IModuleCollector {

dist/exceptionless.js

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.min.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/integrations/angular.js

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
angular.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) {
@@ -27,7 +27,7 @@ angular.module('exceptionless', [])
2727
$provide.decorator('$log', ['$delegate', function ($delegate) {
2828
function decorateRegularCall(property, logLevel) {
2929
var previousFn = $delegate[property];
30-
$delegate[property] = function () {
30+
return $delegate[property] = function () {
3131
previousFn.call(null, arguments);
3232
ExceptionlessClient.submitLog('Angular', arguments[0], logLevel);
3333
};
@@ -39,4 +39,47 @@ angular.module('exceptionless', [])
3939
$delegate.error = decorateRegularCall('error', 'Error');
4040
return $delegate;
4141
}]);
42+
}])
43+
.run(['$rootScope', 'ExceptionlessClient', function ($rootScope, ExceptionlessClient) {
44+
$rootScope.$on('$routeChangeSuccess', function (event, next, current) {
45+
ExceptionlessClient.createFeatureUsage(current.name)
46+
.setProperty('next', next)
47+
.setProperty('current', current)
48+
.submit();
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+
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
57+
if (toState.name === 'otherwise') {
58+
return;
59+
}
60+
ExceptionlessClient.createFeatureUsage(toState.controller || toState.name)
61+
.setProperty('toState', toState)
62+
.setProperty('toParams', toParams)
63+
.setProperty('fromState', fromState)
64+
.setProperty('fromParams', fromParams)
65+
.submit();
66+
});
67+
$rootScope.$on('$stateNotFound', function (event, unfoundState, fromState, fromParams) {
68+
ExceptionlessClient.createNotFound(unfoundState.to)
69+
.setProperty('unfoundState', unfoundState)
70+
.setProperty('fromState', fromState)
71+
.setProperty('fromParams', fromParams)
72+
.submit();
73+
});
74+
$rootScope.$on('$stateChangeError', function (event, toState, toParams, fromState, fromParams, error) {
75+
if (!error) {
76+
return;
77+
}
78+
ExceptionlessClient.createUnhandledException(error, '$stateChangeError')
79+
.setProperty('toState', toState)
80+
.setProperty('toParams', toParams)
81+
.setProperty('fromState', fromState)
82+
.setProperty('fromParams', fromParams)
83+
.submit();
84+
});
4285
}]);

src/integrations/angular.ts

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
angular.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

4692
declare var Exceptionless;

0 commit comments

Comments
 (0)