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
@@ -9,40 +9,55 @@ var polyfillJSON = require('../vendor/JSON-js/json3');
9
9
 
10
10
  utility.setupJSON();
11
11
 
12
- describe('setupJSON', function() {
13
- beforeEach(function(){
12
+ describe('setupJSON', function () {
13
+ beforeEach(function () {
14
14
  utility.RollbarJSON.stringify = null;
15
15
  utility.RollbarJSON.parse = null;
16
16
  });
17
17
 
18
- afterEach(function(){
18
+ afterEach(function () {
19
19
  // Resets utility.RollbarJSON
20
20
  utility.RollbarJSON.stringify = null;
21
21
  utility.RollbarJSON.parse = null;
22
22
  utility.setupJSON();
23
23
  });
24
24
 
25
- it('should use native interface when polyfill is provided', function() {
26
- var native = {stringify: JSON.stringify, parse: JSON.parse};
25
+ it('should use native interface when polyfill is provided', function () {
26
+ var native = { stringify: JSON.stringify, parse: JSON.parse };
27
27
 
28
28
  utility.setupJSON(polyfillJSON);
29
29
 
30
- expect(utility.RollbarJSON.stringify.toString()).to.equal(native.stringify.toString());
31
- expect(utility.RollbarJSON.parse.toString()).to.equal(native.parse.toString());
30
+ expect(utility.RollbarJSON.stringify.toString()).to.equal(
31
+ native.stringify.toString(),
32
+ );
33
+ expect(utility.RollbarJSON.parse.toString()).to.equal(
34
+ native.parse.toString(),
35
+ );
32
36
  });
33
37
 
34
- it('should use native interface when polyfill is not provided', function() {
35
- var native = {stringify: JSON.stringify, parse: JSON.parse};
38
+ it('should use native interface when polyfill is not provided', function () {
39
+ var native = { stringify: JSON.stringify, parse: JSON.parse };
36
40
 
37
41
  utility.setupJSON();
38
42
 
39
- expect(utility.RollbarJSON.stringify.toString()).to.equal(native.stringify.toString());
40
- expect(utility.RollbarJSON.parse.toString()).to.equal(native.parse.toString());
43
+ expect(utility.RollbarJSON.stringify.toString()).to.equal(
44
+ native.stringify.toString(),
45
+ );
46
+ expect(utility.RollbarJSON.parse.toString()).to.equal(
47
+ native.parse.toString(),
48
+ );
41
49
  });
42
50
 
43
- it('should replace custom interface when polyfill is provided', function() {
44
- var native = {stringify: JSON.stringify, parse: JSON.parse};
45
- var custom = {stringify: function(json){ return json;}, parse: function(json){ return json;}};
51
+ it('should replace custom interface when polyfill is provided', function () {
52
+ var native = { stringify: JSON.stringify, parse: JSON.parse };
53
+ var custom = {
54
+ stringify: function (json) {
55
+ return json;
56
+ },
57
+ parse: function (json) {
58
+ return json;
59
+ },
60
+ };
46
61
  var polyfill = {};
47
62
  polyfillJSON(polyfill);
48
63
 
@@ -52,17 +67,28 @@ describe('setupJSON', function() {
52
67
 
53
68
  utility.setupJSON(polyfillJSON);
54
69
 
55
- expect(utility.RollbarJSON.stringify.toString()).to.equal(polyfill.stringify.toString());
56
- expect(utility.RollbarJSON.parse.toString()).to.equal(polyfill.parse.toString());
70
+ expect(utility.RollbarJSON.stringify.toString()).to.equal(
71
+ polyfill.stringify.toString(),
72
+ );
73
+ expect(utility.RollbarJSON.parse.toString()).to.equal(
74
+ polyfill.parse.toString(),
75
+ );
57
76
 
58
77
  // restore original interface
59
78
  JSON.stringify = native.stringify;
60
79
  JSON.parse = native.parse;
61
80
  });
62
81
 
63
- it('should keep custom interface when polyfill is not provided', function() {
64
- var native = {stringify: JSON.stringify, parse: JSON.parse};
65
- var custom = {stringify: function(json){ return json;}, parse: function(json){ return json;}};
82
+ it('should keep custom interface when polyfill is not provided', function () {
83
+ var native = { stringify: JSON.stringify, parse: JSON.parse };
84
+ var custom = {
85
+ stringify: function (json) {
86
+ return json;
87
+ },
88
+ parse: function (json) {
89
+ return json;
90
+ },
91
+ };
66
92
 
67
93
  // Set to custom interface
68
94
  JSON.stringify = custom.stringify;
@@ -70,8 +96,12 @@ describe('setupJSON', function() {
70
96
 
71
97
  utility.setupJSON();
72
98
 
73
- expect(utility.RollbarJSON.stringify.toString()).to.equal(custom.stringify.toString());
74
- expect(utility.RollbarJSON.parse.toString()).to.equal(custom.parse.toString());
99
+ expect(utility.RollbarJSON.stringify.toString()).to.equal(
100
+ custom.stringify.toString(),
101
+ );
102
+ expect(utility.RollbarJSON.parse.toString()).to.equal(
103
+ custom.parse.toString(),
104
+ );
75
105
 
76
106
  // restore original interface
77
107
  JSON.stringify = native.stringify;
@@ -79,18 +109,18 @@ describe('setupJSON', function() {
79
109
  });
80
110
  });
81
111
 
82
- describe('typeName', function() {
83
- it('should handle undefined', function(done) {
112
+ describe('typeName', function () {
113
+ it('should handle undefined', function (done) {
84
114
  expect(_.typeName(undefined)).to.eql('undefined');
85
115
  done();
86
116
  });
87
117
 
88
- it('should handle null', function(done) {
118
+ it('should handle null', function (done) {
89
119
  expect(_.typeName(null)).to.eql('null');
90
120
  done();
91
121
  });
92
122
 
93
- it('should handle numbers', function(done) {
123
+ it('should handle numbers', function (done) {
94
124
  expect(_.typeName(1)).to.eql('number');
95
125
  expect(_.typeName(-32)).to.eql('number');
96
126
  expect(_.typeName(1.452)).to.eql('number');
@@ -98,49 +128,48 @@ describe('typeName', function() {
98
128
  done();
99
129
  });
100
130
 
101
- it('should handle bools', function(done) {
131
+ it('should handle bools', function (done) {
102
132
  expect(_.typeName(true)).to.eql('boolean');
103
133
  expect(_.typeName(false)).to.eql('boolean');
104
134
  done();
105
135
  });
106
136
 
107
- it('should handle strings', function(done) {
137
+ it('should handle strings', function (done) {
108
138
  expect(_.typeName('')).to.eql('string');
109
139
  expect(_.typeName('a longer string')).to.eql('string');
110
140
  done();
111
141
  });
112
142
 
113
- it('should handle functions', function(done) {
114
- expect(_.typeName(function(){})).to.eql('function');
115
- var f = function(x) {
143
+ it('should handle functions', function (done) {
144
+ expect(_.typeName(function () {})).to.eql('function');
145
+ var f = function (x) {
116
146
  return x;
117
147
  };
118
148
  expect(_.typeName(f)).to.eql('function');
119
149
  done();
120
150
  });
121
151
 
122
- it('should handle objects', function(done) {
152
+ it('should handle objects', function (done) {
123
153
  expect(_.typeName({})).to.eql('object');
124
- expect(_.typeName({a: 123})).to.eql('object');
154
+ expect(_.typeName({ a: 123 })).to.eql('object');
125
155
  done();
126
156
  });
127
157
 
128
- it('should handle arrays', function(done) {
158
+ it('should handle arrays', function (done) {
129
159
  expect(_.typeName([])).to.eql('array');
130
- expect(_.typeName([1, {a: 42}, null])).to.eql('array');
160
+ expect(_.typeName([1, { a: 42 }, null])).to.eql('array');
131
161
  done();
132
162
  });
133
-
134
163
  });
135
164
 
136
- describe('isType', function() {
137
- it('should handle all types', function(done) {
165
+ describe('isType', function () {
166
+ it('should handle all types', function (done) {
138
167
  expect(_.isType(undefined, 'undefined')).to.be.ok();
139
168
  expect(_.isType(undefined, 'null')).to.not.be.ok();
140
169
  expect(_.isType(null, 'null')).to.be.ok();
141
170
  expect(_.isType(null, 'object')).to.not.be.ok();
142
171
  expect(_.isType({}, 'object')).to.be.ok();
143
- expect(_.isType(function(){}, 'function')).to.be.ok();
172
+ expect(_.isType(function () {}, 'function')).to.be.ok();
144
173
  expect(_.isType(42, 'number')).to.be.ok();
145
174
  expect(_.isType('42', 'string')).to.be.ok();
146
175
  expect(_.isType([], 'array')).to.be.ok();
@@ -150,10 +179,12 @@ describe('isType', function() {
150
179
  });
151
180
  });
152
181
 
153
- describe('isFunction', function() {
154
- it('should work for all functions', function(done) {
155
- var f = function() { return; };
156
- var g = function(x) {
182
+ describe('isFunction', function () {
183
+ it('should work for all functions', function (done) {
184
+ var f = function () {
185
+ return;
186
+ };
187
+ var g = function (x) {
157
188
  return f(x);
158
189
  };
159
190
  expect(_.isFunction({})).to.not.be.ok();
@@ -162,12 +193,13 @@ describe('isFunction', function() {
162
193
  expect(_.isFunction(g)).to.be.ok();
163
194
  done();
164
195
  });
165
-
166
196
  });
167
- describe('isNativeFunction', function() {
168
- it('should work for all native functions', function(done) {
169
- var f = function() { return; };
170
- var g = function(x) {
197
+ describe('isNativeFunction', function () {
198
+ it('should work for all native functions', function (done) {
199
+ var f = function () {
200
+ return;
201
+ };
202
+ var g = function (x) {
171
203
  return f(x);
172
204
  };
173
205
  var h = String.prototype.substr;
@@ -182,11 +214,11 @@ describe('isNativeFunction', function() {
182
214
  });
183
215
  });
184
216
 
185
- describe('isIterable', function() {
186
- it('should work for all types', function(done) {
217
+ describe('isIterable', function () {
218
+ it('should work for all types', function (done) {
187
219
  expect(_.isIterable({})).to.be.ok();
188
220
  expect(_.isIterable([])).to.be.ok();
189
- expect(_.isIterable([{a: 1}])).to.be.ok();
221
+ expect(_.isIterable([{ a: 1 }])).to.be.ok();
190
222
  expect(_.isIterable(null)).to.not.be.ok();
191
223
  expect(_.isIterable(undefined)).to.not.be.ok();
192
224
  expect(_.isIterable('object')).to.not.be.ok();
@@ -195,17 +227,17 @@ describe('isIterable', function() {
195
227
  });
196
228
  });
197
229
 
198
- describe('isError', function() {
199
- it('should handle null', function(done) {
230
+ describe('isError', function () {
231
+ it('should handle null', function (done) {
200
232
  expect(_.isError(null)).to.not.be.ok();
201
233
  done();
202
234
  });
203
- it('should handle errors', function(done) {
235
+ it('should handle errors', function (done) {
204
236
  var e = new Error('hello');
205
237
  expect(_.isError(e)).to.be.ok();
206
238
  done();
207
239
  });
208
- it('should handle subclasses of error', function(done) {
240
+ it('should handle subclasses of error', function (done) {
209
241
  // This is a mostly browser compliant way of doing this
210
242
  // just for the sake of doing it, even though we mostly
211
243
  // need this to work in node environments
@@ -213,13 +245,13 @@ describe('isError', function() {
213
245
  Object.defineProperty(this, 'name', {
214
246
  enumerable: false,
215
247
  writable: false,
216
- value: 'TestCustomError'
248
+ value: 'TestCustomError',
217
249
  });
218
250
 
219
251
  Object.defineProperty(this, 'message', {
220
252
  enumerable: false,
221
253
  writable: true,
222
- value: message
254
+ value: message,
223
255
  });
224
256
 
225
257
  if (Error.hasOwnProperty('captureStackTrace')) {
@@ -228,7 +260,7 @@ describe('isError', function() {
228
260
  Object.defineProperty(this, 'stack', {
229
261
  enumerable: false,
230
262
  writable: false,
231
- value: (new Error(message)).stack
263
+ value: new Error(message).stack,
232
264
  });
233
265
  }
234
266
  }
@@ -237,7 +269,7 @@ describe('isError', function() {
237
269
  Object.setPrototypeOf(TestCustomError.prototype, Error.prototype);
238
270
  } else {
239
271
  TestCustomError.prototype = Object.create(Error.prototype, {
240
- constructor: { value: TestCustomError }
272
+ constructor: { value: TestCustomError },
241
273
  });
242
274
  }
243
275
  var e = new TestCustomError('bork');
@@ -246,25 +278,25 @@ describe('isError', function() {
246
278
  });
247
279
  });
248
280
 
249
- describe('isFiniteNumber', function() {
250
- [ NaN, null, undefined, 'x' ].forEach(function(value) {
251
- it(`should return false for ${value}`, function(done) {
281
+ describe('isFiniteNumber', function () {
282
+ [NaN, null, undefined, 'x'].forEach(function (value) {
283
+ it(`should return false for ${value}`, function (done) {
252
284
  expect(_.isFiniteNumber(value)).to.equal(false);
253
285
  done();
254
286
  });
255
287
  });
256
- [ -100, 0, 100 ].forEach(function(value) {
257
- it(`should return true for ${value}`, function(done) {
288
+ [-100, 0, 100].forEach(function (value) {
289
+ it(`should return true for ${value}`, function (done) {
258
290
  expect(_.isFiniteNumber(value)).to.equal(true);
259
291
  done();
260
292
  });
261
293
  });
262
294
  });
263
295
 
264
- describe('merge', function() {
265
- it('should work for simple objects', function(done) {
266
- var o1 = {a: 1, b: 2};
267
- var o2 = {a: 42, c: 101};
296
+ describe('merge', function () {
297
+ it('should work for simple objects', function (done) {
298
+ var o1 = { a: 1, b: 2 };
299
+ var o2 = { a: 42, c: 101 };
268
300
  var e = _.merge(o1, o2);
269
301
 
270
302
  expect(e.a).to.eql(42);
@@ -278,9 +310,9 @@ describe('merge', function() {
278
310
 
279
311
  done();
280
312
  });
281
- it('should not concat arrays', function(done) {
282
- var o1 = {a: 1, b: ['hello', 'world']};
283
- var o2 = {a: 42, b: ['goodbye']};
313
+ it('should not concat arrays', function (done) {
314
+ var o1 = { a: 1, b: ['hello', 'world'] };
315
+ var o2 = { a: 42, b: ['goodbye'] };
284
316
  var e = _.merge(o1, o2);
285
317
 
286
318
  expect(e.a).to.eql(42);
@@ -292,17 +324,17 @@ describe('merge', function() {
292
324
  expect(o1.b).not.to.contain('goodbye');
293
325
  done();
294
326
  });
295
- it('should handle nested objects', function(done) {
327
+ it('should handle nested objects', function (done) {
296
328
  var o1 = {
297
329
  a: 1,
298
330
  c: 100,
299
331
  payload: {
300
332
  person: {
301
333
  id: 'xxx',
302
- name: 'hello'
334
+ name: 'hello',
303
335
  },
304
- environment: 'foo'
305
- }
336
+ environment: 'foo',
337
+ },
306
338
  };
307
339
  var o2 = {
308
340
  a: 42,
@@ -310,10 +342,10 @@ describe('merge', function() {
310
342
  payload: {
311
343
  person: {
312
344
  id: 'yesyes',
313
- email: 'cool'
345
+ email: 'cool',
314
346
  },
315
- other: 'bar'
316
- }
347
+ other: 'bar',
348
+ },
317
349
  };
318
350
  var e = _.merge(o1, o2);
319
351
 
@@ -327,7 +359,7 @@ describe('merge', function() {
327
359
  expect(e.payload.other).to.eql('bar');
328
360
  done();
329
361
  });
330
- it('should handle nested arrays and objects, with non-matching structure', function(done) {
362
+ it('should handle nested arrays and objects, with non-matching structure', function (done) {
331
363
  var o1 = {
332
364
  a: 1,
333
365
  c: {
@@ -335,12 +367,12 @@ describe('merge', function() {
335
367
  other: [99, 100, 101],
336
368
  payload: {
337
369
  foo: {
338
- bar: 'baz'
370
+ bar: 'baz',
339
371
  },
340
372
  hello: 'world',
341
- keeper: 'yup'
342
- }
343
- }
373
+ keeper: 'yup',
374
+ },
375
+ },
344
376
  };
345
377
  var o2 = {
346
378
  a: 32,
@@ -350,10 +382,10 @@ describe('merge', function() {
350
382
  payload: {
351
383
  foo: 'hello',
352
384
  hello: {
353
- baz: 'bar'
354
- }
355
- }
356
- }
385
+ baz: 'bar',
386
+ },
387
+ },
388
+ },
357
389
  };
358
390
  var e = _.merge(o1, o2);
359
391
 
@@ -368,17 +400,17 @@ describe('merge', function() {
368
400
  done();
369
401
  });
370
402
 
371
- it('should handle many nested objects', function(done) {
403
+ it('should handle many nested objects', function (done) {
372
404
  var o1 = {
373
405
  a: 1,
374
406
  c: 100,
375
407
  payload: {
376
408
  person: {
377
409
  id: 'xxx',
378
- name: 'hello'
410
+ name: 'hello',
379
411
  },
380
- environment: 'foo'
381
- }
412
+ environment: 'foo',
413
+ },
382
414
  };
383
415
  var o2 = {
384
416
  a: 42,
@@ -386,19 +418,19 @@ describe('merge', function() {
386
418
  payload: {
387
419
  person: {
388
420
  id: 'yesyes',
389
- email: 'cool'
421
+ email: 'cool',
390
422
  },
391
- other: 'bar'
392
- }
423
+ other: 'bar',
424
+ },
393
425
  };
394
426
  var o3 = {
395
427
  payload: {
396
428
  fuzz: 'buzz',
397
429
  person: {
398
- name: 'nope'
399
- }
430
+ name: 'nope',
431
+ },
400
432
  },
401
- amihere: 'yes'
433
+ amihere: 'yes',
402
434
  };
403
435
  var e = _.merge(o1, o2, o3);
404
436
 
@@ -417,13 +449,13 @@ describe('merge', function() {
417
449
  });
418
450
 
419
451
  var traverse = require('../src/utility/traverse');
420
- describe('traverse', function() {
421
- describe('should call the func for every key,value', function() {
422
- it('simple object', function(done) {
423
- var obj = {a: 1, b: 2};
424
- var expectedOutput = {a: 2, b: 3};
452
+ describe('traverse', function () {
453
+ describe('should call the func for every key,value', function () {
454
+ it('simple object', function (done) {
455
+ var obj = { a: 1, b: 2 };
456
+ var expectedOutput = { a: 2, b: 3 };
425
457
  var callCount = 0;
426
- var result = traverse(obj, function(k, v) {
458
+ var result = traverse(obj, function (k, v) {
427
459
  callCount++;
428
460
  return v + 1;
429
461
  });
@@ -432,15 +464,15 @@ describe('traverse', function() {
432
464
 
433
465
  done();
434
466
  });
435
- it('nested object', function(done) {
436
- var obj = {a: 1, b: 2, c: {ca: 11}};
437
- var expectedOutput = {a: 2, b: 3, c: {ca: 12}};
467
+ it('nested object', function (done) {
468
+ var obj = { a: 1, b: 2, c: { ca: 11 } };
469
+ var expectedOutput = { a: 2, b: 3, c: { ca: 12 } };
438
470
  var callCount = 0;
439
- var result = traverse(obj, function(k, v) {
471
+ var result = traverse(obj, function (k, v) {
440
472
  callCount++;
441
473
  if (k === 'c') {
442
- return {ca: v.ca+1};
443
- }
474
+ return { ca: v.ca + 1 };
475
+ }
444
476
  return v + 1;
445
477
  });
446
478
  expect(result).to.eql(expectedOutput);
@@ -448,14 +480,18 @@ describe('traverse', function() {
448
480
 
449
481
  done();
450
482
  });
451
- it('array', function(done) {
483
+ it('array', function (done) {
452
484
  var obj = [1, 2, 3];
453
485
  var expected = [0, 1, 2];
454
486
  var callCount = 0;
455
- var result = traverse(obj, function(k, v) {
456
- callCount++;
457
- return v - 1;
458
- }, []);
487
+ var result = traverse(
488
+ obj,
489
+ function (k, v) {
490
+ callCount++;
491
+ return v - 1;
492
+ },
493
+ [],
494
+ );
459
495
  expect(result).to.eql(expected);
460
496
  expect(callCount).to.eql(3);
461
497
  done();
@@ -463,8 +499,8 @@ describe('traverse', function() {
463
499
  });
464
500
  });
465
501
 
466
- describe('uuid4', function() {
467
- it('should return a version 4 uuid', function(done) {
502
+ describe('uuid4', function () {
503
+ it('should return a version 4 uuid', function (done) {
468
504
  var id = _.uuid4();
469
505
  var otherId = _.uuid4();
470
506
  expect(id).to.not.eql(otherId);
@@ -480,11 +516,11 @@ describe('uuid4', function() {
480
516
  });
481
517
  });
482
518
 
483
- describe('redact', function() {
484
- it('should return a string of stars', function(done) {
519
+ describe('redact', function () {
520
+ it('should return a string of stars', function (done) {
485
521
  var s1 = 'thisIsApasswrD';
486
522
  var s2 = 'short';
487
- var o = {a: 123};
523
+ var o = { a: 123 };
488
524
  var a = [12, 34, 56];
489
525
 
490
526
  expect(_.redact(s1)).to.not.match(/[^*]/);
@@ -494,184 +530,192 @@ describe('redact', function() {
494
530
  expect(_.redact(a)).to.not.match(/[^*]/);
495
531
 
496
532
  done();
497
- })
533
+ });
498
534
  });
499
535
 
500
- describe('LEVELS', function() {
501
- it('should include debug', function() {
536
+ describe('LEVELS', function () {
537
+ it('should include debug', function () {
502
538
  expect(_.LEVELS['debug']).to.not.eql(undefined);
503
539
  });
504
- it('should have critical higher than debug', function() {
540
+ it('should have critical higher than debug', function () {
505
541
  expect(_.LEVELS['critical']).to.be.greaterThan(_.LEVELS['debug']);
506
542
  });
507
543
  });
508
544
 
509
- describe('formatUrl', function() {
510
- it('should handle a missing protocol', function() {
545
+ describe('formatUrl', function () {
546
+ it('should handle a missing protocol', function () {
511
547
  var u = {
512
548
  hostname: 'a.b.com',
513
549
  path: '/wooza/',
514
- port: 42
550
+ port: 42,
515
551
  };
516
552
  expect(_.formatUrl(u)).to.eql('https://a.b.com:42/wooza/');
517
553
  });
518
- it('should use a forced protocol', function() {
554
+ it('should use a forced protocol', function () {
519
555
  var u = {
520
556
  hostname: 'a.b.com',
521
557
  path: '/wooza/',
522
- port: 42
558
+ port: 42,
523
559
  };
524
560
  expect(_.formatUrl(u, 'file:')).to.eql('file://a.b.com:42/wooza/');
525
561
  });
526
- it('should pick a protocol based on port if others are missing', function() {
562
+ it('should pick a protocol based on port if others are missing', function () {
527
563
  var u = {
528
564
  hostname: 'a.b.com',
529
565
  port: 80,
530
- path: '/woo'
566
+ path: '/woo',
531
567
  };
532
568
  expect(_.formatUrl(u)).to.eql('http://a.b.com:80/woo');
533
569
  u.protocol = 'https:';
534
570
  expect(_.formatUrl(u)).to.eql('https://a.b.com:80/woo');
535
571
  });
536
- it('should handle missing parts', function() {
572
+ it('should handle missing parts', function () {
537
573
  var u = {
538
- hostname: 'a.b.com'
574
+ hostname: 'a.b.com',
539
575
  };
540
576
  expect(_.formatUrl(u)).to.eql('https://a.b.com');
541
577
  expect(_.formatUrl(u, 'http:')).to.eql('http://a.b.com');
542
578
  });
543
- it('should return null without a hostname', function() {
579
+ it('should return null without a hostname', function () {
544
580
  var u = {};
545
581
  expect(_.formatUrl(u)).to.not.be.ok();
546
582
  expect(_.formatUrl(u, 'https:')).to.not.be.ok();
547
583
  });
548
584
  });
549
585
 
550
- describe('addParamsAndAccessTokenToPath', function() {
586
+ describe('addParamsAndAccessTokenToPath', function () {
551
587
  var accessToken = 'abc123';
552
- it('should handle no params and no path', function() {
588
+ it('should handle no params and no path', function () {
553
589
  var options = {};
554
590
  _.addParamsAndAccessTokenToPath(accessToken, options);
555
591
  expect(options.path).to.eql('?access_token=abc123');
556
592
  });
557
- it('should handle existing params', function() {
558
- var options = {path: '/api?a=b'};
593
+ it('should handle existing params', function () {
594
+ var options = { path: '/api?a=b' };
559
595
  _.addParamsAndAccessTokenToPath(accessToken, options);
560
596
  expect(options.path).to.eql('/api?access_token=abc123&a=b');
561
597
  });
562
- it('should handle a hash with params', function() {
563
- var options = {path: '/api?a=b#moreStuff??here'};
598
+ it('should handle a hash with params', function () {
599
+ var options = { path: '/api?a=b#moreStuff??here' };
564
600
  _.addParamsAndAccessTokenToPath(accessToken, options);
565
601
  expect(options.path).to.eql('/api?access_token=abc123&a=b#moreStuff??here');
566
602
  });
567
- it('should handle a hash without params', function() {
568
- var options = {path: '/api#moreStuff??here'};
603
+ it('should handle a hash without params', function () {
604
+ var options = { path: '/api#moreStuff??here' };
569
605
  _.addParamsAndAccessTokenToPath(accessToken, options);
570
606
  expect(options.path).to.eql('/api?access_token=abc123#moreStuff??here');
571
607
  });
572
- it('should handle a hash without params and no ?', function() {
573
- var options = {path: '/api#moreStuff'};
608
+ it('should handle a hash without params and no ?', function () {
609
+ var options = { path: '/api#moreStuff' };
574
610
  _.addParamsAndAccessTokenToPath(accessToken, options);
575
611
  expect(options.path).to.eql('/api?access_token=abc123#moreStuff');
576
612
  });
577
- it('should handle extra params', function() {
578
- var options = {path: '/api#moreStuff'};
579
- _.addParamsAndAccessTokenToPath(accessToken, options, {foo: 'boo'});
613
+ it('should handle extra params', function () {
614
+ var options = { path: '/api#moreStuff' };
615
+ _.addParamsAndAccessTokenToPath(accessToken, options, { foo: 'boo' });
580
616
  expect(options.path).to.eql('/api?access_token=abc123&foo=boo#moreStuff');
581
617
  });
582
618
  });
583
619
 
584
- describe('json3', function() {
620
+ describe('json3', function () {
585
621
  var setupCustomJSON = require('../vendor/JSON-js/json3.js');
586
- it('should replace stringify if not there', function() {
622
+ it('should replace stringify if not there', function () {
587
623
  var j = {};
588
624
  setupCustomJSON(j);
589
- expect(j.stringify({a: 1})).to.eql('{"a":1}');
625
+ expect(j.stringify({ a: 1 })).to.eql('{"a":1}');
590
626
  });
591
- it('should replace parse if not there', function() {
627
+ it('should replace parse if not there', function () {
592
628
  var j = {};
593
629
  setupCustomJSON(j);
594
630
  expect(j.parse('{"a":1}').a).to.eql(1);
595
631
  });
596
- it('should not replace parse if there', function() {
597
- var j = {parse: function(s) { return 42; }};
632
+ it('should not replace parse if there', function () {
633
+ var j = {
634
+ parse: function (s) {
635
+ return 42;
636
+ },
637
+ };
598
638
  setupCustomJSON(j);
599
639
  expect(j.parse('{"a":1}')).to.eql(42);
600
- expect(j.stringify({a: 1})).to.eql('{"a":1}');
640
+ expect(j.stringify({ a: 1 })).to.eql('{"a":1}');
601
641
  });
602
- it('should not replace stringify if there', function() {
603
- var j = {stringify: function(s) { return '42'; }};
642
+ it('should not replace stringify if there', function () {
643
+ var j = {
644
+ stringify: function (s) {
645
+ return '42';
646
+ },
647
+ };
604
648
  setupCustomJSON(j);
605
- expect(j.stringify({a: 1})).to.eql('42');
649
+ expect(j.stringify({ a: 1 })).to.eql('42');
606
650
  expect(j.parse('{"a":1}').a).to.eql(1);
607
651
  });
608
652
  });
609
653
 
610
- describe('get', function() {
611
- it('should get a deeply nested value', function() {
612
- var o = {a: {b: {c: {d: 42}}}};
654
+ describe('get', function () {
655
+ it('should get a deeply nested value', function () {
656
+ var o = { a: { b: { c: { d: 42 } } } };
613
657
  expect(_.get(o, 'a.b.c.d')).to.eql(42);
614
658
  });
615
- it('should be undefined for a missing value', function() {
616
- var o = {a: {b: {c: {d: 42}}}};
659
+ it('should be undefined for a missing value', function () {
660
+ var o = { a: { b: { c: { d: 42 } } } };
617
661
  expect(_.get(o, 'a.b.x.d')).to.not.be.ok();
618
662
  });
619
- it('should handle bad input', function() {
663
+ it('should handle bad input', function () {
620
664
  var o = 'hello';
621
665
  expect(_.get(o, 'oops.1.2.3')).to.not.be.ok();
622
666
  });
623
- it('should actually work with arrays too', function() {
624
- var o = {a: [{b: {c: [1, {d: 42}, null]}}, 99]};
667
+ it('should actually work with arrays too', function () {
668
+ var o = { a: [{ b: { c: [1, { d: 42 }, null] } }, 99] };
625
669
  expect(_.get(o, 'a.0.b.c.1.d')).to.eql(42);
626
670
  });
627
- it('should handle undefined input', function() {
671
+ it('should handle undefined input', function () {
628
672
  var u = undefined;
629
673
  expect(_.get(u, 'a.b.c')).to.not.be.ok();
630
674
  });
631
675
  });
632
676
 
633
- describe('filterIp', function() {
634
- it('no user_ip', function() {
635
- var requestData = {'something': 'but no ip'};
677
+ describe('filterIp', function () {
678
+ it('no user_ip', function () {
679
+ var requestData = { something: 'but no ip' };
636
680
  _.filterIp(requestData, false);
637
681
  expect(requestData['user_ip']).to.not.be.ok();
638
682
  });
639
- it('capture true', function() {
683
+ it('capture true', function () {
640
684
  var ip = '123.32.394.99';
641
- var requestData = {'user_ip': ip};
685
+ var requestData = { user_ip: ip };
642
686
  _.filterIp(requestData, true);
643
687
  expect(requestData['user_ip']).to.eql(ip);
644
688
  });
645
- it('anonymize ip4', function() {
689
+ it('anonymize ip4', function () {
646
690
  var ip = '123.32.394.99';
647
- var requestData = {'user_ip': ip};
691
+ var requestData = { user_ip: ip };
648
692
  _.filterIp(requestData, 'anonymize');
649
693
  expect(requestData['user_ip']).to.not.eql(ip);
650
694
  expect(requestData['user_ip']).to.be.ok();
651
695
  });
652
- it('capture false', function() {
696
+ it('capture false', function () {
653
697
  var ip = '123.32.394.99';
654
- var requestData = {'user_ip': ip};
698
+ var requestData = { user_ip: ip };
655
699
  _.filterIp(requestData, false);
656
700
  expect(requestData['user_ip']).to.not.eql(ip);
657
701
  expect(requestData['user_ip']).to.not.be.ok();
658
702
  });
659
- it('ipv6 capture false', function() {
703
+ it('ipv6 capture false', function () {
660
704
  var ip = '2607:f0d0:1002:51::4';
661
- var requestData = {'user_ip': ip};
705
+ var requestData = { user_ip: ip };
662
706
  _.filterIp(requestData, false);
663
707
  expect(requestData['user_ip']).to.not.eql(ip);
664
708
  expect(requestData['user_ip']).to.not.be.ok();
665
709
  });
666
- it('ipv6 anonymize', function() {
710
+ it('ipv6 anonymize', function () {
667
711
  var ips = [
668
- 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329',
669
- 'FE80::0202:B3FF:FE1E:8329',
670
- '2607:f0d0:1002:51::4',
712
+ 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329',
713
+ 'FE80::0202:B3FF:FE1E:8329',
714
+ '2607:f0d0:1002:51::4',
671
715
  ];
672
716
  for (var i = 0; i < ips.length; i++) {
673
717
  var ip = ips[i];
674
- var requestData = {'user_ip': ip};
718
+ var requestData = { user_ip: ip };
675
719
  _.filterIp(requestData, 'anonymize');
676
720
  expect(requestData['user_ip']).to.not.eql(ip);
677
721
  expect(requestData['user_ip']).to.be.ok();
@@ -679,42 +723,42 @@ describe('filterIp', function() {
679
723
  });
680
724
  });
681
725
 
682
- describe('set', function() {
683
- it('should handle a top level key', function() {
684
- var o = {a: 42};
726
+ describe('set', function () {
727
+ it('should handle a top level key', function () {
728
+ var o = { a: 42 };
685
729
  _.set(o, 'b', 1);
686
730
  expect(o.b).to.eql(1);
687
731
  expect(o.a).to.eql(42);
688
732
  });
689
- it('should handle a top level key', function() {
690
- var o = {a: 42, b: {c: 44, d: {e: 99}}};
733
+ it('should handle a top level key', function () {
734
+ var o = { a: 42, b: { c: 44, d: { e: 99 } } };
691
735
  _.set(o, 'f', 1);
692
736
  expect(o.f).to.eql(1);
693
737
  expect(o.a).to.eql(42);
694
738
  expect(o.b.c).to.eql(44);
695
739
  expect(o.b.d.e).to.eql(99);
696
740
  });
697
- it('should replace a value that is already there', function() {
698
- var o = {a: 42};
741
+ it('should replace a value that is already there', function () {
742
+ var o = { a: 42 };
699
743
  _.set(o, 'a', 1);
700
744
  expect(o.a).to.eql(1);
701
745
  });
702
- it('should set a nested value with missing keys', function() {
703
- var o = {baz: 21};
746
+ it('should set a nested value with missing keys', function () {
747
+ var o = { baz: 21 };
704
748
  _.set(o, 'foo.bar', [42]);
705
749
  expect(o.baz).to.eql(21);
706
750
  expect(o.foo.bar).to.eql([42]);
707
751
  });
708
- it('should replace a nested value', function() {
709
- var o = {woo: 99, foo: {bar: {baz: 42, buzz: 97}, a: 98}};
752
+ it('should replace a nested value', function () {
753
+ var o = { woo: 99, foo: { bar: { baz: 42, buzz: 97 }, a: 98 } };
710
754
  _.set(o, 'foo.bar.baz', 1);
711
755
  expect(o.woo).to.eql(99);
712
756
  expect(o.foo.a).to.eql(98);
713
757
  expect(o.foo.bar.buzz).to.eql(97);
714
758
  expect(o.foo.bar.baz).to.eql(1);
715
759
  });
716
- it('should set a nested value with some missing keys', function() {
717
- var o = {woo: 99, foo: {bar: {buzz: 97}, a: 98}};
760
+ it('should set a nested value with some missing keys', function () {
761
+ var o = { woo: 99, foo: { bar: { buzz: 97 }, a: 98 } };
718
762
  _.set(o, 'foo.bar.baz.fizz', 1);
719
763
  expect(o.woo).to.eql(99);
720
764
  expect(o.foo.a).to.eql(98);
@@ -724,12 +768,12 @@ describe('set', function() {
724
768
  });
725
769
 
726
770
  var scrub = require('../src/scrub');
727
- describe('scrub', function() {
728
- it('should not redact fields that are okay', function() {
771
+ describe('scrub', function () {
772
+ it('should not redact fields that are okay', function () {
729
773
  var data = {
730
774
  a: 'somestring',
731
775
  password: 'abc123',
732
- tempWorker: 'cool'
776
+ tempWorker: 'cool',
733
777
  };
734
778
  var scrubFields = ['password', 'b', 'pw'];
735
779
 
@@ -738,10 +782,10 @@ describe('scrub', function() {
738
782
  expect(result.a).to.eql('somestring');
739
783
  expect(result.tempWorker).to.eql('cool');
740
784
  });
741
- it('should redact fields that are in the field list', function() {
785
+ it('should redact fields that are in the field list', function () {
742
786
  var data = {
743
787
  a: 'somestring',
744
- password: 'abc123'
788
+ password: 'abc123',
745
789
  };
746
790
  var scrubFields = ['password', 'b'];
747
791
 
@@ -749,17 +793,17 @@ describe('scrub', function() {
749
793
 
750
794
  expect(result.password).to.eql(_.redact());
751
795
  });
752
- it('should handle nested objects', function() {
796
+ it('should handle nested objects', function () {
753
797
  var data = {
754
798
  a: {
755
799
  b: {
756
800
  badthing: 'secret',
757
- other: 'stuff'
801
+ other: 'stuff',
758
802
  },
759
803
  c: 'bork',
760
- password: 'abc123'
804
+ password: 'abc123',
761
805
  },
762
- secret: 'blahblah'
806
+ secret: 'blahblah',
763
807
  };
764
808
  var scrubFields = ['badthing', 'password', 'secret'];
765
809
 
@@ -772,14 +816,14 @@ describe('scrub', function() {
772
816
  expect(result.secret).to.eql(_.redact());
773
817
  expect(data.secret).to.eql('blahblah');
774
818
  });
775
- it('should do something sane for recursive objects', function() {
819
+ it('should do something sane for recursive objects', function () {
776
820
  var inner = {
777
821
  a: 'what',
778
- b: 'yes'
822
+ b: 'yes',
779
823
  };
780
824
  var data = {
781
825
  thing: 'stuff',
782
- password: 'abc123'
826
+ password: 'abc123',
783
827
  };
784
828
  data.inner = inner;
785
829
  inner.outer = data;
@@ -793,15 +837,15 @@ describe('scrub', function() {
793
837
  expect(result.inner.a).to.be.ok();
794
838
  expect(result.inner.b).to.eql('yes');
795
839
  });
796
- it('should scrub objects seen twice', function() {
840
+ it('should scrub objects seen twice', function () {
797
841
  var request = {
798
- password: 'foo'
799
- }
842
+ password: 'foo',
843
+ };
800
844
 
801
845
  var data = {
802
846
  request,
803
- response: { request }
804
- }
847
+ response: { request },
848
+ };
805
849
 
806
850
  var scrubFields = ['password'];
807
851
 
@@ -810,23 +854,23 @@ describe('scrub', function() {
810
854
  expect(result.request.password).to.eql(_.redact());
811
855
  expect(result.response.request.password).to.eql(_.redact());
812
856
  });
813
- it('should handle scrubPaths', function() {
857
+ it('should handle scrubPaths', function () {
814
858
  var data = {
815
859
  a: {
816
860
  b: {
817
861
  foo: 'secret',
818
- bar: 'stuff'
862
+ bar: 'stuff',
819
863
  },
820
864
  c: 'bork',
821
- password: 'abc123'
865
+ password: 'abc123',
822
866
  },
823
- secret: 'blahblah'
867
+ secret: 'blahblah',
824
868
  };
825
869
  var scrubPaths = [
826
870
  'nowhere', // path not found
827
871
  'a.b.foo', // nested path
828
872
  'a.password', // nested path
829
- 'secret' // root path
873
+ 'secret', // root path
830
874
  ];
831
875
 
832
876
  var result = scrub(data, [], scrubPaths);
@@ -839,32 +883,32 @@ describe('scrub', function() {
839
883
  });
840
884
  });
841
885
 
842
- describe('formatArgsAsString', function() {
843
- it('should handle null', function() {
886
+ describe('formatArgsAsString', function () {
887
+ it('should handle null', function () {
844
888
  var args = [null, 1];
845
889
  var result = _.formatArgsAsString(args);
846
890
 
847
891
  expect(result).to.eql('null 1');
848
892
  });
849
- it('should handle undefined', function() {
893
+ it('should handle undefined', function () {
850
894
  var args = [null, 1, undefined];
851
895
  var result = _.formatArgsAsString(args);
852
896
 
853
897
  expect(result).to.eql('null 1 undefined');
854
898
  });
855
- it('should handle objects', function() {
856
- var args = [1, {a: 42}];
899
+ it('should handle objects', function () {
900
+ var args = [1, { a: 42 }];
857
901
  var result = _.formatArgsAsString(args);
858
902
 
859
903
  expect(result).to.eql('1 {"a":42}');
860
904
  });
861
- it('should handle strings', function() {
905
+ it('should handle strings', function () {
862
906
  var args = [1, 'foo'];
863
907
  var result = _.formatArgsAsString(args);
864
908
 
865
909
  expect(result).to.eql('1 foo');
866
910
  });
867
- it('should handle empty args', function() {
911
+ it('should handle empty args', function () {
868
912
  var args = [];
869
913
  var result = _.formatArgsAsString(args);
870
914