rollbar 2.26.3 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/guidelines.mdc +154 -0
- package/.github/workflows/ci.yml +32 -12
- package/.lgtm.yml +7 -7
- package/.prettierignore +18 -0
- package/.vscode/settings.json +39 -0
- package/CHANGELOG.md +121 -35
- package/CLAUDE.md +201 -0
- package/Gruntfile.js +101 -48
- package/Makefile +3 -3
- package/README.md +2 -4
- package/SECURITY.md +5 -0
- package/babel.config.json +9 -0
- package/bower.json +1 -3
- package/codex.md +148 -0
- package/defaults.js +17 -5
- package/dist/plugins/jquery.min.js +1 -1
- package/dist/rollbar.js +18748 -5375
- package/dist/rollbar.js.map +1 -1
- package/dist/rollbar.min.js +2 -1
- package/dist/rollbar.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.min.js.map +1 -1
- package/dist/rollbar.named-amd.js +19368 -6000
- package/dist/rollbar.named-amd.js.map +1 -1
- package/dist/rollbar.named-amd.min.js +3 -1
- package/dist/rollbar.named-amd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.named-amd.min.js.map +1 -1
- package/dist/rollbar.noconflict.umd.js +18749 -5380
- package/dist/rollbar.noconflict.umd.js.map +1 -1
- package/dist/rollbar.noconflict.umd.min.js +3 -1
- package/dist/rollbar.noconflict.umd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.noconflict.umd.min.js.map +1 -1
- package/dist/rollbar.snippet.js +1 -1
- package/dist/rollbar.umd.js +19367 -6000
- package/dist/rollbar.umd.js.map +1 -1
- package/dist/rollbar.umd.min.js +3 -1
- package/dist/rollbar.umd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.umd.min.js.map +1 -1
- package/docs/extension-exceptions.md +35 -30
- package/docs/migration_v0_to_v1.md +41 -38
- package/eslint.config.mjs +33 -0
- package/get_versions.js +33 -0
- package/index.d.ts +270 -231
- package/karma.conf.js +18 -27
- package/package.json +21 -21
- package/prettier.config.js +7 -0
- package/src/api.js +78 -14
- package/src/apiUtility.js +14 -11
- package/src/browser/core.js +138 -72
- package/src/browser/defaults/scrubFields.js +3 -3
- package/src/browser/detection.js +7 -8
- package/src/browser/domUtility.js +18 -8
- package/src/browser/globalSetup.js +12 -6
- package/src/browser/logger.js +1 -1
- package/src/browser/plugins/jquery.js +35 -35
- package/src/browser/predicates.js +1 -1
- package/src/browser/replay/defaults.js +71 -0
- package/src/browser/replay/recorder.js +193 -0
- package/src/browser/replay/replayMap.js +195 -0
- package/src/browser/rollbar.js +12 -8
- package/src/browser/rollbarWrapper.js +8 -5
- package/src/browser/shim.js +43 -19
- package/src/browser/snippet_callback.js +6 -4
- package/src/browser/telemetry.js +573 -361
- package/src/browser/transforms.js +46 -27
- package/src/browser/transport/fetch.js +26 -14
- package/src/browser/transport/xhr.js +41 -14
- package/src/browser/transport.js +93 -33
- package/src/browser/url.js +16 -8
- package/src/browser/wrapGlobals.js +27 -8
- package/src/defaults.js +3 -3
- package/src/errorParser.js +14 -11
- package/src/merge.js +32 -23
- package/src/notifier.js +16 -13
- package/src/predicates.js +43 -23
- package/src/queue.js +133 -40
- package/src/rateLimiter.js +59 -18
- package/src/react-native/logger.js +1 -1
- package/src/react-native/rollbar.js +59 -55
- package/src/react-native/transforms.js +13 -9
- package/src/react-native/transport.js +44 -34
- package/src/rollbar.js +72 -21
- package/src/scrub.js +0 -1
- package/src/server/locals.js +69 -39
- package/src/server/logger.js +4 -4
- package/src/server/parser.js +72 -47
- package/src/server/rollbar.js +135 -56
- package/src/server/sourceMap/stackTrace.js +33 -18
- package/src/server/telemetry/urlHelpers.js +9 -11
- package/src/server/telemetry.js +68 -45
- package/src/server/transforms.js +37 -21
- package/src/server/transport.js +62 -32
- package/src/telemetry.js +162 -33
- package/src/tracing/context.js +24 -0
- package/src/tracing/contextManager.js +37 -0
- package/src/tracing/defaults.js +7 -0
- package/src/tracing/exporter.js +188 -0
- package/src/tracing/hrtime.js +98 -0
- package/src/tracing/id.js +24 -0
- package/src/tracing/session.js +55 -0
- package/src/tracing/span.js +92 -0
- package/src/tracing/spanProcessor.js +15 -0
- package/src/tracing/tracer.js +46 -0
- package/src/tracing/tracing.js +89 -0
- package/src/transforms.js +33 -21
- package/src/truncation.js +8 -5
- package/src/utility/headers.js +43 -43
- package/src/utility/replace.js +9 -0
- package/src/utility/traverse.js +1 -1
- package/src/utility.js +123 -52
- package/test/api.test.js +88 -41
- package/test/apiUtility.test.js +48 -50
- package/test/browser.core.test.js +142 -141
- package/test/browser.domUtility.test.js +53 -36
- package/test/browser.predicates.test.js +14 -14
- package/test/browser.replay.recorder.test.js +416 -0
- package/test/browser.rollbar.test.js +655 -515
- package/test/browser.telemetry.test.js +46 -39
- package/test/browser.transforms.test.js +164 -139
- package/test/browser.transport.test.js +59 -50
- package/test/browser.url.test.js +13 -12
- package/test/fixtures/locals.fixtures.js +245 -126
- package/test/fixtures/replay/index.js +20 -0
- package/test/fixtures/replay/payloads.fixtures.js +229 -0
- package/test/fixtures/replay/rrwebEvents.fixtures.js +251 -0
- package/test/fixtures/replay/rrwebSyntheticEvents.fixtures.js +328 -0
- package/test/notifier.test.js +91 -79
- package/test/predicates.test.js +261 -215
- package/test/queue.test.js +231 -215
- package/test/rateLimiter.test.js +51 -43
- package/test/react-native.rollbar.test.js +150 -116
- package/test/react-native.transforms.test.js +23 -25
- package/test/react-native.transport.test.js +26 -14
- package/test/replay/index.js +2 -0
- package/test/replay/integration/api.spans.test.js +136 -0
- package/test/replay/integration/e2e.test.js +228 -0
- package/test/replay/integration/index.js +9 -0
- package/test/replay/integration/queue.replayMap.test.js +332 -0
- package/test/replay/integration/replayMap.test.js +163 -0
- package/test/replay/integration/sessionRecording.test.js +390 -0
- package/test/replay/unit/api.postSpans.test.js +150 -0
- package/test/replay/unit/index.js +7 -0
- package/test/replay/unit/queue.replayMap.test.js +225 -0
- package/test/replay/unit/replayMap.test.js +348 -0
- package/test/replay/util/index.js +5 -0
- package/test/replay/util/mockRecordFn.js +80 -0
- package/test/server.lambda.mocha.test.mjs +172 -0
- package/test/server.locals.constructor.mocha.test.mjs +80 -0
- package/test/server.locals.error-handling.mocha.test.mjs +387 -0
- package/test/server.locals.merge.mocha.test.mjs +267 -0
- package/test/server.locals.test-utils.mjs +114 -0
- package/test/server.parser.mocha.test.mjs +87 -0
- package/test/server.predicates.mocha.test.mjs +63 -0
- package/test/server.rollbar.constructor.mocha.test.mjs +199 -0
- package/test/server.rollbar.handlers.mocha.test.mjs +253 -0
- package/test/server.rollbar.logging.mocha.test.mjs +326 -0
- package/test/server.rollbar.misc.mocha.test.mjs +44 -0
- package/test/server.rollbar.test-utils.mjs +57 -0
- package/test/server.telemetry.mocha.test.mjs +377 -0
- package/test/server.transforms.data.mocha.test.mjs +163 -0
- package/test/server.transforms.error.mocha.test.mjs +199 -0
- package/test/server.transforms.request.mocha.test.mjs +208 -0
- package/test/server.transforms.scrub.mocha.test.mjs +140 -0
- package/test/server.transforms.sourcemaps.mocha.test.mjs +122 -0
- package/test/server.transforms.test-utils.mjs +62 -0
- package/test/server.transport.mocha.test.mjs +269 -0
- package/test/telemetry.test.js +178 -38
- package/test/tracing/contextManager.test.js +28 -0
- package/test/tracing/exporter.toPayload.test.js +400 -0
- package/test/tracing/id.test.js +24 -0
- package/test/tracing/span.test.js +183 -0
- package/test/tracing/spanProcessor.test.js +73 -0
- package/test/tracing/tracing.test.js +105 -0
- package/test/transforms.test.js +70 -68
- package/test/truncation.test.js +57 -55
- package/test/utility.test.js +310 -228
- package/webpack.config.js +36 -70
- package/.eslintignore +0 -7
- package/.gitmodules +0 -3
- package/test/server.lambda.test.js +0 -177
- package/test/server.locals.test.js +0 -841
- package/test/server.parser.test.js +0 -72
- package/test/server.predicates.test.js +0 -89
- package/test/server.rollbar.test.js +0 -676
- package/test/server.telemetry.test.js +0 -318
- package/test/server.transforms.test.js +0 -1099
- package/test/server.transport.test.js +0 -201
package/src/server/rollbar.js
CHANGED
|
@@ -39,9 +39,14 @@ function Rollbar(options, client) {
|
|
|
39
39
|
this.lambdaTimeoutHandle = null;
|
|
40
40
|
var transport = new Transport();
|
|
41
41
|
var api = new API(this.options, transport, urllib, truncation, jsonBackup);
|
|
42
|
-
var telemeter = new Telemeter(this.options)
|
|
43
|
-
this.client =
|
|
44
|
-
|
|
42
|
+
var telemeter = new Telemeter(this.options);
|
|
43
|
+
this.client =
|
|
44
|
+
client || new Client(this.options, api, logger, telemeter, null, null, 'server');
|
|
45
|
+
this.instrumenter = new Instrumenter(
|
|
46
|
+
this.options,
|
|
47
|
+
this.client.telemeter,
|
|
48
|
+
this,
|
|
49
|
+
);
|
|
45
50
|
this.instrumenter.instrument();
|
|
46
51
|
if (this.options.locals) {
|
|
47
52
|
this.locals = initLocals(this.options.locals, logger);
|
|
@@ -55,7 +60,9 @@ function Rollbar(options, client) {
|
|
|
55
60
|
function initLocals(localsOptions, logger) {
|
|
56
61
|
// Capturing stack local variables is only supported in Node 10 and higher.
|
|
57
62
|
var nodeMajorVersion = process.versions.node.split('.')[0];
|
|
58
|
-
if (nodeMajorVersion < 10) {
|
|
63
|
+
if (nodeMajorVersion < 10) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
59
66
|
|
|
60
67
|
var Locals;
|
|
61
68
|
if (typeof localsOptions === 'function') {
|
|
@@ -65,7 +72,9 @@ function initLocals(localsOptions, logger) {
|
|
|
65
72
|
Locals = localsOptions.module;
|
|
66
73
|
delete localsOptions.module;
|
|
67
74
|
} else {
|
|
68
|
-
logger.error(
|
|
75
|
+
logger.error(
|
|
76
|
+
'options.locals or options.locals.module must be a Locals module',
|
|
77
|
+
);
|
|
69
78
|
return null;
|
|
70
79
|
}
|
|
71
80
|
return new Locals(localsOptions, logger);
|
|
@@ -110,7 +119,11 @@ Rollbar.prototype.configure = function (options, payloadData) {
|
|
|
110
119
|
payload = { payload: payloadData };
|
|
111
120
|
}
|
|
112
121
|
this.options = _.handleOptions(oldOptions, options, payload, logger);
|
|
113
|
-
this.options._configuredOptions = _.handleOptions(
|
|
122
|
+
this.options._configuredOptions = _.handleOptions(
|
|
123
|
+
oldOptions._configuredOptions,
|
|
124
|
+
options,
|
|
125
|
+
payload,
|
|
126
|
+
);
|
|
114
127
|
// On the server we want to ignore any maxItems setting
|
|
115
128
|
delete this.options.maxItems;
|
|
116
129
|
logger.setVerbose(this.options.verbose);
|
|
@@ -121,7 +134,7 @@ Rollbar.prototype.configure = function (options, payloadData) {
|
|
|
121
134
|
if (this.locals) {
|
|
122
135
|
this.locals.updateOptions(this.options.locals);
|
|
123
136
|
} else {
|
|
124
|
-
this.locals = initLocals(this.options.locals, logger)
|
|
137
|
+
this.locals = initLocals(this.options.locals, logger);
|
|
125
138
|
}
|
|
126
139
|
}
|
|
127
140
|
return this;
|
|
@@ -205,7 +218,6 @@ Rollbar.warn = function () {
|
|
|
205
218
|
}
|
|
206
219
|
};
|
|
207
220
|
|
|
208
|
-
|
|
209
221
|
Rollbar.prototype.warning = function () {
|
|
210
222
|
var item = this._createItem(arguments);
|
|
211
223
|
var uuid = item.uuid;
|
|
@@ -221,7 +233,6 @@ Rollbar.warning = function () {
|
|
|
221
233
|
}
|
|
222
234
|
};
|
|
223
235
|
|
|
224
|
-
|
|
225
236
|
Rollbar.prototype.error = function () {
|
|
226
237
|
var item = this._createItem(arguments);
|
|
227
238
|
var uuid = item.uuid;
|
|
@@ -239,8 +250,9 @@ Rollbar.error = function () {
|
|
|
239
250
|
Rollbar.prototype._uncaughtError = function () {
|
|
240
251
|
var item = this._createItem(arguments);
|
|
241
252
|
item._isUncaught = true;
|
|
253
|
+
item.level = this.options.uncaughtErrorLevel;
|
|
242
254
|
var uuid = item.uuid;
|
|
243
|
-
this.client.
|
|
255
|
+
this.client.log(item);
|
|
244
256
|
return { uuid: uuid };
|
|
245
257
|
};
|
|
246
258
|
|
|
@@ -286,7 +298,7 @@ Rollbar.prototype.wait = function (callback) {
|
|
|
286
298
|
};
|
|
287
299
|
Rollbar.wait = function (callback) {
|
|
288
300
|
if (_instance) {
|
|
289
|
-
return _instance.wait(callback)
|
|
301
|
+
return _instance.wait(callback);
|
|
290
302
|
} else {
|
|
291
303
|
var maybeCallback = _getFirstFunction(arguments);
|
|
292
304
|
handleUninitialized(maybeCallback);
|
|
@@ -313,7 +325,7 @@ Rollbar.prototype.errorHandler = function () {
|
|
|
313
325
|
};
|
|
314
326
|
Rollbar.errorHandler = function () {
|
|
315
327
|
if (_instance) {
|
|
316
|
-
return _instance.errorHandler()
|
|
328
|
+
return _instance.errorHandler();
|
|
317
329
|
} else {
|
|
318
330
|
handleUninitialized();
|
|
319
331
|
}
|
|
@@ -341,8 +353,15 @@ Rollbar.prototype.asyncLambdaHandler = function (handler, timeoutHandler) {
|
|
|
341
353
|
return new Promise(function (resolve, reject) {
|
|
342
354
|
self.lambdaContext = context;
|
|
343
355
|
if (shouldReportTimeouts) {
|
|
344
|
-
var timeoutCb = (timeoutHandler || _timeoutHandler).bind(
|
|
345
|
-
|
|
356
|
+
var timeoutCb = (timeoutHandler || _timeoutHandler).bind(
|
|
357
|
+
null,
|
|
358
|
+
event,
|
|
359
|
+
context,
|
|
360
|
+
);
|
|
361
|
+
self.lambdaTimeoutHandle = setTimeout(
|
|
362
|
+
timeoutCb,
|
|
363
|
+
context.getRemainingTimeInMillis() - 1000,
|
|
364
|
+
);
|
|
346
365
|
}
|
|
347
366
|
handler(event, context)
|
|
348
367
|
.then(function (resp) {
|
|
@@ -375,8 +394,16 @@ Rollbar.prototype.syncLambdaHandler = function (handler, timeoutHandler) {
|
|
|
375
394
|
return function (event, context, callback) {
|
|
376
395
|
self.lambdaContext = context;
|
|
377
396
|
if (shouldReportTimeouts) {
|
|
378
|
-
var timeoutCb = (timeoutHandler || _timeoutHandler).bind(
|
|
379
|
-
|
|
397
|
+
var timeoutCb = (timeoutHandler || _timeoutHandler).bind(
|
|
398
|
+
null,
|
|
399
|
+
event,
|
|
400
|
+
context,
|
|
401
|
+
callback,
|
|
402
|
+
);
|
|
403
|
+
self.lambdaTimeoutHandle = setTimeout(
|
|
404
|
+
timeoutCb,
|
|
405
|
+
context.getRemainingTimeInMillis() - 1000,
|
|
406
|
+
);
|
|
380
407
|
}
|
|
381
408
|
try {
|
|
382
409
|
handler(event, context, function (err, resp) {
|
|
@@ -456,19 +483,33 @@ Rollbar.reportMessage = function (message, level, request, callback) {
|
|
|
456
483
|
}
|
|
457
484
|
};
|
|
458
485
|
|
|
459
|
-
Rollbar.prototype.reportMessageWithPayloadData = function (
|
|
486
|
+
Rollbar.prototype.reportMessageWithPayloadData = function (
|
|
487
|
+
message,
|
|
488
|
+
payloadData,
|
|
489
|
+
request,
|
|
490
|
+
callback,
|
|
491
|
+
) {
|
|
460
492
|
logger.log('reportMessageWithPayloadData is deprecated');
|
|
461
493
|
return this.error(message, request, payloadData, callback);
|
|
462
494
|
};
|
|
463
|
-
Rollbar.reportMessageWithPayloadData = function (
|
|
495
|
+
Rollbar.reportMessageWithPayloadData = function (
|
|
496
|
+
message,
|
|
497
|
+
payloadData,
|
|
498
|
+
request,
|
|
499
|
+
callback,
|
|
500
|
+
) {
|
|
464
501
|
if (_instance) {
|
|
465
|
-
return _instance.reportMessageWithPayloadData(
|
|
502
|
+
return _instance.reportMessageWithPayloadData(
|
|
503
|
+
message,
|
|
504
|
+
payloadData,
|
|
505
|
+
request,
|
|
506
|
+
callback,
|
|
507
|
+
);
|
|
466
508
|
} else {
|
|
467
509
|
handleUninitialized(callback);
|
|
468
510
|
}
|
|
469
511
|
};
|
|
470
512
|
|
|
471
|
-
|
|
472
513
|
Rollbar.prototype.handleError = function (err, request, callback) {
|
|
473
514
|
logger.log('handleError is deprecated');
|
|
474
515
|
return this.error(err, request, callback);
|
|
@@ -481,14 +522,28 @@ Rollbar.handleError = function (err, request, callback) {
|
|
|
481
522
|
}
|
|
482
523
|
};
|
|
483
524
|
|
|
484
|
-
|
|
485
|
-
|
|
525
|
+
Rollbar.prototype.handleErrorWithPayloadData = function (
|
|
526
|
+
err,
|
|
527
|
+
payloadData,
|
|
528
|
+
request,
|
|
529
|
+
callback,
|
|
530
|
+
) {
|
|
486
531
|
logger.log('handleErrorWithPayloadData is deprecated');
|
|
487
532
|
return this.error(err, request, payloadData, callback);
|
|
488
533
|
};
|
|
489
|
-
Rollbar.handleErrorWithPayloadData = function (
|
|
534
|
+
Rollbar.handleErrorWithPayloadData = function (
|
|
535
|
+
err,
|
|
536
|
+
payloadData,
|
|
537
|
+
request,
|
|
538
|
+
callback,
|
|
539
|
+
) {
|
|
490
540
|
if (_instance) {
|
|
491
|
-
return _instance.handleErrorWithPayloadData(
|
|
541
|
+
return _instance.handleErrorWithPayloadData(
|
|
542
|
+
err,
|
|
543
|
+
payloadData,
|
|
544
|
+
request,
|
|
545
|
+
callback,
|
|
546
|
+
);
|
|
492
547
|
} else {
|
|
493
548
|
handleUninitialized(callback);
|
|
494
549
|
}
|
|
@@ -514,7 +569,10 @@ Rollbar.handleUnhandledRejections = function (accessToken, options) {
|
|
|
514
569
|
}
|
|
515
570
|
};
|
|
516
571
|
|
|
517
|
-
Rollbar.handleUncaughtExceptionsAndRejections = function (
|
|
572
|
+
Rollbar.handleUncaughtExceptionsAndRejections = function (
|
|
573
|
+
accessToken,
|
|
574
|
+
options,
|
|
575
|
+
) {
|
|
518
576
|
if (_instance) {
|
|
519
577
|
options = options || {};
|
|
520
578
|
options.accessToken = accessToken;
|
|
@@ -577,7 +635,10 @@ Rollbar.prototype.setupUnhandledCapture = function () {
|
|
|
577
635
|
if (this.options.captureUncaught || this.options.handleUncaughtExceptions) {
|
|
578
636
|
this.handleUncaughtExceptions();
|
|
579
637
|
}
|
|
580
|
-
if (
|
|
638
|
+
if (
|
|
639
|
+
this.options.captureUnhandledRejections ||
|
|
640
|
+
this.options.handleUnhandledRejections
|
|
641
|
+
) {
|
|
581
642
|
this.handleUnhandledRejections();
|
|
582
643
|
}
|
|
583
644
|
};
|
|
@@ -586,40 +647,58 @@ Rollbar.prototype.handleUncaughtExceptions = function () {
|
|
|
586
647
|
var exitOnUncaught = !!this.options.exitOnUncaughtException;
|
|
587
648
|
delete this.options.exitOnUncaughtException;
|
|
588
649
|
|
|
589
|
-
addOrReplaceRollbarHandler(
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
650
|
+
addOrReplaceRollbarHandler(
|
|
651
|
+
'uncaughtException',
|
|
652
|
+
function (err) {
|
|
653
|
+
if (
|
|
654
|
+
!this.options.captureUncaught &&
|
|
655
|
+
!this.options.handleUncaughtExceptions
|
|
656
|
+
) {
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
593
659
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
660
|
+
this._uncaughtError(err, function (err) {
|
|
661
|
+
if (err) {
|
|
662
|
+
logger.error(
|
|
663
|
+
'Encountered error while handling an uncaught exception.',
|
|
664
|
+
);
|
|
665
|
+
logger.error(err);
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
if (exitOnUncaught) {
|
|
669
|
+
setImmediate(
|
|
670
|
+
function () {
|
|
671
|
+
this.wait(function () {
|
|
672
|
+
process.exit(1);
|
|
673
|
+
});
|
|
674
|
+
}.bind(this),
|
|
675
|
+
);
|
|
598
676
|
}
|
|
599
|
-
})
|
|
600
|
-
|
|
601
|
-
setImmediate(function () {
|
|
602
|
-
this.wait(function () {
|
|
603
|
-
process.exit(1);
|
|
604
|
-
});
|
|
605
|
-
}.bind(this));
|
|
606
|
-
}
|
|
607
|
-
}.bind(this));
|
|
677
|
+
}.bind(this),
|
|
678
|
+
);
|
|
608
679
|
};
|
|
609
680
|
|
|
610
681
|
Rollbar.prototype.handleUnhandledRejections = function () {
|
|
611
|
-
addOrReplaceRollbarHandler(
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
logger.error(err);
|
|
682
|
+
addOrReplaceRollbarHandler(
|
|
683
|
+
'unhandledRejection',
|
|
684
|
+
function (reason) {
|
|
685
|
+
if (
|
|
686
|
+
!this.options.captureUnhandledRejections &&
|
|
687
|
+
!this.options.handleUnhandledRejections
|
|
688
|
+
) {
|
|
689
|
+
return;
|
|
620
690
|
}
|
|
621
|
-
|
|
622
|
-
|
|
691
|
+
|
|
692
|
+
this._uncaughtError(reason, function (err) {
|
|
693
|
+
if (err) {
|
|
694
|
+
logger.error(
|
|
695
|
+
'Encountered error while handling an uncaught exception.',
|
|
696
|
+
);
|
|
697
|
+
logger.error(err);
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
}.bind(this),
|
|
701
|
+
);
|
|
623
702
|
};
|
|
624
703
|
|
|
625
704
|
function addOrReplaceRollbarHandler(event, action) {
|
|
@@ -658,7 +737,7 @@ Rollbar.defaultOptions = {
|
|
|
658
737
|
showReportedMessageTraces: false,
|
|
659
738
|
notifier: {
|
|
660
739
|
name: 'node_rollbar',
|
|
661
|
-
version: packageJson.version
|
|
740
|
+
version: packageJson.version,
|
|
662
741
|
},
|
|
663
742
|
scrubHeaders: packageJson.defaults.server.scrubHeaders,
|
|
664
743
|
scrubFields: packageJson.defaults.server.scrubFields,
|
|
@@ -675,7 +754,7 @@ Rollbar.defaultOptions = {
|
|
|
675
754
|
captureLambdaTimeouts: true,
|
|
676
755
|
ignoreDuplicateErrors: true,
|
|
677
756
|
scrubRequestBody: true,
|
|
678
|
-
autoInstrument: false
|
|
757
|
+
autoInstrument: false,
|
|
679
758
|
};
|
|
680
759
|
|
|
681
760
|
module.exports = Rollbar;
|
|
@@ -31,10 +31,10 @@ function retrieveFile(path) {
|
|
|
31
31
|
path = path.trim();
|
|
32
32
|
if (/^file:/.test(path)) {
|
|
33
33
|
// existsSync/readFileSync can't handle file protocol, but once stripped, it works
|
|
34
|
-
path = path.replace(/file:\/\/\/(\w:)?/, function(_protocol, drive) {
|
|
35
|
-
return drive
|
|
36
|
-
''
|
|
37
|
-
'/'; // file:///root-dir/file -> /root-dir/file
|
|
34
|
+
path = path.replace(/file:\/\/\/(\w:)?/, function (_protocol, drive) {
|
|
35
|
+
return drive
|
|
36
|
+
? '' // file:///C:/dir/file -> C:/dir/file
|
|
37
|
+
: '/'; // file:///root-dir/file -> /root-dir/file
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
if (path in fileContentsCache) {
|
|
@@ -50,7 +50,7 @@ function retrieveFile(path) {
|
|
|
50
50
|
/* ignore any errors */
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
return fileContentsCache[path] = contents;
|
|
53
|
+
return (fileContentsCache[path] = contents);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// Support URLs relative to a directory, but be careful about a protocol prefix
|
|
@@ -64,7 +64,10 @@ function supportRelativeURL(file, url) {
|
|
|
64
64
|
if (protocol && /^\/\w\:/.test(startPath)) {
|
|
65
65
|
// handle file:///C:/ paths
|
|
66
66
|
protocol += '/';
|
|
67
|
-
return
|
|
67
|
+
return (
|
|
68
|
+
protocol +
|
|
69
|
+
path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/')
|
|
70
|
+
);
|
|
68
71
|
}
|
|
69
72
|
return protocol + path.resolve(dir.slice(protocol.length), url);
|
|
70
73
|
}
|
|
@@ -74,7 +77,8 @@ function retrieveSourceMapURL(source) {
|
|
|
74
77
|
|
|
75
78
|
// Get the URL of the source map
|
|
76
79
|
fileData = retrieveFile(source);
|
|
77
|
-
var re =
|
|
80
|
+
var re =
|
|
81
|
+
/(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/)[ \t]*$)/gm;
|
|
78
82
|
// Keep executing the search to find the *last* sourceMappingURL to avoid
|
|
79
83
|
// picking up sourceMappingURLs from comments, strings, etc.
|
|
80
84
|
var lastMatch, match;
|
|
@@ -110,7 +114,7 @@ function retrieveSourceMap(source) {
|
|
|
110
114
|
|
|
111
115
|
return {
|
|
112
116
|
url: sourceMappingURL,
|
|
113
|
-
map: sourceMapData
|
|
117
|
+
map: sourceMapData,
|
|
114
118
|
};
|
|
115
119
|
}
|
|
116
120
|
|
|
@@ -122,7 +126,10 @@ function cacheSourceContent(sourceMap, originalSource, newSource) {
|
|
|
122
126
|
// The sourceContentFor lookup needs the original source url as found in the
|
|
123
127
|
// map file. However the client lookup in sourcesContentCache will use
|
|
124
128
|
// a rewritten form of the url, hence originalSource and newSource.
|
|
125
|
-
sourcesContentCache[newSource] = sourceMap.map.sourceContentFor(
|
|
129
|
+
sourcesContentCache[newSource] = sourceMap.map.sourceContentFor(
|
|
130
|
+
originalSource,
|
|
131
|
+
true,
|
|
132
|
+
);
|
|
126
133
|
}
|
|
127
134
|
|
|
128
135
|
exports.mapSourcePosition = function mapSourcePosition(position, diagnostic) {
|
|
@@ -133,14 +140,15 @@ exports.mapSourcePosition = function mapSourcePosition(position, diagnostic) {
|
|
|
133
140
|
if (urlAndMap) {
|
|
134
141
|
sourceMap = sourceMapCache[position.source] = {
|
|
135
142
|
url: urlAndMap.url,
|
|
136
|
-
map: new SourceMapConsumer(urlAndMap.map)
|
|
143
|
+
map: new SourceMapConsumer(urlAndMap.map),
|
|
137
144
|
};
|
|
138
|
-
diagnostic.node_source_maps.source_mapping_urls[position.source] =
|
|
145
|
+
diagnostic.node_source_maps.source_mapping_urls[position.source] =
|
|
146
|
+
urlAndMap.url;
|
|
139
147
|
|
|
140
148
|
// Load all sources stored inline with the source map into the file cache
|
|
141
149
|
// to pretend like they are already loaded. They may not exist on disk.
|
|
142
150
|
if (sourceMap.map.sourcesContent) {
|
|
143
|
-
sourceMap.map.sources.forEach(function(source, i) {
|
|
151
|
+
sourceMap.map.sources.forEach(function (source, i) {
|
|
144
152
|
var contents = sourceMap.map.sourcesContent[i];
|
|
145
153
|
if (contents) {
|
|
146
154
|
var url = supportRelativeURL(sourceMap.url, source);
|
|
@@ -151,14 +159,19 @@ exports.mapSourcePosition = function mapSourcePosition(position, diagnostic) {
|
|
|
151
159
|
} else {
|
|
152
160
|
sourceMap = sourceMapCache[position.source] = {
|
|
153
161
|
url: null,
|
|
154
|
-
map: null
|
|
162
|
+
map: null,
|
|
155
163
|
};
|
|
156
|
-
diagnostic.node_source_maps.source_mapping_urls[position.source] =
|
|
164
|
+
diagnostic.node_source_maps.source_mapping_urls[position.source] =
|
|
165
|
+
'not found';
|
|
157
166
|
}
|
|
158
167
|
}
|
|
159
168
|
|
|
160
169
|
// Resolve the source URL relative to the URL of the source map
|
|
161
|
-
if (
|
|
170
|
+
if (
|
|
171
|
+
sourceMap &&
|
|
172
|
+
sourceMap.map &&
|
|
173
|
+
typeof sourceMap.map.originalPositionFor === 'function'
|
|
174
|
+
) {
|
|
162
175
|
var originalPosition = sourceMap.map.originalPositionFor(position);
|
|
163
176
|
|
|
164
177
|
// Only return the original position if a matching line was found. If no
|
|
@@ -169,15 +182,17 @@ exports.mapSourcePosition = function mapSourcePosition(position, diagnostic) {
|
|
|
169
182
|
if (originalPosition.source !== null) {
|
|
170
183
|
var originalSource = originalPosition.source;
|
|
171
184
|
originalPosition.source = supportRelativeURL(
|
|
172
|
-
sourceMap.url,
|
|
185
|
+
sourceMap.url,
|
|
186
|
+
originalPosition.source,
|
|
187
|
+
);
|
|
173
188
|
cacheSourceContent(sourceMap, originalSource, originalPosition.source);
|
|
174
189
|
return originalPosition;
|
|
175
190
|
}
|
|
176
191
|
}
|
|
177
192
|
|
|
178
193
|
return position;
|
|
179
|
-
}
|
|
194
|
+
};
|
|
180
195
|
|
|
181
196
|
exports.sourceContent = function sourceContent(source) {
|
|
182
197
|
return sourcesContentCache[source];
|
|
183
|
-
}
|
|
198
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var url = require('url');
|
|
2
1
|
var { URL } = require('url');
|
|
3
2
|
var merge = require('../../merge');
|
|
4
3
|
|
|
@@ -12,8 +11,7 @@ function mergeOptions(input, options, cb) {
|
|
|
12
11
|
if (typeof input === 'string') {
|
|
13
12
|
const urlStr = input;
|
|
14
13
|
input = urlToHttpOptions(new URL(urlStr));
|
|
15
|
-
} else if (input && input
|
|
16
|
-
input[url.searchParamsSymbol][url.searchParamsSymbol]) {
|
|
14
|
+
} else if (input && input instanceof URL) {
|
|
17
15
|
// url.URL instance
|
|
18
16
|
input = urlToHttpOptions(input);
|
|
19
17
|
} else {
|
|
@@ -28,7 +26,7 @@ function mergeOptions(input, options, cb) {
|
|
|
28
26
|
} else {
|
|
29
27
|
options = merge(input || {}, options);
|
|
30
28
|
}
|
|
31
|
-
return {options: options, cb: cb};
|
|
29
|
+
return { options: options, cb: cb };
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
// This function replicates the relevant logic in node/lib/url.js as closely
|
|
@@ -40,15 +38,15 @@ function mergeOptions(input, options, cb) {
|
|
|
40
38
|
function urlToHttpOptions(url) {
|
|
41
39
|
const options = {
|
|
42
40
|
protocol: url.protocol,
|
|
43
|
-
hostname:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
hostname:
|
|
42
|
+
typeof url.hostname === 'string' && url.hostname.startsWith('[')
|
|
43
|
+
? url.hostname.slice(1, -1)
|
|
44
|
+
: url.hostname,
|
|
47
45
|
hash: url.hash,
|
|
48
46
|
search: url.search,
|
|
49
47
|
pathname: url.pathname,
|
|
50
48
|
path: `${url.pathname || ''}${url.search || ''}`,
|
|
51
|
-
href: url.href
|
|
49
|
+
href: url.href,
|
|
52
50
|
};
|
|
53
51
|
if (url.port !== '') {
|
|
54
52
|
options.port = Number(url.port);
|
|
@@ -67,7 +65,7 @@ function constructUrl(options) {
|
|
|
67
65
|
}
|
|
68
66
|
url += options.hostname || options.host || 'localhost';
|
|
69
67
|
if (options.port) {
|
|
70
|
-
url += `:${options.port}
|
|
68
|
+
url += `:${options.port}`;
|
|
71
69
|
}
|
|
72
70
|
url += options.path || '/';
|
|
73
71
|
|
|
@@ -76,5 +74,5 @@ function constructUrl(options) {
|
|
|
76
74
|
|
|
77
75
|
module.exports = {
|
|
78
76
|
mergeOptions,
|
|
79
|
-
constructUrl
|
|
77
|
+
constructUrl,
|
|
80
78
|
};
|