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.
Files changed (117) hide show
  1. package/.github/workflows/ci.yml +32 -10
  2. package/.lgtm.yml +7 -7
  3. package/.prettierignore +18 -0
  4. package/.vscode/settings.json +39 -0
  5. package/CHANGELOG.md +121 -35
  6. package/Gruntfile.js +51 -71
  7. package/README.md +2 -4
  8. package/bower.json +1 -3
  9. package/defaults.js +17 -5
  10. package/dist/plugins/jquery.min.js +1 -1
  11. package/dist/rollbar.js +5699 -5052
  12. package/dist/rollbar.js.map +1 -1
  13. package/dist/rollbar.min.js +1 -1
  14. package/dist/rollbar.min.js.map +1 -1
  15. package/dist/rollbar.named-amd.js +5704 -5062
  16. package/dist/rollbar.named-amd.js.map +1 -1
  17. package/dist/rollbar.named-amd.min.js +1 -1
  18. package/dist/rollbar.named-amd.min.js.map +1 -1
  19. package/dist/rollbar.noconflict.umd.js +5693 -5052
  20. package/dist/rollbar.noconflict.umd.js.map +1 -1
  21. package/dist/rollbar.noconflict.umd.min.js +1 -1
  22. package/dist/rollbar.noconflict.umd.min.js.map +1 -1
  23. package/dist/rollbar.snippet.js +1 -1
  24. package/dist/rollbar.umd.js +5704 -5063
  25. package/dist/rollbar.umd.js.map +1 -1
  26. package/dist/rollbar.umd.min.js +1 -1
  27. package/dist/rollbar.umd.min.js.map +1 -1
  28. package/docs/extension-exceptions.md +35 -30
  29. package/docs/migration_v0_to_v1.md +41 -38
  30. package/index.d.ts +270 -231
  31. package/karma.conf.js +16 -34
  32. package/package.json +21 -17
  33. package/prettier.config.js +7 -0
  34. package/src/api.js +21 -10
  35. package/src/apiUtility.js +12 -8
  36. package/src/browser/core.js +103 -65
  37. package/src/browser/defaults/scrubFields.js +3 -3
  38. package/src/browser/detection.js +7 -8
  39. package/src/browser/domUtility.js +18 -8
  40. package/src/browser/globalSetup.js +12 -6
  41. package/src/browser/logger.js +1 -1
  42. package/src/browser/plugins/jquery.js +35 -35
  43. package/src/browser/predicates.js +1 -1
  44. package/src/browser/rollbar.js +1 -1
  45. package/src/browser/rollbarWrapper.js +8 -5
  46. package/src/browser/shim.js +43 -19
  47. package/src/browser/snippet_callback.js +6 -4
  48. package/src/browser/telemetry.js +573 -354
  49. package/src/browser/transforms.js +46 -27
  50. package/src/browser/transport/fetch.js +16 -14
  51. package/src/browser/transport/xhr.js +29 -13
  52. package/src/browser/transport.js +82 -25
  53. package/src/browser/url.js +16 -8
  54. package/src/browser/wrapGlobals.js +27 -8
  55. package/src/defaults.js +3 -3
  56. package/src/errorParser.js +14 -11
  57. package/src/merge.js +32 -23
  58. package/src/notifier.js +16 -13
  59. package/src/predicates.js +43 -23
  60. package/src/queue.js +71 -39
  61. package/src/rateLimiter.js +59 -18
  62. package/src/react-native/logger.js +1 -1
  63. package/src/react-native/rollbar.js +59 -55
  64. package/src/react-native/transforms.js +13 -9
  65. package/src/react-native/transport.js +44 -34
  66. package/src/rollbar.js +22 -13
  67. package/src/scrub.js +0 -1
  68. package/src/server/locals.js +69 -39
  69. package/src/server/logger.js +4 -4
  70. package/src/server/parser.js +72 -47
  71. package/src/server/rollbar.js +133 -55
  72. package/src/server/sourceMap/stackTrace.js +33 -18
  73. package/src/server/telemetry/urlHelpers.js +9 -11
  74. package/src/server/telemetry.js +68 -45
  75. package/src/server/transforms.js +37 -21
  76. package/src/server/transport.js +62 -32
  77. package/src/telemetry.js +92 -28
  78. package/src/transforms.js +33 -21
  79. package/src/truncation.js +8 -5
  80. package/src/utility/headers.js +43 -43
  81. package/src/utility/replace.js +9 -0
  82. package/src/utility/traverse.js +1 -1
  83. package/src/utility.js +89 -52
  84. package/test/api.test.js +31 -29
  85. package/test/apiUtility.test.js +43 -44
  86. package/test/browser.core.test.js +141 -131
  87. package/test/browser.domUtility.test.js +52 -35
  88. package/test/browser.predicates.test.js +13 -13
  89. package/test/browser.rollbar.test.js +597 -503
  90. package/test/browser.telemetry.test.js +76 -0
  91. package/test/browser.transforms.test.js +146 -128
  92. package/test/browser.transport.test.js +54 -46
  93. package/test/browser.url.test.js +12 -11
  94. package/test/fixtures/locals.fixtures.js +245 -126
  95. package/test/notifier.test.js +90 -78
  96. package/test/predicates.test.js +260 -214
  97. package/test/queue.test.js +230 -214
  98. package/test/rateLimiter.test.js +50 -42
  99. package/test/react-native.rollbar.test.js +149 -115
  100. package/test/react-native.transforms.test.js +21 -23
  101. package/test/react-native.transport.test.js +23 -11
  102. package/test/server.lambda.test.js +70 -53
  103. package/test/server.locals.test.js +437 -210
  104. package/test/server.parser.test.js +32 -26
  105. package/test/server.predicates.test.js +45 -43
  106. package/test/server.rollbar.test.js +311 -259
  107. package/test/server.telemetry.test.js +208 -83
  108. package/test/server.transforms.test.js +455 -361
  109. package/test/server.transport.test.js +144 -76
  110. package/test/telemetry.test.js +46 -37
  111. package/test/transforms.test.js +68 -66
  112. package/test/truncation.test.js +55 -53
  113. package/test/utility.test.js +266 -222
  114. package/webpack.config.js +46 -43
  115. package/.gitmodules +0 -3
  116. package/browserstack.browsers.js +0 -153
  117. package/browserstack.browsers.json +0 -4384
@@ -13,50 +13,50 @@ const ValidOpenTracingTracerStub = {
13
13
  return {
14
14
  active: () => {
15
15
  return {
16
- setTag: () => { },
16
+ setTag: () => {},
17
17
  context: () => {
18
18
  return {
19
19
  toTraceId: () => DUMMY_TRACE_ID,
20
- toSpanId: () => DUMMY_SPAN_ID
21
- }
22
- }
23
- }
24
- }
25
- }
26
- }
20
+ toSpanId: () => DUMMY_SPAN_ID,
21
+ };
22
+ },
23
+ };
24
+ },
25
+ };
26
+ },
27
27
  };
28
28
 
29
29
  const InvalidOpenTracingTracerStub = {
30
- foo: () => { }
30
+ foo: () => {},
31
31
  };
32
32
 
