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
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  var assert = require('assert');
4
4
  var util = require('util');
@@ -16,7 +16,7 @@ function CustomError(message, nested) {
16
16
  util.inherits(CustomError, rollbar.Error);
17
17
 
18
18
  async function wait(ms) {
19
- return new Promise(resolve => {
19
+ return new Promise((resolve) => {
20
20
  setTimeout(resolve, ms);
21
21
  });
22
22
  }
@@ -30,47 +30,45 @@ async function throwInScriptFile(rollbar, filepath, callback) {
30
30
  callback(rollbar);
31
31
  }
32
32
 
33
- var nodeVersion = function () {
33
+ var nodeVersion = (function () {
34
34
  var version = process.versions.node.split('.');
35
35
 
36
- return [
37
- parseInt(version[0]),
38
- parseInt(version[1]),
39
- parseInt(version[2]),
40
- ];
41
- }();
36
+ return [parseInt(version[0]), parseInt(version[1]), parseInt(version[2])];
37
+ })();
42
38
 
43
- var isMinNodeVersion = function(major, minor) {
39
+ var isMinNodeVersion = function (major, minor) {
44
40
  return (
45
- nodeVersion[0] > major || (nodeVersion[0] === major && nodeVersion[1] >= minor)
41
+ nodeVersion[0] > major ||
42
+ (nodeVersion[0] === major && nodeVersion[1] >= minor)
46
43
  );
47
- }
44
+ };
48
45
 
49
- vows.describe('transforms')
46
+ vows
47
+ .describe('transforms')
50
48
  .addBatch({
51
- 'baseData': {
52
- 'options': {
53
- 'defaults': {
54
- topic: function() {
49
+ baseData: {
50
+ options: {
51
+ defaults: {
52
+ topic: function () {
55
53
  return rollbar.defaultOptions;
56
54
  },
57
- 'item': {
58
- 'empty': {
59
- topic: function(options) {
55
+ item: {
56
+ empty: {
57
+ topic: function (options) {
60
58
  var item = {};
61
59
  t.baseData(item, options, this.callback);
62
60
  },
63
- 'should have a timestamp': function(err, item) {
61
+ 'should have a timestamp': function (err, item) {
64
62
  assert.ifError(err);
65
63
  assert.notEqual(item.data, undefined);
66
64
  assert.notEqual(item.data.timestamp, undefined);
67
65
  },
68
- 'should have an error level': function(err, item) {
66
+ 'should have an error level': function (err, item) {
69
67
  assert.ifError(err);
70
68
  assert.notEqual(item.data, undefined);
71
69
  assert.equal(item.data.level, 'error');
72
70
  },
73
- 'should have some defaults': function(err, item) {
71
+ 'should have some defaults': function (err, item) {
74
72
  assert.ifError(err);
75
73
  var data = item.data;
76
74
  assert.equal(data.environment, process.env.NODE_ENV);
@@ -79,10 +77,10 @@ vows.describe('transforms')
79
77
  assert.ok(data.server);
80
78
  assert.ok(data.server.host);
81
79
  assert.ok(data.server.pid);
82
- }
80
+ },
83
81
  },
84
82
  'with values': {
85
- topic: function(options) {
83
+ topic: function (options) {
86
84
  var item = {
87
85
  level: 'critical',
88
86
  framework: 'star-wars',
@@ -91,58 +89,64 @@ vows.describe('transforms')
91
89
  custom: {
92
90
  one: 'a1',
93
91
  stuff: 'b2',
94
- language: 'english'
95
- }
92
+ language: 'english',
93
+ },
96
94
  };
97
95
  t.baseData(item, options, this.callback);
98
96
  },
99
- 'should have a critical level': function(err, item) {
97
+ 'should have a critical level': function (err, item) {
100
98
  assert.ifError(err);
101
99
  assert.equal(item.data.level, 'critical');
102
100
  },
103
- 'should have the defaults overriden by the item': function(err, item) {
101
+ 'should have the defaults overriden by the item': function (
102
+ err,
103
+ item,
104
+ ) {
104
105
  assert.ifError(err);
105
106
  assert.equal(item.data.environment, 'production');
106
107
  assert.equal(item.data.framework, 'star-wars');
107
108
  assert.equal(item.data.language, 'javascript');
108
109
  assert.equal(item.data.uuid, '12345');
109
110
  },
110
- 'should have data from custom': function(err, item) {
111
+ 'should have data from custom': function (err, item) {
111
112
  assert.equal(item.data.one, 'a1');
112
113
  assert.equal(item.data.stuff, 'b2');
113
114
  assert.notEqual(item.data.language, 'english');
114
- }
115
- }
116
- }
115
+ },
116
+ },
117
+ },
117
118
  },
118
119
  'with values': {
119
- topic: function() {
120
+ topic: function () {
120
121
  return _.merge(rollbar.defaultOptions, {
121
122
  payload: {
122
123
  environment: 'payload-prod',
123
124
  },
124
125
  framework: 'opt-node',
125
126
  host: 'opt-host',
126
- branch: 'opt-master'
127
+ branch: 'opt-master',
127
128
  });
128
129
  },
129
- 'item': {
130
- 'empty': {
131
- topic: function(options) {
130
+ item: {
131
+ empty: {
132
+ topic: function (options) {
132
133
  var item = {};
133
134
  t.baseData(item, options, this.callback);
134
135
  },
135
- 'should have a timestamp': function(err, item) {
136
+ 'should have a timestamp': function (err, item) {
136
137
  assert.ifError(err);
137
138
  assert.notEqual(item.data, undefined);
138
139
  assert.notEqual(item.data.timestamp, undefined);
139
140
  },
140
- 'should have an error level': function(err, item) {
141
+ 'should have an error level': function (err, item) {
141
142
  assert.ifError(err);
142
143
  assert.notEqual(item.data, undefined);
143
144
  assert.equal(item.data.level, 'error');
144
145
  },
145
- 'should have data from options and defaults': function(err, item) {
146
+ 'should have data from options and defaults': function (
147
+ err,
148
+ item,
149
+ ) {
146
150
  assert.ifError(err);
147
151
  var data = item.data;
148
152
  assert.equal(data.environment, 'payload-prod');
@@ -152,10 +156,10 @@ vows.describe('transforms')
152
156
  assert.equal(data.server.host, 'opt-host');
153
157
  assert.equal(data.server.branch, 'opt-master');
154
158
  assert.ok(data.server.pid);
155
- }
159
+ },
156
160
  },
157
161
  'with values': {
158
- topic: function(options) {
162
+ topic: function (options) {
159
163
  var item = {
160
164
  level: 'critical',
161
165
  environment: 'production',
@@ -164,147 +168,161 @@ vows.describe('transforms')
164
168
  custom: {
165
169
  one: 'a1',
166
170
  stuff: 'b2',
167
- language: 'english'
168
- }
171
+ language: 'english',
172
+ },
169
173
  };
170
174
  t.baseData(item, options, this.callback);
171
175
  },
172
- 'should have a critical level': function(err, item) {
176
+ 'should have a critical level': function (err, item) {
173
177
  assert.ifError(err);
174
178
  assert.equal(item.data.level, 'critical');
175
179
  },
176
- 'should have the defaults overriden by the item': function(err, item) {
180
+ 'should have the defaults overriden by the item': function (
181
+ err,
182
+ item,
183
+ ) {
177
184
  assert.ifError(err);
178
185
  assert.equal(item.data.environment, 'production');
179
186
  assert.equal(item.data.framework, 'star-wars');
180
187
  assert.equal(item.data.language, 'javascript');
181
188
  assert.equal(item.data.uuid, '12345');
182
189
  },
183
- 'should have data from custom': function(err, item) {
190
+ 'should have data from custom': function (err, item) {
184
191
  assert.equal(item.data.one, 'a1');
185
192
  assert.equal(item.data.stuff, 'b2');
186
193
  assert.notEqual(item.data.language, 'english');
187
- }
188
- }
189
- }
190
- }
191
- }
192
- }
194
+ },
195
+ },
196
+ },
197
+ },
198
+ },
199
+ },
193
200
  })
194
201
  .addBatch({
195
- 'addBody': {
196
- 'options': {
197
- 'anything': {
198
- topic: function() {
199
- return {whatever: 'stuff'};
202
+ addBody: {
203
+ options: {
204
+ anything: {
205
+ topic: function () {
206
+ return { whatever: 'stuff' };
200
207
  },
201
- 'item': {
208
+ item: {
202
209
  'with stackInfo': {
203
- topic: function(options) {
204
- var item = {stackInfo: [{message: 'hey'}]};
210
+ topic: function (options) {
211
+ var item = { stackInfo: [{ message: 'hey' }] };
205
212
  t.addBody(item, options, this.callback);
206
213
  },
207
- 'should not error': function(err, item) {
214
+ 'should not error': function (err, item) {
208
215
  assert.ifError(err);
209
216
  },
210
- 'should set the trace_chain': function(err, item) {
217
+ 'should set the trace_chain': function (err, item) {
211
218
  assert.ok(item.data.body.trace_chain);
212
219
  },
213
- 'should not set a message': function(err, item) {
220
+ 'should not set a message': function (err, item) {
214
221
  assert.ok(!item.data.body.message);
215
- }
222
+ },
216
223
  },
217
224
  'with no stackInfo': {
218
- topic: function(options) {
219
- var item = {message: 'hello'};
225
+ topic: function (options) {
226
+ var item = { message: 'hello' };
220
227
  t.addBody(item, options, this.callback);
221
228
  },
222
- 'should not error': function(err, item) {
229
+ 'should not error': function (err, item) {
223
230
  assert.ifError(err);
224
231
  },
225
- 'should not set the trace_chain': function(err, item) {
232
+ 'should not set the trace_chain': function (err, item) {
226
233
  assert.ok(!item.data.body.trace_chain);
227
234
  },
228
- 'should set a message': function(err, item) {
235
+ 'should set a message': function (err, item) {
229
236
  assert.ok(item.data.body.message);
230
- }
231
- }
232
- }
233
- }
234
- }
235
- }
237
+ },
238
+ },
239
+ },
240
+ },
241
+ },
242
+ },
236
243
  })
237
244
  .addBatch({
238
- 'addMessageData': {
239
- 'options': {
240
- 'anything': {
241
- topic: function() {
242
- return {random: 'stuff'};
245
+ addMessageData: {
246
+ options: {
247
+ anything: {
248
+ topic: function () {
249
+ return { random: 'stuff' };
243
250
  },
244
- 'item': {
251
+ item: {
245
252
  'no message': {
246
- topic: function(options) {
247
- var item = {err: 'stuff', not: 'a message'};
253
+ topic: function (options) {
254
+ var item = { err: 'stuff', not: 'a message' };
248
255
  t.addMessageData(item, options, this.callback);
249
256
  },
250
- 'should not error': function(err, item) {
257
+ 'should not error': function (err, item) {
251
258
  assert.ifError(err);
252
259
  },
253
- 'should add an empty body': function(err, item) {
260
+ 'should add an empty body': function (err, item) {
254
261
  assert.ok(item.data.body);
255
- }
262
+ },
256
263
  },
257
264
  'with a message': {
258
- topic: function(options) {
259
- var item = {message: 'this is awesome'};
265
+ topic: function (options) {
266
+ var item = { message: 'this is awesome' };
260
267
  t.addMessageData(item, options, this.callback);
261
268
  },
262
- 'should not error': function(err, item) {
269
+ 'should not error': function (err, item) {
263
270
  assert.ifError(err);
264
271
  },
265
- 'should add a body with the message': function(err, item) {
272
+ 'should add a body with the message': function (err, item) {
266
273
  assert.equal(item.data.body.message.body, 'this is awesome');
267
- }
268
- }
269
- }
270
- }
271
- }
272
- }
274
+ },
275
+ },
276
+ },
277
+ },
278
+ },
279
+ },
273
280
  })
274
281
  .addBatch({
275
- 'nodeSourceMaps': {
282
+ nodeSourceMaps: {
276
283
  'with original source present': {
277
- topic: function() {
284
+ topic: function () {
278
285
  var Rollbar = new rollbar({
279
286
  accessToken: 'abc123',
280
287
  captureUncaught: true,
281
- nodeSourceMaps: true
288
+ nodeSourceMaps: true,
282
289
  });
283
290
  var queue = Rollbar.client.notifier.queue;
284
291
  Rollbar.addItemStub = sinon.stub(queue, 'addItem');
285
292
 
286
- throwInScriptFile(Rollbar, '../examples/node-typescript/dist/index',
287
- this.callback);
293
+ throwInScriptFile(
294
+ Rollbar,
295
+ '../examples/node-typescript/dist/index',
296
+ this.callback,
297
+ );
288
298
  },
289
- 'should map the stack with context': function(r) {
299
+ 'should map the stack with context': function (r) {
290
300
  var addItem = r.addItemStub;
291
301
 
292
302
  assert.isTrue(addItem.called);
293
303
  if (addItem.called) {
294
- var frame = addItem.getCall(0).args[0].body.trace_chain[0].frames.pop();
304
+ var frame = addItem
305
+ .getCall(0)
306
+ .args[0].body.trace_chain[0].frames.pop();
295
307
  assert.ok(frame.filename.includes('src/index.ts'));
296
308
  assert.equal(frame.lineno, 10);
297
309
  assert.equal(frame.colno, 22);
298
- assert.equal(frame.code, " var error = <Error> new CustomError('foo');");
310
+ assert.equal(
311
+ frame.code,
312
+ " var error = <Error> new CustomError('foo');",
313
+ );
299
314
  assert.equal(frame.context.pre[0], ' }');
300
315
  assert.equal(frame.context.pre[1], ' }');
301
- assert.equal(frame.context.pre[2],
302
- ' // TypeScript code snippet will include `<Error>`');
316
+ assert.equal(
317
+ frame.context.pre[2],
318
+ ' // TypeScript code snippet will include `<Error>`',
319
+ );
303
320
  assert.equal(frame.context.post[0], ' throw error;');
304
321
  assert.equal(frame.context.post[1], '}');
305
322
 
306
- var sourceMappingURLs = addItem.getCall(0).args[0].notifier.diagnostic
307
- .node_source_maps.source_mapping_urls;
323
+ var sourceMappingURLs =
324
+ addItem.getCall(0).args[0].notifier.diagnostic.node_source_maps
325
+ .source_mapping_urls;
308
326
  var urls = Object.keys(sourceMappingURLs);
309
327
  assert.ok(urls[0].includes('index.js'));
310
328
  assert.ok(sourceMappingURLs[urls[0]].includes('index.js.map'));
@@ -319,97 +337,109 @@ vows.describe('transforms')
319
337
  assert.ok(sourceMappingURLs[urls[2]].includes('not found'));
320
338
  }
321
339
  addItem.reset();
322
- }
323
- }
324
- }
340
+ },
341
+ },
342
+ },
325
343
  })
326
344
  .addBatch({
327
- 'nodeSourceMaps': {
345
+ nodeSourceMaps: {
328
346
  'using sourcesContent': {
329
- topic: function() {
347
+ topic: function () {
330
348
  var Rollbar = new rollbar({
331
349
  accessToken: 'abc123',
332
350
  captureUncaught: true,
333
- nodeSourceMaps: true
351
+ nodeSourceMaps: true,
334
352
  });
335
353
  var queue = Rollbar.client.notifier.queue;
336
354
  Rollbar.addItemStub = sinon.stub(queue, 'addItem');
337
355
 
338
- throwInScriptFile(Rollbar, '../examples/node-dist/index', this.callback);
356
+ throwInScriptFile(
357
+ Rollbar,
358
+ '../examples/node-dist/index',
359
+ this.callback,
360
+ );
339
361
  },
340
- 'should map the stack with context': function(r) {
362
+ 'should map the stack with context': function (r) {
341
363
  var addItem = r.addItemStub;
342
364
 
343
365
  assert.isTrue(addItem.called);
344
366
  if (addItem.called) {
345
- var frame = addItem.getCall(0).args[0].body.trace_chain[0].frames.pop();
367
+ var frame = addItem
368
+ .getCall(0)
369
+ .args[0].body.trace_chain[0].frames.pop();
346
370
  assert.ok(frame.filename.includes('src/index.ts'));
347
371
  assert.equal(frame.lineno, 10);
348
372
  assert.equal(frame.colno, 22);
349
- assert.equal(frame.code, " var error = <Error> new CustomError('foo');");
373
+ assert.equal(
374
+ frame.code,
375
+ " var error = <Error> new CustomError('foo');",
376
+ );
350
377
  assert.equal(frame.context.pre[0], ' }');
351
378
  assert.equal(frame.context.pre[1], ' }');
352
- assert.equal(frame.context.pre[2],
353
- ' // TypeScript code snippet will include `<Error>`');
379
+ assert.equal(
380
+ frame.context.pre[2],
381
+ ' // TypeScript code snippet will include `<Error>`',
382
+ );
354
383
  assert.equal(frame.context.post[0], ' throw error;');
355
384
  assert.equal(frame.context.post[1], '}');
356
385
 
357
- var sourceMappingURLs = addItem.getCall(0).args[0].notifier.diagnostic
358
- .node_source_maps.source_mapping_urls;
386
+ var sourceMappingURLs =
387
+ addItem.getCall(0).args[0].notifier.diagnostic.node_source_maps
388
+ .source_mapping_urls;
359
389
  var urls = Object.keys(sourceMappingURLs);
360
390
  assert.ok(urls.length === 1);
361
391
  assert.ok(urls[0].includes('index.js'));
362
392
  assert.ok(sourceMappingURLs[urls[0]].includes('index.js.map'));
363
393
  }
364
394
  addItem.reset();
365
- }
366
- }
367
- }
395
+ },
396
+ },
397
+ },
368
398
  })
369
399
  .addBatch({
370
- 'handleItemWithError': {
371
- 'options': {
372
- 'anything': {
373
- topic: function() {
400
+ handleItemWithError: {
401
+ options: {
402
+ anything: {
403
+ topic: function () {
374
404
  return {
375
405
  some: 'stuff',
376
406
  captureIp: true,
377
407
  };
378
408
  },
379
- 'item': {
409
+ item: {
380
410
  'no error': {
381
- topic: function(options) {
411
+ topic: function (options) {
382
412
  var item = {
383
- data: {body: {yo: 'hey'}},
384
- message: 'hey'
413
+ data: { body: { yo: 'hey' } },
414
+ message: 'hey',
385
415
  };
386
416
  t.handleItemWithError(item, options, this.callback);
387
417
  },
388
- 'should not error': function(err, item) {
418
+ 'should not error': function (err, item) {
389
419
  assert.ifError(err);
390
420
  },
391
- 'should not change the item': function(err, item) {
421
+ 'should not change the item': function (err, item) {
392
422
  assert.equal(item.data.body.yo, 'hey');
393
- }
423
+ },
394
424
  },
395
425
  'with a simple error': {
396
426
  topic: function (options) {
397
427
  var item = {
398
- data: {body: {}},
399
- err: new Error('wookie')
428
+ data: { body: {} },
429
+ err: new Error('wookie'),
400
430
  };
401
431
  t.handleItemWithError(item, options, this.callback);
402
432
  },
403
- 'should not error': function(err, item) {
433
+ 'should not error': function (err, item) {
404
434
  assert.ifError(err);
405
435
  },
406
- 'should add some data to the trace_chain': function(err, item) {
436
+ 'should add some data to the trace_chain': function (err, item) {
407
437
  assert.ok(item.stackInfo);
408
- }
438
+ },
409
439
  },
410
440
  'with a normal error': {
411
441
  topic: function (options) {
412
- var test = function() {
442
+ var test = function () {
413
443
  var x = thisVariableIsNotDefined;
414
444
  };
415
445
  var err;
@@ -419,21 +449,21 @@ vows.describe('transforms')
419
449
  err = e;
420
450
  }
421
451
  var item = {
422
- data: {body: {}},
423
- err: err
452
+ data: { body: {} },
453
+ err: err,
424
454
  };
425
455
  t.handleItemWithError(item, options, this.callback);
426
456
  },
427
- 'should not error': function(err, item) {
457
+ 'should not error': function (err, item) {
428
458
  assert.ifError(err);
429
459
  },
430
- 'should add some data to the trace_chain': function(err, item) {
460
+ 'should add some data to the trace_chain': function (err, item) {
431
461
  assert.ok(item.stackInfo);
432
- }
462
+ },
433
463
  },
434
464
  'with a nested error': {
435
465
  topic: function (options) {
436
- var test = function() {
466
+ var test = function () {
437
467
  var x = thisVariableIsNotDefined;
438
468
  };
439
469
  var err;
@@ -443,21 +473,27 @@ vows.describe('transforms')
443
473
  err = new CustomError('nested-message', e);
444
474
  }
445
475
  var item = {
446
- data: {body: {}},
447
- err: err
476
+ data: { body: {} },
477
+ err: err,
448
478
  };
449
479
  t.handleItemWithError(item, options, this.callback);
450
480
  },
451
- 'should not error': function(err, item) {
481
+ 'should not error': function (err, item) {
452
482
  assert.ifError(err);
453
483
  },
454
- 'should have the right data in the trace_chain': function(err, item) {
484
+ 'should have the right data in the trace_chain': function (
485
+ err,
486
+ item,
487
+ ) {
455
488
  var trace_chain = item.stackInfo;
456
489
  assert.lengthOf(trace_chain, 2);
457
490
  assert.equal(trace_chain[0].exception.class, 'CustomError');
458
- assert.equal(trace_chain[0].exception.message, 'nested-message');
491
+ assert.equal(
492
+ trace_chain[0].exception.message,
493
+ 'nested-message',
494
+ );
459
495
  assert.equal(trace_chain[1].exception.class, 'ReferenceError');
460
- }
496
+ },
461
497
  },
462
498
  'with a null nested error': {
463
499
  topic: function (options) {
@@ -467,23 +503,26 @@ vows.describe('transforms')
467
503
  err.nested = null;
468
504
 
469
505
  var item = {
470
- data: {body: {}},
471
- err: err
506
+ data: { body: {} },
507
+ err: err,
472
508
  };
473
509
  t.handleItemWithError(item, options, this.callback);
474
510
  },
475
- 'should not error': function(err, item) {
511
+ 'should not error': function (err, item) {
476
512
  assert.ifError(err);
477
513
  },
478
- 'should have the right data in the trace_chain': function(err, item) {
514
+ 'should have the right data in the trace_chain': function (
515
+ err,
516
+ item,
517
+ ) {
479
518
  var trace_chain = item.stackInfo;
480
519
  assert.lengthOf(trace_chain, 1);
481
520
  assert.equal(trace_chain[0].exception.class, 'CustomError');
482
- }
521
+ },
483
522
  },
484
523
  'with error context': {
485
524
  topic: function (options) {
486
- var test = function() {
525
+ var test = function () {
487
526
  var x = thisVariableIsNotDefined;
488
527
  };
489
528
  var err;
@@ -495,25 +534,25 @@ vows.describe('transforms')
495
534
  err.rollbarContext = { err2: 'error context' };
496
535
  }
497
536
  var item = {
498
- data: {body: {}},
499
- err: err
537
+ data: { body: {} },
538
+ err: err,
500
539
  };
501
540
  options.addErrorContext = true;
502
541
  t.handleItemWithError(item, options, this.callback);
503
542
  },
504
- 'should not error': function(err, item) {
543
+ 'should not error': function (err, item) {
505
544
  assert.ifError(err);
506
545
  },
507
- 'should add the error context': function(err, item) {
546
+ 'should add the error context': function (err, item) {
508
547
  var trace_chain = item.stackInfo;
509
548
  assert.lengthOf(trace_chain, 2);
510
549
  assert.equal(item.data.custom.err1, 'nested context');
511
550
  assert.equal(item.data.custom.err2, 'error context');
512
- }
551
+ },
513
552
  },
514
553
  'with an error cause': {
515
554
  topic: function (options) {
516
- var test = function() {
555
+ var test = function () {
517
556
  var x = thisVariableIsNotDefined;
518
557
  };
519
558
  var err;
@@ -525,15 +564,18 @@ vows.describe('transforms')
525
564
  err.rollbarContext = { err2: 'error context' };
526
565
  }
527
566
  var item = {
528
- data: {body: {}},
529
- err: err
567
+ data: { body: {} },
568
+ err: err,
530
569
  };
531
570
  t.handleItemWithError(item, options, this.callback);
532
571
  },
533
- 'should not error': function(err, item) {
572
+ 'should not error': function (err, item) {
534
573
  assert.ifError(err);
535
574
  },
536
- 'should have the right data in the trace_chain': function(err, item) {
575
+ 'should have the right data in the trace_chain': function (
576
+ err,
577
+ item,
578
+ ) {
537
579
  // Error cause was introduced in Node 16.9.
538
580
  if (!isMinNodeVersion(16, 9)) return;
539
581
 
@@ -544,64 +586,64 @@ vows.describe('transforms')
544
586
  assert.equal(trace_chain[1].exception.class, 'ReferenceError');
545
587
  assert.equal(item.data.custom.err1, 'cause context');
546
588
  assert.equal(item.data.custom.err2, 'error context');
547
- }
589
+ },
548
590
  },
549
- }
550
- }
551
- }
552
- }
591
+ },
592
+ },
593
+ },
594
+ },
553
595
  })
554
596
  .addBatch({
555
- 'addRequestData': {
556
- 'options': {
597
+ addRequestData: {
598
+ options: {
557
599
  'without custom addRequestData method': {
558
600
  'without scrub fields': {
559
- topic: function() {
601
+ topic: function () {
560
602
  return {
561
603
  nothing: 'here',
562
604
  captureEmail: true,
563
605
  captureUsername: true,
564
- captureIp: true
606
+ captureIp: true,
565
607
  };
566
608
  },
567
- 'item': {
609
+ item: {
568
610
  'without a request': {
569
- topic: function(options) {
611
+ topic: function (options) {
570
612
  var item = {
571
- data: {body: {message: 'hey'}}
613
+ data: { body: { message: 'hey' } },
572
614
  };
573
615
  t.addRequestData(item, options, this.callback);
574
616
  },
575
- 'should not error': function(err, item) {
617
+ 'should not error': function (err, item) {
576
618
  assert.ifError(err);
577
619
  },
578
- 'should not change the item': function(err, item) {
620
+ 'should not change the item': function (err, item) {
579
621
  assert.equal(item.request, undefined);
580
622
  assert.equal(item.data.request, undefined);
581
- }
623
+ },
582
624
  },
583
625
  'with an empty request object': {
584
- topic: function(options) {
626
+ topic: function (options) {
585
627
  var item = {
586
628
  request: {},
587
- data: {body: {message: 'hey'}}
629
+ data: { body: { message: 'hey' } },
588
630
  };
589
631
  t.addRequestData(item, options, this.callback);
590
632
  },
591
- 'should not error': function(err, item) {
633
+ 'should not error': function (err, item) {
592
634
  assert.ifError(err);
593
635
  },
594
- 'should not change request object': function(err, item) {
636
+ 'should not change request object': function (err, item) {
595
637
  assert.equal(item.request.headers, undefined);
596
- }
638
+ },
597
639
  },
598
640
  'with a request': {
599
- topic: function(options) {
641
+ topic: function (options) {
600
642
  var item = {
601
643
  request: {
602
644
  headers: {
603
645
  host: 'example.com',
604
- 'x-auth-token': '12345'
646
+ 'x-auth-token': '12345',
605
647
  },
606
648
  protocol: 'https',
607
649
  url: '/some/endpoint',
@@ -609,30 +651,39 @@ vows.describe('transforms')
609
651
  method: 'GET',
610
652
  body: {
611
653
  token: 'abc123',
612
- something: 'else'
654
+ something: 'else',
613
655
  },
614
656
  route: { path: '/api/:bork' },
615
657
  user: {
616
658
  id: 42,
617
- email: 'fake@example.com'
618
- }
659
+ email: 'fake@example.com',
660
+ },
619
661
  },
620
662
  stuff: 'hey',
621
- data: {other: 'thing'}
663
+ data: { other: 'thing' },
622
664
  };
623
665
  t.addRequestData(item, options, this.callback);
624
666
  },
625
- 'should not error': function(err, item) {
667
+ 'should not error': function (err, item) {
626
668
  assert.ifError(err);
627
669
  },
628
- 'should have a request object inside data': function(err, item) {
670
+ 'should have a request object inside data': function (
671
+ err,
672
+ item,
673
+ ) {
629
674
  assert.ok(item.data.request);
630
675
  },
631
- 'should set a person based on request user': function(err, item) {
676
+ 'should set a person based on request user': function (
677
+ err,
678
+ item,
679
+ ) {
632
680
  assert.equal(item.data.person.id, 42);
633
681
  assert.equal(item.data.person.email, 'fake@example.com');
634
682
  },
635
- 'should set some fields based on request data': function(err, item) {
683
+ 'should set some fields based on request data': function (
684
+ err,
685
+ item,
686
+ ) {
636
687
  var r = item.data.request;
637
688
  assert.equal(r.url, 'https://example.com/some/endpoint');
638
689
  assert.equal(r.user_ip, '192.192.192.1');
@@ -642,12 +693,12 @@ vows.describe('transforms')
642
693
  },
643
694
  },
644
695
  'with a request for a nested router with a baseURL': {
645
- topic: function(options) {
696
+ topic: function (options) {
646
697
  var item = {
647
698
  request: {
648
699
  headers: {
649
700
  host: 'example.com',
650
- 'x-auth-token': '12345'
701
+ 'x-auth-token': '12345',
651
702
  },
652
703
  protocol: 'https',
653
704
  url: '/some/endpoint',
@@ -656,38 +707,47 @@ vows.describe('transforms')
656
707
  method: 'GET',
657
708
  body: {
658
709
  token: 'abc123',
659
- something: 'else'
710
+ something: 'else',
660
711
  },
661
712
  route: { path: '/api/:bork' },
662
713
  user: {
663
714
  id: 42,
664
- email: 'fake@example.com'
665
- }
715
+ email: 'fake@example.com',
716
+ },
666
717
  },
667
718
  stuff: 'hey',
668
- data: {other: 'thing'}
719
+ data: { other: 'thing' },
669
720
  };
670
721
  t.addRequestData(item, options, this.callback);
671
722
  },
672
- 'should not error': function(err, item) {
723
+ 'should not error': function (err, item) {
673
724
  assert.ifError(err);
674
725
  },
675
- 'should have a request object inside data': function(err, item) {
726
+ 'should have a request object inside data': function (
727
+ err,
728
+ item,
729
+ ) {
676
730
  assert.ok(item.data.request);
677
731
  },
678
- 'should set some fields based on request data': function(err, item) {
732
+ 'should set some fields based on request data': function (
733
+ err,
734
+ item,
735
+ ) {
679
736
  var r = item.data.request;
680
- assert.equal(r.url, 'https://example.com/nested/some/endpoint');
737
+ assert.equal(
738
+ r.url,
739
+ 'https://example.com/nested/some/endpoint',
740
+ );
681
741
  assert.equal(item.data.context, '/nested/api/:bork');
682
742
  },
683
743
  },
684
744
  'with a request like from hapi': {
685
- topic: function(options) {
745
+ topic: function (options) {
686
746
  var item = {
687
747
  request: {
688
748
  headers: {
689
749
  host: 'example.com',
690
- 'x-auth-token': '12345'
750
+ 'x-auth-token': '12345',
691
751
  },
692
752
  protocol: 'https',
693
753
  url: {
@@ -702,36 +762,45 @@ vows.describe('transforms')
702
762
  query: {},
703
763
  pathname: '/some/endpoint',
704
764
  path: '/some/endpoint',
705
- href: '/some/endpoint'
765
+ href: '/some/endpoint',
706
766
  },
707
767
  ip: '192.192.192.1',
708
768
  method: 'POST',
709
769
  payload: {
710
770
  token: 'abc123',
711
- something: 'else'
771
+ something: 'else',
712
772
  },
713
773
  route: { path: '/api/:bork' },
714
774
  user: {
715
775
  id: 42,
716
- email: 'fake@example.com'
717
- }
776
+ email: 'fake@example.com',
777
+ },
718
778
  },
719
779
  stuff: 'hey',
720
- data: {other: 'thing'}
780
+ data: { other: 'thing' },
721
781
  };
722
782
  t.addRequestData(item, options, this.callback);
723
783
  },
724
- 'should not error': function(err, item) {
784
+ 'should not error': function (err, item) {
725
785
  assert.ifError(err);
726
786
  },
727
- 'should have a request object inside data': function(err, item) {
787
+ 'should have a request object inside data': function (
788
+ err,
789
+ item,
790
+ ) {
728
791
  assert.ok(item.data.request);
729
792
  },
730
- 'should set a person based on request user': function(err, item) {
793
+ 'should set a person based on request user': function (
794
+ err,
795
+ item,
796
+ ) {
731
797
  assert.equal(item.data.person.id, 42);
732
798
  assert.equal(item.data.person.email, 'fake@example.com');
733
799
  },
734
- 'should set some fields based on request data': function(err, item) {
800
+ 'should set some fields based on request data': function (
801
+ err,
802
+ item,
803
+ ) {
735
804
  var r = item.data.request;
736
805
  assert.equal(r.url, 'https://example.com/some/endpoint');
737
806
  assert.equal(r.user_ip, '192.192.192.1');
@@ -742,42 +811,54 @@ vows.describe('transforms')
742
811
  },
743
812
  },
744
813
  'with a request with an array body': {
745
- topic: function(options) {
814
+ topic: function (options) {
746
815
  var item = {
747
816
  request: {
748
817
  headers: {
749
818
  host: 'example.com',
750
- 'x-auth-token': '12345'
819
+ 'x-auth-token': '12345',
751
820
  },
752
821
  protocol: 'https',
753
822
  url: '/some/endpoint',
754
823
  ip: '192.192.192.1',
755
824
  method: 'POST',
756
- body: [{
757
- token: 'abc123',
758
- something: 'else'
759
- }, 'otherStuff'],
825
+ body: [
826
+ {
827
+ token: 'abc123',
828
+ something: 'else',
829
+ },
830
+ 'otherStuff',
831
+ ],
760
832
  user: {
761
833
  id: 42,
762
- email: 'fake@example.com'
763
- }
834
+ email: 'fake@example.com',
835
+ },
764
836
  },
765
837
  stuff: 'hey',
766
- data: {other: 'thing'}
838
+ data: { other: 'thing' },
767
839
  };
768
840
  t.addRequestData(item, options, this.callback);
769
841
  },
770
- 'should not error': function(err, item) {
842
+ 'should not error': function (err, item) {
771
843
  assert.ifError(err);
772
844
  },
773
- 'should have a request object inside data': function(err, item) {
845
+ 'should have a request object inside data': function (
846
+ err,
847
+ item,
848
+ ) {
774
849
  assert.ok(item.data.request);
775
850
  },
776
- 'should set a person based on request user': function(err, item) {
851
+ 'should set a person based on request user': function (
852
+ err,
853
+ item,
854
+ ) {
777
855
  assert.equal(item.data.person.id, 42);
778
856
  assert.equal(item.data.person.email, 'fake@example.com');
779
857
  },
780
- 'should set some fields based on request data': function(err, item) {
858
+ 'should set some fields based on request data': function (
859
+ err,
860
+ item,
861
+ ) {
781
862
  var r = item.data.request;
782
863
  assert.equal(r.url, 'https://example.com/some/endpoint');
783
864
  assert.equal(r.user_ip, '192.192.192.1');
@@ -785,30 +866,24 @@ vows.describe('transforms')
785
866
  assert.equal(r.POST['0'].something, 'else');
786
867
  assert.equal(r.POST['1'], 'otherStuff');
787
868
  },
788
- }
789
- }
869
+ },
870
+ },
790
871
  },
791
872
  'with scrub fields': {
792
- topic: function() {
873
+ topic: function () {
793
874
  return {
794
- scrubHeaders: [
795
- 'x-auth-token'
796
- ],
797
- scrubFields: [
798
- 'passwd',
799
- 'access_token',
800
- 'request.cookie'
801
- ]
875
+ scrubHeaders: ['x-auth-token'],
876
+ scrubFields: ['passwd', 'access_token', 'request.cookie'],
802
877
  };
803
878
  },
804
- 'item': {
879
+ item: {
805
880
  'with a request': {
806
- topic: function(options) {
881
+ topic: function (options) {
807
882
  var item = {
808
883
  request: {
809
884
  headers: {
810
885
  host: 'example.com',
811
- 'x-auth-token': '12345'
886
+ 'x-auth-token': '12345',
812
887
  },
813
888
  protocol: 'https',
814
889
  url: '/some/endpoint',
@@ -816,35 +891,38 @@ vows.describe('transforms')
816
891
  method: 'GET',
817
892
  body: {
818
893
  token: 'abc123',
819
- something: 'else'
894
+ something: 'else',
820
895
  },
821
896
  user: {
822
897
  id: 42,
823
- email: 'fake@example.com'
824
- }
898
+ email: 'fake@example.com',
899
+ },
825
900
  },
826
901
  stuff: 'hey',
827
- data: {other: 'thing'}
902
+ data: { other: 'thing' },
828
903
  };
829
904
  t.addRequestData(item, options, this.callback);
830
905
  },
831
- 'should not error': function(err, item) {
906
+ 'should not error': function (err, item) {
832
907
  assert.ifError(err);
833
908
  },
834
- 'should have a request object inside data': function(err, item) {
909
+ 'should have a request object inside data': function (
910
+ err,
911
+ item,
912
+ ) {
835
913
  assert.ok(item.data.request);
836
914
  },
837
- }
838
- }
839
- }
915
+ },
916
+ },
917
+ },
840
918
  },
841
919
  'with custom addRequestData': {
842
920
  'with scrub fields': {
843
- topic: function() {
844
- var customFn = function(i, r) {
921
+ topic: function () {
922
+ var customFn = function (i, r) {
845
923
  assert.equal(i.stuff, undefined);
846
924
  assert.equal(i.other, 'thing');
847
- i.myRequest = {body: r.body.token};
925
+ i.myRequest = { body: r.body.token };
848
926
  };
849
927
  return {
850
928
  captureIp: true,
@@ -853,18 +931,18 @@ vows.describe('transforms')
853
931
  'passwd',
854
932
  'access_token',
855
933
  'token',
856
- 'request.cookie'
857
- ]
934
+ 'request.cookie',
935
+ ],
858
936
  };
859
937
  },
860
- 'item': {
938
+ item: {
861
939
  'with a request': {
862
- topic: function(options) {
940
+ topic: function (options) {
863
941
  var item = {
864
942
  request: {
865
943
  headers: {
866
944
  host: 'example.com',
867
- 'x-auth-token': '12345'
945
+ 'x-auth-token': '12345',
868
946
  },
869
947
  protocol: 'https',
870
948
  url: '/some/endpoint',
@@ -872,88 +950,86 @@ vows.describe('transforms')
872
950
  method: 'GET',
873
951
  body: {
874
952
  token: 'abc123',
875
- something: 'else'
953
+ something: 'else',
876
954
  },
877
955
  user: {
878
956
  id: 42,
879
- email: 'fake@example.com'
880
- }
957
+ email: 'fake@example.com',
958
+ },
881
959
  },
882
960
  stuff: 'hey',
883
- data: {other: 'thing'}
961
+ data: { other: 'thing' },
884
962
  };
885
963
  t.addRequestData(item, options, this.callback);
886
964
  },
887
- 'should not error': function(err, item) {
965
+ 'should not error': function (err, item) {
888
966
  assert.ifError(err);
889
967
  },
890
- 'should do what the function does': function(err, item) {
968
+ 'should do what the function does': function (err, item) {
891
969
  assert.equal(item.data.request, undefined);
892
970
  assert.equal(item.data.myRequest.body, 'abc123');
893
- }
894
- }
895
- }
896
- }
897
- }
898
- }
899
- }
971
+ },
972
+ },
973
+ },
974
+ },
975
+ },
976
+ },
977
+ },
900
978
  })
901
979
  .addBatch({
902
- 'scrubPayload': {
903
- 'options': {
980
+ scrubPayload: {
981
+ options: {
904
982
  'without scrub fields': {
905
- topic: function() {
983
+ topic: function () {
906
984
  return rollbar.defaultOptions;
907
985
  },
908
- 'item': {
909
- topic: function(options) {
986
+ item: {
987
+ topic: function (options) {
910
988
  var item = {
911
989
  data: {
912
990
  body: {
913
991
  message: 'hey',
914
992
  password: '123',
915
- secret: {stuff: 'here'}
916
- }
917
- }
993
+ secret: { stuff: 'here' },
994
+ },
995
+ },
918
996
  };
919
997
  t.scrubPayload(item, options, this.callback);
920
998
  },
921
- 'should not error': function(err, item) {
999
+ 'should not error': function (err, item) {
922
1000
  assert.ifError(err);
923
1001
  },
924
- 'should not scrub okay keys': function(err, item) {
1002
+ 'should not scrub okay keys': function (err, item) {
925
1003
  assert.equal(item.data.body.message, 'hey');
926
1004
  },
927
- 'should scrub key/value based on defaults': function(err, item) {
1005
+ 'should scrub key/value based on defaults': function (err, item) {
928
1006
  assert.matches(item.data.body.password, /\*+/);
929
1007
  assert.matches(item.data.body.secret, /\*+/);
930
- }
931
- }
1008
+ },
1009
+ },
932
1010
  },
933
1011
  'with scrub fields': {
934
- topic: function() {
1012
+ topic: function () {
935
1013
  return {
936
1014
  captureIp: true,
937
- scrubHeaders: [
938
- 'x-auth-token'
939
- ],
1015
+ scrubHeaders: ['x-auth-token'],
940
1016
  scrubFields: [
941
1017
  'passwd',
942
1018
  'access_token',
943
1019
  'request.cookie',
944
- 'sauce'
1020
+ 'sauce',
945
1021
  ],
946
- scrubRequestBody: true
1022
+ scrubRequestBody: true,
947
1023
  };
948
1024
  },
949
- 'item': {
1025
+ item: {
950
1026
  'with a request': {
951
- topic: function(options) {
1027
+ topic: function (options) {
952
1028
  var item = {
953
1029
  request: {
954
1030
  headers: {
955
1031
  host: 'example.com',
956
- 'x-auth-token': '12345'
1032
+ 'x-auth-token': '12345',
957
1033
  },
958
1034
  protocol: 'https',
959
1035
  url: '/some/endpoint',
@@ -961,35 +1037,39 @@ vows.describe('transforms')
961
1037
  method: 'GET',
962
1038
  body: {
963
1039
  token: 'abc123',
964
- something: 'else'
1040
+ something: 'else',
965
1041
  },
966
1042
  user: {
967
1043
  id: 42,
968
- email: 'fake@example.com'
969
- }
1044
+ email: 'fake@example.com',
1045
+ },
970
1046
  },
971
1047
  stuff: 'hey',
972
1048
  data: {
973
1049
  other: 'thing',
974
1050
  sauce: 'secrets',
975
- someParams: 'foo=okay&passwd=iamhere'
976
- }
1051
+ someParams: 'foo=okay&passwd=iamhere',
1052
+ },
977
1053
  };
978
- t.addRequestData(item, options, function(e, i) {
979
- if (e) {
980
- this.callback(e);
981
- return;
982
- }
983
- t.scrubPayload(i, options, this.callback)
984
- }.bind(this));
985
- },
986
- 'should not error': function(err, item) {
1054
+ t.addRequestData(
1055
+ item,
1056
+ options,
1057
+ function (e, i) {
1058
+ if (e) {
1059
+ this.callback(e);
1060
+ return;
1061
+ }
1062
+ t.scrubPayload(i, options, this.callback);
1063
+ }.bind(this),
1064
+ );
1065
+ },
1066
+ 'should not error': function (err, item) {
987
1067
  assert.ifError(err);
988
1068
  },
989
- 'should have a request object inside data': function(err, item) {
1069
+ 'should have a request object inside data': function (err, item) {
990
1070
  assert.ok(item.data.request);
991
1071
  },
992
- 'should scrub based on the options': function(err, item) {
1072
+ 'should scrub based on the options': function (err, item) {
993
1073
  var r = item.data.request;
994
1074
  assert.equal(r.GET.token, 'abc123');
995
1075
  assert.match(r.headers['x-auth-token'], /\*+/);
@@ -997,21 +1077,21 @@ vows.describe('transforms')
997
1077
  assert.match(item.data.sauce, /\*+/);
998
1078
  assert.equal(item.data.other, 'thing');
999
1079
  assert.match(item.data.someParams, /foo=okay&passwd=\*+/);
1000
- }
1080
+ },
1001
1081
  },
1002
1082
  'with a json request body': {
1003
- topic: function(options) {
1083
+ topic: function (options) {
1004
1084
  var requestBody = JSON.stringify({
1005
1085
  token: 'abc123',
1006
1086
  something: 'else',
1007
- passwd: '123456'
1087
+ passwd: '123456',
1008
1088
  });
1009
1089
  var item = {
1010
1090
  request: {
1011
1091
  headers: {
1012
1092
  host: 'example.com',
1013
1093
  'content-type': 'application/json',
1014
- 'x-auth-token': '12345'
1094
+ 'x-auth-token': '12345',
1015
1095
  },
1016
1096
  protocol: 'https',
1017
1097
  url: '/some/endpoint',
@@ -1020,31 +1100,35 @@ vows.describe('transforms')
1020
1100
  body: requestBody,
1021
1101
  user: {
1022
1102
  id: 42,
1023
- email: 'fake@example.com'
1024
- }
1103
+ email: 'fake@example.com',
1104
+ },
1025
1105
  },
1026
1106
  stuff: 'hey',
1027
1107
  data: {
1028
1108
  other: 'thing',
1029
1109
  sauce: 'secrets',
1030
- someParams: 'foo=okay&passwd=iamhere'
1031
- }
1110
+ someParams: 'foo=okay&passwd=iamhere',
1111
+ },
1032
1112
  };
1033
- t.addRequestData(item, options, function(e, i) {
1034
- if (e) {
1035
- this.callback(e);
1036
- return;
1037
- }
1038
- t.scrubPayload(i, options, this.callback)
1039
- }.bind(this));
1040
- },
1041
- 'should not error': function(err, item) {
1113
+ t.addRequestData(
1114
+ item,
1115
+ options,
1116
+ function (e, i) {
1117
+ if (e) {
1118
+ this.callback(e);
1119
+ return;
1120
+ }
1121
+ t.scrubPayload(i, options, this.callback);
1122
+ }.bind(this),
1123
+ );
1124
+ },
1125
+ 'should not error': function (err, item) {
1042
1126
  assert.ifError(err);
1043
1127
  },
1044
- 'should have a request object inside data': function(err, item) {
1128
+ 'should have a request object inside data': function (err, item) {
1045
1129
  assert.ok(item.data.request);
1046
1130
  },
1047
- 'should scrub based on the options': function(err, item) {
1131
+ 'should scrub based on the options': function (err, item) {
1048
1132
  var r = item.data.request;
1049
1133
  assert.match(r.headers['x-auth-token'], /\*+/);
1050
1134
  assert.equal(r.headers['host'], 'example.com');
@@ -1054,46 +1138,56 @@ vows.describe('transforms')
1054
1138
 
1055
1139
  var requestBody = JSON.parse(item.data.request.body);
1056
1140
  assert.match(requestBody.passwd, /\*+/);
1057
- }
1141
+ },
1058
1142
  },
1059
1143
  'with a bad json request body': {
1060
- topic: function(options) {
1144
+ topic: function (options) {
1061
1145
  var requestBody = 'not valid json';
1062
1146
  var item = {
1063
1147
  request: {
1064
1148
  headers: {
1065
- 'content-type': 'application/json'
1149
+ 'content-type': 'application/json',
1066
1150
  },
1067
1151
  protocol: 'https',
1068
1152
  url: '/some/endpoint',
1069
1153
  ip: '192.192.192.192',
1070
1154
  method: 'GET',
1071
- body: requestBody
1072
- }
1155
+ body: requestBody,
1156
+ },
1073
1157
  };
1074
- t.addRequestData(item, options, function(e, i) {
1075
- if (e) {
1076
- this.callback(e);
1077
- return;
1078
- }
1079
- t.scrubPayload(i, options, this.callback)
1080
- }.bind(this));
1081
- },
1082
- 'should not error': function(err, item) {
1158
+ t.addRequestData(
1159
+ item,
1160
+ options,
1161
+ function (e, i) {
1162
+ if (e) {
1163
+ this.callback(e);
1164
+ return;
1165
+ }
1166
+ t.scrubPayload(i, options, this.callback);
1167
+ }.bind(this),
1168
+ );
1169
+ },
1170
+ 'should not error': function (err, item) {
1083
1171
  assert.ifError(err);
1084
1172
  },
1085
- 'should have a request object inside data': function(err, item) {
1173
+ 'should have a request object inside data': function (err, item) {
1086
1174
  assert.ok(item.data.request);
1087
1175
  },
1088
- 'should delete the body and add a diagnostic error': function(err, item) {
1176
+ 'should delete the body and add a diagnostic error': function (
1177
+ err,
1178
+ item,
1179
+ ) {
1089
1180
  var requestBody = JSON.parse(item.data.request.body);
1090
1181
  assert.equal(requestBody, null);
1091
- assert.match(item.data.request.error, /request.body parse failed/);
1092
- }
1093
- }
1094
- }
1095
- }
1096
- }
1097
- }
1182
+ assert.match(
1183
+ item.data.request.error,
1184
+ /request.body parse failed/,
1185
+ );
1186
+ },
1187
+ },
1188
+ },
1189
+ },
1190
+ },
1191
+ },
1098
1192
  })
1099
- .export(module, {error: false});
1193
+ .export(module, { error: false });