Skip to content

Commit 1a3dd74

Browse files
committed
Added angular integration.
1 parent 15d2ae8 commit 1a3dd74

File tree

8 files changed

+174
-2
lines changed

8 files changed

+174
-2
lines changed

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.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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
angular.module('exceptionless', [])
2+
.value('ExceptionlessClient', ExceptionlessClient.default)
3+
.factory('exceptionlessHttpInterceptor', ['$q', 'ExceptionlessClient', function ($q, ExceptionlessClient) {
4+
return {
5+
responseError: function responseError(rejection) {
6+
if (rejection.status === 404) {
7+
ExceptionlessClient.submitNotFound(rejection.config);
8+
} else {
9+
ExceptionlessClient.createUnhandledException(new Error('HTTP response error'), 'errorHttpInterceptor')
10+
.setProperty('status', rejection.status)
11+
.setProperty('config', rejection.config)
12+
.submit();
13+
}
14+
15+
return $q.reject(rejection);
16+
}
17+
};
18+
}])
19+
.config(['$httpProvider', '$provide', 'ExceptionlessClient', function($httpProvider, $provide, ExceptionlessClient) {
20+
$httpProvider.interceptors.push('exceptionlessHttpInterceptor');
21+
22+
$provide.decorator('$exceptionHandler', ['$delegate', function ($delegate) {
23+
return function (exception, cause) {
24+
$delegate(exception, cause);
25+
ExceptionlessClient.createUnhandledException(exception, '$exceptionHandler').setMessage(cause).submit();
26+
};
27+
}]);
28+
$provide.decorator('$log', ['$delegate', function ($delegate) {
29+
function decorateRegularCall(property, logLevel) {
30+
var previousFn = $delegate[property];
31+
$delegate[property] = function () {
32+
previousFn.call(null, arguments);
33+
ExceptionlessClient.submitLog('Angular', arguments[0], logLevel);
34+
};
35+
}
36+
37+
$delegate.log = decorateRegularCall('log', 'Trace');
38+
$delegate.info = decorateRegularCall('info', 'Info');
39+
$delegate.warn = decorateRegularCall('warn', 'Warn');
40+
$delegate.debug = decorateRegularCall('debug', 'Debug');
41+
$delegate.error = decorateRegularCall('error', 'Error');
42+
return $delegate;
43+
}]);
44+
}]);

gulpfile.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ gulp.task('typescript.es5', function() {
1616
return tsProject.src('src/tsconfig.es5.json').pipe(gulp.dest('dist/temp'));
1717
});
1818

