rollbar 2.26.2 → 2.26.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +32 -10
- package/.lgtm.yml +7 -7
- package/.prettierignore +18 -0
- package/.vscode/settings.json +39 -0
- package/CHANGELOG.md +121 -35
- package/Gruntfile.js +51 -71
- package/README.md +2 -4
- package/bower.json +1 -3
- package/defaults.js +17 -5
- package/dist/plugins/jquery.min.js +1 -1
- package/dist/rollbar.js +5699 -5052
- package/dist/rollbar.js.map +1 -1
- package/dist/rollbar.min.js +1 -1
- package/dist/rollbar.min.js.map +1 -1
- package/dist/rollbar.named-amd.js +5704 -5062
- package/dist/rollbar.named-amd.js.map +1 -1
- package/dist/rollbar.named-amd.min.js +1 -1
- package/dist/rollbar.named-amd.min.js.map +1 -1
- package/dist/rollbar.noconflict.umd.js +5693 -5052
- package/dist/rollbar.noconflict.umd.js.map +1 -1
- package/dist/rollbar.noconflict.umd.min.js +1 -1
- package/dist/rollbar.noconflict.umd.min.js.map +1 -1
- package/dist/rollbar.snippet.js +1 -1
- package/dist/rollbar.umd.js +5704 -5063
- package/dist/rollbar.umd.js.map +1 -1
- package/dist/rollbar.umd.min.js +1 -1
- package/dist/rollbar.umd.min.js.map +1 -1
- package/docs/extension-exceptions.md +35 -30
- package/docs/migration_v0_to_v1.md +41 -38
- package/index.d.ts +270 -231
- package/karma.conf.js +16 -34
- package/package.json +21 -17
- package/prettier.config.js +7 -0
- package/src/api.js +21 -10
- package/src/apiUtility.js +12 -8
- package/src/browser/core.js +103 -65
- package/src/browser/defaults/scrubFields.js +3 -3
- package/src/browser/detection.js +7 -8
- package/src/browser/domUtility.js +18 -8
- package/src/browser/globalSetup.js +12 -6
- package/src/browser/logger.js +1 -1
- package/src/browser/plugins/jquery.js +35 -35
- package/src/browser/predicates.js +1 -1
- package/src/browser/rollbar.js +1 -1
- package/src/browser/rollbarWrapper.js +8 -5
- package/src/browser/shim.js +43 -19
- package/src/browser/snippet_callback.js +6 -4
- package/src/browser/telemetry.js +573 -354
- package/src/browser/transforms.js +46 -27
- package/src/browser/transport/fetch.js +16 -14
- package/src/browser/transport/xhr.js +29 -13
- package/src/browser/transport.js +82 -25
- package/src/browser/url.js +16 -8
- package/src/browser/wrapGlobals.js +27 -8
- package/src/defaults.js +3 -3
- package/src/errorParser.js +14 -11
- package/src/merge.js +32 -23
- package/src/notifier.js +16 -13
- package/src/predicates.js +43 -23
- package/src/queue.js +71 -39
- package/src/rateLimiter.js +59 -18
- package/src/react-native/logger.js +1 -1
- package/src/react-native/rollbar.js +59 -55
- package/src/react-native/transforms.js +13 -9
- package/src/react-native/transport.js +44 -34
- package/src/rollbar.js +22 -13
- package/src/scrub.js +0 -1
- package/src/server/locals.js +69 -39
- package/src/server/logger.js +4 -4
- package/src/server/parser.js +72 -47
- package/src/server/rollbar.js +133 -55
- package/src/server/sourceMap/stackTrace.js +33 -18
- package/src/server/telemetry/urlHelpers.js +9 -11
- package/src/server/telemetry.js +68 -45
- package/src/server/transforms.js +37 -21
- package/src/server/transport.js +62 -32
- package/src/telemetry.js +92 -28
- package/src/transforms.js +33 -21
- package/src/truncation.js +8 -5
- package/src/utility/headers.js +43 -43
- package/src/utility/replace.js +9 -0
- package/src/utility/traverse.js +1 -1
- package/src/utility.js +89 -52
- package/test/api.test.js +31 -29
- package/test/apiUtility.test.js +43 -44
- package/test/browser.core.test.js +141 -131
- package/test/browser.domUtility.test.js +52 -35
- package/test/browser.predicates.test.js +13 -13
- package/test/browser.rollbar.test.js +597 -503
- package/test/browser.telemetry.test.js +76 -0
- package/test/browser.transforms.test.js +146 -128
- package/test/browser.transport.test.js +54 -46
- package/test/browser.url.test.js +12 -11
- package/test/fixtures/locals.fixtures.js +245 -126
- package/test/notifier.test.js +90 -78
- package/test/predicates.test.js +260 -214
- package/test/queue.test.js +230 -214
- package/test/rateLimiter.test.js +50 -42
- package/test/react-native.rollbar.test.js +149 -115
- package/test/react-native.transforms.test.js +21 -23
- package/test/react-native.transport.test.js +23 -11
- package/test/server.lambda.test.js +70 -53
- package/test/server.locals.test.js +437 -210
- package/test/server.parser.test.js +32 -26
- package/test/server.predicates.test.js +45 -43
- package/test/server.rollbar.test.js +311 -259
- package/test/server.telemetry.test.js +208 -83
- package/test/server.transforms.test.js +455 -361
- package/test/server.transport.test.js +144 -76
- package/test/telemetry.test.js +46 -37
- package/test/transforms.test.js +68 -66
- package/test/truncation.test.js +55 -53
- package/test/utility.test.js +266 -222
- package/webpack.config.js +46 -43
- package/.gitmodules +0 -3
- package/browserstack.browsers.js +0 -153
- package/browserstack.browsers.json +0 -4384
|
@@ -7,16 +7,16 @@ var Rollbar = require('../src/browser/rollbar');
|
|
|
7
7
|
var t = require('../src/browser/transforms');
|
|
8
8
|
|
|
9
9
|
function TestClientGen() {
|
|
10
|
-
var TestClient = function() {
|
|
10
|
+
var TestClient = function () {
|
|
11
11
|
this.notifier = {
|
|
12
|
-
addTransform: function() {
|
|
12
|
+
addTransform: function () {
|
|
13
13
|
return this.notifier;
|
|
14
|
-
}.bind(this)
|
|
14
|
+
}.bind(this),
|
|
15
15
|
};
|
|
16
16
|
this.queue = {
|
|
17
|
-
addPredicate: function() {
|
|
17
|
+
addPredicate: function () {
|
|
18
18
|
return this.queue;
|
|
19
|
-
}.bind(this)
|
|
19
|
+
}.bind(this),
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
return TestClient;
|
|
@@ -24,7 +24,7 @@ function TestClientGen() {
|
|
|
24
24
|
|
|
25
25
|
function itemFromArgs(args) {
|
|
26
26
|
var client = new (TestClientGen())();
|
|
27
|
-
var rollbar = new Rollbar({autoInstrument: false}, client);
|
|
27
|
+
var rollbar = new Rollbar({ autoInstrument: false }, client);
|
|
28
28
|
var item = rollbar._createItem(args);
|
|
29
29
|
item.level = 'debug';
|
|
30
30
|
return item;
|
|
@@ -34,53 +34,53 @@ function chromeMajorVersion() {
|
|
|
34
34
|
return parseInt(navigator.userAgent.match(/Chrome\/([0-9]+)\./)[1]);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
describe('handleDomException', function() {
|
|
38
|
-
it('should do nothing if not a DOMException', function(done) {
|
|
37
|
+
describe('handleDomException', function () {
|
|
38
|
+
it('should do nothing if not a DOMException', function (done) {
|
|
39
39
|
var err = new Error('test');
|
|
40
40
|
var args = ['a message', err];
|
|
41
41
|
var item = itemFromArgs(args);
|
|
42
42
|
var options = {};
|
|
43
|
-
t.handleDomException(item, options, function(e, i) {
|
|
43
|
+
t.handleDomException(item, options, function (e, i) {
|
|
44
44
|
expect(item.err).to.eql(item.err);
|
|
45
45
|
expect(item.err.nested).to.not.be.ok();
|
|
46
46
|
done(e);
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
|
-
it('should create nested exception for DOMException', function(done) {
|
|
49
|
+
it('should create nested exception for DOMException', function (done) {
|
|
50
50
|
var err = new DOMException('dom error');
|
|
51
51
|
var args = ['a message', err];
|
|
52
52
|
var item = itemFromArgs(args);
|
|
53
53
|
var options = {};
|
|
54
|
-
t.handleDomException(item, options, function(e, i) {
|
|
54
|
+
t.handleDomException(item, options, function (e, i) {
|
|
55
55
|
expect(item.err.nested.constructor.name).to.eql('DOMException');
|
|
56
56
|
expect(item.err.constructor.name).to.eql('Error');
|
|
57
57
|
done(e);
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
|
-
describe('handleItemWithError', function() {
|
|
62
|
-
it('should do nothing if there is no err', function(done) {
|
|
61
|
+
describe('handleItemWithError', function () {
|
|
62
|
+
it('should do nothing if there is no err', function (done) {
|
|
63
63
|
var args = ['a message'];
|
|
64
64
|
var item = itemFromArgs(args);
|
|
65
65
|
var options = {};
|
|
66
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
66
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
67
67
|
expect(i).to.eql(item);
|
|
68
68
|
done(e);
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
|
-
it('should set stack info from error if it is already saved', function(done) {
|
|
71
|
+
it('should set stack info from error if it is already saved', function (done) {
|
|
72
72
|
var err = new Error('bork');
|
|
73
|
-
var myTrace = {trace: {frames: [1,2,3]}};
|
|
73
|
+
var myTrace = { trace: { frames: [1, 2, 3] } };
|
|
74
74
|
err._savedStackTrace = myTrace;
|
|
75
75
|
var args = ['a message', err];
|
|
76
76
|
var item = itemFromArgs(args);
|
|
77
77
|
var options = {};
|
|
78
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
78
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
79
79
|
expect(i.stackInfo).to.eql(myTrace);
|
|
80
80
|
done(e);
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
|
-
it('should set stack info from error', function(done) {
|
|
83
|
+
it('should set stack info from error', function (done) {
|
|
84
84
|
var err;
|
|
85
85
|
try {
|
|
86
86
|
throw new Error('bork');
|
|
@@ -90,102 +90,102 @@ describe('handleItemWithError', function() {
|
|
|
90
90
|
var args = ['a message', err];
|
|
91
91
|
var item = itemFromArgs(args);
|
|
92
92
|
var options = {};
|
|
93
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
93
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
94
94
|
expect(i.message).to.eql('a message');
|
|
95
95
|
expect(i.stackInfo).to.be.ok();
|
|
96
96
|
done(e);
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
|
-
it('should handle bad errors and still set stackInfo', function(done) {
|
|
100
|
-
var err = {description: 'bork'};
|
|
99
|
+
it('should handle bad errors and still set stackInfo', function (done) {
|
|
100
|
+
var err = { description: 'bork' };
|
|
101
101
|
var args = ['a message', 'fuzz'];
|
|
102
102
|
var item = itemFromArgs(args);
|
|
103
103
|
item.err = err;
|
|
104
104
|
var options = {};
|
|
105
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
105
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
106
106
|
expect(i.stackInfo).to.be.ok();
|
|
107
107
|
expect(i.message).to.eql('a message');
|
|
108
108
|
done(e);
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
|
-
it('should use most specific error name', function(done) {
|
|
111
|
+
it('should use most specific error name', function (done) {
|
|
112
112
|
var err = new Error('bork');
|
|
113
113
|
var args = ['a message', err];
|
|
114
114
|
var options = {};
|
|
115
115
|
|
|
116
116
|
var names = [
|
|
117
|
-
{name: 'TypeError', constructor: 'EvalError', result: 'TypeError'},
|
|
118
|
-
{name: 'TypeError', constructor: 'Error', result: 'TypeError'},
|
|
119
|
-
{name: 'Error', constructor: 'TypeError', result: 'TypeError'},
|
|
120
|
-
{name: 'Error', constructor: '', result: 'Error'},
|
|
121
|
-
{name: '', constructor: 'Error', result: 'Error'},
|
|
122
|
-
{name: '', constructor: '', result: ''}
|
|
117
|
+
{ name: 'TypeError', constructor: 'EvalError', result: 'TypeError' },
|
|
118
|
+
{ name: 'TypeError', constructor: 'Error', result: 'TypeError' },
|
|
119
|
+
{ name: 'Error', constructor: 'TypeError', result: 'TypeError' },
|
|
120
|
+
{ name: 'Error', constructor: '', result: 'Error' },
|
|
121
|
+
{ name: '', constructor: 'Error', result: 'Error' },
|
|
122
|
+
{ name: '', constructor: '', result: '' },
|
|
123
123
|
];
|
|
124
124
|
|
|
125
|
-
for(var i = 0; i < names.length; i++) {
|
|
125
|
+
for (var i = 0; i < names.length; i++) {
|
|
126
126
|
err.name = names[i].name;
|
|
127
127
|
err.constructor = { name: names[i].constructor };
|
|
128
128
|
var item = itemFromArgs(args);
|
|
129
129
|
var result = names[i].result;
|
|
130
130
|
|
|
131
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
131
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
132
132
|
expect(i.stackInfo.name).to.eql(result);
|
|
133
133
|
});
|
|
134
|
-
}
|
|
134
|
+
}
|
|
135
135
|
done();
|
|
136
136
|
});
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
describe('ensureItemHasSomethingToSay', function() {
|
|
140
|
-
it('should error if item has nothing', function(done) {
|
|
139
|
+
describe('ensureItemHasSomethingToSay', function () {
|
|
140
|
+
it('should error if item has nothing', function (done) {
|
|
141
141
|
var args = [];
|
|
142
142
|
var item = itemFromArgs(args);
|
|
143
143
|
var options = {};
|
|
144
|
-
t.ensureItemHasSomethingToSay(item, options, function(e, i) {
|
|
144
|
+
t.ensureItemHasSomethingToSay(item, options, function (e, i) {
|
|
145
145
|
expect(e).to.be.ok();
|
|
146
146
|
done(i);
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
|
-
it('should do nothing if item has a message', function(done) {
|
|
149
|
+
it('should do nothing if item has a message', function (done) {
|
|
150
150
|
var args = [];
|
|
151
151
|
var item = itemFromArgs(args);
|
|
152
152
|
item.message = 'bork';
|
|
153
153
|
var options = {};
|
|
154
|
-
t.ensureItemHasSomethingToSay(item, options, function(e, i) {
|
|
154
|
+
t.ensureItemHasSomethingToSay(item, options, function (e, i) {
|
|
155
155
|
expect(i).to.be.ok();
|
|
156
156
|
done(e);
|
|
157
157
|
});
|
|
158
158
|
});
|
|
159
|
-
it('should do nothing if item has stackInfo', function(done) {
|
|
159
|
+
it('should do nothing if item has stackInfo', function (done) {
|
|
160
160
|
var args = [];
|
|
161
161
|
var item = itemFromArgs(args);
|
|
162
162
|
item.data = item.data || {};
|
|
163
163
|
item.stackInfo = {};
|
|
164
164
|
var options = {};
|
|
165
|
-
t.ensureItemHasSomethingToSay(item, options, function(e, i) {
|
|
165
|
+
t.ensureItemHasSomethingToSay(item, options, function (e, i) {
|
|
166
166
|
expect(i).to.be.ok();
|
|
167
167
|
done(e);
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
|
-
it('should do nothing if item has custom data', function(done) {
|
|
170
|
+
it('should do nothing if item has custom data', function (done) {
|
|
171
171
|
var args = [];
|
|
172
172
|
var item = itemFromArgs(args);
|
|
173
173
|
item.custom = {};
|
|
174
174
|
var options = {};
|
|
175
|
-
t.ensureItemHasSomethingToSay(item, options, function(e, i) {
|
|
175
|
+
t.ensureItemHasSomethingToSay(item, options, function (e, i) {
|
|
176
176
|
expect(i).to.be.ok();
|
|
177
177
|
done(e);
|
|
178
178
|
});
|
|
179
179
|
});
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
-
describe('addBaseInfo', function() {
|
|
183
|
-
it('should add all of the expected data', function(done) {
|
|
182
|
+
describe('addBaseInfo', function () {
|
|
183
|
+
it('should add all of the expected data', function (done) {
|
|
184
184
|
var args = ['a message'];
|
|
185
185
|
var item = itemFromArgs(args);
|
|
186
186
|
item.level = 'critical';
|
|
187
187
|
var options = {};
|
|
188
|
-
t.addBaseInfo(item, options, function(e, i) {
|
|
188
|
+
t.addBaseInfo(item, options, function (e, i) {
|
|
189
189
|
expect(i.data.level).to.eql('critical');
|
|
190
190
|
expect(i.data.platform).to.eql('browser');
|
|
191
191
|
expect(i.data.framework).to.eql('browser-js');
|
|
@@ -194,63 +194,63 @@ describe('addBaseInfo', function() {
|
|
|
194
194
|
done(e);
|
|
195
195
|
});
|
|
196
196
|
});
|
|
197
|
-
it('should pull data from options', function(done) {
|
|
197
|
+
it('should pull data from options', function (done) {
|
|
198
198
|
var args = ['a message'];
|
|
199
199
|
var item = itemFromArgs(args);
|
|
200
200
|
var options = {
|
|
201
201
|
environment: 'dev',
|
|
202
202
|
endpoint: 'api.rollbar.com',
|
|
203
|
-
version: '42'
|
|
203
|
+
version: '42',
|
|
204
204
|
};
|
|
205
|
-
t.addBaseInfo(item, options, function(e, i) {
|
|
205
|
+
t.addBaseInfo(item, options, function (e, i) {
|
|
206
206
|
expect(i.data.environment).to.eql('dev');
|
|
207
207
|
expect(i.data.endpoint).to.eql('api.rollbar.com');
|
|
208
208
|
expect(i.data.notifier.version).to.eql('42');
|
|
209
209
|
done(e);
|
|
210
210
|
});
|
|
211
211
|
});
|
|
212
|
-
it('should pull environment from payload options', function(done) {
|
|
212
|
+
it('should pull environment from payload options', function (done) {
|
|
213
213
|
var args = ['a message'];
|
|
214
214
|
var item = itemFromArgs(args);
|
|
215
215
|
var options = {
|
|
216
|
-
payload: {environment: 'dev'}
|
|
216
|
+
payload: { environment: 'dev' },
|
|
217
217
|
};
|
|
218
|
-
t.addBaseInfo(item, options, function(e, i) {
|
|
218
|
+
t.addBaseInfo(item, options, function (e, i) {
|
|
219
219
|
expect(i.data.environment).to.eql('dev');
|
|
220
220
|
done(e);
|
|
221
221
|
});
|
|
222
222
|
});
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
-
describe('addRequestInfo', function() {
|
|
226
|
-
it('should use window info to set request properties', function(done) {
|
|
225
|
+
describe('addRequestInfo', function () {
|
|
226
|
+
it('should use window info to set request properties', function (done) {
|
|
227
227
|
var args = ['a message'];
|
|
228
228
|
var item = itemFromArgs(args);
|
|
229
229
|
var options = { captureIp: 'anonymize' };
|
|
230
|
-
t.addRequestInfo(window)(item, options, function(e, i) {
|
|
230
|
+
t.addRequestInfo(window)(item, options, function (e, i) {
|
|
231
231
|
expect(i.data.request).to.be.ok();
|
|
232
232
|
expect(i.data.request.user_ip).to.eql('$remote_ip_anonymize');
|
|
233
233
|
done(e);
|
|
234
234
|
});
|
|
235
235
|
});
|
|
236
|
-
it('should do nothing without window', function(done) {
|
|
236
|
+
it('should do nothing without window', function (done) {
|
|
237
237
|
var args = ['a message'];
|
|
238
238
|
var item = itemFromArgs(args);
|
|
239
239
|
item.data = {};
|
|
240
240
|
var options = {};
|
|
241
241
|
var w = null;
|
|
242
|
-
t.addRequestInfo(w)(item, options, function(e, i) {
|
|
242
|
+
t.addRequestInfo(w)(item, options, function (e, i) {
|
|
243
243
|
expect(i.data.request).to.not.be.ok();
|
|
244
244
|
done(e);
|
|
245
245
|
});
|
|
246
246
|
});
|
|
247
|
-
it('should honor captureIp without window', function(done) {
|
|
247
|
+
it('should honor captureIp without window', function (done) {
|
|
248
248
|
var args = ['a message'];
|
|
249
249
|
var item = itemFromArgs(args);
|
|
250
250
|
item.data = {};
|
|
251
251
|
var options = { captureIp: true };
|
|
252
252
|
var w = null;
|
|
253
|
-
t.addRequestInfo(w)(item, options, function(e, i) {
|
|
253
|
+
t.addRequestInfo(w)(item, options, function (e, i) {
|
|
254
254
|
expect(i.data.request.url).to.not.be.ok();
|
|
255
255
|
expect(i.data.request.query_string).to.not.be.ok();
|
|
256
256
|
expect(i.data.request.user_ip).to.eql('$remote_ip');
|
|
@@ -259,23 +259,23 @@ describe('addRequestInfo', function() {
|
|
|
259
259
|
});
|
|
260
260
|
});
|
|
261
261
|
|
|
262
|
-
describe('addClientInfo', function() {
|
|
263
|
-
it('should do nothing without a window', function(done) {
|
|
262
|
+
describe('addClientInfo', function () {
|
|
263
|
+
it('should do nothing without a window', function (done) {
|
|
264
264
|
var args = ['a message'];
|
|
265
265
|
var item = itemFromArgs(args);
|
|
266
266
|
item.data = {};
|
|
267
267
|
var options = {};
|
|
268
268
|
var w = null;
|
|
269
|
-
t.addClientInfo(w)(item, options, function(e, i) {
|
|
269
|
+
t.addClientInfo(w)(item, options, function (e, i) {
|
|
270
270
|
expect(i.data.client).to.not.be.ok();
|
|
271
271
|
done(e);
|
|
272
272
|
});
|
|
273
273
|
});
|
|
274
|
-
it('should use window info to set client properties', function(done) {
|
|
274
|
+
it('should use window info to set client properties', function (done) {
|
|
275
275
|
var args = ['a message'];
|
|
276
276
|
var item = itemFromArgs(args);
|
|
277
277
|
var options = {};
|
|
278
|
-
t.addClientInfo(window)(item, options, function(e, i) {
|
|
278
|
+
t.addClientInfo(window)(item, options, function (e, i) {
|
|
279
279
|
expect(i.data.client).to.be.ok();
|
|
280
280
|
expect(i.data.client.javascript).to.be.ok();
|
|
281
281
|
done(e);
|
|
@@ -283,25 +283,30 @@ describe('addClientInfo', function() {
|
|
|
283
283
|
});
|
|
284
284
|
});
|
|
285
285
|
|
|
286
|
-
describe('addPluginInfo', function() {
|
|
287
|
-
it('should do nothing without a window', function(done) {
|
|
286
|
+
describe('addPluginInfo', function () {
|
|
287
|
+
it('should do nothing without a window', function (done) {
|
|
288
288
|
var args = ['a message'];
|
|
289
289
|
var item = itemFromArgs(args);
|
|
290
290
|
var options = {};
|
|
291
291
|
var w = null;
|
|
292
|
-
t.addPluginInfo(w)(item, options, function(e, i) {
|
|
293
|
-
expect(
|
|
292
|
+
t.addPluginInfo(w)(item, options, function (e, i) {
|
|
293
|
+
expect(
|
|
294
|
+
i.data &&
|
|
295
|
+
i.data.client &&
|
|
296
|
+
i.data.client.javascript &&
|
|
297
|
+
i.data.client.javascript.plugins,
|
|
298
|
+
).to.not.be.ok();
|
|
294
299
|
done(e);
|
|
295
300
|
});
|
|
296
301
|
});
|
|
297
|
-
it('should add plugin data from the window', function(done) {
|
|
302
|
+
it('should add plugin data from the window', function (done) {
|
|
298
303
|
var args = ['a message'];
|
|
299
304
|
var item = itemFromArgs(args);
|
|
300
305
|
var options = {};
|
|
301
|
-
var w = {navigator: {plugins: []}};
|
|
302
|
-
w.navigator.plugins.push({name: 'plugin 1', description: '1'});
|
|
303
|
-
w.navigator.plugins.push({name: 'plugin 2', description: '2'});
|
|
304
|
-
t.addPluginInfo(w)(item, options, function(e, i) {
|
|
306
|
+
var w = { navigator: { plugins: [] } };
|
|
307
|
+
w.navigator.plugins.push({ name: 'plugin 1', description: '1' });
|
|
308
|
+
w.navigator.plugins.push({ name: 'plugin 2', description: '2' });
|
|
309
|
+
t.addPluginInfo(w)(item, options, function (e, i) {
|
|
305
310
|
expect(i.data.client.javascript.plugins).to.be.ok();
|
|
306
311
|
expect(i.data.client.javascript.plugins.length).to.eql(2);
|
|
307
312
|
expect(i.data.client.javascript.plugins[0].name).to.eql('plugin 1');
|
|
@@ -310,120 +315,122 @@ describe('addPluginInfo', function() {
|
|
|
310
315
|
});
|
|
311
316
|
});
|
|
312
317
|
|
|
313
|
-
describe('addBody', function() {
|
|
314
|
-
describe('with stackInfo', function() {
|
|
315
|
-
it('should use the stackInfo to add a trace to the body', function(done) {
|
|
318
|
+
describe('addBody', function () {
|
|
319
|
+
describe('with stackInfo', function () {
|
|
320
|
+
it('should use the stackInfo to add a trace to the body', function (done) {
|
|
316
321
|
var err;
|
|
317
322
|
try {
|
|
318
323
|
throw new Error('bork');
|
|
319
324
|
} catch (e) {
|
|
320
325
|
err = e;
|
|
321
326
|
}
|
|
322
|
-
var args = ['a message', err, {custom: 'stuff'}];
|
|
327
|
+
var args = ['a message', err, { custom: 'stuff' }];
|
|
323
328
|
var item = itemFromArgs(args);
|
|
324
329
|
item.description = 'borked';
|
|
325
330
|
var options = {};
|
|
326
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
331
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
327
332
|
expect(i.stackInfo).to.be.ok();
|
|
328
|
-
t.addBody(i, options, function(e, i) {
|
|
333
|
+
t.addBody(i, options, function (e, i) {
|
|
329
334
|
expect(i.data.body.trace).to.be.ok();
|
|
330
335
|
done(e);
|
|
331
336
|
});
|
|
332
337
|
});
|
|
333
338
|
});
|
|
334
|
-
it('should add a message with a bad stackInfo', function(done) {
|
|
339
|
+
it('should add a message with a bad stackInfo', function (done) {
|
|
335
340
|
var args = ['a message'];
|
|
336
341
|
var item = itemFromArgs(args);
|
|
337
342
|
item.description = 'borked';
|
|
338
343
|
item.data = item.data || {};
|
|
339
|
-
item.stackInfo = {name: 'bork'};
|
|
344
|
+
item.stackInfo = { name: 'bork' };
|
|
340
345
|
var options = {};
|
|
341
|
-
t.addBody(item, options, function(e, i) {
|
|
346
|
+
t.addBody(item, options, function (e, i) {
|
|
342
347
|
expect(i.data.body.trace).to.not.be.ok();
|
|
343
348
|
expect(i.data.body.message.body).to.be.ok();
|
|
344
349
|
done(e);
|
|
345
350
|
});
|
|
346
351
|
});
|
|
347
352
|
});
|
|
348
|
-
describe('without stackInfo', function() {
|
|
349
|
-
it('should add a message as the body', function(done) {
|
|
350
|
-
var args = ['a message', {custom: 'stuff'}];
|
|
353
|
+
describe('without stackInfo', function () {
|
|
354
|
+
it('should add a message as the body', function (done) {
|
|
355
|
+
var args = ['a message', { custom: 'stuff' }];
|
|
351
356
|
var item = itemFromArgs(args);
|
|
352
357
|
var options = {};
|
|
353
|
-
t.addBody(item, options, function(e, i) {
|
|
358
|
+
t.addBody(item, options, function (e, i) {
|
|
354
359
|
expect(i.data.body.message.body).to.be.ok();
|
|
355
360
|
done(e);
|
|
356
361
|
});
|
|
357
362
|
});
|
|
358
|
-
it('should send message when sent without a message', function(done) {
|
|
359
|
-
var args = [{custom: 'stuff'}];
|
|
363
|
+
it('should send message when sent without a message', function (done) {
|
|
364
|
+
var args = [{ custom: 'stuff' }];
|
|
360
365
|
var item = itemFromArgs(args);
|
|
361
366
|
var options = {};
|
|
362
|
-
t.addBody(item, options, function(e, i) {
|
|
363
|
-
expect(i.data.body.message.body).to.eql(
|
|
367
|
+
t.addBody(item, options, function (e, i) {
|
|
368
|
+
expect(i.data.body.message.body).to.eql(
|
|
369
|
+
'Item sent with null or missing arguments.',
|
|
370
|
+
);
|
|
364
371
|
done(e);
|
|
365
372
|
});
|
|
366
373
|
});
|
|
367
374
|
});
|
|
368
|
-
describe('without stackInfo.name', function() {
|
|
369
|
-
it('should set error class unknown', function(done) {
|
|
375
|
+
describe('without stackInfo.name', function () {
|
|
376
|
+
it('should set error class unknown', function (done) {
|
|
370
377
|
var err;
|
|
371
378
|
try {
|
|
372
379
|
throw new Error('bork');
|
|
373
380
|
} catch (e) {
|
|
374
381
|
err = e;
|
|
375
382
|
}
|
|
376
|
-
var args = ['a message', err, {custom: 'stuff'}];
|
|
383
|
+
var args = ['a message', err, { custom: 'stuff' }];
|
|
377
384
|
var item = itemFromArgs(args);
|
|
378
385
|
item.description = 'borked';
|
|
379
386
|
var options = {};
|
|
380
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
387
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
381
388
|
expect(i.stackInfo).to.be.ok();
|
|
382
389
|
i.stackInfo.name = null; // force alternate path to determine error class.
|
|
383
|
-
t.addBody(i, options, function(e, i) {
|
|
390
|
+
t.addBody(i, options, function (e, i) {
|
|
384
391
|
expect(i.data.body.trace.exception.class).to.eql('(unknown)');
|
|
385
392
|
expect(i.data.body.trace.exception.message).to.eql('bork');
|
|
386
393
|
done(e);
|
|
387
394
|
});
|
|
388
395
|
});
|
|
389
396
|
});
|
|
390
|
-
describe('when config.guessErrorClass is set', function() {
|
|
391
|
-
it('should guess error class ', function(done) {
|
|
397
|
+
describe('when config.guessErrorClass is set', function () {
|
|
398
|
+
it('should guess error class ', function (done) {
|
|
392
399
|
var err;
|
|
393
400
|
try {
|
|
394
401
|
throw new Error('GuessedError: bork');
|
|
395
402
|
} catch (e) {
|
|
396
403
|
err = e;
|
|
397
404
|
}
|
|
398
|
-
var args = [err, {custom: 'stuff'}];
|
|
405
|
+
var args = [err, { custom: 'stuff' }];
|
|
399
406
|
var item = itemFromArgs(args);
|
|
400
407
|
item.description = 'borked';
|
|
401
408
|
var options = { guessErrorClass: true };
|
|
402
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
409
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
403
410
|
expect(i.stackInfo).to.be.ok();
|
|
404
411
|
i.stackInfo.name = null; // force alternate path to determine error class.
|
|
405
|
-
t.addBody(i, options, function(e, i) {
|
|
412
|
+
t.addBody(i, options, function (e, i) {
|
|
406
413
|
expect(i.data.body.trace.exception.class).to.eql('GuessedError');
|
|
407
414
|
expect(i.data.body.trace.exception.message).to.eql('bork');
|
|
408
415
|
done(e);
|
|
409
416
|
});
|
|
410
417
|
});
|
|
411
418
|
});
|
|
412
|
-
it('should set error class unknown', function(done) {
|
|
419
|
+
it('should set error class unknown', function (done) {
|
|
413
420
|
var err;
|
|
414
421
|
try {
|
|
415
422
|
throw new Error('bork');
|
|
416
423
|
} catch (e) {
|
|
417
424
|
err = e;
|
|
418
425
|
}
|
|
419
|
-
var args = [err, {custom: 'stuff'}];
|
|
426
|
+
var args = [err, { custom: 'stuff' }];
|
|
420
427
|
var item = itemFromArgs(args);
|
|
421
428
|
item.description = 'borked';
|
|
422
429
|
var options = { guessErrorClass: true };
|
|
423
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
430
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
424
431
|
expect(i.stackInfo).to.be.ok();
|
|
425
432
|
i.stackInfo.name = null; // force alternate path to determine error class.
|
|
426
|
-
t.addBody(i, options, function(e, i) {
|
|
433
|
+
t.addBody(i, options, function (e, i) {
|
|
427
434
|
expect(i.data.body.trace.exception.class).to.eql('(unknown)');
|
|
428
435
|
expect(i.data.body.trace.exception.message).to.eql('bork');
|
|
429
436
|
done(e);
|
|
@@ -432,25 +439,29 @@ describe('addBody', function() {
|
|
|
432
439
|
});
|
|
433
440
|
});
|
|
434
441
|
});
|
|
435
|
-
describe('with nested error', function() {
|
|
436
|
-
it('should create trace_chain', function(done) {
|
|
442
|
+
describe('with nested error', function () {
|
|
443
|
+
it('should create trace_chain', function (done) {
|
|
437
444
|
var nestedErr = new Error('nested error');
|
|
438
445
|
var err = new Error('test error');
|
|
439
446
|
err.nested = nestedErr;
|
|
440
447
|
var args = ['a message', err];
|
|
441
448
|
var item = itemFromArgs(args);
|
|
442
449
|
var options = {};
|
|
443
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
450
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
444
451
|
expect(i.stackInfo).to.be.ok();
|
|
445
452
|
});
|
|
446
|
-
t.addBody(item, options, function(e, i) {
|
|
453
|
+
t.addBody(item, options, function (e, i) {
|
|
447
454
|
expect(i.data.body.trace_chain.length).to.eql(2);
|
|
448
|
-
expect(i.data.body.trace_chain[0].exception.message).to.eql(
|
|
449
|
-
|
|
455
|
+
expect(i.data.body.trace_chain[0].exception.message).to.eql(
|
|
456
|
+
'test error',
|
|
457
|
+
);
|
|
458
|
+
expect(i.data.body.trace_chain[1].exception.message).to.eql(
|
|
459
|
+
'nested error',
|
|
460
|
+
);
|
|
450
461
|
done(e);
|
|
451
462
|
});
|
|
452
463
|
});
|
|
453
|
-
it('should create add error context as custom data', function(done) {
|
|
464
|
+
it('should create add error context as custom data', function (done) {
|
|
454
465
|
var nestedErr = new Error('nested error');
|
|
455
466
|
nestedErr.rollbarContext = { err1: 'nested context' };
|
|
456
467
|
var err = new Error('test error');
|
|
@@ -459,10 +470,10 @@ describe('addBody', function() {
|
|
|
459
470
|
var args = ['a message', err];
|
|
460
471
|
var item = itemFromArgs(args);
|
|
461
472
|
var options = { addErrorContext: true };
|
|
462
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
473
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
463
474
|
expect(i.stackInfo).to.be.ok();
|
|
464
475
|
});
|
|
465
|
-
t.addBody(item, options, function(e, i) {
|
|
476
|
+
t.addBody(item, options, function (e, i) {
|
|
466
477
|
expect(i.data.body.trace_chain.length).to.eql(2);
|
|
467
478
|
expect(i.data.custom.err1).to.eql('nested context');
|
|
468
479
|
expect(i.data.custom.err2).to.eql('error context');
|
|
@@ -470,38 +481,42 @@ describe('addBody', function() {
|
|
|
470
481
|
});
|
|
471
482
|
});
|
|
472
483
|
});
|
|
473
|
-
describe('with error cause', function() {
|
|
484
|
+
describe('with error cause', function () {
|
|
474
485
|
// Error cause was introduced in Chrome 93.
|
|
475
486
|
if (chromeMajorVersion() < 93) return;
|
|
476
487
|
|
|
477
|
-
it('should create trace_chain', function(done) {
|
|
488
|
+
it('should create trace_chain', function (done) {
|
|
478
489
|
var causeErr = new Error('cause error');
|
|
479
|
-
var err = new Error('test error', { cause: causeErr});
|
|
490
|
+
var err = new Error('test error', { cause: causeErr });
|
|
480
491
|
var args = ['a message', err];
|
|
481
492
|
var item = itemFromArgs(args);
|
|
482
493
|
var options = {};
|
|
483
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
494
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
484
495
|
expect(i.stackInfo).to.be.ok();
|
|
485
496
|
});
|
|
486
|
-
t.addBody(item, options, function(e, i) {
|
|
497
|
+
t.addBody(item, options, function (e, i) {
|
|
487
498
|
expect(i.data.body.trace_chain.length).to.eql(2);
|
|
488
|
-
expect(i.data.body.trace_chain[0].exception.message).to.eql(
|
|
489
|
-
|
|
499
|
+
expect(i.data.body.trace_chain[0].exception.message).to.eql(
|
|
500
|
+
'test error',
|
|
501
|
+
);
|
|
502
|
+
expect(i.data.body.trace_chain[1].exception.message).to.eql(
|
|
503
|
+
'cause error',
|
|
504
|
+
);
|
|
490
505
|
done(e);
|
|
491
506
|
});
|
|
492
507
|
});
|
|
493
|
-
it('should create add error context as custom data', function(done) {
|
|
508
|
+
it('should create add error context as custom data', function (done) {
|
|
494
509
|
var causeErr = new Error('cause error');
|
|
495
510
|
causeErr.rollbarContext = { err1: 'cause context' };
|
|
496
|
-
var err = new Error('test error', { cause: causeErr});
|
|
511
|
+
var err = new Error('test error', { cause: causeErr });
|
|
497
512
|
err.rollbarContext = { err2: 'error context' };
|
|
498
513
|
var args = ['a message', err];
|
|
499
514
|
var item = itemFromArgs(args);
|
|
500
515
|
var options = { addErrorContext: true };
|
|
501
|
-
t.handleItemWithError(item, options, function(e, i) {
|
|
516
|
+
t.handleItemWithError(item, options, function (e, i) {
|
|
502
517
|
expect(i.stackInfo).to.be.ok();
|
|
503
518
|
});
|
|
504
|
-
t.addBody(item, options, function(e, i) {
|
|
519
|
+
t.addBody(item, options, function (e, i) {
|
|
505
520
|
expect(i.data.body.trace_chain.length).to.eql(2);
|
|
506
521
|
expect(i.data.custom.err1).to.eql('cause context');
|
|
507
522
|
expect(i.data.custom.err2).to.eql('error context');
|
|
@@ -511,18 +526,21 @@ describe('addBody', function() {
|
|
|
511
526
|
});
|
|
512
527
|
});
|
|
513
528
|
|
|
514
|
-
describe('scrubPayload', function() {
|
|
515
|
-
it('only scrubs payload data', function(done) {
|
|
516
|
-
var args = [
|
|
529
|
+
describe('scrubPayload', function () {
|
|
530
|
+
it('only scrubs payload data', function (done) {
|
|
531
|
+
var args = [
|
|
532
|
+
'a message',
|
|
533
|
+
{ scooby: 'doo', okay: 'fizz=buzz&fuzz=baz', user: { id: 42 } },
|
|
534
|
+
];
|
|
517
535
|
var item = itemFromArgs(args);
|
|
518
536
|
var accessToken = 'abc123';
|
|
519
537
|
var options = {
|
|
520
538
|
endpoint: 'api.rollbar.com/',
|
|
521
|
-
scrubFields: ['access_token', 'accessToken', 'scooby', 'fizz', 'user']
|
|
539
|
+
scrubFields: ['access_token', 'accessToken', 'scooby', 'fizz', 'user'],
|
|
522
540
|
};
|
|
523
541
|
var payload = {
|
|
524
542
|
access_token: accessToken,
|
|
525
|
-
data: item
|
|
543
|
+
data: item,
|
|
526
544
|
};
|
|
527
545
|
expect(payload.access_token).to.eql(accessToken);
|
|
528
546
|
expect(payload.data.custom.scooby).to.eql('doo');
|
|
@@ -530,7 +548,7 @@ describe('scrubPayload', function() {
|
|
|
530
548
|
expect(payload.data.custom.user.id).to.eql(42);
|
|
531
549
|
|
|
532
550
|
var scrub = require('../src/scrub');
|
|
533
|
-
|
|
551
|
+
t.addScrubber(scrub)(payload, options, function (e, i) {
|
|
534
552
|
expect(i.access_token).to.eql(accessToken);
|
|
535
553
|
expect(i.data.custom.scooby).to.not.eql('doo');
|
|
536
554
|
expect(payload.data.custom.okay).to.not.eql('fizz=buzz&fuzz=baz');
|