33
33
  function TestClientGen() {
34
- var TestClient = function() {
34
+ var TestClient = function () {
35
35
  this.transforms = [];
36
36
  this.predicates = [];
37
37
  this.notifier = {
38
- addTransform: function(t) {
38
+ addTransform: function (t) {
39
39
  this.transforms.push(t);
40
40
  return this.notifier;
41
- }.bind(this)
41
+ }.bind(this),
42
42
  };
43
43
  this.queue = {
44
- addPredicate: function(p) {
44
+ addPredicate: function (p) {
45
45
  this.predicates.push(p);
46
46
  return this.queue;
47
- }.bind(this)
47
+ }.bind(this),
48
48
  };
49
49
  this.logCalls = [];
50
50
  var logs = 'log,debug,info,warn,warning,error,critical'.split(',');
51
- for (var i=0, len=logs.length; i < len; i++) {
51
+ for (var i = 0, len = logs.length; i < len; i++) {
52
52
  var fn = logs[i].slice(0);
53
- this[fn] = function(fn, item) {
54
- this.logCalls.push({func: fn, item: item})
55
- }.bind(this, fn)
53
+ this[fn] = function (fn, item) {
54
+ this.logCalls.push({ func: fn, item: item });
55
+ }.bind(this, fn);
56
56
  }
57
57
  this.options = {};
58
58
  this.payloadData = {};
59
- this.configure = function(o, payloadData) {
59
+ this.configure = function (o, payloadData) {
60
60
  this.options = o;
61
61
  this.payloadData = payloadData;
62
62
  };
@@ -66,14 +66,14 @@ function TestClientGen() {
66
66
  return TestClient;
67
67
  }
68
68
 
69
- describe('Rollbar()', function() {
69
+ describe('Rollbar()', function () {
70
70
  afterEach(function () {
71
71
  window.rollbar.configure({ autoInstrument: false, captureUncaught: false });
72
72
  });
73
73
 
74
- it('should have all of the expected methods with a real client', function(done) {
74
+ it('should have all of the expected methods with a real client', function (done) {
75
75
  var options = {};
76
- var rollbar = window.rollbar = new Rollbar(options);
76
+ var rollbar = (window.rollbar = new Rollbar(options));
77
77
 
78
78
  expect(rollbar).to.have.property('log');
79
79
  expect(rollbar).to.have.property('debug');
@@ -86,10 +86,10 @@ describe('Rollbar()', function() {
86
86
  done();
87
87
  });
88
88
 
89
- it('should have all of the expected methods', function(done) {
89
+ it('should have all of the expected methods', function (done) {
90
90
  var client = new (TestClientGen())();
91
91
  var options = {};
92
- var rollbar = window.rollbar = new Rollbar(options, client);
92
+ var rollbar = (window.rollbar = new Rollbar(options, client));
93
93
 
94
94
  expect(rollbar).to.have.property('log');
95
95
  expect(rollbar).to.have.property('debug');
@@ -102,51 +102,47 @@ describe('Rollbar()', function() {
102
102
  done();
103
103
  });
104
104
 
105
- it ('should have some default options', function(done) {
105
+ it('should have some default options', function (done) {
106
106
  var client = new (TestClientGen())();
107
107
  var options = {};
108
- var rollbar = window.rollbar = new Rollbar(options, client);
108
+ var rollbar = (window.rollbar = new Rollbar(options, client));
109
109
 
110
110
  expect(rollbar.options.scrubFields).to.contain('password');
111
111
  done();
112
112
  });
113
113
 
114
- it ('should merge with the defaults options', function(done) {
114
+ it('should merge with the defaults options', function (done) {
115
115
  var client = new (TestClientGen())();
116
116
  var options = {
117
- scrubFields: [
118
- 'foobar'
119
- ]
117
+ scrubFields: ['foobar'],
120
118
  };
121
- var rollbar = window.rollbar = new Rollbar(options, client);
119
+ var rollbar = (window.rollbar = new Rollbar(options, client));
122
120
 
123
121
  expect(rollbar.options.scrubFields).to.contain('foobar');
124
122
  expect(rollbar.options.scrubFields).to.contain('password');
125
123
  done();
126
124
  });
127
125
 
128
- it ('should overwrite default if specified', function(done) {
126
+ it('should overwrite default if specified', function (done) {
129
127
  var client = new (TestClientGen())();
130
128
  var options = {
131
- scrubFields: [
132
- 'foobar'
133
- ],
129
+ scrubFields: ['foobar'],
134
130
  overwriteScrubFields: true,
135
131
  };
136
- var rollbar = window.rollbar = new Rollbar(options, client);
132
+ var rollbar = (window.rollbar = new Rollbar(options, client));
137
133
 
138
134
  expect(rollbar.options.scrubFields).to.contain('foobar');
139
135
  expect(rollbar.options.scrubFields).to.not.contain('password');
140
136
  done();
141
137
  });
142
138
 
143
- it ('should replace deprecated options', function(done) {
139
+ it('should replace deprecated options', function (done) {
144
140
  var client = new (TestClientGen())();
145
141
  var options = {
146
142
  hostWhiteList: ['foo'],
147
- hostBlackList: ['bar']
143
+ hostBlackList: ['bar'],
148
144
  };
149
- var rollbar = window.rollbar = new Rollbar(options, client);
145
+ var rollbar = (window.rollbar = new Rollbar(options, client));
150
146
 
151
147
  expect(rollbar.options.hostWhiteList).to.eql(undefined);
152
148
  expect(rollbar.options.hostBlackList).to.eql(undefined);
@@ -155,10 +151,10 @@ describe('Rollbar()', function() {
155
151
  done();
156
152
  });
157
153
 
158
- it('should return a uuid when logging', function(done) {
154
+ it('should return a uuid when logging', function (done) {
159
155
  var client = new (TestClientGen())();
160
156
  var options = {};
161
- var rollbar = window.rollbar = new Rollbar(options, client);
157
+ var rollbar = (window.rollbar = new Rollbar(options, client));
162
158
 
163
159
  var result = rollbar.log('a messasge', 'another one');
164
160
  expect(result.uuid).to.be.ok();
@@ -166,10 +162,10 @@ describe('Rollbar()', function() {
166
162
  done();
167
163
  });
168
164
 
169
- it('should package up the inputs', function(done) {
165
+ it('should package up the inputs', function (done) {
170
166
  var client = new (TestClientGen())();
171
167
  var options = {};
172
- var rollbar = window.rollbar = new Rollbar(options, client);
168
+ var rollbar = (window.rollbar = new Rollbar(options, client));
173
169
 
174
170
  var result = rollbar.log('a message', 'another one');
175
171
  var loggedItem = client.logCalls[0].item;
@@ -179,34 +175,34 @@ describe('Rollbar()', function() {
179
175
  done();
180
176
  });
181
177
 
182
- it('should call the client with the right method', function(done) {
178
+ it('should call the client with the right method', function (done) {
183
179
  var client = new (TestClientGen())();
184
180
  var options = {};
185
- var rollbar = window.rollbar = new Rollbar(options, client);
181
+ var rollbar = (window.rollbar = new Rollbar(options, client));
186
182
 
187
183
  var methods = 'log,debug,info,warn,warning,error,critical'.split(',');
188
- for (var i=0; i < methods.length; i++) {
184
+ for (var i = 0; i < methods.length; i++) {
189
185
  var msg = 'message:' + i;
190
186
  rollbar[methods[i]](msg);
191
187
  expect(client.logCalls[i].func).to.eql(methods[i]);
192
- expect(client.logCalls[i].item.message).to.eql(msg)
188
+ expect(client.logCalls[i].item.message).to.eql(msg);
193
189
  }
194
190
 
195
191
  done();
196
192
  });
197
193
 
198
- it('should have a tracer if valid tracer is provided', function(done) {
194
+ it('should have a tracer if valid tracer is provided', function (done) {
199
195
  var options = { tracer: ValidOpenTracingTracerStub };
200
- var rollbar = window.rollbar = new Rollbar(options);
196
+ var rollbar = (window.rollbar = new Rollbar(options));
201
197
 
202
198
  expect(rollbar.client.tracer).to.eql(ValidOpenTracingTracerStub);
203
199
 
204
200
  done();
205
201
  });
206
202
 
207
- it('should not have a tracer if invalid tracer is provided', function(done) {
203
+ it('should not have a tracer if invalid tracer is provided', function (done) {
208
204
  var options = { tracer: InvalidOpenTracingTracerStub };
209
- var rollbar = window.rollbar = new Rollbar(options);
205
+ var rollbar = (window.rollbar = new Rollbar(options));
210
206
 
211
207
  expect(rollbar.client.tracer).to.eql(null);
212
208
 
@@ -214,68 +210,71 @@ describe('Rollbar()', function() {
214
210
  });
215
211
  });
216
212
 
217
- describe('configure', function() {
213
+ describe('configure', function () {
218
214
  afterEach(function () {
219
215
  window.rollbar.configure({ autoInstrument: false, captureUncaught: false });
220
216
  });
221
217
 
222
- it('should configure client', function(done) {
218
+ it('should configure client', function (done) {
223
219
  var client = new (TestClientGen())();
224
220
  var options = {
225
221
  payload: {
226
222
  a: 42,
227
- environment: 'testtest'
228
- }
223
+ environment: 'testtest',
224
+ },
229
225
  };
230
- var rollbar = window.rollbar = new Rollbar(options, client);
226
+ var rollbar = (window.rollbar = new Rollbar(options, client));
231
227
  expect(rollbar.options.payload.environment).to.eql('testtest');
232
228
 
233
- rollbar.configure({payload: {environment: 'borkbork'}});
229
+ rollbar.configure({ payload: { environment: 'borkbork' } });
234
230
  expect(rollbar.options.payload.environment).to.eql('borkbork');
235
231
  expect(client.options.payload.environment).to.eql('borkbork');
236
232
  done();
237
233
  });
238
- it('should accept a second parameter and use it as the payload value', function(done) {
234
+ it('should accept a second parameter and use it as the payload value', function (done) {
239
235
  var client = new (TestClientGen())();
240
236
  var options = {
241
237
  payload: {
242
238
  a: 42,
243
- environment: 'testtest'
244
- }
239
+ environment: 'testtest',
240
+ },
245
241
  };
246
- var rollbar = window.rollbar = new Rollbar(options, client);
242
+ var rollbar = (window.rollbar = new Rollbar(options, client));
247
243
  expect(rollbar.options.payload.environment).to.eql('testtest');
248
244
 
249
- rollbar.configure({somekey: 'borkbork'}, {b: 97});
245
+ rollbar.configure({ somekey: 'borkbork' }, { b: 97 });
250
246
  expect(rollbar.options.somekey).to.eql('borkbork');
251
247
  expect(rollbar.options.payload.b).to.eql(97);
252
248
  expect(client.payloadData.b).to.eql(97);
253
249
  done();
254
250
  });
255
- it('should accept a second parameter and override the payload with it', function(done) {
251
+ it('should accept a second parameter and override the payload with it', function (done) {
256
252
  var client = new (TestClientGen())();
257
253
  var options = {
258
254
  payload: {
259
255
  a: 42,
260
- environment: 'testtest'
261
- }
256
+ environment: 'testtest',
257
+ },
262
258
  };
263
- var rollbar = window.rollbar = new Rollbar(options, client);
259
+ var rollbar = (window.rollbar = new Rollbar(options, client));
264
260
  expect(rollbar.options.payload.environment).to.eql('testtest');
265
261
 
266
- rollbar.configure({somekey: 'borkbork', payload: {b: 101}}, {b: 97});
262
+ rollbar.configure({ somekey: 'borkbork', payload: { b: 101 } }, { b: 97 });
267
263
  expect(rollbar.options.somekey).to.eql('borkbork');
268
264
  expect(rollbar.options.payload.b).to.eql(97);
269
265
  expect(client.payloadData.b).to.eql(97);
270
266
  done();
271
267
  });
272
- it ('should replace deprecated options', function(done) {
268
+ it('should replace deprecated options', function (done) {
273
269
  var client = new (TestClientGen())();
274
270
  var options = {
275
271
  hostWhiteList: ['foo'],
276
- hostBlackList: ['bar']
272
+ hostBlackList: ['bar'],
277
273
  };
278
- var rollbar = window.rollbar = new Rollbar({ autoInstrument: false }, client);
274
+ var rollbar = (window.rollbar = new Rollbar(
275
+ { autoInstrument: false },
276
+ client,
277
+ ));
279
278
  rollbar.configure(options);
280
279
 
281
280
  expect(rollbar.options.hostWhiteList).to.eql(undefined);
@@ -284,27 +283,34 @@ describe('configure', function() {
284
283
  expect(rollbar.options.hostBlockList).to.contain('bar');
285
284
  done();
286
285
  });
287
- it('should store configured options', function(done) {
286
+ it('should store configured options', function (done) {
288
287
  var client = new (TestClientGen())();
289
288
  var options = {
290
289
  captureUncaught: true,
291
290
  payload: {
292
291
  a: 42,
293
- environment: 'testtest'
294
- }
292
+ environment: 'testtest',
293
+ },
295
294
  };
296
- var rollbar = window.rollbar = new Rollbar(options, client);
297
- expect(rollbar.options._configuredOptions.payload.environment).to.eql('testtest');
295
+ var rollbar = (window.rollbar = new Rollbar(options, client));
296
+ expect(rollbar.options._configuredOptions.payload.environment).to.eql(
297
+ 'testtest',
298
+ );
298
299
  expect(rollbar.options._configuredOptions.captureUncaught).to.eql(true);
299
300
 
300
- rollbar.configure({ captureUncaught: false, payload: {environment: 'borkbork'}});
301
- expect(rollbar.options._configuredOptions.payload.environment).to.eql('borkbork');
301
+ rollbar.configure({
302
+ captureUncaught: false,
303
+ payload: { environment: 'borkbork' },
304
+ });
305
+ expect(rollbar.options._configuredOptions.payload.environment).to.eql(
306
+ 'borkbork',
307
+ );
302
308
  expect(rollbar.options._configuredOptions.captureUncaught).to.eql(false);
303
309
  done();
304
310
  });
305
311
  });
306
312
 
307
- describe('options.captureUncaught', function() {
313
+ describe('options.captureUncaught', function () {
308
314
  beforeEach(function (done) {
309
315
  // Load the HTML page, so errors can be generated.
310
316
  document.write(window.__html__['examples/error.html']);
@@ -319,51 +325,51 @@ describe('options.captureUncaught', function() {
319
325
  });
320
326
 
321
327
  function stubResponse(server) {
322
- server.respondWith('POST', 'api/1/item',
323
- [
324
- 200,
325
- { 'Content-Type': 'application/json' },
326
- '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}'
327
- ]
328
- );
328
+ server.respondWith('POST', 'api/1/item', [
329
+ 200,
330
+ { 'Content-Type': 'application/json' },
331
+ '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}',
332
+ ]);
329
333
  }
330
334
 
331
- it('should capture when enabled in constructor', function(done) {
335
+ it('should capture when enabled in constructor', function (done) {
332
336
  var server = window.server;
333
337
  stubResponse(server);
334
338
  server.requests.length = 0;
335
339
 
336
340
  var options = {
337
341
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
338
- captureUncaught: true
342
+ captureUncaught: true,
339
343
  };
340
- var rollbar = window.rollbar = new Rollbar(options);
344
+ var rollbar = (window.rollbar = new Rollbar(options));
341
345
 
342
346
  var element = document.getElementById('throw-error');
343
347
  element.click();
344
348
 
345
- setTimeout(function() {
349
+ setTimeout(function () {
346
350
  server.respond();
347
351
 
348
352
  var body = JSON.parse(server.requests[0].requestBody);
349
353
 
350
354
  expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
351
355
  expect(body.data.body.trace.exception.message).to.eql('test error');
352
- expect(body.data.notifier.diagnostic.raw_error.message).to.eql('test error');
356
+ expect(body.data.notifier.diagnostic.raw_error.message).to.eql(
357
+ 'test error',
358
+ );
353
359
  expect(body.data.notifier.diagnostic.is_uncaught).to.eql(true);
354
360
 
355
361
  // karma doesn't unload the browser between tests, so the onerror handler
356
362
  // will remain installed. Unset captureUncaught so the onerror handler
357
363
  // won't affect other tests.
358
364
  rollbar.configure({
359
- captureUncaught: false
365
+ captureUncaught: false,
360
366
  });
361
367
 
362
368
  done();
363
369
  }, 1);
364
370
  });
365
371
 
366
- it('should respond to enable/disable in configure', function(done) {
372
+ it('should respond to enable/disable in configure', function (done) {
367
373
  var server = window.server;
368
374
  var element = document.getElementById('throw-error');
369
375
  stubResponse(server);
@@ -371,24 +377,24 @@ describe('options.captureUncaught', function() {
371
377
 
372
378
  var options = {
373
379
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
374
- captureUncaught: false
380
+ captureUncaught: false,
375
381
  };
376
- var rollbar = window.rollbar = new Rollbar(options);
382
+ var rollbar = (window.rollbar = new Rollbar(options));
377
383
 
378
384
  element.click();
379
385
 
380
- setTimeout(function() {
386
+ setTimeout(function () {
381
387
  server.respond();
382
388
  expect(server.requests.length).to.eql(0); // Disabled, no event
383
389
  server.requests.length = 0;
384
390
 
385
391
  rollbar.configure({
386
- captureUncaught: true
392
+ captureUncaught: true,
387
393
  });
388
394
 
389
395
  element.click();
390
396
 
391
- setTimeout(function() {
397
+ setTimeout(function () {
392
398
  server.respond();
393
399
 
394
400
  var body = JSON.parse(server.requests[0].requestBody);
@@ -400,12 +406,12 @@ describe('options.captureUncaught', function() {
400
406
  server.requests.length = 0;
401
407
 
402
408
  rollbar.configure({
403
- captureUncaught: false
409
+ captureUncaught: false,
404
410
  });
405
411
 
406
412
  element.click();
407
413
 
408
- setTimeout(function() {
414
+ setTimeout(function () {
409
415
  server.respond();
410
416
  expect(server.requests.length).to.eql(0); // Disabled, no event
411
417
 
@@ -413,37 +419,36 @@ describe('options.captureUncaught', function() {
413
419
  }, 1);
414
420
  }, 1);
415
421
  }, 1);
416
-
417
422
  });
418
423
 
419
424
  // Test case expects Chrome, which is the currently configured karma js/browser
420
425
  // engine at the time of this comment. However, karma's Chrome and ChromeHeadless
421
426
  // don't actually behave like real Chrome so we settle for stubbing some things.
422
- it('should capture external error data when inspectAnonymousErrors is true', function(done) {
427
+ it('should capture external error data when inspectAnonymousErrors is true', function (done) {
423
428
  var server = window.server;
424
429
  stubResponse(server);
425
430
  server.requests.length = 0;
426
431
 
427
432
  // We're supposedly running on ChromeHeadless, but still need to spoof Chrome. :\
428
- window.chrome = { runtime: true};
433
+ window.chrome = { runtime: true };
429
434
 
430
435
  var options = {
431
436
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
432
437
  captureUncaught: true,
433
- inspectAnonymousErrors: true
438
+ inspectAnonymousErrors: true,
434
439
  };
435
- var rollbar = window.rollbar = new Rollbar(options);
440
+ var rollbar = (window.rollbar = new Rollbar(options));
436
441
 
437
442
  // Simulate receiving onerror without an error object.
438
443
  rollbar.anonymousErrorsPending += 1;
439
444
 
440
445
  try {
441
- throw new Error('anon error')
442
- } catch(e) {
446
+ throw new Error('anon error');
447
+ } catch (e) {
443
448
  Error.prepareStackTrace(e);
444
449
  }
445
450
 
446
- setTimeout(function() {
451
+ setTimeout(function () {
447
452
  server.respond();
448
453
 
449
454
  var body = JSON.parse(server.requests[0].requestBody);
@@ -456,32 +461,32 @@ describe('options.captureUncaught', function() {
456
461
  // will remain installed. Unset captureUncaught so the onerror handler
457
462
  // won't affect other tests.
458
463
  rollbar.configure({
459
- captureUncaught: false
464
+ captureUncaught: false,
460
465
  });
461
466
 
462
467
  done();
463
468
  }, 1);
464
469
  });
465
470
 
466
- it('should ignore duplicate errors by default', function(done) {
471
+ it('should ignore duplicate errors by default', function (done) {
467
472
  var server = window.server;
468
473
  stubResponse(server);
469
474
  server.requests.length = 0;
470
475
 
471
476
  var options = {
472
477
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
473
- captureUncaught: true
478
+ captureUncaught: true,
474
479
  };
475
- var rollbar = window.rollbar = new Rollbar(options);
480
+ var rollbar = (window.rollbar = new Rollbar(options));
476
481
 
477
482
  var element = document.getElementById('throw-error');
478
483
 
479
484
  // generate same error twice
480
- for(var i = 0; i < 2; i++) {
485
+ for (var i = 0; i < 2; i++) {
481
486
  element.click(); // use for loop to ensure the stack traces have identical line/col info
482
487
  }
483
488
 
484
- setTimeout(function() {
489
+ setTimeout(function () {
485
490
  server.respond();
486
491
 
487
492
  // transmit only once
@@ -496,14 +501,14 @@ describe('options.captureUncaught', function() {
496
501
  // will remain installed. Unset captureUncaught so the onerror handler
497
502
  // won't affect other tests.
498
503
  rollbar.configure({
499
- captureUncaught: false
504
+ captureUncaught: false,
500
505
  });
501
506
 
502
507
  done();
503
508
  }, 1);
504
509
  });
505
510
 
506
- it('should transmit duplicate errors when set in config', function(done) {
511
+ it('should transmit duplicate errors when set in config', function (done) {
507
512
  var server = window.server;
508
513
  stubResponse(server);
509
514
  server.requests.length = 0;
@@ -511,18 +516,18 @@ describe('options.captureUncaught', function() {
511
516
  var options = {
512
517
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
513
518
  captureUncaught: true,
514
- ignoreDuplicateErrors: false
519
+ ignoreDuplicateErrors: false,
515
520
  };
516
- var rollbar = window.rollbar = new Rollbar(options);
521
+ var rollbar = (window.rollbar = new Rollbar(options));
517
522
 
518
523
  var element = document.getElementById('throw-error');
519
524
 
520
525
  // generate same error twice
521
- for(var i = 0; i < 2; i++) {
526
+ for (var i = 0; i < 2; i++) {
522
527
  element.click(); // use for loop to ensure the stack traces have identical line/col info
523
528
  }
524
529
 
525
- setTimeout(function() {
530
+ setTimeout(function () {
526
531
  server.respond();
527
532
 
528
533
  // transmit both errors
@@ -537,46 +542,48 @@ describe('options.captureUncaught', function() {
537
542
  // will remain installed. Unset captureUncaught so the onerror handler
538
543
  // won't affect other tests.
539
544
  rollbar.configure({
540
- captureUncaught: false
545
+ captureUncaught: false,
541
546
  });
542
547
 
543
548
  done();
544
549
  }, 1);
545
550
  });
546
- it('should send DOMException as trace_chain', function(done) {
551
+ it('should send DOMException as trace_chain', function (done) {
547
552
  var server = window.server;
548
553
  stubResponse(server);
549
554
  server.requests.length = 0;
550
555
 
551
556
  var options = {
552
557
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
553
- captureUncaught: true
558
+ captureUncaught: true,
554
559
  };
555
- var rollbar = window.rollbar = new Rollbar(options);
560
+ var rollbar = (window.rollbar = new Rollbar(options));
556
561
 
557
562
  var element = document.getElementById('throw-dom-exception');
558
563
  element.click();
559
564
 
560
- setTimeout(function() {
565
+ setTimeout(function () {
561
566
  server.respond();
562
567
 
563
568
  var body = JSON.parse(server.requests[0].requestBody);
564
569
 
565
570
  expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
566
- expect(body.data.body.trace_chain[0].exception.message).to.eql('test DOMException');
571
+ expect(body.data.body.trace_chain[0].exception.message).to.eql(
572
+ 'test DOMException',
573
+ );
567
574
 
568
575
  // karma doesn't unload the browser between tests, so the onerror handler
569
576
  // will remain installed. Unset captureUncaught so the onerror handler
570
577
  // won't affect other tests.
571
578
  rollbar.configure({
572
- captureUncaught: false
579
+ captureUncaught: false,
573
580
  });
574
581
 
575
582
  done();
576
583
  }, 1);
577
584
  });
578
585
 
579
- it('should capture exta frames when stackTraceLimit is set', function(done) {
586
+ it('should capture exta frames when stackTraceLimit is set', function (done) {
580
587
  var server = window.server;
581
588
  stubResponse(server);
582
589
  server.requests.length = 0;
@@ -585,14 +592,14 @@ describe('options.captureUncaught', function() {
585
592
  var options = {
586
593
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
587
594
  captureUncaught: true,
588
- stackTraceLimit: 50
595
+ stackTraceLimit: 50,
589
596
  };
590
- var rollbar = window.rollbar = new Rollbar(options);
597
+ var rollbar = (window.rollbar = new Rollbar(options));
591
598
 
592
599
  var element = document.getElementById('throw-depp-stack-error');
593
600
  element.click();
594
601
 
595
- setTimeout(function() {
602
+ setTimeout(function () {
596
603
  server.respond();
597
604
 
598
605
  var body = JSON.parse(server.requests[0].requestBody);
@@ -606,14 +613,14 @@ describe('options.captureUncaught', function() {
606
613
  // won't affect other tests.
607
614
  rollbar.configure({
608
615
  captureUncaught: false,
609
- stackTraceLimit: oldLimit // reset to default
616
+ stackTraceLimit: oldLimit, // reset to default
610
617
  });
611
618
 
612
619
  done();
613
620
  }, 1);
614
621
  });
615
622
 
616
- it('should add _wrappedSource when wrapGlobalEventHandlers is set', function(done) {
623
+ it('should add _wrappedSource when wrapGlobalEventHandlers is set', function (done) {
617
624
  var server = window.server;
618
625
  stubResponse(server);
619
626
  server.requests.length = 0;
@@ -621,21 +628,22 @@ describe('options.captureUncaught', function() {
621
628
  var options = {
622
629
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
623
630
  captureUncaught: true,
624
- wrapGlobalEventHandlers: true
631
+ wrapGlobalEventHandlers: true,
625
632
  };
626
- var rollbar = window.rollbar = new Rollbar(options);
633
+ var rollbar = (window.rollbar = new Rollbar(options));
627
634
 
628
635
  var element = document.getElementById('throw-event-handler-error');
629
636
  element.click();
630
637
 
631
- setTimeout(function() {
632
-
638
+ setTimeout(function () {
633
639
  server.respond();
634
640
 
635
641
  var body = JSON.parse(server.requests[0].requestBody);
636
642
 
637
643
  expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
638
- expect(body.data.body.trace.exception.message).to.eql('event handler error');
644
+ expect(body.data.body.trace.exception.message).to.eql(
645
+ 'event handler error',
646
+ );
639
647
  expect(body.data.body.trace.extra).to.have.property('_wrappedSource');
640
648
 
641
649
  // karma doesn't unload the browser between tests, so the onerror handler
@@ -643,7 +651,7 @@ describe('options.captureUncaught', function() {
643
651
  // won't affect other tests.
644
652
  rollbar.configure({
645
653
  captureUncaught: false,
646
- wrapGlobalEventHandlers: false
654
+ wrapGlobalEventHandlers: false,
647
655
  });
648
656
 
649
657
  done();
@@ -651,7 +659,7 @@ describe('options.captureUncaught', function() {
651
659
  });
652
660
  });
653
661
 
654
- describe('options.captureUnhandledRejections', function() {
662
+ describe('options.captureUnhandledRejections', function () {
655
663
  beforeEach(function (done) {
656
664
  window.server = sinon.createFakeServer();
657
665
  done();
@@ -663,29 +671,27 @@ describe('options.captureUnhandledRejections', function() {
663
671
  });
664
672
 
665
673
  function stubResponse(server) {
666
- server.respondWith('POST', 'api/1/item',
667
- [
668
- 200,
669
- { 'Content-Type': 'application/json' },
670
- '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}'
671
- ]
672
- );
674
+ server.respondWith('POST', 'api/1/item', [
675
+ 200,
676
+ { 'Content-Type': 'application/json' },
677
+ '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}',
678
+ ]);
673
679
  }
674
680
 
675
- it('should capture when enabled in constructor', function(done) {
681
+ it('should capture when enabled in constructor', function (done) {
676
682
  var server = window.server;
677
683
  stubResponse(server);
678
684
  server.requests.length = 0;
679
685
 
680
686
  var options = {
681
687
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
682
- captureUnhandledRejections: true
688
+ captureUnhandledRejections: true,
683
689
  };
684
- var rollbar = window.rollbar = new Rollbar(options);
690
+ var rollbar = (window.rollbar = new Rollbar(options));
685
691
 
686
692
  Promise.reject(new Error('test reject'));
687
693
 
688
- setTimeout(function() {
694
+ setTimeout(function () {
689
695
  server.respond();
690
696
 
691
697
  var body = JSON.parse(server.requests[0].requestBody);
@@ -695,7 +701,7 @@ describe('options.captureUnhandledRejections', function() {
695
701
  expect(body.data.notifier.diagnostic.is_uncaught).to.eql(true);
696
702
 
697
703
  rollbar.configure({
698
- captureUnhandledRejections: false
704
+ captureUnhandledRejections: false,
699
705
  });
700
706
  window.removeEventListener('unhandledrejection', window._rollbarURH);
701
707
 
@@ -703,24 +709,24 @@ describe('options.captureUnhandledRejections', function() {
703
709
  }, 500);
704
710
  });
705
711
 
706
- it('should respond to enable in configure', function(done) {
712
+ it('should respond to enable in configure', function (done) {
707
713
  var server = window.server;
708
714
  stubResponse(server);
709
715
  server.requests.length = 0;
710
716
 
711
717
  var options = {
712
718
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
713
- captureUnhandledRejections: false
719
+ captureUnhandledRejections: false,
714
720
  };
715
- var rollbar = window.rollbar = new Rollbar(options);
721
+ var rollbar = (window.rollbar = new Rollbar(options));
716
722
 
717
723
  rollbar.configure({
718
- captureUnhandledRejections: true
724
+ captureUnhandledRejections: true,
719
725
  });
720
726
 
721
727
  Promise.reject(new Error('test reject'));
722
728
 
723
- setTimeout(function() {
729
+ setTimeout(function () {
724
730
  server.respond();
725
731
 
726
732
  var body = JSON.parse(server.requests[0].requestBody);
@@ -731,7 +737,7 @@ describe('options.captureUnhandledRejections', function() {
731
737
  server.requests.length = 0;
732
738
 
733
739
  rollbar.configure({
734
- captureUnhandledRejections: false
740
+ captureUnhandledRejections: false,
735
741
  });
736
742
  window.removeEventListener('unhandledrejection', window._rollbarURH);
737
743
 
@@ -739,24 +745,24 @@ describe('options.captureUnhandledRejections', function() {
739
745
  }, 500);
740
746
  });
741
747
 
742
- it('should respond to disable in configure', function(done) {
748
+ it('should respond to disable in configure', function (done) {
743
749
  var server = window.server;
744
750
  stubResponse(server);
745
751
  server.requests.length = 0;
746
752
 
747
753
  var options = {
748
754
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
749
- captureUnhandledRejections: true
755
+ captureUnhandledRejections: true,
750
756
  };
751
- var rollbar = window.rollbar = new Rollbar(options);
757
+ var rollbar = (window.rollbar = new Rollbar(options));
752
758
 
753
759
  rollbar.configure({
754
- captureUnhandledRejections: false
760
+ captureUnhandledRejections: false,
755
761
  });
756
762
 
757
763
  Promise.reject(new Error('test reject'));
758
764
 
759
- setTimeout(function() {
765
+ setTimeout(function () {
760
766
  server.respond();
761
767
 
762
768
  expect(server.requests.length).to.eql(0); // Disabled, no event
@@ -766,10 +772,10 @@ describe('options.captureUnhandledRejections', function() {
766
772
 
767
773
  done();
768
774
  }, 500);
769
- })
775
+ });
770
776
  });
771
777
 
772
- describe('log', function() {
778
+ describe('log', function () {
773
779
  beforeEach(function (done) {
774
780
  window.server = sinon.createFakeServer();
775
781
  done();
@@ -781,84 +787,88 @@ describe('log', function() {
781
787
  });
782
788
 
783
789
  function stubResponse(server) {
784
- server.respondWith('POST', 'api/1/item',
785
- [
786
- 200,
787
- { 'Content-Type': 'application/json' },
788
- '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}'
789
- ]
790
- );
790
+ server.respondWith('POST', 'api/1/item', [
791
+ 200,
792
+ { 'Content-Type': 'application/json' },
793
+ '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}',
794
+ ]);
791
795
  }
792
796
 
793
- it('should send message when called with message and extra args', function(done) {
797
+ it('should send message when called with message and extra args', function (done) {
794
798
  var server = window.server;
795
799
  stubResponse(server);
796
800
  server.requests.length = 0;
797
801
 
798
802
  var options = {
799
- accessToken: 'POST_CLIENT_ITEM_TOKEN'
803
+ accessToken: 'POST_CLIENT_ITEM_TOKEN',
800
804
  };
801
- var rollbar = window.rollbar = new Rollbar(options);
805
+ var rollbar = (window.rollbar = new Rollbar(options));
802
806
 
803
- rollbar.log('test message', { 'foo': 'bar' });
807
+ rollbar.log('test message', { foo: 'bar' });
804
808
 
805
- setTimeout(function() {
809
+ setTimeout(function () {
806
810
  server.respond();
807
811
 
808
812
  var body = JSON.parse(server.requests[0].requestBody);
809
813
 
810
814
  expect(body.data.body.message.body).to.eql('test message');
811
- expect(body.data.body.message.extra).to.eql({ 'foo': 'bar' });
815
+ expect(body.data.body.message.extra).to.eql({ foo: 'bar' });
812
816
  expect(body.data.notifier.diagnostic.is_uncaught).to.eql(undefined);
813
- expect(body.data.notifier.diagnostic.original_arg_types).to.eql(['string', 'object']);
817
+ expect(body.data.notifier.diagnostic.original_arg_types).to.eql([
818
+ 'string',
819
+ 'object',
820
+ ]);
814
821
 
815
822
  done();
816
823
  }, 1);
817
- })
824
+ });
818
825
 
819
- it('should send exception when called with error and extra args', function(done) {
826
+ it('should send exception when called with error and extra args', function (done) {
820
827
  var server = window.server;
821
828
  stubResponse(server);
822
829
  server.requests.length = 0;
823
830
 
824
831
  var options = {
825
- accessToken: 'POST_CLIENT_ITEM_TOKEN'
832
+ accessToken: 'POST_CLIENT_ITEM_TOKEN',
826
833
  };
827
- var rollbar = window.rollbar = new Rollbar(options);
834
+ var rollbar = (window.rollbar = new Rollbar(options));
828
835
 
829
- rollbar.log(new Error('test error'), { 'foo': 'bar' });
836
+ rollbar.log(new Error('test error'), { foo: 'bar' });
830
837
 
831
- setTimeout(function() {
838
+ setTimeout(function () {
832
839
  server.respond();
833
840
 
834
841
  var body = JSON.parse(server.requests[0].requestBody);
835
842
 
836
843
  expect(body.data.body.trace.exception.message).to.eql('test error');
837
- expect(body.data.body.trace.extra).to.eql({ 'foo': 'bar' });
844
+ expect(body.data.body.trace.extra).to.eql({ foo: 'bar' });
838
845
  expect(body.data.notifier.diagnostic.is_uncaught).to.eql(undefined);
839
- expect(body.data.notifier.diagnostic.original_arg_types).to.eql(['error', 'object']);
846
+ expect(body.data.notifier.diagnostic.original_arg_types).to.eql([
847
+ 'error',
848
+ 'object',
849
+ ]);
840
850
 
841
851
  done();
842
852
  }, 1);
843
- })
853
+ });
844
854
 
845
- it('should add custom data when called with error context', function(done) {
855
+ it('should add custom data when called with error context', function (done) {
846
856
  var server = window.server;
847
857
  stubResponse(server);
848
858
  server.requests.length = 0;
849
859
 
850
860
  var options = {
851
861
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
852
- addErrorContext: true
862
+ addErrorContext: true,
853
863
  };
854
- var rollbar = window.rollbar = new Rollbar(options);
864
+ var rollbar = (window.rollbar = new Rollbar(options));
855
865
 
856
866
  var err = new Error('test error');
857
867
  err.rollbarContext = { err: 'test' };
858
868
 
859
- rollbar.error(err, { 'foo': 'bar' });
869
+ rollbar.error(err, { foo: 'bar' });
860
870
 
861
- setTimeout(function() {
871
+ setTimeout(function () {
862
872
  server.respond();
863
873
 
864
874
  var body = JSON.parse(server.requests[0].requestBody);
@@ -869,103 +879,107 @@ describe('log', function() {
869
879
 
870
880
  done();
871
881
  }, 1);
872
- })
882
+ });
873
883
 
874
- it('should send message when called with only null arguments', function(done) {
884
+ it('should send message when called with only null arguments', function (done) {
875
885
  var server = window.server;
876
886
  stubResponse(server);
877
887
  server.requests.length = 0;
878
888
 
879
889
  var options = {
880
890
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
881
- captureUnhandledRejections: true
891
+ captureUnhandledRejections: true,
882
892
  };
883
- var rollbar = window.rollbar = new Rollbar(options);
893
+ var rollbar = (window.rollbar = new Rollbar(options));
884
894
 
885
895
  rollbar.log(null);
886
896
 
887
- setTimeout(function() {
897
+ setTimeout(function () {
888
898
  server.respond();
889
899
 
890
900
  var body = JSON.parse(server.requests[0].requestBody);
891
901
 
892
- expect(body.data.body.message.body).to.eql('Item sent with null or missing arguments.');
902
+ expect(body.data.body.message.body).to.eql(
903
+ 'Item sent with null or missing arguments.',
904
+ );
893
905
  expect(body.data.notifier.diagnostic.original_arg_types).to.eql(['null']);
894
906
 
895
907
  done();
896
908
  }, 1);
897
- })
909
+ });
898
910
 
899
- it('should skipFrames when set', function(done) {
911
+ it('should skipFrames when set', function (done) {
900
912
  var server = window.server;
901
913
  stubResponse(server);
902
914
  server.requests.length = 0;
903
915
 
904
916
  var options = {
905
917
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
906
- captureUnhandledRejections: true
918
+ captureUnhandledRejections: true,
907
919
  };
908
- var rollbar = window.rollbar = new Rollbar(options);
920
+ var rollbar = (window.rollbar = new Rollbar(options));
909
921
 
910
922
  var error = new Error('error with stack');
911
923
 
912
924
  rollbar.log(error);
913
925
  rollbar.log(error, { skipFrames: 1 });
914
926
 
915
- setTimeout(function() {
927
+ setTimeout(function () {
916
928
  server.respond();
917
929
 
918
- var frames1 = JSON.parse(server.requests[0].requestBody).data.body.trace.frames;
919
- var frames2 = JSON.parse(server.requests[1].requestBody).data.body.trace.frames;
930
+ var frames1 = JSON.parse(server.requests[0].requestBody).data.body.trace
931
+ .frames;
932
+ var frames2 = JSON.parse(server.requests[1].requestBody).data.body.trace
933
+ .frames;
920
934
 
921
935
  expect(frames1.length).to.eql(frames2.length + 1);
922
- expect(frames1.slice(0,-1)).to.eql(frames2);
936
+ expect(frames1.slice(0, -1)).to.eql(frames2);
923
937
 
924
938
  done();
925
939
  }, 1);
926
- })
940
+ });
927
941
 
928
- it('should call the item callback on error', function(done) {
942
+ it('should call the item callback on error', function (done) {
929
943
  var server = window.server;
930
944
  stubResponse(server);
931
945
  server.requests.length = 0;
932
946
 
933
947
  // Create an invalid tracer, in order to force an error in notifier._log()
934
948
  var tracer = {
935
- scope: function() {
949
+ scope: function () {
936
950
  return {
937
- active: function() {
951
+ active: function () {
938
952
  throw new Error('Test error');
939
- }
940
- }
941
- }
953
+ },
954
+ };
955
+ },
942
956
  };
943
957
 
944
958
  var options = {
945
959
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
946
- tracer: tracer
960
+ tracer: tracer,
947
961
  };
948
- var rollbar = window.rollbar = new Rollbar(options);
962
+ var rollbar = (window.rollbar = new Rollbar(options));
949
963
 
950
964
  var callbackCalled;
951
- var callback = function(err) {
965
+ var callback = function (err) {
952
966
  callbackCalled = err;
953
967
  };
954
968
 
955
969
  rollbar.log('test', callback);
956
970
 
957
- setTimeout(function() {
971
+ setTimeout(function () {
958
972
  server.respond();
959
973
 
960
974
  expect(callbackCalled.message).to.eql('Test error');
961
975
 
962
976
  done();
963
977
  }, 1);
964
- })
978
+ });
965
979
  });
966
980
 
967
981
  // Test direct call to onerror, as used in verification of browser js install.
968
- describe('onerror', function() {
982
+ describe('onerror', function () {
969
983
  beforeEach(function (done) {
970
984
  window.server = sinon.createFakeServer();
971
985
  done();
@@ -977,42 +991,45 @@ describe('onerror', function() {
977
991
  });
978
992
 
979
993
  function stubResponse(server) {
980
- server.respondWith('POST', 'api/1/item',
981
- [
982
- 200,
983
- { 'Content-Type': 'application/json' },
984
- '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}'
985
- ]
986
- );
994
+ server.respondWith('POST', 'api/1/item', [
995
+ 200,
996
+ { 'Content-Type': 'application/json' },
997
+ '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}',
998
+ ]);
987
999
  }
988
1000
 
989
- it('should send message when calling onerror directly', function(done) {
1001
+ it('should send message when calling onerror directly', function (done) {
990
1002
  var server = window.server;
991
1003
  stubResponse(server);
992
1004
  server.requests.length = 0;
993
1005
 
994
1006
  var options = {
995
1007
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
996
- captureUncaught: true
1008
+ captureUncaught: true,
997
1009
  };
998
1010
  window.rollbar = new Rollbar(options);
999
1011
 
1000
- window.onerror("TestRollbarError: testing window.onerror", window.location.href);
1012
+ window.onerror(
1013
+ 'TestRollbarError: testing window.onerror',
1014
+ window.location.href,
1015
+ );
1001
1016
 
1002
- setTimeout(function() {
1017
+ setTimeout(function () {
1003
1018
  server.respond();
1004
1019
 
1005
1020
  var body = JSON.parse(server.requests[0].requestBody);
1006
1021
 
1007
1022
  expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
1008
- expect(body.data.body.trace.exception.message).to.eql('testing window.onerror');
1023
+ expect(body.data.body.trace.exception.message).to.eql(
1024
+ 'testing window.onerror',
1025
+ );
1009
1026
 
1010
1027
  done();
1011
1028
  }, 1);
1012
- })
1029
+ });
1013
1030
  });
1014
1031
 
1015
- describe('callback options', function() {
1032
+ describe('callback options', function () {
1016
1033
  beforeEach(function (done) {
1017
1034
  window.server = sinon.createFakeServer();
1018
1035
  done();
@@ -1024,31 +1041,29 @@ describe('callback options', function() {
1024
1041
  });
1025
1042
 
1026
1043
  function stubResponse(server) {
1027
- server.respondWith('POST', 'api/1/item',
1028
- [
1029
- 200,
1030
- { 'Content-Type': 'application/json' },
1031
- '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}'
1032
- ]
1033
- );
1044
+ server.respondWith('POST', 'api/1/item', [
1045
+ 200,
1046
+ { 'Content-Type': 'application/json' },
1047
+ '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}',
1048
+ ]);
1034
1049
  }
1035
1050
 
1036
- it('should use checkIgnore when set', function(done) {
1051
+ it('should use checkIgnore when set', function (done) {
1037
1052
  var server = window.server;
1038
1053
  stubResponse(server);
1039
1054
  server.requests.length = 0;
1040
1055
 
1041
1056
  var options = {
1042
1057
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
1043
- checkIgnore: function(_isUncaught, _args, _payload) {
1058
+ checkIgnore: function (_isUncaught, _args, _payload) {
1044
1059
  return true;
1045
- }
1060
+ },
1046
1061
  };
1047
- var rollbar = window.rollbar = new Rollbar(options);
1062
+ var rollbar = (window.rollbar = new Rollbar(options));
1048
1063
 
1049
1064
  rollbar.log('test'); // generate a payload to ignore
1050
1065
 
1051
- setTimeout(function() {
1066
+ setTimeout(function () {
1052
1067
  server.respond();
1053
1068
 
1054
1069
  expect(server.requests.length).to.eql(0);
@@ -1057,25 +1072,25 @@ describe('callback options', function() {
1057
1072
  }, 1);
1058
1073
  });
1059
1074
 
1060
- it('should receive valid arguments at checkIgnore', function(done) {
1075
+ it('should receive valid arguments at checkIgnore', function (done) {
1061
1076
  var server = window.server;
1062
1077
  stubResponse(server);
1063
1078
  server.requests.length = 0;
1064
1079
 
1065
1080
  var options = {
1066
1081
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
1067
- checkIgnore: function(_isUncaught, args, payload) {
1082
+ checkIgnore: function (_isUncaught, args, payload) {
1068
1083
  if (_isUncaught === false && args[0] instanceof Error && payload.uuid) {
1069
1084
  return true;
1070
1085
  }
1071
1086
  return false;
1072
- }
1087
+ },
1073
1088
  };
1074
- var rollbar = window.rollbar = new Rollbar(options);
1089
+ var rollbar = (window.rollbar = new Rollbar(options));
1075
1090
 
1076
1091
  rollbar.log(new Error('test'));
1077
1092
 
1078
- setTimeout(function() {
1093
+ setTimeout(function () {
1079
1094
  server.respond();
1080
1095
 
1081
1096
  // Should be ignored if all checks pass.
@@ -1085,7 +1100,7 @@ describe('callback options', function() {
1085
1100
  }, 1);
1086
1101
  });
1087
1102
 
1088
- it('should receive uncaught at checkIgnore', function(done) {
1103
+ it('should receive uncaught at checkIgnore', function (done) {
1089
1104
  var server = window.server;
1090
1105
  stubResponse(server);
1091
1106
  server.requests.length = 0;
@@ -1093,19 +1108,19 @@ describe('callback options', function() {
1093
1108
  var options = {
1094
1109
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
1095
1110
  captureUncaught: true,
1096
- checkIgnore: function(isUncaught, args, payload) {
1111
+ checkIgnore: function (isUncaught, args, payload) {
1097
1112
  if (isUncaught === true) {
1098
1113
  return true;
1099
1114
  }
1100
1115
  return false;
1101
- }
1116
+ },
1102
1117
  };
1103
1118
  window.rollbar = new Rollbar(options);
1104
1119
 
1105
1120
  var element = document.getElementById('throw-error');
1106
1121
  element.click();
1107
1122
 
1108
- setTimeout(function() {
1123
+ setTimeout(function () {
1109
1124
  server.respond();
1110
1125
 
1111
1126
  // Should be ignored if checkIgnore receives isUncaught.
@@ -1113,93 +1128,96 @@ describe('callback options', function() {
1113
1128
 
1114
1129
  done();
1115
1130
  }, 1);
1116
- })
1131
+ });
1117
1132
 
1118
- it('should send when checkIgnore returns false', function(done) {
1133
+ it('should send when checkIgnore returns false', function (done) {
1119
1134
  var server = window.server;
1120
1135
  stubResponse(server);
1121
1136
  server.requests.length = 0;
1122
1137
 
1123
1138
  var options = {
1124
1139
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
1125
- checkIgnore: function(_isUncaught, _args, _payload) {
1140
+ checkIgnore: function (_isUncaught, _args, _payload) {
1126
1141
  return false;
1127
- }
1142
+ },
1128
1143
  };
1129
- var rollbar = window.rollbar = new Rollbar(options);
1144
+ var rollbar = (window.rollbar = new Rollbar(options));
1130
1145
 
1131
1146
  rollbar.log('test'); // generate a payload to inspect
1132
1147
 
1133
- setTimeout(function() {
1148
+ setTimeout(function () {
1134
1149
  server.respond();
1135
1150
 
1136
1151
  expect(server.requests.length).to.eql(1);
1137
1152
  var body = JSON.parse(server.requests[0].requestBody);
1138
- expect(body.data.notifier.configured_options.checkIgnore.substr(0,8))
1139
- .to.eql('function');
1153
+ expect(
1154
+ body.data.notifier.configured_options.checkIgnore.substr(0, 8),
1155
+ ).to.eql('function');
1140
1156
 
1141
1157
  done();
1142
1158
  }, 1);
1143
1159
  });
1144
1160
 
1145
- it('should use onSendCallback when set', function(done) {
1161
+ it('should use onSendCallback when set', function (done) {
1146
1162
  var server = window.server;
1147
1163
  stubResponse(server);
1148
1164
  server.requests.length = 0;
1149
1165
 
1150
1166
  var options = {
1151
1167
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
1152
- onSendCallback: function(_isUncaught, _args, payload) {
1168
+ onSendCallback: function (_isUncaught, _args, payload) {
1153
1169
  payload.foo = 'bar';
1154
- }
1170
+ },
1155
1171
  };
1156
- var rollbar = window.rollbar = new Rollbar(options);
1172
+ var rollbar = (window.rollbar = new Rollbar(options));
1157
1173
 
1158
1174
  rollbar.log('test'); // generate a payload to inspect
1159
1175
 
1160
- setTimeout(function() {
1176
+ setTimeout(function () {
1161
1177
  server.respond();
1162
1178
 
1163
1179
  expect(server.requests.length).to.eql(1);
1164
1180
  var body = JSON.parse(server.requests[0].requestBody);
1165
1181
  expect(body.data.foo).to.eql('bar');
1166
- expect(body.data.notifier.configured_options.onSendCallback.substr(0,8))
1167
- .to.eql('function');
1182
+ expect(
1183
+ body.data.notifier.configured_options.onSendCallback.substr(0, 8),
1184
+ ).to.eql('function');
1168
1185
 
1169
1186
  done();
1170
1187
  }, 1);
1171
1188
  });
1172
1189
 
1173
- it('should use transform when set', function(done) {
1190
+ it('should use transform when set', function (done) {
1174
1191
  var server = window.server;
1175
1192
  stubResponse(server);
1176
1193
  server.requests.length = 0;
1177
1194
 
1178
1195
  var options = {
1179
1196
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
1180
- transform: function(data, _item) {
1197
+ transform: function (data, _item) {
1181
1198
  data.foo = 'baz';
1182
- }
1199
+ },
1183
1200
  };
1184
- var rollbar = window.rollbar = new Rollbar(options);
1201
+ var rollbar = (window.rollbar = new Rollbar(options));
1185
1202
 
1186
1203
  rollbar.log('test'); // generate a payload to inspect
1187
1204
 
1188
- setTimeout(function() {
1205
+ setTimeout(function () {
1189
1206
  server.respond();
1190
1207
 
1191
1208
  expect(server.requests.length).to.eql(1);
1192
1209
  var body = JSON.parse(server.requests[0].requestBody);
1193
1210
  expect(body.data.foo).to.eql('baz');
1194
- expect(body.data.notifier.configured_options.transform.substr(0,8))
1195
- .to.eql('function');
1211
+ expect(
1212
+ body.data.notifier.configured_options.transform.substr(0, 8),
1213
+ ).to.eql('function');
1196
1214
 
1197
1215
  done();
1198
1216
  }, 1);
1199
1217
  });
1200
1218
  });
1201
1219
 
1202
- describe('options.autoInstrument', function() {
1220
+ describe('options.autoInstrument', function () {
1203
1221
  beforeEach(function (done) {
1204
1222
  window.server = sinon.createFakeServer();
1205
1223
  done();
@@ -1211,57 +1229,66 @@ describe('options.autoInstrument', function() {
1211
1229
  });
1212
1230
 
1213
1231
  function stubResponse(server) {
1214
- server.respondWith('POST', 'api/1/item',
1215
- [
1216
- 200,
1217
- { 'Content-Type': 'application/json' },
1218
- '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}'
1219
- ]
1220
- );
1232
+ server.respondWith('POST', 'api/1/item', [
1233
+ 200,
1234
+ { 'Content-Type': 'application/json' },
1235
+ '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}',
1236
+ ]);
1221
1237
  }
1222
1238
 
1223
- describe('options.autoInstrument.contentSecurityPolicy', function() {
1239
+ describe('options.autoInstrument.contentSecurityPolicy', function () {
1224
1240
  beforeEach(function (done) {
1225
1241
  var options = {
1226
1242
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
1227
1243
  autoInstrument: {
1228
1244
  log: false,
1229
1245
  contentSecurityPolicy: true,
1230
- errorOnContentSecurityPolicy: true
1231
- }
1246
+ errorOnContentSecurityPolicy: true,
1247
+ },
1232
1248
  };
1233
1249
  window.rollbar = new Rollbar(options);
1234
1250
  done();
1235
1251
  });
1236
1252
 
1237
1253
  afterEach(function () {
1238
- window.rollbar.configure({ autoInstrument: false, captureUncaught: false });
1254
+ window.rollbar.configure({
1255
+ autoInstrument: false,
1256
+ captureUncaught: false,
1257
+ });
1239
1258
  });
1240
1259
 
1241
- it('should report content security policy errors', function(done) {
1260
+ it('should report content security policy errors', function (done) {
1242
1261
  var queue = rollbar.client.notifier.queue;
1243
1262
  var queueStub = sinon.stub(queue, '_makeApiRequest');
1244
1263
 
1245
1264
  // Load the HTML page, so errors can be generated.
1246
1265
  document.write(window.__html__['examples/csp-errors.html']);
1247
1266
 
1248
- setTimeout(function() {
1267
+ setTimeout(function () {
1249
1268
  try {
1250
1269
  var item = queueStub.getCall(0).args[0];
1251
1270
  var message = item.body.message.body;
1252
- var telemetry = item.body.telemetry[0]
1271
+ var telemetry = item.body.telemetry[0];
1253
1272
 
1254
1273
  expect(message).to.match(/Security Policy Violation/);
1255
1274
  expect(message).to.match(/blockedURI: https:\/\/example.com\/v3\//);
1256
1275
  expect(message).to.match(/violatedDirective: script-src/);
1257
- expect(message).to.match(/originalPolicy: default-src 'self' 'unsafe-inline' 'unsafe-eval';/);
1276
+ expect(message).to.match(
1277
+ /originalPolicy: default-src 'self' 'unsafe-inline' 'unsafe-eval';/,
1278
+ );
1258
1279
 
1259
1280
  expect(telemetry.level).to.eql('error');
1260
1281
  expect(telemetry.type).to.eql('log');
1261
1282
  expect(telemetry.body.message).to.match(/Security Policy Violation/);
1262
- expect(telemetry.body.message).to.match(/blockedURI: https:\/\/example.com\/v3\//);
1263
- expect(telemetry.body.message).to.match(/violatedDirective: script-src/);
1264
- expect(telemetry.body.message).to.match(/originalPolicy: default-src 'self' 'unsafe-inline' 'unsafe-eval';/);
1283
+ expect(telemetry.body.message).to.match(
1284
+ /blockedURI: https:\/\/example.com\/v3\//,
1285
+ );
1286
+ expect(telemetry.body.message).to.match(
1287
+ /violatedDirective: script-src/,
1288
+ );
1289
+ expect(telemetry.body.message).to.match(
1290
+ /originalPolicy: default-src 'self' 'unsafe-inline' 'unsafe-eval';/,
1291
+ );
1265
1292
 
1266
1293
  done();
1267
1294
  } catch (e) {
@@ -1271,21 +1298,21 @@ describe('options.autoInstrument', function() {
1271
1298
  });
1272
1299
  });
1273
1300
 
1274
- it('should add telemetry events when console.log is called', function(done) {
1301
+ it('should add telemetry events when console.log is called', function (done) {
1275
1302
  var server = window.server;
1276
1303
  stubResponse(server);
1277
1304
  server.requests.length = 0;
1278
1305
 
1279
1306
  var options = {
1280
- accessToken: 'POST_CLIENT_ITEM_TOKEN'
1307
+ accessToken: 'POST_CLIENT_ITEM_TOKEN',
1281
1308
  };
1282
- var rollbar = window.rollbar = new Rollbar(options);
1309
+ var rollbar = (window.rollbar = new Rollbar(options));
1283
1310
 
1284
1311
  console.log('console test'); // generate a telemetry event
1285
1312
 
1286
1313
  rollbar.log('test'); // generate a payload to inspect
1287
1314
 
1288
- setTimeout(function() {
1315
+ setTimeout(function () {
1289
1316
  server.respond();
1290
1317
 
1291
1318
  var body = JSON.parse(server.requests[0].requestBody);
@@ -1305,26 +1332,24 @@ describe('options.autoInstrument', function() {
1305
1332
  networkResponseHeaders: true,
1306
1333
  networkResponseBody: true,
1307
1334
  networkRequestBody: true,
1308
- networkRequestHeaders: true
1309
- }
1335
+ networkRequestHeaders: true,
1336
+ },
1310
1337
  };
1311
1338
  return new Rollbar(options);
1312
1339
  }
1313
1340
 
1314
- it('should add telemetry events for POST xhr calls', function(done) {
1341
+ it('should add telemetry events for POST xhr calls', function (done) {
1315
1342
  var server = window.server;
1316
1343
  stubResponse(server);
1317
1344
  server.requests.length = 0;
1318
1345
 
1319
- server.respondWith('POST', 'https://example.com/xhr-test',
1320
- [
1321
- 200,
1322
- { 'Content-Type': 'application/json', 'Password': '123456' },
1323
- JSON.stringify({name: 'foo', password: '123456'})
1324
- ]
1325
- );
1346
+ server.respondWith('POST', 'https://example.com/xhr-test', [
1347
+ 200,
1348
+ { 'Content-Type': 'application/json', Password: '123456' },
1349
+ JSON.stringify({ name: 'foo', password: '123456' }),
1350
+ ]);
1326
1351
 
1327
- var rollbar = window.rollbar = initRollbarForNetworkTelemetry();
1352
+ var rollbar = (window.rollbar = initRollbarForNetworkTelemetry());
1328
1353
 
1329
1354
  // generate a telemetry event
1330
1355
  var xhr = new XMLHttpRequest();
@@ -1332,25 +1357,34 @@ describe('options.autoInstrument', function() {
1332
1357
  xhr.setRequestHeader('Content-type', 'application/json');
1333
1358
  xhr.setRequestHeader('Secret', 'abcdef');
1334
1359
  xhr.onreadystatechange = function () {
1335
- if(xhr.readyState === 4) {
1360
+ if (xhr.readyState === 4) {
1336
1361
  try {
1337
1362
  rollbar.log('test'); // generate a payload to inspect
1338
1363
 
1339
- setTimeout(function() {
1364
+ setTimeout(function () {
1340
1365
  server.respond();
1341
1366
 
1342
1367
  expect(server.requests.length).to.eql(2);
1343
1368
  var body = JSON.parse(server.requests[1].requestBody);
1344
1369
 
1345
1370
  // Verify request capture and scrubbing
1346
- expect(body.data.body.telemetry[0].body.request).to.eql('{"name":"bar","secret":"********"}');
1371
+ expect(body.data.body.telemetry[0].body.request).to.eql(
1372
+ '{"name":"bar","secret":"********"}',
1373
+ );
1347
1374
 
1348
1375
  // Verify request headers capture and case-insensitive scrubbing
1349
- expect(body.data.body.telemetry[0].body.request_headers).to.eql({'Content-type': 'application/json', Secret: '********'});
1376
+ expect(body.data.body.telemetry[0].body.request_headers).to.eql({
1377
+ 'Content-type': 'application/json',
1378
+ Secret: '********',
1379
+ });
1350
1380
 
1351
1381
  // Verify response capture and scrubbing
1352
- expect(body.data.body.telemetry[0].body.response.body).to.eql('{"name":"foo","password":"********"}');
1353
- expect(body.data.body.telemetry[0].body.response.headers['Password']).to.eql('********');
1382
+ expect(body.data.body.telemetry[0].body.response.body).to.eql(
1383
+ '{"name":"foo","password":"********"}',
1384
+ );
1385
+ expect(
1386
+ body.data.body.telemetry[0].body.response.headers['Password'],
1387
+ ).to.eql('********');
1354
1388
 
1355
1389
  done();
1356
1390
  }, 1);
@@ -1359,48 +1393,50 @@ describe('options.autoInstrument', function() {
1359
1393
  }
1360
1394
  }
1361
1395
  };
1362
- xhr.send(JSON.stringify({name: 'bar', secret: 'xhr post' }));
1396
+ xhr.send(JSON.stringify({ name: 'bar', secret: 'xhr post' }));
1363
1397
  server.respond();
1364
1398
  });
1365
1399
 
1366
- it('should add telemetry events for GET xhr calls', function(done) {
1400
+ it('should add telemetry events for GET xhr calls', function (done) {
1367
1401
  var server = window.server;
1368
1402
  stubResponse(server);
1369
1403
  server.requests.length = 0;
1370
1404
 
1371
- server.respondWith('GET', 'https://example.com/xhr-test',
1372
- [
1373
- 200,
1374
- { 'Content-Type': 'application/json',
1375
- 'Password': 'abcdef'
1376
- },
1377
- JSON.stringify({name: 'foo', password: '123456'})
1378
- ]
1379
- );
1405
+ server.respondWith('GET', 'https://example.com/xhr-test', [
1406
+ 200,
1407
+ { 'Content-Type': 'application/json', Password: 'abcdef' },
1408
+ JSON.stringify({ name: 'foo', password: '123456' }),
1409
+ ]);
1380
1410
 
1381
- var rollbar = window.rollbar = initRollbarForNetworkTelemetry();
1411
+ var rollbar = (window.rollbar = initRollbarForNetworkTelemetry());
1382
1412
 
1383
1413
  // generate a telemetry event
1384
1414
  var xhr = new XMLHttpRequest();
1385
1415
  xhr.open('GET', 'https://example.com/xhr-test', true);
1386
1416
  xhr.setRequestHeader('Secret', 'abcdef');
1387
1417
  xhr.onreadystatechange = function () {
1388
- if(xhr.readyState === 4) {
1418
+ if (xhr.readyState === 4) {
1389
1419
  try {
1390
1420
  rollbar.log('test'); // generate a payload to inspect
1391
1421
 
1392
- setTimeout(function() {
1422
+ setTimeout(function () {
1393
1423
  server.respond();
1394
1424
 
1395
1425
  expect(server.requests.length).to.eql(2);
1396
1426
  var body = JSON.parse(server.requests[1].requestBody);
1397
1427
 
1398
1428
  // Verify request headers capture and case-insensitive scrubbing
1399
- expect(body.data.body.telemetry[0].body.request_headers).to.eql({Secret: '********'});
1429
+ expect(body.data.body.telemetry[0].body.request_headers).to.eql({
1430
+ Secret: '********',
1431
+ });
1400
1432
 
1401
1433
  // Verify response capture and scrubbing
1402
- expect(body.data.body.telemetry[0].body.response.body).to.eql('{"name":"foo","password":"********"}');
1403
- expect(body.data.body.telemetry[0].body.response.headers['Password']).to.eql('********');
1434
+ expect(body.data.body.telemetry[0].body.response.body).to.eql(
1435
+ '{"name":"foo","password":"********"}',
1436
+ );
1437
+ expect(
1438
+ body.data.body.telemetry[0].body.response.headers['Password'],
1439
+ ).to.eql('********');
1404
1440
 
1405
1441
  done();
1406
1442
  }, 1);
@@ -1409,49 +1445,54 @@ describe('options.autoInstrument', function() {
1409
1445
  }
1410
1446
  }
1411
1447
  };
1412
- xhr.send(JSON.stringify({name: 'bar', secret: 'xhr post' }));
1448
+ xhr.send(JSON.stringify({ name: 'bar', secret: 'xhr post' }));
1413
1449
  server.respond();
1414
1450
  });
1415
1451
 
1416
- it('should handle non-string Content-Type', function(done) {
1452
+ it('should handle non-string Content-Type', function (done) {
1417
1453
  var server = window.server;
1418
1454
  stubResponse(server);
1419
1455
  server.requests.length = 0;
1420
1456
 
1421
- server.respondWith('GET', 'https://example.com/xhr-test',
1422
- [
1423
- 200,
1424
- { 'Content-Type': {}, // unexpected/invalid (non-string) content type
1425
- 'Password': 'abcdef'
1426
- },
1427
- JSON.stringify({name: 'foo', password: '123456'})
1428
- ]
1429
- );
1457
+ server.respondWith('GET', 'https://example.com/xhr-test', [
1458
+ 200,
1459
+ {
1460
+ 'Content-Type': {}, // unexpected/invalid (non-string) content type
1461
+ Password: 'abcdef',
1462
+ },
1463
+ JSON.stringify({ name: 'foo', password: '123456' }),
1464
+ ]);
1430
1465
 
1431
- var rollbar = window.rollbar = initRollbarForNetworkTelemetry();
1466
+ var rollbar = (window.rollbar = initRollbarForNetworkTelemetry());
1432
1467
 
1433
1468
  // generate a telemetry event
1434
1469
  var xhr = new XMLHttpRequest();
1435
1470
  xhr.open('GET', 'https://example.com/xhr-test', true);
1436
1471
  xhr.setRequestHeader('Secret', 'abcdef');
1437
1472
  xhr.onreadystatechange = function () {
1438
- if(xhr.readyState === 4) {
1473
+ if (xhr.readyState === 4) {
1439
1474
  try {
1440
1475
  rollbar.log('test'); // generate a payload to inspect
1441
1476
 
1442
- setTimeout(function() {
1477
+ setTimeout(function () {
1443
1478
  server.respond();
1444
1479
 
1445
1480
  expect(server.requests.length).to.eql(2);
1446
1481
  var body = JSON.parse(server.requests[1].requestBody);
1447
1482
 
1448
1483
  // Verify request headers capture and case-insensitive scrubbing
1449
- expect(body.data.body.telemetry[0].body.request_headers).to.eql({Secret: '********'});
1484
+ expect(body.data.body.telemetry[0].body.request_headers).to.eql({
1485
+ Secret: '********',
1486
+ });
1450
1487
 
1451
1488
  // Not scrubbed for unrecognized content type
1452
- expect(body.data.body.telemetry[0].body.response.body).to.eql('{"name":"foo","password":"123456"}');
1489
+ expect(body.data.body.telemetry[0].body.response.body).to.eql(
1490
+ '{"name":"foo","password":"123456"}',
1491
+ );
1453
1492
 
1454
- expect(body.data.body.telemetry[0].body.response.headers['Password']).to.eql('********');
1493
+ expect(
1494
+ body.data.body.telemetry[0].body.response.headers['Password'],
1495
+ ).to.eql('********');
1455
1496
 
1456
1497
  done();
1457
1498
  }, 1);
@@ -1460,30 +1501,28 @@ describe('options.autoInstrument', function() {
1460
1501
  }
1461
1502
  }
1462
1503
  };
1463
- xhr.send(JSON.stringify({name: 'bar', secret: 'xhr post' }));
1504
+ xhr.send(JSON.stringify({ name: 'bar', secret: 'xhr post' }));
1464
1505
  server.respond();
1465
1506
  });
1466
1507
 
1467
- it('should send errors for xhr http errors', function(done) {
1508
+ it('should send errors for xhr http errors', function (done) {
1468
1509
  var server = window.server;
1469
1510
  stubResponse(server);
1470
1511
  server.requests.length = 0;
1471
1512
 
1472
- server.respondWith('POST', 'xhr-test',
1473
- [
1474
- 404,
1475
- { 'Content-Type': 'application/json' },
1476
- JSON.stringify({foo: 'bar'})
1477
- ]
1478
- );
1513
+ server.respondWith('POST', 'xhr-test', [
1514
+ 404,
1515
+ { 'Content-Type': 'application/json' },
1516
+ JSON.stringify({ foo: 'bar' }),
1517
+ ]);
1479
1518
 
1480
1519
  var options = {
1481
1520
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
1482
1521
  autoInstrument: {
1483
1522
  log: false,
1484
1523
  network: true,
1485
- networkErrorOnHttp4xx: true
1486
- }
1524
+ networkErrorOnHttp4xx: true,
1525
+ },
1487
1526
  };
1488
1527
  window.rollbar = new Rollbar(options);
1489
1528
 
@@ -1492,16 +1531,18 @@ describe('options.autoInstrument', function() {
1492
1531
  xhr.open('POST', 'https://example.com/xhr-test', true);
1493
1532
  xhr.setRequestHeader('Content-type', 'application/json');
1494
1533
  xhr.onreadystatechange = function () {
1495
- if(xhr.readyState === 4) {
1534
+ if (xhr.readyState === 4) {
1496
1535
  try {
1497
- setTimeout(function() {
1536
+ setTimeout(function () {
1498
1537
  try {
1499
1538
  server.respond();
1500
1539
 
1501
1540
  expect(server.requests.length).to.eql(2);
1502
1541
  var body = JSON.parse(server.requests[1].requestBody);
1503
1542
 
1504
- expect(body.data.body.trace.exception.message).to.eql('HTTP request failed with Status 404');
1543
+ expect(body.data.body.trace.exception.message).to.eql(
1544
+ 'HTTP request failed with Status 404',
1545
+ );
1505
1546
 
1506
1547
  // Just knowing a stack is present is enough for this test.
1507
1548
  expect(body.data.body.trace.frames.length).to.be.above(1);
@@ -1516,24 +1557,29 @@ describe('options.autoInstrument', function() {
1516
1557
  }
1517
1558
  }
1518
1559
  };
1519
- xhr.send(JSON.stringify({name: 'bar', secret: 'xhr post' }));
1520
- setTimeout(function() {
1560
+ xhr.send(JSON.stringify({ name: 'bar', secret: 'xhr post' }));
1561
+ setTimeout(function () {
1521
1562
  server.respond();
1522
1563
  }, 1);
1523
1564
  });
1524
1565
 
1525
- it('should add telemetry events for fetch calls', function(done) {
1566
+ it('should add telemetry events for fetch calls', function (done) {
1526
1567
  var server = window.server;
1527
1568
  stubResponse(server);
1528
1569
  server.requests.length = 0;
1529
1570
 
1530
1571
  window.fetchStub = sinon.stub(window, 'fetch');
1531
1572
 
1532
- var responseBody = JSON.stringify({name: 'foo', password: '123456'});
1533
- window.fetch.returns(Promise.resolve(new Response(
1534
- responseBody,
1535
- { status: 200, statusText: 'OK', headers: { 'content-type': 'application/json', 'password': '123456' }}
1536
- )));
1573
+ var responseBody = JSON.stringify({ name: 'foo', password: '123456' });
1574
+ window.fetch.returns(
1575
+ Promise.resolve(
1576
+ new Response(responseBody, {
1577
+ status: 200,
1578
+ statusText: 'OK',
1579
+ headers: { 'content-type': 'application/json', password: '123456' },
1580
+ }),
1581
+ ),
1582
+ );
1537
1583
 
1538
1584
  var options = {
1539
1585
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
@@ -1543,10 +1589,10 @@ describe('options.autoInstrument', function() {
1543
1589
  networkResponseHeaders: true,
1544
1590
  networkResponseBody: true,
1545
1591
  networkRequestBody: true,
1546
- networkRequestHeaders: true
1547
- }
1592
+ networkRequestHeaders: true,
1593
+ },
1548
1594
  };
1549
- var rollbar = window.rollbar = new Rollbar(options);
1595
+ var rollbar = (window.rollbar = new Rollbar(options));
1550
1596
 
1551
1597
  var fetchHeaders = new Headers();
1552
1598
  fetchHeaders.append('Content-Type', 'application/json');
@@ -1555,74 +1601,90 @@ describe('options.autoInstrument', function() {
1555
1601
  const fetchInit = {
1556
1602
  method: 'POST',
1557
1603
  headers: fetchHeaders,
1558
- body: JSON.stringify({name: 'bar', secret: 'fetch post'})
1604
+ body: JSON.stringify({ name: 'bar', secret: 'fetch post' }),
1559
1605
  };
1560
1606
  var fetchRequest = new Request('https://example.com/fetch-test');
1561
- window.fetch(fetchRequest, fetchInit)
1562
- .then(function(response) {
1563
- // Assert that the original stream reader hasn't been read.
1564
- expect(response.bodyUsed).to.eql(false);
1565
- return response.text()
1566
- })
1567
- .then(function(text) {
1568
- expect(text).to.eql(responseBody);
1607
+ window
1608
+ .fetch(fetchRequest, fetchInit)
1609
+ .then(function (response) {
1610
+ // Assert that the original stream reader hasn't been read.
1611
+ expect(response.bodyUsed).to.eql(false);
1612
+ return response.text();
1613
+ })
1614
+ .then(function (text) {
1615
+ expect(text).to.eql(responseBody);
1569
1616
 
1570
- try {
1571
- rollbar.log('test'); // generate a payload to inspect
1572
- } catch (e) {
1573
- done(e);
1574
- return;
1575
- }
1576
-
1577
- setTimeout(function() {
1578
1617
  try {
1579
- server.respond();
1618
+ rollbar.log('test'); // generate a payload to inspect
1619
+ } catch (e) {
1620
+ done(e);
1621
+ return;
1622
+ }
1580
1623
 
1581
- expect(window.fetchStub.called).to.be.ok();
1582
- expect(server.requests.length).to.eql(1);
1583
- var body = JSON.parse(server.requests[0].requestBody);
1624
+ setTimeout(function () {
1625
+ try {
1626
+ server.respond();
1584
1627
 
1585
- // Verify request capture and scrubbing
1586
- expect(body.data.body.telemetry[0].body.request).to.eql('{"name":"bar","secret":"********"}');
1628
+ expect(window.fetchStub.called).to.be.ok();
1629
+ expect(server.requests.length).to.eql(1);
1630
+ var body = JSON.parse(server.requests[0].requestBody);
1587
1631
 
1588
- // Verify request headers capture and case-insensitive scrubbing
1589
- expect(body.data.body.telemetry[0].body.request_headers).to.eql({'content-type': 'application/json', secret: '********'});
1632
+ // Verify request capture and scrubbing
1633
+ expect(body.data.body.telemetry[0].body.request).to.eql(
1634
+ '{"name":"bar","secret":"********"}',
1635
+ );
1590
1636
 
1591
- // Verify response capture and scrubbing
1592
- expect(body.data.body.telemetry[0].body.response.body).to.eql('{"name":"foo","password":"********"}');
1637
+ // Verify request headers capture and case-insensitive scrubbing
1638
+ expect(body.data.body.telemetry[0].body.request_headers).to.eql({
1639
+ 'content-type': 'application/json',
1640
+ secret: '********',
1641
+ });
1593
1642
 
1594
- // Verify response headers capture and case-insensitive scrubbing
1595
- expect(body.data.body.telemetry[0].body.response.headers).to.eql({'content-type': 'application/json', password: '********'});
1643
+ // Verify response capture and scrubbing
1644
+ expect(body.data.body.telemetry[0].body.response.body).to.eql(
1645
+ '{"name":"foo","password":"********"}',
1646
+ );
1596
1647
 
1597
- rollbar.configure({ autoInstrument: false });
1598
- window.fetch.restore();
1599
- done();
1600
- } catch (e) {
1601
- done(e);
1602
- return;
1603
- }
1604
- }, 1);
1605
- })
1648
+ // Verify response headers capture and case-insensitive scrubbing
1649
+ expect(body.data.body.telemetry[0].body.response.headers).to.eql({
1650
+ 'content-type': 'application/json',
1651
+ password: '********',
1652
+ });
1653
+
1654
+ rollbar.configure({ autoInstrument: false });
1655
+ window.fetch.restore();
1656
+ done();
1657
+ } catch (e) {
1658
+ done(e);
1659
+ return;
1660
+ }
1661
+ }, 1);
1662
+ });
1606
1663
  });
1607
1664
 
1608
- it('should report error for http 4xx fetch calls, when enabled', function(done) {
1665
+ it('should report error for http 4xx fetch calls, when enabled', function (done) {
1609
1666
  var server = window.server;
1610
1667
  stubResponse(server);
1611
1668
  server.requests.length = 0;
1612
1669
 
1613
1670
  window.fetchStub = sinon.stub(window, 'fetch');
1614
- window.fetch.returns(Promise.resolve(new Response(
1615
- JSON.stringify({foo: 'bar'}),
1616
- { status: 404, statusText: 'Not Found', headers: { 'content-type': 'application/json' }}
1617
- )));
1671
+ window.fetch.returns(
1672
+ Promise.resolve(
1673
+ new Response(JSON.stringify({ foo: 'bar' }), {
1674
+ status: 404,
1675
+ statusText: 'Not Found',
1676
+ headers: { 'content-type': 'application/json' },
1677
+ }),
1678
+ ),
1679
+ );
1618
1680
 
1619
1681
  var options = {
1620
1682
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
1621
1683
  autoInstrument: {
1622
1684
  log: false,
1623
1685
  network: true,
1624
- networkErrorOnHttp4xx: true
1625
- }
1686
+ networkErrorOnHttp4xx: true,
1687
+ },
1626
1688
  };
1627
1689
  window.rollbar = new Rollbar(options);
1628
1690
 
@@ -1632,18 +1694,20 @@ describe('options.autoInstrument', function() {
1632
1694
  const fetchInit = {
1633
1695
  method: 'POST',
1634
1696
  headers: fetchHeaders,
1635
- body: JSON.stringify({foo: 'bar'})
1697
+ body: JSON.stringify({ foo: 'bar' }),
1636
1698
  };
1637
1699
  var fetchRequest = new Request('https://example.com/xhr-test');
1638
- window.fetch(fetchRequest, fetchInit).then(function(_response) {
1639
- setTimeout(function() {
1700
+ window.fetch(fetchRequest, fetchInit).then(function (_response) {
1701
+ setTimeout(function () {
1640
1702
  try {
1641
1703
  server.respond();
1642
1704
 
1643
1705
  expect(server.requests.length).to.eql(1);
1644
1706
  var body = JSON.parse(server.requests[0].requestBody);
1645
1707
 
1646
- expect(body.data.body.trace.exception.message).to.eql('HTTP request failed with Status 404');
1708
+ expect(body.data.body.trace.exception.message).to.eql(
1709
+ 'HTTP request failed with Status 404',
1710
+ );
1647
1711
 
1648
1712
  // Just knowing a stack is present is enough for this test.
1649
1713
  expect(body.data.body.trace.frames.length).to.be.above(1);
@@ -1655,10 +1719,10 @@ describe('options.autoInstrument', function() {
1655
1719
  done(e);
1656
1720
  }
1657
1721
  }, 1);
1658
- })
1722
+ });
1659
1723
  });
1660
1724
 
1661
- it('should add telemetry headers when fetch Headers object is undefined', function(done) {
1725
+ it('should add telemetry headers when fetch Headers object is undefined', function (done) {
1662
1726
  var server = window.server;
1663
1727
  stubResponse(server);
1664
1728
  server.requests.length = 0;
@@ -1667,15 +1731,20 @@ describe('options.autoInstrument', function() {
1667
1731
 
1668
1732
  var readableStream = new ReadableStream({
1669
1733
  start(controller) {
1670
- controller.enqueue(JSON.stringify({name: 'foo', password: '123456'}));
1734
+ controller.enqueue(JSON.stringify({ name: 'foo', password: '123456' }));
1671
1735
  controller.close();
1672
- }
1736
+ },
1673
1737
  });
1674
1738
 
1675
- window.fetch.returns(Promise.resolve(new Response(
1676
- readableStream,
1677
- { status: 200, statusText: 'OK', headers: { 'content-type': 'application/json', 'password': '123456' }}
1678
- )));
1739
+ window.fetch.returns(
1740
+ Promise.resolve(
1741
+ new Response(readableStream, {
1742
+ status: 200,
1743
+ statusText: 'OK',
1744
+ headers: { 'content-type': 'application/json', password: '123456' },
1745
+ }),
1746
+ ),
1747
+ );
1679
1748
 
1680
1749
  var options = {
1681
1750
  accessToken: 'POST_CLIENT_ITEM_TOKEN',
@@ -1683,10 +1752,10 @@ describe('options.autoInstrument', function() {
1683
1752
  log: false,
1684
1753
  network: true,
1685
1754
  networkResponseHeaders: true,
1686
- networkRequestHeaders: true
1687
- }
1755
+ networkRequestHeaders: true,
1756
+ },
1688
1757
  };
1689
- var rollbar = window.rollbar = new Rollbar(options);
1758
+ var rollbar = (window.rollbar = new Rollbar(options));
1690
1759
 
1691
1760
  // Remove Headers from window object
1692
1761
  var originalHeaders = window.Headers;
@@ -1694,15 +1763,14 @@ describe('options.autoInstrument', function() {
1694
1763
 
1695
1764
  const fetchInit = {
1696
1765
  method: 'POST',
1697
- headers: {'Content-Type': 'application/json', Secret: '123456'},
1698
- body: JSON.stringify({name: 'bar', secret: 'xhr post'})
1766
+ headers: { 'Content-Type': 'application/json', Secret: '123456' },
1767
+ body: JSON.stringify({ name: 'bar', secret: 'xhr post' }),
1699
1768
  };
1700
1769
  var fetchRequest = new Request('https://example.com/xhr-test');
1701
- window.fetch(fetchRequest, fetchInit)
1702
- .then(function(response) {
1770
+ window.fetch(fetchRequest, fetchInit).then(function (response) {
1703
1771
  try {
1704
1772
  rollbar.log('test'); // generate a payload to inspect
1705
- setTimeout(function() {
1773
+ setTimeout(function () {
1706
1774
  try {
1707
1775
  server.respond();
1708
1776
 
@@ -1710,10 +1778,16 @@ describe('options.autoInstrument', function() {
1710
1778
  var body = JSON.parse(server.requests[0].requestBody);
1711
1779
 
1712
1780
  // Verify request headers capture and case-insensitive scrubbing
1713
- expect(body.data.body.telemetry[0].body.request_headers).to.eql({'content-type': 'application/json', secret: '********'});
1781
+ expect(body.data.body.telemetry[0].body.request_headers).to.eql({
1782
+ 'content-type': 'application/json',
1783
+ secret: '********',
1784
+ });
1714
1785
 
1715
1786
  // Verify response headers capture and case-insensitive scrubbing
1716
- expect(body.data.body.telemetry[0].body.response.headers).to.eql({'content-type': 'application/json', password: '********'});
1787
+ expect(body.data.body.telemetry[0].body.response.headers).to.eql({
1788
+ 'content-type': 'application/json',
1789
+ password: '********',
1790
+ });
1717
1791
 
1718
1792
  // Assert that the original stream reader hasn't been read.
1719
1793
  expect(response.bodyUsed).to.eql(false);
@@ -1729,88 +1803,101 @@ describe('options.autoInstrument', function() {
1729
1803
  } catch (e) {
1730
1804
  done(e);
1731
1805
  }
1732
- })
1806
+ });
1733
1807
  });
1734
1808
 
1735
- it('should add a diagnostic message when wrapConsole fails', function(done) {
1809
+ it('should add a diagnostic message when wrapConsole fails', function (done) {
1736
1810
  var server = window.server;
1737
1811
  stubResponse(server);
1738
1812
  server.requests.length = 0;
1739
1813
 
1740
1814
  var oldConsole = window.console;
1741
- var newConsole = {}
1742
- Object.defineProperty( newConsole, 'log', {
1815
+ var newConsole = {};
1816
+ Object.defineProperty(newConsole, 'log', {
1743
1817
  get: function () {
1744
- return function(message) { oldConsole.log(message); return message; };
1745
- }
1818
+ return function (message) {
1819
+ oldConsole.log(message);
1820
+ return message;
1821
+ };
1822
+ },
1746
1823
  });
1747
1824
  window.console = newConsole;
1748
1825
 
1749
1826
  var options = {
1750
- accessToken: 'POST_CLIENT_ITEM_TOKEN'
1827
+ accessToken: 'POST_CLIENT_ITEM_TOKEN',
1751
1828
  };
1752
- var rollbar = window.rollbar = new Rollbar(options);
1829
+ var rollbar = (window.rollbar = new Rollbar(options));
1753
1830
 
1754
1831
  rollbar.log('test'); // generate a payload to inspect
1755
1832
 
1756
- setTimeout(function() {
1833
+ setTimeout(function () {
1757
1834
  server.respond();
1758
1835
 
1759
1836
  var body = JSON.parse(server.requests[0].requestBody);
1760
1837
 
1761
1838
  window.console = oldConsole;
1762
1839
 
1763
- expect(rollbar.client.notifier.diagnostic.instrumentConsole).to.have.property('error');
1764
- expect(body.data.notifier.diagnostic.instrumentConsole).to.have.property('error');
1840
+ expect(
1841
+ rollbar.client.notifier.diagnostic.instrumentConsole,
1842
+ ).to.have.property('error');
1843
+ expect(body.data.notifier.diagnostic.instrumentConsole).to.have.property(
1844
+ 'error',
1845
+ );
1765
1846
 
1766
1847
  done();
1767
1848
  }, 1);
1768
1849
  });
1769
1850
  });
1770
1851
 
1771
- describe('captureEvent', function() {
1852
+ describe('captureEvent', function () {
1772
1853
  afterEach(function () {
1773
1854
  window.rollbar.configure({ autoInstrument: false, captureUncaught: false });
1774
1855
  });
1775
1856
 
1776
- it('should handle missing/default type and level', function(done) {
1857
+ it('should handle missing/default type and level', function (done) {
1777
1858
  var options = {};
1778
- var rollbar = window.rollbar = new Rollbar(options);
1859
+ var rollbar = (window.rollbar = new Rollbar(options));
1779
1860
 
1780
- var event = rollbar.captureEvent({foo: 'bar'});
1861
+ var event = rollbar.captureEvent({ foo: 'bar' });
1781
1862
  expect(event.type).to.eql('manual');
1782
1863
  expect(event.level).to.eql('info');
1783
1864
  expect(event.body.foo).to.eql('bar');
1784
1865
 
1785
1866
  done();
1786
1867
  });
1787
- it('should handle specified type and level', function(done) {
1868
+ it('should handle specified type and level', function (done) {
1788
1869
  var options = {};
1789
- var rollbar = window.rollbar = new Rollbar(options);
1870
+ var rollbar = (window.rollbar = new Rollbar(options));
1790
1871
 
1791
- var event = rollbar.captureEvent('log', {foo: 'bar'}, 'debug');
1872
+ var event = rollbar.captureEvent('log', { foo: 'bar' }, 'debug');
1792
1873
  expect(event.type).to.eql('log');
1793
1874
  expect(event.level).to.eql('debug');
1794
1875
  expect(event.body.foo).to.eql('bar');
1795
1876
 
1796
1877
  done();
1797
1878
  });
1798
- it('should handle extra args', function(done) {
1879
+ it('should handle extra args', function (done) {
1799
1880
  var options = {};
1800
- var rollbar = window.rollbar = new Rollbar(options);
1801
-
1802
- var event = rollbar.captureEvent('meaningless', 'info', {foo: 'bar'}, 23, 'debug');
1881
+ var rollbar = (window.rollbar = new Rollbar(options));
1882
+
1883
+ var event = rollbar.captureEvent(
1884
+ 'meaningless',
1885
+ 'info',
1886
+ { foo: 'bar' },
1887
+ 23,
1888
+ 'debug',
1889
+ );
1803
1890
  expect(event.type).to.eql('manual');
1804
1891
  expect(event.level).to.eql('info');
1805
1892
  expect(event.body.foo).to.eql('bar');
1806
1893
 
1807
1894
  done();
1808
1895
  });
1809
- it('should handle level that matches a type string', function(done) {
1896
+ it('should handle level that matches a type string', function (done) {
1810
1897
  var options = {};
1811
- var rollbar = window.rollbar = new Rollbar(options);
1898
+ var rollbar = (window.rollbar = new Rollbar(options));
1812
1899
 
1813
- var event = rollbar.captureEvent('log', {foo: 'bar'}, 'error');
1900
+ var event = rollbar.captureEvent('log', { foo: 'bar' }, 'error');
1814
1901
  // ensure level 'error' doesn't overwrite type 'log'
1815
1902
  expect(event.type).to.eql('log');
1816
1903
  expect(event.level).to.eql('error');
@@ -1820,15 +1907,15 @@ describe('captureEvent', function() {
1820
1907
  });
1821
1908
  });
1822
1909
 
1823
- describe('createItem', function() {
1910
+ describe('createItem', function () {
1824
1911
  afterEach(function () {
1825
1912
  window.rollbar.configure({ autoInstrument: false, captureUncaught: false });
1826
1913
  });
1827
1914
 
1828
- it('should handle multiple strings', function(done) {
1915
+ it('should handle multiple strings', function (done) {
1829
1916
  var client = new (TestClientGen())();
1830
1917
  var options = {};
1831
- var rollbar = window.rollbar = new Rollbar(options, client);
1918
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1832
1919
 
1833
1920
  var args = ['first', 'second'];
1834
1921
  var item = rollbar._createItem(args);
@@ -1837,10 +1924,10 @@ describe('createItem', function() {
1837
1924
 
1838
1925
  done();
1839
1926
  });
1840
- it('should handle errors', function(done) {
1927
+ it('should handle errors', function (done) {
1841
1928
  var client = new (TestClientGen())();
1842
1929
  var options = {};
1843
- var rollbar = window.rollbar = new Rollbar(options, client);
1930
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1844
1931
 
1845
1932
  var args = [new Error('Whoa'), 'first', 'second'];
1846
1933
  var item = rollbar._createItem(args);
@@ -1850,13 +1937,13 @@ describe('createItem', function() {
1850
1937
 
1851
1938
  done();
1852
1939
  });
1853
- it('should handle a callback', function(done) {
1940
+ it('should handle a callback', function (done) {
1854
1941
  var client = new (TestClientGen())();
1855
1942
  var options = {};
1856
- var rollbar = window.rollbar = new Rollbar(options, client);
1943
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1857
1944
 
1858
1945
  var myCallbackCalled = false;
1859
- var myCallback = function() {
1946
+ var myCallback = function () {
1860
1947
  myCallbackCalled = true;
1861
1948
  };
1862
1949
  var args = [new Error('Whoa'), 'first', myCallback, 'second'];
@@ -1870,10 +1957,10 @@ describe('createItem', function() {
1870
1957
 
1871
1958
  done();
1872
1959
  });
1873
- it('should handle arrays', function(done) {
1960
+ it('should handle arrays', function (done) {
1874
1961
  var client = new (TestClientGen())();
1875
1962
  var options = {};
1876
- var rollbar = window.rollbar = new Rollbar(options, client);
1963
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1877
1964
 
1878
1965
  var args = [new Error('Whoa'), 'first', [1, 2, 3], 'second'];
1879
1966
  var item = rollbar._createItem(args);
@@ -1884,12 +1971,12 @@ describe('createItem', function() {
1884
1971
 
1885
1972
  done();
1886
1973
  });
1887
- it('should handle objects', function(done) {
1974
+ it('should handle objects', function (done) {
1888
1975
  var client = new (TestClientGen())();
1889
1976
  var options = {};
1890
- var rollbar = window.rollbar = new Rollbar(options, client);
1977
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1891
1978
 
1892
- var args = [new Error('Whoa'), 'first', {a: 1, b: 2}, 'second'];
1979
+ var args = [new Error('Whoa'), 'first', { a: 1, b: 2 }, 'second'];
1893
1980
  var item = rollbar._createItem(args);
1894
1981
  expect(item.err).to.eql(args[0]);
1895
1982
  expect(item.message).to.eql('first');
@@ -1899,12 +1986,15 @@ describe('createItem', function() {
1899
1986
 
1900
1987
  done();
1901
1988
  });
1902
- it('should handle custom arguments', function(done) {
1989
+ it('should handle custom arguments', function (done) {
1903
1990
  var client = new (TestClientGen())();
1904
1991
  var options = {};
1905
- var rollbar = window.rollbar = new Rollbar(options, client);
1992
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1906
1993
 
1907
- var args = [new Error('Whoa'), {level: 'info', skipFrames: 1, foo: 'bar'}];
1994
+ var args = [
1995
+ new Error('Whoa'),
1996
+ { level: 'info', skipFrames: 1, foo: 'bar' },
1997
+ ];
1908
1998
  var item = rollbar._createItem(args);
1909
1999
  expect(item.err).to.eql(args[0]);
1910
2000
  expect(item.level).to.eql('info');
@@ -1915,24 +2005,24 @@ describe('createItem', function() {
1915
2005
 
1916
2006
  done();
1917
2007
  });
1918
- it('should have a timestamp', function(done) {
2008
+ it('should have a timestamp', function (done) {
1919
2009
  var client = new (TestClientGen())();
1920
2010
  var options = {};
1921
- var rollbar = window.rollbar = new Rollbar(options, client);
2011
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1922
2012
 
1923
- var args = [new Error('Whoa'), 'first', {a: 1, b: 2}, 'second'];
2013
+ var args = [new Error('Whoa'), 'first', { a: 1, b: 2 }, 'second'];
1924
2014
  var item = rollbar._createItem(args);
1925
- var now = (new Date()).getTime();
2015
+ var now = new Date().getTime();
1926
2016
  expect(item.timestamp).to.be.within(now - 1000, now + 1000);
1927
2017
 
1928
2018
  done();
1929
2019
  });
1930
- it('should have an uuid', function(done) {
2020
+ it('should have an uuid', function (done) {
1931
2021
  var client = new (TestClientGen())();
1932
2022
  var options = {};
1933
- var rollbar = window.rollbar = new Rollbar(options, client);
2023
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1934
2024
 
1935
- var args = [new Error('Whoa'), 'first', {a: 1, b: 2}, 'second'];
2025
+ var args = [new Error('Whoa'), 'first', { a: 1, b: 2 }, 'second'];
1936
2026
  var item = rollbar._createItem(args);
1937
2027
  expect(item.uuid).to.be.ok();
1938
2028
 
@@ -1943,38 +2033,42 @@ describe('createItem', function() {
1943
2033
 
1944
2034
  done();
1945
2035
  });
1946
- it('should handle dates', function(done) {
2036
+ it('should handle dates', function (done) {
1947
2037
  var client = new (TestClientGen())();
1948
2038
  var options = {};
1949
- var rollbar = window.rollbar = new Rollbar(options, client);
2039
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1950
2040
 
1951
- var y2k = new Date(2000, 0, 1)
1952
- var args = [new Error('Whoa'), 'first', y2k, {a: 1, b: 2}, 'second'];
2041
+ var y2k = new Date(2000, 0, 1);
2042
+ var args = [new Error('Whoa'), 'first', y2k, { a: 1, b: 2 }, 'second'];
1953
2043
  var item = rollbar._createItem(args);
1954
2044
  expect(item.custom.extraArgs).to.eql([y2k, 'second']);
1955
2045
 
1956
2046
  done();
1957
2047
  });
1958
- it('should handle numbers', function(done) {
2048
+ it('should handle numbers', function (done) {
1959
2049
  var client = new (TestClientGen())();
1960
2050
  var options = {};
1961
- var rollbar = window.rollbar = new Rollbar(options, client);
2051
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1962
2052
 
1963
- var args = [new Error('Whoa'), 'first', 42, {a: 1, b: 2}, 'second'];
2053
+ var args = [new Error('Whoa'), 'first', 42, { a: 1, b: 2 }, 'second'];
1964
2054
  var item = rollbar._createItem(args);
1965
2055
  expect(item.custom.extraArgs).to.eql([42, 'second']);
1966
2056
 
1967
2057
  done();
1968
2058
  });
1969
- it('should handle domexceptions', function(done) {
2059
+ it('should handle domexceptions', function (done) {
1970
2060
  var client = new (TestClientGen())();
1971
2061
  var options = {};
1972
- var rollbar = window.rollbar = new Rollbar(options, client);
2062
+ var rollbar = (window.rollbar = new Rollbar(options, client));
1973
2063
 
1974
2064
  if (document && document.querySelectorAll) {
1975
2065
  var e;
1976
- try { document.querySelectorAll('div:foo'); } catch (ee) { e = ee }
1977
- var args = [e, 'first', 42, {a: 1, b: 2}, 'second'];
2066
+ try {
2067
+ document.querySelectorAll('div:foo');
2068
+ } catch (ee) {
2069
+ e = ee;
2070
+ }
2071
+ var args = [e, 'first', 42, { a: 1, b: 2 }, 'second'];
1978
2072
  var item = rollbar._createItem(args);
1979
2073
  expect(item.err).to.be.ok();
1980
2074
  }
@@ -1983,8 +2077,8 @@ describe('createItem', function() {
1983
2077
  });
1984
2078
  });
1985
2079
 
1986
- describe('singleton', function() {
1987
- it('should pass through the underlying client after init', function(done) {
2080
+ describe('singleton', function () {
2081
+ it('should pass through the underlying client after init', function (done) {
1988
2082
  var client = new (TestClientGen())();
1989
2083
  var options = {};
1990
2084
  var rollbar = Rollbar.init(options, client);