19+
gulp.task('typescript.es5.integrations', function() {
20+
return tsProject.src('src/integrations/tsconfig.json').pipe(gulp.dest('dist/temp'));
21+
});
22+
1923
gulp.task('exceptionless.es5.umd', ['typescript.es5'], function() {
2024
return gulp.src('dist/temp/src/exceptionless.js')
2125
.pipe(sourcemaps.init({ loadMaps: true }))
@@ -33,6 +37,13 @@ gulp.task('exceptionless.es5', ['exceptionless.es5.umd'], function() {
3337
gulp.src('dist/temp/src/exceptionless.d.ts')
3438
.pipe(gulp.dest('dist'));
3539

40+
var integrations = [
41+
'src/integrations/angular.js'
42+
];
43+
44+
gulp.src(integrations)
45+
.pipe(gulp.dest('dist/integrations'));
46+
3647
var files = [
3748
'node_modules/es6-promise/dist/es6-promise.js',
3849
'node_modules/stackframe/dist/stackframe.js',

src/integrations/angular.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
angular.module('exceptionless', [])
2+
.value('ExceptionlessClient', ExceptionlessClient.default)
3+
.factory('exceptionlessHttpInterceptor', ['$q', 'ExceptionlessClient', function ($q, ExceptionlessClient) {
4+
return {
5+
responseError: function responseError(rejection) {
6+
if (rejection.status === 404) {
7+
ExceptionlessClient.submitNotFound(rejection.config);
8+
} else {
9+
ExceptionlessClient.createUnhandledException(new Error('HTTP response error'), 'errorHttpInterceptor')
10+
.setProperty('status', rejection.status)
11+
.setProperty('config', rejection.config)
12+
.submit();
13+
}
14+
15+
return $q.reject(rejection);
16+
}
17+
};
18+
}])
19+
.config(['$httpProvider', '$provide', 'ExceptionlessClient', function($httpProvider, $provide, ExceptionlessClient) {
20+
$httpProvider.interceptors.push('exceptionlessHttpInterceptor');
21+
22+
$provide.decorator('$exceptionHandler', ['$delegate', function ($delegate) {
23+
return function (exception, cause) {
24+
$delegate(exception, cause);
25+
ExceptionlessClient.createUnhandledException(exception, '$exceptionHandler').setMessage(cause).submit();
26+
};
27+
}]);
28+
$provide.decorator('$log', ['$delegate', function ($delegate) {
29+
function decorateRegularCall(property, logLevel) {
30+
var previousFn = $delegate[property];
31+
$delegate[property] = function () {
32+
previousFn.call(null, arguments);
33+
ExceptionlessClient.submitLog('Angular', arguments[0], logLevel);
34+
};
35+
}
36+
37+
$delegate.log = decorateRegularCall('log', 'Trace');
38+
$delegate.info = decorateRegularCall('info', 'Info');
39+
$delegate.warn = decorateRegularCall('warn', 'Warn');
40+
$delegate.debug = decorateRegularCall('debug', 'Debug');
41+
$delegate.error = decorateRegularCall('error', 'Error');
42+
return $delegate;
43+
}]);
44+
}]);

src/integrations/angular.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
angular.module('exceptionless', [])
2+
.value('ExceptionlessClient', ExceptionlessClient.default)
3+
.factory('exceptionlessHttpInterceptor', ['$q', 'ExceptionlessClient', function ($q, ExceptionlessClient) {
4+
return {
5+
responseError: function responseError(rejection) {
6+
if (rejection.status === 404) {
7+
ExceptionlessClient.submitNotFound(rejection.config);
8+
} else {
9+
ExceptionlessClient.createUnhandledException(new Error('HTTP response error'), 'errorHttpInterceptor')
10+
.setProperty('status', rejection.status)
11+
.setProperty('config', rejection.config)
12+
.submit();
13+
}
14+
15+
return $q.reject(rejection);
16+
}
17+
};
18+
}])
19+
.config(['$httpProvider', '$provide', 'ExceptionlessClient', function($httpProvider, $provide, ExceptionlessClient) {
20+
$httpProvider.interceptors.push('exceptionlessHttpInterceptor');
21+
22+
$provide.decorator('$exceptionHandler', ['$delegate', function ($delegate) {
23+
return function (exception, cause) {
24+
$delegate(exception, cause);
25+
ExceptionlessClient.createUnhandledException(exception, '$exceptionHandler').setMessage(cause).submit();
26+
};
27+
}]);
28+
$provide.decorator('$log', ['$delegate', function ($delegate) {
29+
function decorateRegularCall(property, logLevel) {
30+
var previousFn = $delegate[property];
31+
$delegate[property] = function () {
32+
previousFn.call(null, arguments);
33+
ExceptionlessClient.submitLog('Angular', arguments[0], logLevel);
34+
};
35+
}
36+
37+
$delegate.log = decorateRegularCall('log', 'Trace');
38+
$delegate.info = decorateRegularCall('info', 'Info');
39+
$delegate.warn = decorateRegularCall('warn', 'Warn');
40+
$delegate.debug = decorateRegularCall('debug', 'Debug');
41+
$delegate.error = decorateRegularCall('error', 'Error');
42+
return $delegate;
43+
}]);
44+
}]);
45+
46+
declare var ExceptionlessClient;

src/integrations/tsconfig.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"removeComments": true,
5+
"target": "es5"
6+
},
7+
"files": [
8+
"../../typings/angularjs/angular.d.ts",
9+
"../../typings/jquery/jquery.d.ts",
10+
"angular.ts"
11+
],
12+
"bundles": {
13+
"exceptionless": {
14+
"files": [
15+
"../../typings/angularjs/angular.d.ts",
16+
"../../typings/jquery/jquery.d.ts",
17+
"angular.ts"
18+
]
19+
}
20+
}
21+
}

tsd.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
},
1414
"node/node.d.ts": {
1515
"commit": "00e7f3fede5f2df55b56c72f40a144824f0f0bfa"
16+
},
17+
"angularjs/angular.d.ts": {
18+
"commit": "557bb595af0ab301d098fb5bd50943fffbfcee57"
19+
},
20+
"jquery/jquery.d.ts": {
21+
"commit": "557bb595af0ab301d098fb5bd50943fffbfcee57"
1622
}
1723
}
1824
}

0 commit comments

Comments
 (0)