Skip to content

Commit a2ef6f7

Browse files
committed
Make Raven a singleton class instance
1 parent 3c22256 commit a2ef6f7

File tree

9 files changed

+836
-950
lines changed

9 files changed

+836
-950
lines changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = function(grunt) {
7575
key.sort();
7676

7777
var dest = path.join('build/', key.join(','), '/raven.js');
78-
dict[dest] = ['src/raven.js'].concat(comb);
78+
dict[dest] = ['src/singleton.js'].concat(comb);
7979

8080
return dict;
8181
}, {});
@@ -94,7 +94,7 @@ module.exports = function(grunt) {
9494
}
9595
},
9696
core: {
97-
src: 'src/raven.js',
97+
src: 'src/singleton.js',
9898
dest: 'build/raven.js'
9999
},
100100
plugins: {

plugins/angular.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,31 @@
66
* Provides an $exceptionHandler for Angular.js
77
*/
88

9-
var Raven = require('../src/raven');
10-
11-
function RavenProvider() {
12-
this.$get = ['$window', function($window, $log) {
13-
return $window.Raven;
14-
}];
15-
}
16-
17-
function ExceptionHandlerProvider($provide) {
18-
$provide.decorator('$exceptionHandler',
19-
['Raven', '$delegate', exceptionHandler]);
20-
}
21-
22-
function exceptionHandler(Raven, $delegate) {
23-
return function (ex, cause) {
24-
Raven.captureException(ex, {
25-
extra: { cause: cause }
26-
});
27-
$delegate(ex, cause);
28-
};
29-
}
30-
319
// See https://github.com/angular/angular.js/blob/v1.4.7/src/minErr.js
3210
var angularPattern = /^\[((?:[$a-zA-Z0-9]+:)?(?:[$a-zA-Z0-9]+))\] (.+?)\n(\S+)$/;
3311

3412
function install() {
13+
var Raven = this;
14+
function RavenProvider() {
15+
this.$get = ['$window', function($window, $log) {
16+
return Raven;
17+
}];
18+
}
19+
20+
function ExceptionHandlerProvider($provide) {
21+
$provide.decorator('$exceptionHandler',
22+
['Raven', '$delegate', exceptionHandler]);
23+
}
24+
25+
function exceptionHandler(Raven, $delegate) {
26+
return function (ex, cause) {
27+
Raven.captureException(ex, {
28+
extra: { cause: cause }
29+
});
30+
$delegate(ex, cause);
31+
};
32+
}
33+
3534
var angular = window.angular;
3635
if (!angular) return;
3736

plugins/jquery.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
*/
66
'use strict';
77

8-
var Raven = require('../src/raven');
9-
108
function install(jQuery) {
9+
var Raven = this;
1110
var $ = jQuery || window.jQuery;
1211

1312
// quit if jQuery isn't on the page

0 commit comments

Comments
 (0)