rollbar 3.0.0-beta.5 → 3.0.0
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/.git-blame-ignore-revs +3 -1
- package/AGENTS.md +21 -0
- package/CONTRIBUTING.md +68 -73
- package/babel.config.json +7 -0
- package/bower.json +1 -1
- package/dist/plugins/jquery.min.js +1 -1
- package/dist/rollbar.cjs +2216 -2022
- package/dist/rollbar.js +6098 -5886
- package/dist/rollbar.js.map +1 -1
- package/dist/rollbar.min.cjs +1 -1
- package/dist/rollbar.min.cjs.LICENSE.txt +1 -1
- package/dist/rollbar.min.js +1 -1
- package/dist/rollbar.min.js.LICENSE.txt +1 -1
- package/dist/rollbar.min.js.map +1 -1
- package/dist/rollbar.named-amd.js +6097 -5886
- package/dist/rollbar.named-amd.js.map +1 -1
- package/dist/rollbar.named-amd.min.js +1 -1
- package/dist/rollbar.named-amd.min.js.LICENSE.txt +1 -1
- package/dist/rollbar.named-amd.min.js.map +1 -1
- package/dist/rollbar.noconflict.umd.js +6097 -5886
- package/dist/rollbar.noconflict.umd.js.map +1 -1
- package/dist/rollbar.noconflict.umd.min.js +1 -1
- package/dist/rollbar.noconflict.umd.min.js.LICENSE.txt +1 -1
- package/dist/rollbar.noconflict.umd.min.js.map +1 -1
- package/dist/rollbar.replay.js +8123 -7924
- package/dist/rollbar.replay.js.map +1 -1
- package/dist/rollbar.replay.min.js +1 -1
- package/dist/rollbar.replay.min.js.LICENSE.txt +1 -1
- package/dist/rollbar.replay.min.js.map +1 -1
- package/dist/rollbar.replay.noconflict.umd.js +8122 -7924
- package/dist/rollbar.replay.noconflict.umd.js.map +1 -1
- package/dist/rollbar.replay.noconflict.umd.min.js +1 -1
- package/dist/rollbar.replay.noconflict.umd.min.js.LICENSE.txt +1 -1
- package/dist/rollbar.replay.noconflict.umd.min.js.map +1 -1
- package/dist/rollbar.replay.umd.js +8122 -7924
- package/dist/rollbar.replay.umd.js.map +1 -1
- package/dist/rollbar.replay.umd.min.js +1 -1
- package/dist/rollbar.replay.umd.min.js.LICENSE.txt +1 -1
- package/dist/rollbar.replay.umd.min.js.map +1 -1
- package/dist/rollbar.snippet.js +1 -1
- package/dist/rollbar.umd.js +6097 -5886
- package/dist/rollbar.umd.js.map +1 -1
- package/dist/rollbar.umd.min.js +1 -1
- package/dist/rollbar.umd.min.js.LICENSE.txt +1 -1
- package/dist/rollbar.umd.min.js.map +1 -1
- package/eslint.config.js +151 -0
- package/index.d.ts +45 -13
- package/package.json +26 -6
- package/src/api.js +130 -136
- package/src/apiUtility.js +2 -2
- package/src/browser/bundles/rollbar.snippet.js +1 -0
- package/src/browser/core.js +31 -42
- package/src/browser/domUtility.js +11 -17
- package/src/browser/globalSetup.js +3 -3
- package/src/browser/replay/checkoutWatchdog.js +104 -0
- package/src/browser/replay/recorder.d.ts +5 -2
- package/src/browser/replay/recorder.js +22 -4
- package/src/browser/replay/replay.js +8 -4
- package/src/browser/replay/replayPredicates.js +1 -1
- package/src/browser/rollbar.js +5 -4
- package/src/browser/rollbarReplay.js +6 -5
- package/src/browser/rollbarWrapper.js +2 -2
- package/src/browser/shim.js +15 -15
- package/src/browser/telemetry.js +26 -22
- package/src/browser/transforms.js +4 -4
- package/src/browser/transport/xhr.js +4 -4
- package/src/browser/transport.js +9 -10
- package/src/browser/wrapGlobals.js +3 -4
- package/src/defaults.js +1 -1
- package/src/errorParser.js +1 -1
- package/src/logger.js +1 -0
- package/src/notifier.js +102 -100
- package/src/predicates.js +3 -4
- package/src/rateLimiter.js +107 -104
- package/src/react-native/rollbar.js +9 -10
- package/src/react-native/transforms.js +4 -5
- package/src/react-native/transport.js +7 -7
- package/src/rollbar.js +7 -4
- package/src/scrub.js +16 -20
- package/src/server/locals.js +7 -7
- package/src/server/parser.js +9 -6
- package/src/server/rollbar.js +54 -49
- package/src/server/sourceMap/stackTrace.js +7 -6
- package/src/server/telemetry/urlHelpers.js +2 -1
- package/src/server/telemetry.js +10 -10
- package/src/server/transforms.js +10 -6
- package/src/server/transport.js +8 -7
- package/src/telemetry.js +22 -25
- package/src/tracing/tracer.js +2 -2
- package/src/tracing/tracing.js +2 -2
- package/src/truncation.js +6 -6
- package/src/utility/headers.js +4 -2
- package/src/utility/traverse.js +1 -1
- package/src/utility.js +111 -33
- package/tsconfig.json +16 -0
- package/tsconfig.test.json +10 -0
- package/{web-test-runner.config.mjs → web-test-runner.config.js} +10 -0
- package/{webpack.config.cjs → webpack.config.js} +39 -27
- package/.eslintrc +0 -27
- package/eslint.config.mjs +0 -33
- package/src/merge.js +0 -61
package/dist/rollbar.cjs
CHANGED
|
@@ -29,70 +29,19 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
"default": () => (/* binding */ server_rollbar)
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
;// external "util"
|
|
33
|
-
const external_util_namespaceObject = require("util");
|
|
34
32
|
;// external "os"
|
|
35
33
|
const external_os_namespaceObject = require("os");
|
|
36
|
-
;//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
|
|
44
|
-
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
|
|
45
|
-
// Not own constructor property must be Object
|
|
46
|
-
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Own properties are enumerated firstly, so to speed up,
|
|
51
|
-
// if last one is own, then all properties are own.
|
|
52
|
-
var key;
|
|
53
|
-
for (key in obj) {
|
|
54
|
-
/**/
|
|
55
|
-
}
|
|
56
|
-
return typeof key === 'undefined' || hasOwn.call(obj, key);
|
|
57
|
-
};
|
|
58
|
-
function merge() {
|
|
59
|
-
var i,
|
|
60
|
-
src,
|
|
61
|
-
copy,
|
|
62
|
-
clone,
|
|
63
|
-
name,
|
|
64
|
-
result = Object.create(null),
|
|
65
|
-
// no prototype pollution on Object
|
|
66
|
-
current = null,
|
|
67
|
-
length = arguments.length;
|
|
68
|
-
for (i = 0; i < length; i++) {
|
|
69
|
-
current = arguments[i];
|
|
70
|
-
if (current == null) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
for (name in current) {
|
|
74
|
-
src = result[name];
|
|
75
|
-
copy = current[name];
|
|
76
|
-
if (result !== copy) {
|
|
77
|
-
if (copy && isPlainObject(copy)) {
|
|
78
|
-
clone = src && isPlainObject(src) ? src : {};
|
|
79
|
-
result[name] = merge(clone, copy);
|
|
80
|
-
} else if (typeof copy !== 'undefined') {
|
|
81
|
-
result[name] = copy;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
/* harmony default export */ const src_merge = (merge);
|
|
34
|
+
;// external "url"
|
|
35
|
+
const external_url_namespaceObject = require("url");
|
|
36
|
+
;// external "util"
|
|
37
|
+
const external_util_namespaceObject = require("util");
|
|
38
|
+
;// external "json-stringify-safe"
|
|
39
|
+
const external_json_stringify_safe_namespaceObject = require("json-stringify-safe");
|
|
89
40
|
;// ./src/utility.js
|
|
90
41
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
91
42
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
92
43
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
93
44
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
94
|
-
|
|
95
|
-
|
|
96
45
|
/*
|
|
97
46
|
* isType - Given a Javascript value and a string, returns true if the type of the value matches the
|
|
98
47
|
* given string.
|
|
@@ -159,8 +108,18 @@ function isNativeFunction(f) {
|
|
|
159
108
|
* @returns true is value is an object function is an object)
|
|
160
109
|
*/
|
|
161
110
|
function isObject(value) {
|
|
162
|
-
|
|
163
|
-
|
|
111
|
+
return value != null && (_typeof(value) == 'object' || typeof value == 'function');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* hasOwn - safe helper around Object.hasOwnProperty */
|
|
115
|
+
function hasOwn(obj, prop) {
|
|
116
|
+
if (obj == null) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (Object.hasOwn) {
|
|
120
|
+
return Object.hasOwn(obj, prop);
|
|
121
|
+
}
|
|
122
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
164
123
|
}
|
|
165
124
|
|
|
166
125
|
/* isString - Checks if the argument is a string
|
|
@@ -182,16 +141,6 @@ function isFiniteNumber(n) {
|
|
|
182
141
|
return Number.isFinite(n);
|
|
183
142
|
}
|
|
184
143
|
|
|
185
|
-
/*
|
|
186
|
-
* isDefined - a convenience function for checking if a value is not equal to undefined
|
|
187
|
-
*
|
|
188
|
-
* @param u - any value
|
|
189
|
-
* @returns true if u is anything other than undefined
|
|
190
|
-
*/
|
|
191
|
-
function isDefined(u) {
|
|
192
|
-
return !isType(u, 'undefined');
|
|
193
|
-
}
|
|
194
|
-
|
|
195
144
|
/*
|
|
196
145
|
* isIterable - convenience function for checking if a value can be iterated, essentially
|
|
197
146
|
* whether it is an object or an array.
|
|
@@ -238,7 +187,7 @@ function redact() {
|
|
|
238
187
|
|
|
239
188
|
// from http://stackoverflow.com/a/8809472/1138191
|
|
240
189
|
function uuid4() {
|
|
241
|
-
var d =
|
|
190
|
+
var d = now();
|
|
242
191
|
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
243
192
|
var r = (d + Math.random() * 16) % 16 | 0;
|
|
244
193
|
d = Math.floor(d / 16);
|
|
@@ -288,8 +237,8 @@ var parseUriOptions = {
|
|
|
288
237
|
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
|
|
289
238
|
},
|
|
290
239
|
parser: {
|
|
291
|
-
strict: /^(?:([
|
|
292
|
-
loose: /^(?:(?![^:@]+:[
|
|
240
|
+
strict: /^(?:([^:/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\d*))?))?((((?:[^?#/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
|
241
|
+
loose: /^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#/]*\.[^?#/.]+(?:[?#]|$)))*\/?)?([^?#/]*))(?:\?([^#]*))?(?:#(.*))?)/
|
|
293
242
|
}
|
|
294
243
|
};
|
|
295
244
|
function parseUri(str) {
|
|
@@ -489,7 +438,11 @@ function createItem(args, logger, notifier, requestKeys, lambdaContext) {
|
|
|
489
438
|
case 'undefined':
|
|
490
439
|
break;
|
|
491
440
|
case 'string':
|
|
492
|
-
|
|
441
|
+
if (message) {
|
|
442
|
+
extraArgs.push(arg);
|
|
443
|
+
} else {
|
|
444
|
+
message = arg;
|
|
445
|
+
}
|
|
493
446
|
break;
|
|
494
447
|
case 'function':
|
|
495
448
|
callback = wrapCallback(logger, arg);
|
|
@@ -501,12 +454,20 @@ function createItem(args, logger, notifier, requestKeys, lambdaContext) {
|
|
|
501
454
|
case 'domexception':
|
|
502
455
|
case 'exception':
|
|
503
456
|
// Firefox Exception type
|
|
504
|
-
|
|
457
|
+
if (err) {
|
|
458
|
+
extraArgs.push(arg);
|
|
459
|
+
} else {
|
|
460
|
+
err = arg;
|
|
461
|
+
}
|
|
505
462
|
break;
|
|
506
463
|
case 'object':
|
|
507
464
|
case 'array':
|
|
508
465
|
if (arg instanceof Error || typeof DOMException !== 'undefined' && arg instanceof DOMException) {
|
|
509
|
-
|
|
466
|
+
if (err) {
|
|
467
|
+
extraArgs.push(arg);
|
|
468
|
+
} else {
|
|
469
|
+
err = arg;
|
|
470
|
+
}
|
|
510
471
|
break;
|
|
511
472
|
}
|
|
512
473
|
if (requestKeys && typ === 'object' && !request) {
|
|
@@ -520,11 +481,19 @@ function createItem(args, logger, notifier, requestKeys, lambdaContext) {
|
|
|
520
481
|
break;
|
|
521
482
|
}
|
|
522
483
|
}
|
|
523
|
-
|
|
484
|
+
if (custom) {
|
|
485
|
+
extraArgs.push(arg);
|
|
486
|
+
} else {
|
|
487
|
+
custom = arg;
|
|
488
|
+
}
|
|
524
489
|
break;
|
|
525
490
|
default:
|
|
526
491
|
if (arg instanceof Error || typeof DOMException !== 'undefined' && arg instanceof DOMException) {
|
|
527
|
-
|
|
492
|
+
if (err) {
|
|
493
|
+
extraArgs.push(arg);
|
|
494
|
+
} else {
|
|
495
|
+
err = arg;
|
|
496
|
+
}
|
|
528
497
|
break;
|
|
529
498
|
}
|
|
530
499
|
extraArgs.push(arg);
|
|
@@ -541,7 +510,7 @@ function createItem(args, logger, notifier, requestKeys, lambdaContext) {
|
|
|
541
510
|
message: message,
|
|
542
511
|
err: err,
|
|
543
512
|
custom: custom,
|
|
544
|
-
timestamp:
|
|
513
|
+
timestamp: now(),
|
|
545
514
|
callback: callback,
|
|
546
515
|
notifier: notifier,
|
|
547
516
|
diagnostic: diagnostic,
|
|
@@ -573,14 +542,23 @@ function addErrorContext(item, errors) {
|
|
|
573
542
|
var custom = item.data.custom || {};
|
|
574
543
|
var contextAdded = false;
|
|
575
544
|
try {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
545
|
+
var _iterator = _createForOfIteratorHelper(errors),
|
|
546
|
+
_step;
|
|
547
|
+
try {
|
|
548
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
549
|
+
var error = _step.value;
|
|
550
|
+
if (hasOwn(error, 'rollbarContext')) {
|
|
551
|
+
custom = merge(custom, nonCircularClone(error.rollbarContext));
|
|
552
|
+
contextAdded = true;
|
|
553
|
+
}
|
|
580
554
|
}
|
|
581
|
-
}
|
|
582
555
|
|
|
583
|
-
|
|
556
|
+
// Avoid adding an empty object to the data.
|
|
557
|
+
} catch (err) {
|
|
558
|
+
_iterator.e(err);
|
|
559
|
+
} finally {
|
|
560
|
+
_iterator.f();
|
|
561
|
+
}
|
|
584
562
|
if (contextAdded) {
|
|
585
563
|
item.data.custom = custom;
|
|
586
564
|
}
|
|
@@ -591,10 +569,19 @@ function addErrorContext(item, errors) {
|
|
|
591
569
|
var TELEMETRY_TYPES = ['log', 'network', 'dom', 'navigation', 'error', 'manual'];
|
|
592
570
|
var TELEMETRY_LEVELS = ['critical', 'error', 'warning', 'info', 'debug'];
|
|
593
571
|
function arrayIncludes(arr, val) {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
572
|
+
var _iterator2 = _createForOfIteratorHelper(arr),
|
|
573
|
+
_step2;
|
|
574
|
+
try {
|
|
575
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
576
|
+
var entry = _step2.value;
|
|
577
|
+
if (entry === val) {
|
|
578
|
+
return true;
|
|
579
|
+
}
|
|
597
580
|
}
|
|
581
|
+
} catch (err) {
|
|
582
|
+
_iterator2.e(err);
|
|
583
|
+
} finally {
|
|
584
|
+
_iterator2.f();
|
|
598
585
|
}
|
|
599
586
|
return false;
|
|
600
587
|
}
|
|
@@ -628,20 +615,20 @@ function createTelemetryEvent(args) {
|
|
|
628
615
|
}
|
|
629
616
|
function addItemAttributes(itemData, attributes) {
|
|
630
617
|
itemData.attributes = itemData.attributes || [];
|
|
631
|
-
var
|
|
632
|
-
|
|
618
|
+
var _iterator3 = _createForOfIteratorHelper(attributes),
|
|
619
|
+
_step3;
|
|
633
620
|
try {
|
|
634
|
-
for (
|
|
635
|
-
var a =
|
|
621
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
622
|
+
var a = _step3.value;
|
|
636
623
|
if (a.value === undefined) {
|
|
637
624
|
continue;
|
|
638
625
|
}
|
|
639
626
|
itemData.attributes.push(a);
|
|
640
627
|
}
|
|
641
628
|
} catch (err) {
|
|
642
|
-
|
|
629
|
+
_iterator3.e(err);
|
|
643
630
|
} finally {
|
|
644
|
-
|
|
631
|
+
_iterator3.f();
|
|
645
632
|
}
|
|
646
633
|
}
|
|
647
634
|
|
|
@@ -663,7 +650,7 @@ function get(obj, path) {
|
|
|
663
650
|
for (var i = 0, len = keys.length; i < len; ++i) {
|
|
664
651
|
result = result[keys[i]];
|
|
665
652
|
}
|
|
666
|
-
} catch (
|
|
653
|
+
} catch (_e) {
|
|
667
654
|
result = undefined;
|
|
668
655
|
}
|
|
669
656
|
return result;
|
|
@@ -693,7 +680,7 @@ function set(obj, path, value) {
|
|
|
693
680
|
}
|
|
694
681
|
temp[keys[len - 1]] = value;
|
|
695
682
|
obj[keys[0]] = replacement;
|
|
696
|
-
} catch (
|
|
683
|
+
} catch (_e) {
|
|
697
684
|
return;
|
|
698
685
|
}
|
|
699
686
|
}
|
|
@@ -724,11 +711,11 @@ function formatArgsAsString(args) {
|
|
|
724
711
|
}
|
|
725
712
|
return result.join(' ');
|
|
726
713
|
}
|
|
727
|
-
function
|
|
714
|
+
function now() {
|
|
728
715
|
if (Date.now) {
|
|
729
|
-
return
|
|
716
|
+
return Date.now();
|
|
730
717
|
}
|
|
731
|
-
return
|
|
718
|
+
return Number(new Date());
|
|
732
719
|
}
|
|
733
720
|
function filterIp(requestData, captureIp) {
|
|
734
721
|
if (!requestData || !requestData['user_ip'] || captureIp === true) {
|
|
@@ -759,14 +746,14 @@ function filterIp(requestData, captureIp) {
|
|
|
759
746
|
} else {
|
|
760
747
|
newIp = null;
|
|
761
748
|
}
|
|
762
|
-
} catch (
|
|
749
|
+
} catch (_e) {
|
|
763
750
|
newIp = null;
|
|
764
751
|
}
|
|
765
752
|
}
|
|
766
753
|
requestData['user_ip'] = newIp;
|
|
767
754
|
}
|
|
768
755
|
function handleOptions(current, input, payload, logger) {
|
|
769
|
-
var result =
|
|
756
|
+
var result = merge(current, input, payload);
|
|
770
757
|
result = updateDeprecatedOptions(result, logger);
|
|
771
758
|
if (!input || input.overwriteScrubFields) {
|
|
772
759
|
return result;
|
|
@@ -789,1566 +776,1511 @@ function updateDeprecatedOptions(options, logger) {
|
|
|
789
776
|
}
|
|
790
777
|
return options;
|
|
791
778
|
}
|
|
779
|
+
function merge() {
|
|
780
|
+
function isPlainObject(obj) {
|
|
781
|
+
if (!obj || Object.prototype.toString.call(obj) !== '[object Object]') {
|
|
782
|
+
return false;
|
|
783
|
+
}
|
|
784
|
+
var hasOwnConstructor = hasOwn(obj, 'constructor');
|
|
785
|
+
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn(obj.constructor.prototype, 'isPrototypeOf');
|
|
786
|
+
// Not own constructor property must be Object
|
|
787
|
+
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
792
790
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
*/
|
|
801
|
-
function RateLimiter(options) {
|
|
802
|
-
this.startTime = utility_now();
|
|
803
|
-
this.counter = 0;
|
|
804
|
-
this.perMinCounter = 0;
|
|
805
|
-
this.platform = null;
|
|
806
|
-
this.platformOptions = {};
|
|
807
|
-
this.configureGlobal(options);
|
|
808
|
-
}
|
|
809
|
-
RateLimiter.globalSettings = {
|
|
810
|
-
startTime: utility_now(),
|
|
811
|
-
maxItems: undefined,
|
|
812
|
-
itemsPerMinute: undefined
|
|
813
|
-
};
|
|
814
|
-
|
|
815
|
-
/*
|
|
816
|
-
* configureGlobal - set the global rate limiter options
|
|
817
|
-
*
|
|
818
|
-
* @param options - Only the following values are recognized:
|
|
819
|
-
* startTime: a timestamp of the form returned by (new Date()).getTime()
|
|
820
|
-
* maxItems: the maximum items
|
|
821
|
-
* itemsPerMinute: the max number of items to send in a given minute
|
|
822
|
-
*/
|
|
823
|
-
RateLimiter.prototype.configureGlobal = function (options) {
|
|
824
|
-
if (options.startTime !== undefined) {
|
|
825
|
-
RateLimiter.globalSettings.startTime = options.startTime;
|
|
826
|
-
}
|
|
827
|
-
if (options.maxItems !== undefined) {
|
|
828
|
-
RateLimiter.globalSettings.maxItems = options.maxItems;
|
|
829
|
-
}
|
|
830
|
-
if (options.itemsPerMinute !== undefined) {
|
|
831
|
-
RateLimiter.globalSettings.itemsPerMinute = options.itemsPerMinute;
|
|
791
|
+
// Own properties are enumerated firstly, so to speed up,
|
|
792
|
+
// if last one is own, then all properties are own.
|
|
793
|
+
var key;
|
|
794
|
+
for (key in obj) {
|
|
795
|
+
/**/
|
|
796
|
+
}
|
|
797
|
+
return typeof key === 'undefined' || hasOwn(obj, key);
|
|
832
798
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
799
|
+
var i,
|
|
800
|
+
src,
|
|
801
|
+
copy,
|
|
802
|
+
clone,
|
|
803
|
+
name,
|
|
804
|
+
result = Object.create(null),
|
|
805
|
+
// no prototype pollution on Object
|
|
806
|
+
current = null,
|
|
807
|
+
length = arguments.length;
|
|
808
|
+
for (i = 0; i < length; i++) {
|
|
809
|
+
current = arguments[i];
|
|
810
|
+
if (current === null || current === undefined) {
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
for (name in current) {
|
|
814
|
+
src = result[name];
|
|
815
|
+
copy = current[name];
|
|
816
|
+
if (result !== copy) {
|
|
817
|
+
if (copy && isPlainObject(copy)) {
|
|
818
|
+
clone = src && isPlainObject(src) ? src : {};
|
|
819
|
+
result[name] = merge(clone, copy);
|
|
820
|
+
} else if (typeof copy !== 'undefined') {
|
|
821
|
+
result[name] = copy;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
856
825
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
if (checkRate(item, globalRateLimit, this.counter)) {
|
|
860
|
-
return shouldSendValue(this.platform, this.platformOptions, globalRateLimit + ' max items reached', false);
|
|
861
|
-
} else if (checkRate(item, globalRateLimitPerMin, this.perMinCounter)) {
|
|
862
|
-
return shouldSendValue(this.platform, this.platformOptions, globalRateLimitPerMin + ' items per minute reached', false);
|
|
863
|
-
}
|
|
864
|
-
this.counter++;
|
|
865
|
-
this.perMinCounter++;
|
|
866
|
-
var shouldSend = !checkRate(item, globalRateLimit, this.counter);
|
|
867
|
-
var perMinute = shouldSend;
|
|
868
|
-
shouldSend = shouldSend && !checkRate(item, globalRateLimitPerMin, this.perMinCounter);
|
|
869
|
-
return shouldSendValue(this.platform, this.platformOptions, null, shouldSend, globalRateLimit, globalRateLimitPerMin, perMinute);
|
|
870
|
-
};
|
|
871
|
-
RateLimiter.prototype.setPlatformOptions = function (platform, options) {
|
|
872
|
-
this.platform = platform;
|
|
873
|
-
this.platformOptions = options;
|
|
874
|
-
};
|
|
826
|
+
return result;
|
|
827
|
+
}
|
|
875
828
|
|
|
876
|
-
|
|
829
|
+
;// ./src/apiUtility.js
|
|
877
830
|
|
|
878
|
-
function
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
831
|
+
function buildPayload(data) {
|
|
832
|
+
if (!isType(data.context, 'string')) {
|
|
833
|
+
var contextResult = stringify(data.context);
|
|
834
|
+
if (contextResult.error) {
|
|
835
|
+
data.context = "Error: could not serialize 'context'";
|
|
836
|
+
} else {
|
|
837
|
+
data.context = contextResult.value || '';
|
|
838
|
+
}
|
|
839
|
+
if (data.context.length > 255) {
|
|
840
|
+
data.context = data.context.substr(0, 255);
|
|
841
|
+
}
|
|
888
842
|
}
|
|
889
843
|
return {
|
|
890
|
-
|
|
891
|
-
shouldSend: shouldSend,
|
|
892
|
-
payload: payload
|
|
844
|
+
data: data
|
|
893
845
|
};
|
|
894
846
|
}
|
|
895
|
-
function
|
|
896
|
-
var
|
|
897
|
-
var
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
847
|
+
function getTransportFromOptions(options, defaults, url) {
|
|
848
|
+
var hostname = defaults.hostname;
|
|
849
|
+
var protocol = defaults.protocol;
|
|
850
|
+
var port = defaults.port;
|
|
851
|
+
var path = defaults.path;
|
|
852
|
+
var search = defaults.search;
|
|
853
|
+
var timeout = options.timeout;
|
|
854
|
+
var transport = detectTransport(options);
|
|
855
|
+
var proxy = options.proxy;
|
|
856
|
+
if (options.endpoint) {
|
|
857
|
+
var opts = url.parse(options.endpoint);
|
|
858
|
+
hostname = opts.hostname;
|
|
859
|
+
protocol = opts.protocol;
|
|
860
|
+
port = opts.port;
|
|
861
|
+
path = opts.pathname;
|
|
862
|
+
search = opts.search;
|
|
902
863
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
},
|
|
913
|
-
language: 'javascript',
|
|
914
|
-
environment: environment,
|
|
915
|
-
notifier: {
|
|
916
|
-
version: options.notifier && options.notifier.version || options.version
|
|
917
|
-
}
|
|
864
|
+
return {
|
|
865
|
+
timeout: timeout,
|
|
866
|
+
hostname: hostname,
|
|
867
|
+
protocol: protocol,
|
|
868
|
+
port: port,
|
|
869
|
+
path: path,
|
|
870
|
+
search: search,
|
|
871
|
+
proxy: proxy,
|
|
872
|
+
transport: transport
|
|
918
873
|
};
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
874
|
+
}
|
|
875
|
+
function detectTransport(options) {
|
|
876
|
+
var gWindow = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self;
|
|
877
|
+
var transport = options.defaultTransport || 'xhr';
|
|
878
|
+
if (typeof gWindow.fetch === 'undefined') transport = 'xhr';
|
|
879
|
+
if (typeof gWindow.XMLHttpRequest === 'undefined') transport = 'fetch';
|
|
880
|
+
return transport;
|
|
881
|
+
}
|
|
882
|
+
function apiUtility_transportOptions(transport, method) {
|
|
883
|
+
var protocol = transport.protocol || 'https:';
|
|
884
|
+
var port = transport.port || (protocol === 'http:' ? 80 : protocol === 'https:' ? 443 : undefined);
|
|
885
|
+
var hostname = transport.hostname;
|
|
886
|
+
var path = transport.path;
|
|
887
|
+
var timeout = transport.timeout;
|
|
888
|
+
var transportAPI = transport.transport;
|
|
889
|
+
if (transport.search) {
|
|
890
|
+
path = path + transport.search;
|
|
929
891
|
}
|
|
930
|
-
|
|
892
|
+
if (transport.proxy) {
|
|
893
|
+
path = protocol + '//' + hostname + path;
|
|
894
|
+
hostname = transport.proxy.host || transport.proxy.hostname;
|
|
895
|
+
port = transport.proxy.port;
|
|
896
|
+
protocol = transport.proxy.protocol || protocol;
|
|
897
|
+
}
|
|
898
|
+
return {
|
|
899
|
+
timeout: timeout,
|
|
900
|
+
protocol: protocol,
|
|
901
|
+
hostname: hostname,
|
|
902
|
+
path: path,
|
|
903
|
+
port: port,
|
|
904
|
+
method: method,
|
|
905
|
+
transport: transportAPI
|
|
906
|
+
};
|
|
931
907
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
908
|
+
function appendPathToPath(base, path) {
|
|
909
|
+
var baseTrailingSlash = /\/$/.test(base);
|
|
910
|
+
var pathBeginningSlash = /^\//.test(path);
|
|
911
|
+
if (baseTrailingSlash && pathBeginningSlash) {
|
|
912
|
+
path = path.substring(1);
|
|
913
|
+
} else if (!baseTrailingSlash && !pathBeginningSlash) {
|
|
914
|
+
path = '/' + path;
|
|
915
|
+
}
|
|
916
|
+
return base + path;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
;// ./src/api.js
|
|
920
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
921
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
922
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
923
|
+
function api_typeof(o) { "@babel/helpers - typeof"; return api_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, api_typeof(o); }
|
|
924
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
925
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
926
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
927
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
928
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
929
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
930
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
931
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == api_typeof(i) ? i : i + ""; }
|
|
932
|
+
function _toPrimitive(t, r) { if ("object" != api_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != api_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
941
933
|
|
|
942
934
|
|
|
935
|
+
var defaultOptions = {
|
|
936
|
+
hostname: 'api.rollbar.com',
|
|
937
|
+
path: '/api/1/item/',
|
|
938
|
+
search: null,
|
|
939
|
+
version: '1',
|
|
940
|
+
protocol: 'https:',
|
|
941
|
+
port: 443
|
|
942
|
+
};
|
|
943
|
+
var OTLPDefaultOptions = {
|
|
944
|
+
hostname: 'api.rollbar.com',
|
|
945
|
+
path: '/api/1/session/',
|
|
946
|
+
search: null,
|
|
947
|
+
version: '1',
|
|
948
|
+
protocol: 'https:',
|
|
949
|
+
port: 443
|
|
950
|
+
};
|
|
951
|
+
|
|
943
952
|
/**
|
|
944
|
-
*
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
*
|
|
953
|
+
* Api encapsulates methods of communicating with the Rollbar API. It is a
|
|
954
|
+
* standard interface with some parts implemented differently for server or
|
|
955
|
+
* browser contexts. It is an object that should be instantiated when used so
|
|
956
|
+
* it can contain non-global options that may be different for another instance
|
|
957
|
+
* of RollbarApi.
|
|
948
958
|
*/
|
|
949
|
-
var
|
|
959
|
+
var Api = /*#__PURE__*/function () {
|
|
950
960
|
/**
|
|
951
|
-
* @param
|
|
952
|
-
*
|
|
953
|
-
* @param
|
|
954
|
-
*
|
|
955
|
-
* @param
|
|
956
|
-
*
|
|
957
|
-
* @param
|
|
961
|
+
* @param {Object} options - Configuration supplied from the parent Rollbar instance.
|
|
962
|
+
* @param {string} options.accessToken - Token used to authenticate API calls.
|
|
963
|
+
* @param {string} [options.endpoint] - Optional fully qualified URL overriding
|
|
964
|
+
* the default `https://api.rollbar.com/api/1/item`.
|
|
965
|
+
* @param {Object} [options.proxy] - Optional proxy descriptor containing:
|
|
966
|
+
* `host`/`hostname` (required), `port`, and `protocol`.
|
|
967
|
+
* @param {Object} transport - Adapter implementing `post` and `postJsonPayload`.
|
|
968
|
+
* @param {Object} urllib - Minimal URL helper used for option normalization.
|
|
969
|
+
* @param {Object} truncation - Optional truncation helper for payload size enforcement.
|
|
958
970
|
*/
|
|
959
|
-
function
|
|
960
|
-
_classCallCheck(this,
|
|
961
|
-
this.rateLimiter = rateLimiter;
|
|
962
|
-
this.api = api;
|
|
963
|
-
this.logger = logger;
|
|
971
|
+
function Api(options, transport, urllib, truncation) {
|
|
972
|
+
_classCallCheck(this, Api);
|
|
964
973
|
this.options = options;
|
|
965
|
-
this.
|
|
966
|
-
this.
|
|
967
|
-
this.
|
|
968
|
-
this.
|
|
969
|
-
this.
|
|
970
|
-
this.
|
|
971
|
-
this.waitCallback = null;
|
|
972
|
-
this.waitIntervalID = null;
|
|
974
|
+
this.transport = transport;
|
|
975
|
+
this.url = urllib;
|
|
976
|
+
this.truncation = truncation;
|
|
977
|
+
this.accessToken = options.accessToken;
|
|
978
|
+
this.transportOptions = _getTransport(options, urllib);
|
|
979
|
+
this.OTLPTransportOptions = _getOTLPTransport(options, urllib);
|
|
973
980
|
}
|
|
974
981
|
|
|
975
982
|
/**
|
|
976
|
-
*
|
|
983
|
+
* Wraps transport.post in a Promise to support async/await
|
|
977
984
|
*
|
|
978
|
-
* @param options
|
|
985
|
+
* @param {Object} options - Options for the API request
|
|
986
|
+
* @param {string} options.accessToken - The access token for authentication
|
|
987
|
+
* @param {Object} options.transportOptions - Options for the transport
|
|
988
|
+
* @param {Object} options.payload - The data payload to send
|
|
989
|
+
* @returns {Promise} A promise that resolves with the response or rejects with an error
|
|
990
|
+
* @private
|
|
979
991
|
*/
|
|
980
|
-
return _createClass(
|
|
981
|
-
key: "
|
|
982
|
-
value: function
|
|
983
|
-
var _this
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
992
|
+
return _createClass(Api, [{
|
|
993
|
+
key: "_postPromise",
|
|
994
|
+
value: function _postPromise(_ref) {
|
|
995
|
+
var _this = this;
|
|
996
|
+
var accessToken = _ref.accessToken,
|
|
997
|
+
options = _ref.options,
|
|
998
|
+
payload = _ref.payload,
|
|
999
|
+
headers = _ref.headers;
|
|
1000
|
+
return new Promise(function (resolve, reject) {
|
|
1001
|
+
_this.transport.post({
|
|
1002
|
+
accessToken: accessToken,
|
|
1003
|
+
options: options,
|
|
1004
|
+
payload: payload,
|
|
1005
|
+
headers: headers,
|
|
1006
|
+
callback: function callback(err, resp) {
|
|
1007
|
+
return err ? reject(err) : resolve(resp);
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
});
|
|
988
1011
|
}
|
|
989
1012
|
|
|
990
1013
|
/**
|
|
991
|
-
* addPredicate - adds a predicate to the end of the list of predicates for this queue
|
|
992
1014
|
*
|
|
993
|
-
* @param
|
|
994
|
-
*
|
|
995
|
-
* Returning false means do not add the item to the queue, but it is not an error
|
|
996
|
-
* Returning {err: Error} means do not add the item to the queue, and the given error explains why
|
|
997
|
-
* Returning {err: undefined} is equivalent to returning true but don't do that
|
|
1015
|
+
* @param data
|
|
1016
|
+
* @param callback
|
|
998
1017
|
*/
|
|
999
1018
|
}, {
|
|
1000
|
-
key: "
|
|
1001
|
-
value: function
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
var idx = this.pendingItems.indexOf(item);
|
|
1016
|
-
if (idx !== -1) {
|
|
1017
|
-
this.pendingItems.splice(idx, 1);
|
|
1018
|
-
}
|
|
1019
|
+
key: "postItem",
|
|
1020
|
+
value: function postItem(data, callback) {
|
|
1021
|
+
var _this2 = this;
|
|
1022
|
+
var options = apiUtility_transportOptions(this.transportOptions, 'POST');
|
|
1023
|
+
var payload = buildPayload(data);
|
|
1024
|
+
|
|
1025
|
+
// ensure the network request is scheduled after the current tick.
|
|
1026
|
+
setTimeout(function () {
|
|
1027
|
+
_this2.transport.post({
|
|
1028
|
+
accessToken: _this2.accessToken,
|
|
1029
|
+
options: options,
|
|
1030
|
+
payload: payload,
|
|
1031
|
+
callback: callback
|
|
1032
|
+
});
|
|
1033
|
+
}, 0);
|
|
1019
1034
|
}
|
|
1020
1035
|
|
|
1021
1036
|
/**
|
|
1022
|
-
*
|
|
1037
|
+
* Posts spans to the Rollbar API using the session endpoint
|
|
1023
1038
|
*
|
|
1024
|
-
* @param
|
|
1025
|
-
* @
|
|
1026
|
-
* in the case of a success, otherwise response will be null and error will have a value. If both
|
|
1027
|
-
* error and response are null then the item was stopped by a predicate which did not consider this
|
|
1028
|
-
* to be an error condition, but nonetheless did not send the item to the API.
|
|
1029
|
-
* @param originalError - The original error before any transformations that is to be logged if any
|
|
1030
|
-
* @param originalItem - The original item before transforms, used in pendingItems queue
|
|
1039
|
+
* @param {Array} payload - The spans to send
|
|
1040
|
+
* @returns {Promise<Object>} A promise that resolves with the API response
|
|
1031
1041
|
*/
|
|
1032
1042
|
}, {
|
|
1033
|
-
key: "
|
|
1034
|
-
value: function
|
|
1035
|
-
var
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
if (!this.options.transmit) {
|
|
1051
|
-
callback(new Error('Transmit disabled'));
|
|
1052
|
-
return;
|
|
1053
|
-
}
|
|
1054
|
-
if (this.replay && data.body) {
|
|
1055
|
-
item.replayId = this.replay.capture(null, data.uuid, {
|
|
1056
|
-
type: 'occurrence',
|
|
1057
|
-
level: item.level
|
|
1058
|
-
});
|
|
1059
|
-
if (item.replayId) {
|
|
1060
|
-
addItemAttributes(item.data, [{
|
|
1061
|
-
key: 'replay_id',
|
|
1062
|
-
value: item.replayId
|
|
1063
|
-
}]);
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
this.pendingRequests.push(data);
|
|
1067
|
-
try {
|
|
1068
|
-
this._makeApiRequest(data, function (err, resp, headers) {
|
|
1069
|
-
_this._dequeuePendingRequest(data);
|
|
1070
|
-
if (item.replayId) {
|
|
1071
|
-
_this.replay.sendOrDiscardReplay(item.replayId, err, resp, headers);
|
|
1043
|
+
key: "postSpans",
|
|
1044
|
+
value: (function () {
|
|
1045
|
+
var _postSpans = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
|
|
1046
|
+
var headers,
|
|
1047
|
+
options,
|
|
1048
|
+
_args = arguments;
|
|
1049
|
+
return _regenerator().w(function (_context) {
|
|
1050
|
+
while (1) switch (_context.n) {
|
|
1051
|
+
case 0:
|
|
1052
|
+
headers = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
1053
|
+
options = apiUtility_transportOptions(this.OTLPTransportOptions, 'POST');
|
|
1054
|
+
return _context.a(2, this._postPromise({
|
|
1055
|
+
accessToken: this.accessToken,
|
|
1056
|
+
options: options,
|
|
1057
|
+
payload: payload,
|
|
1058
|
+
headers: headers
|
|
1059
|
+
}));
|
|
1072
1060
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
if (item.replayId) {
|
|
1078
|
-
var _this$replay;
|
|
1079
|
-
(_this$replay = this.replay) === null || _this$replay === void 0 || _this$replay.discard(item.replayId);
|
|
1080
|
-
}
|
|
1081
|
-
callback(err);
|
|
1061
|
+
}, _callee, this);
|
|
1062
|
+
}));
|
|
1063
|
+
function postSpans(_x) {
|
|
1064
|
+
return _postSpans.apply(this, arguments);
|
|
1082
1065
|
}
|
|
1083
|
-
|
|
1084
|
-
|
|
1066
|
+
return postSpans;
|
|
1067
|
+
}()
|
|
1085
1068
|
/**
|
|
1086
|
-
* wait - Stop any further errors from being added to the queue, and get called back when all items
|
|
1087
|
-
* currently processing have finished sending to the backend.
|
|
1088
1069
|
*
|
|
1089
|
-
* @param
|
|
1070
|
+
* @param data
|
|
1071
|
+
* @param callback
|
|
1090
1072
|
*/
|
|
1073
|
+
)
|
|
1091
1074
|
}, {
|
|
1092
|
-
key: "
|
|
1093
|
-
value: function
|
|
1094
|
-
var
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
return;
|
|
1075
|
+
key: "buildJsonPayload",
|
|
1076
|
+
value: function buildJsonPayload(data, callback) {
|
|
1077
|
+
var payload = buildPayload(data);
|
|
1078
|
+
var stringifyResult;
|
|
1079
|
+
if (this.truncation) {
|
|
1080
|
+
stringifyResult = this.truncation.truncate(payload);
|
|
1081
|
+
} else {
|
|
1082
|
+
stringifyResult = stringify(payload);
|
|
1101
1083
|
}
|
|
1102
|
-
if (
|
|
1103
|
-
|
|
1084
|
+
if (stringifyResult.error) {
|
|
1085
|
+
if (callback) {
|
|
1086
|
+
callback(stringifyResult.error);
|
|
1087
|
+
}
|
|
1088
|
+
return null;
|
|
1104
1089
|
}
|
|
1105
|
-
|
|
1106
|
-
_this2._maybeCallWait();
|
|
1107
|
-
}, 500);
|
|
1090
|
+
return stringifyResult.value;
|
|
1108
1091
|
}
|
|
1109
1092
|
|
|
1110
1093
|
/**
|
|
1111
|
-
* Sequentially applies the predicates that have been added to the queue to the
|
|
1112
|
-
* given item with the currently configured options.
|
|
1113
1094
|
*
|
|
1114
|
-
* @param
|
|
1115
|
-
* @
|
|
1116
|
-
* the error value should be passed up to a callbak if we are stopping.
|
|
1095
|
+
* @param jsonPayload
|
|
1096
|
+
* @param callback
|
|
1117
1097
|
*/
|
|
1118
1098
|
}, {
|
|
1119
|
-
key: "
|
|
1120
|
-
value: function
|
|
1121
|
-
var
|
|
1122
|
-
|
|
1123
|
-
p = this.predicates[i](item, this.options);
|
|
1124
|
-
if (!p || p.err !== undefined) {
|
|
1125
|
-
return {
|
|
1126
|
-
stop: true,
|
|
1127
|
-
err: p.err
|
|
1128
|
-
};
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
return {
|
|
1132
|
-
stop: false,
|
|
1133
|
-
err: null
|
|
1134
|
-
};
|
|
1099
|
+
key: "postJsonPayload",
|
|
1100
|
+
value: function postJsonPayload(jsonPayload, callback) {
|
|
1101
|
+
var transportOptions = apiUtility_transportOptions(this.transportOptions, 'POST');
|
|
1102
|
+
this.transport.postJsonPayload(this.accessToken, transportOptions, jsonPayload, callback);
|
|
1135
1103
|
}
|
|
1136
|
-
|
|
1137
|
-
/**
|
|
1138
|
-
* Send an item to Rollbar, callback when done, if there is an error make an
|
|
1139
|
-
* effort to retry if we are configured to do so.
|
|
1140
|
-
*
|
|
1141
|
-
* @param item - an item ready to send to the backend
|
|
1142
|
-
* @param callback - function(err, response)
|
|
1143
|
-
*/
|
|
1144
1104
|
}, {
|
|
1145
|
-
key: "
|
|
1146
|
-
value: function
|
|
1147
|
-
var
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
} else {
|
|
1154
|
-
callback(err, resp, headers);
|
|
1155
|
-
}
|
|
1156
|
-
});
|
|
1157
|
-
} else if (rateLimitResponse.error) {
|
|
1158
|
-
callback(rateLimitResponse.error);
|
|
1159
|
-
} else {
|
|
1160
|
-
this.api.postItem(rateLimitResponse.payload, callback);
|
|
1105
|
+
key: "configure",
|
|
1106
|
+
value: function configure(options) {
|
|
1107
|
+
var oldOptions = this.options;
|
|
1108
|
+
this.options = merge(oldOptions, options);
|
|
1109
|
+
this.transportOptions = _getTransport(this.options, this.url);
|
|
1110
|
+
this.OTLPTransportOptions = _getOTLPTransport(this.options, this.url);
|
|
1111
|
+
if (this.options.accessToken !== undefined) {
|
|
1112
|
+
this.accessToken = this.options.accessToken;
|
|
1161
1113
|
}
|
|
1114
|
+
return this;
|
|
1162
1115
|
}
|
|
1116
|
+
}]);
|
|
1117
|
+
}();
|
|
1118
|
+
function _getTransport(options, url) {
|
|
1119
|
+
return getTransportFromOptions(options, defaultOptions, url);
|
|
1120
|
+
}
|
|
1121
|
+
function _getOTLPTransport(options, url) {
|
|
1122
|
+
var _options$tracing;
|
|
1123
|
+
options = _objectSpread(_objectSpread({}, options), {}, {
|
|
1124
|
+
endpoint: (_options$tracing = options.tracing) === null || _options$tracing === void 0 ? void 0 : _options$tracing.endpoint
|
|
1125
|
+
});
|
|
1126
|
+
return getTransportFromOptions(options, OTLPDefaultOptions, url);
|
|
1127
|
+
}
|
|
1128
|
+
/* harmony default export */ const src_api = (Api);
|
|
1129
|
+
;// ./src/defaults.js
|
|
1130
|
+
/**
|
|
1131
|
+
* Default options shared across platforms
|
|
1132
|
+
*/
|
|
1133
|
+
var version = '3.0.0';
|
|
1134
|
+
var endpoint = 'api.rollbar.com/api/1/item/';
|
|
1135
|
+
var logLevel = 'debug';
|
|
1136
|
+
var reportLevel = 'debug';
|
|
1137
|
+
var uncaughtErrorLevel = 'error';
|
|
1138
|
+
var maxItems = 0;
|
|
1139
|
+
var itemsPerMin = 60;
|
|
1140
|
+
var commonScrubFields = ['pw', 'pass', 'passwd', 'password', 'secret', 'confirm_password', 'confirmPassword', 'password_confirmation', 'passwordConfirmation', 'access_token', 'accessToken', 'X-Rollbar-Access-Token', 'secret_key', 'secretKey', 'secretToken'];
|
|
1141
|
+
var apiScrubFields = ['api_key', 'authenticity_token', 'oauth_token', 'token', 'user_session_secret'];
|
|
1142
|
+
var requestScrubFields = ['request.session.csrf', 'request.session._csrf', 'request.params._csrf', 'request.cookie', 'request.cookies'];
|
|
1143
|
+
var commonScrubHeaders = ['authorization', 'www-authorization', 'http_authorization', 'omniauth.auth', 'cookie', 'oauth-access-token', 'x-access-token', 'x_csrf_token', 'http_x_csrf_token', 'x-csrf-token'];
|
|
1163
1144
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
if (item.retries > this.options.maxRetries) {
|
|
1188
|
-
shouldRetry = false;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
if (shouldRetry) {
|
|
1193
|
-
this._retryApiRequest(item, callback);
|
|
1194
|
-
} else {
|
|
1195
|
-
callback(err);
|
|
1196
|
-
}
|
|
1145
|
+
// For backward compatibility with default export
|
|
1146
|
+
/* harmony default export */ const defaults = ({
|
|
1147
|
+
version: version,
|
|
1148
|
+
endpoint: endpoint,
|
|
1149
|
+
logLevel: logLevel,
|
|
1150
|
+
reportLevel: reportLevel,
|
|
1151
|
+
uncaughtErrorLevel: uncaughtErrorLevel,
|
|
1152
|
+
maxItems: maxItems,
|
|
1153
|
+
itemsPerMin: itemsPerMin
|
|
1154
|
+
});
|
|
1155
|
+
;// ./src/logger.js
|
|
1156
|
+
var _log = function log() {};
|
|
1157
|
+
var levels = {
|
|
1158
|
+
debug: 0,
|
|
1159
|
+
info: 1,
|
|
1160
|
+
warn: 2,
|
|
1161
|
+
error: 3,
|
|
1162
|
+
disable: 4
|
|
1163
|
+
};
|
|
1164
|
+
var logger = {
|
|
1165
|
+
error: function error() {
|
|
1166
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1167
|
+
args[_key] = arguments[_key];
|
|
1197
1168
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
* @param item - an item that failed to send due to an error we deem retriable
|
|
1204
|
-
* @param callback - function(err, response)
|
|
1205
|
-
*/
|
|
1206
|
-
}, {
|
|
1207
|
-
key: "_retryApiRequest",
|
|
1208
|
-
value: function _retryApiRequest(item, callback) {
|
|
1209
|
-
var _this4 = this;
|
|
1210
|
-
this.retryQueue.push({
|
|
1211
|
-
item: item,
|
|
1212
|
-
callback: callback
|
|
1213
|
-
});
|
|
1214
|
-
if (!this.retryHandle) {
|
|
1215
|
-
this.retryHandle = setInterval(function () {
|
|
1216
|
-
while (_this4.retryQueue.length) {
|
|
1217
|
-
var retryObject = _this4.retryQueue.shift();
|
|
1218
|
-
_this4._makeApiRequest(retryObject.item, retryObject.callback);
|
|
1219
|
-
}
|
|
1220
|
-
}, this.options.retryInterval);
|
|
1221
|
-
}
|
|
1169
|
+
return _log('error', args);
|
|
1170
|
+
},
|
|
1171
|
+
warn: function warn() {
|
|
1172
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1173
|
+
args[_key2] = arguments[_key2];
|
|
1222
1174
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
* processing this item. If a `wait` callback is configured, it is called by this function.
|
|
1229
|
-
*
|
|
1230
|
-
* @param item - the item previously added to the pending request queue
|
|
1231
|
-
*/
|
|
1232
|
-
}, {
|
|
1233
|
-
key: "_dequeuePendingRequest",
|
|
1234
|
-
value: function _dequeuePendingRequest(item) {
|
|
1235
|
-
var idx = this.pendingRequests.indexOf(item);
|
|
1236
|
-
if (idx !== -1) {
|
|
1237
|
-
this.pendingRequests.splice(idx, 1);
|
|
1238
|
-
this._maybeCallWait();
|
|
1239
|
-
}
|
|
1175
|
+
return _log('warn', args);
|
|
1176
|
+
},
|
|
1177
|
+
info: function info() {
|
|
1178
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
1179
|
+
args[_key3] = arguments[_key3];
|
|
1240
1180
|
}
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
if (message) {
|
|
1247
|
-
this.logger.error(message);
|
|
1248
|
-
return;
|
|
1249
|
-
}
|
|
1250
|
-
message = get(data, 'body.message.body');
|
|
1251
|
-
if (message) {
|
|
1252
|
-
this.logger.log(message);
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1181
|
+
return _log('info', args);
|
|
1182
|
+
},
|
|
1183
|
+
debug: function debug() {
|
|
1184
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
1185
|
+
args[_key4] = arguments[_key4];
|
|
1255
1186
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
this.waitIntervalID = clearInterval(this.waitIntervalID);
|
|
1262
|
-
}
|
|
1263
|
-
this.waitCallback();
|
|
1264
|
-
return true;
|
|
1265
|
-
}
|
|
1266
|
-
return false;
|
|
1187
|
+
return _log('debug', args);
|
|
1188
|
+
},
|
|
1189
|
+
log: function log() {
|
|
1190
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
1191
|
+
args[_key5] = arguments[_key5];
|
|
1267
1192
|
}
|
|
1268
|
-
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
/*
|
|
1276
|
-
* Notifier - the internal object responsible for delegating between the client exposed API, the
|
|
1277
|
-
* chain of transforms necessary to turn an item into something that can be sent to Rollbar, and the
|
|
1278
|
-
* queue which handles the communcation with the Rollbar API servers.
|
|
1279
|
-
*
|
|
1280
|
-
* @param queue - an object that conforms to the interface: addItem(item, callback)
|
|
1281
|
-
* @param options - an object representing the options to be set for this notifier, this should have
|
|
1282
|
-
* any defaults already set by the caller
|
|
1283
|
-
*/
|
|
1284
|
-
function Notifier(queue, options) {
|
|
1285
|
-
this.queue = queue;
|
|
1286
|
-
this.options = options;
|
|
1287
|
-
this.transforms = [];
|
|
1288
|
-
this.diagnostic = {};
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
/*
|
|
1292
|
-
* configure - updates the options for this notifier with the passed in object
|
|
1293
|
-
*
|
|
1294
|
-
* @param options - an object which gets merged with the current options set on this notifier
|
|
1295
|
-
* @returns this
|
|
1296
|
-
*/
|
|
1297
|
-
Notifier.prototype.configure = function (options) {
|
|
1298
|
-
this.queue && this.queue.configure(options);
|
|
1299
|
-
var oldOptions = this.options;
|
|
1300
|
-
this.options = src_merge(oldOptions, options);
|
|
1301
|
-
return this;
|
|
1302
|
-
};
|
|
1193
|
+
return _log('info', args);
|
|
1194
|
+
},
|
|
1195
|
+
init: function init(_ref) {
|
|
1196
|
+
var logLevel = _ref.logLevel;
|
|
1197
|
+
_log = function _log(level, args) {
|
|
1198
|
+
if (levels[level] < levels[logLevel]) return;
|
|
1199
|
+
args.unshift('Rollbar:');
|
|
1303
1200
|
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
* @param transform - a function which takes three arguments:
|
|
1308
|
-
* * item: An Object representing the data to eventually be sent to Rollbar
|
|
1309
|
-
* * options: The current value of the options for this notifier
|
|
1310
|
-
* * callback: function(err: (Null|Error), item: (Null|Object)) the transform must call this
|
|
1311
|
-
* callback with a null value for error if it wants the processing chain to continue, otherwise
|
|
1312
|
-
* with an error to terminate the processing. The item should be the updated item after this
|
|
1313
|
-
* transform is finished modifying it.
|
|
1314
|
-
*/
|
|
1315
|
-
Notifier.prototype.addTransform = function (transform) {
|
|
1316
|
-
if (isFunction(transform)) {
|
|
1317
|
-
this.transforms.push(transform);
|
|
1201
|
+
// eslint-disable-next-line no-console
|
|
1202
|
+
console[level].apply(console, args);
|
|
1203
|
+
};
|
|
1318
1204
|
}
|
|
1319
|
-
return this;
|
|
1320
1205
|
};
|
|
1206
|
+
/* harmony default export */ const src_logger = (logger);
|
|
1207
|
+
;// ./src/predicates.js
|
|
1208
|
+
function predicates_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = predicates_unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
1209
|
+
function predicates_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return predicates_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? predicates_arrayLikeToArray(r, a) : void 0; } }
|
|
1210
|
+
function predicates_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
1321
1211
|
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
*
|
|
1330
|
-
* @param callback - A function of type function(err, resp) which will be called with exactly one
|
|
1331
|
-
* null argument and one non-null argument. The callback will be called once, either during the
|
|
1332
|
-
* transform stage if an error occurs inside a transform, or in response to the communication with
|
|
1333
|
-
* the backend. The second argument will be the response from the backend in case of success.
|
|
1334
|
-
*/
|
|
1335
|
-
Notifier.prototype.log = function (item, callback) {
|
|
1336
|
-
if (!callback || !isFunction(callback)) {
|
|
1337
|
-
callback = function callback() {};
|
|
1338
|
-
}
|
|
1339
|
-
if (!this.options.enabled) {
|
|
1340
|
-
return callback(new Error('Rollbar is not enabled'));
|
|
1212
|
+
function checkLevel(item, settings) {
|
|
1213
|
+
var level = item.level;
|
|
1214
|
+
var levelVal = LEVELS[level] || 0;
|
|
1215
|
+
var reportLevel = settings.reportLevel;
|
|
1216
|
+
var reportLevelVal = LEVELS[reportLevel] || 0;
|
|
1217
|
+
if (levelVal < reportLevelVal) {
|
|
1218
|
+
return false;
|
|
1341
1219
|
}
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
* `addTransform` for more information.
|
|
1358
|
-
*
|
|
1359
|
-
* @param item - An item to be transformed
|
|
1360
|
-
* @param callback - A function of type function(err, item) which will be called with a non-null
|
|
1361
|
-
* error and a null item in the case of a transform failure, or a null error and non-null item after
|
|
1362
|
-
* all transforms have been applied.
|
|
1363
|
-
*/
|
|
1364
|
-
Notifier.prototype._applyTransforms = function (item, callback) {
|
|
1365
|
-
var transformIndex = -1;
|
|
1366
|
-
var transformsLength = this.transforms.length;
|
|
1367
|
-
var transforms = this.transforms;
|
|
1368
|
-
var options = this.options;
|
|
1369
|
-
var _cb = function cb(err, i) {
|
|
1370
|
-
if (err) {
|
|
1371
|
-
callback(err, null);
|
|
1372
|
-
return;
|
|
1220
|
+
return true;
|
|
1221
|
+
}
|
|
1222
|
+
function userCheckIgnore(logger) {
|
|
1223
|
+
return function (item, settings) {
|
|
1224
|
+
var isUncaught = Boolean(item._isUncaught);
|
|
1225
|
+
delete item._isUncaught;
|
|
1226
|
+
var args = item._originalArgs;
|
|
1227
|
+
delete item._originalArgs;
|
|
1228
|
+
try {
|
|
1229
|
+
if (isFunction(settings.onSendCallback)) {
|
|
1230
|
+
settings.onSendCallback(isUncaught, args, item);
|
|
1231
|
+
}
|
|
1232
|
+
} catch (e) {
|
|
1233
|
+
settings.onSendCallback = null;
|
|
1234
|
+
logger.error('Error while calling onSendCallback, removing', e);
|
|
1373
1235
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1236
|
+
try {
|
|
1237
|
+
if (isFunction(settings.checkIgnore) && settings.checkIgnore(isUncaught, args, item)) {
|
|
1238
|
+
return false;
|
|
1239
|
+
}
|
|
1240
|
+
} catch (e) {
|
|
1241
|
+
settings.checkIgnore = null;
|
|
1242
|
+
logger.error('Error while calling custom checkIgnore(), removing', e);
|
|
1378
1243
|
}
|
|
1379
|
-
|
|
1244
|
+
return true;
|
|
1380
1245
|
};
|
|
1381
|
-
_cb(null, item);
|
|
1382
|
-
};
|
|
1383
|
-
/* harmony default export */ const notifier = (Notifier);
|
|
1384
|
-
;// ./src/rollbar.js
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
/*
|
|
1391
|
-
* Rollbar - the interface to Rollbar
|
|
1392
|
-
*
|
|
1393
|
-
* @param options
|
|
1394
|
-
* @param api
|
|
1395
|
-
* @param logger
|
|
1396
|
-
*/
|
|
1397
|
-
function Rollbar(options, api, logger, telemeter, tracing, replay, platform) {
|
|
1398
|
-
this.options = src_merge(options);
|
|
1399
|
-
this.logger = logger;
|
|
1400
|
-
Rollbar.rateLimiter.configureGlobal(this.options);
|
|
1401
|
-
Rollbar.rateLimiter.setPlatformOptions(platform, this.options);
|
|
1402
|
-
this.api = api;
|
|
1403
|
-
this.queue = new queue(Rollbar.rateLimiter, api, logger, this.options, replay);
|
|
1404
|
-
this.tracing = tracing;
|
|
1405
|
-
|
|
1406
|
-
// Legacy OpenTracing support
|
|
1407
|
-
// This must happen before the Notifier is created
|
|
1408
|
-
var tracer = this.options.tracer || null;
|
|
1409
|
-
if (validateTracer(tracer)) {
|
|
1410
|
-
this.tracer = tracer;
|
|
1411
|
-
// set to a string for api response serialization
|
|
1412
|
-
this.options.tracer = 'opentracing-tracer-enabled';
|
|
1413
|
-
this.options._configuredOptions.tracer = 'opentracing-tracer-enabled';
|
|
1414
|
-
} else {
|
|
1415
|
-
this.tracer = null;
|
|
1416
|
-
}
|
|
1417
|
-
this.notifier = new notifier(this.queue, this.options);
|
|
1418
|
-
this.telemeter = telemeter;
|
|
1419
|
-
setStackTraceLimit(options);
|
|
1420
|
-
this.lastError = null;
|
|
1421
|
-
this.lastErrorHash = 'none';
|
|
1422
1246
|
}
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
};
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
};
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
payload = {
|
|
1437
|
-
payload: payloadData
|
|
1438
|
-
};
|
|
1439
|
-
}
|
|
1440
|
-
this.options = src_merge(oldOptions, options, payload);
|
|
1441
|
-
|
|
1442
|
-
// Legacy OpenTracing support
|
|
1443
|
-
// This must happen before the Notifier is configured
|
|
1444
|
-
var tracer = this.options.tracer || null;
|
|
1445
|
-
if (validateTracer(tracer)) {
|
|
1446
|
-
this.tracer = tracer;
|
|
1447
|
-
// set to a string for api response serialization
|
|
1448
|
-
this.options.tracer = 'opentracing-tracer-enabled';
|
|
1449
|
-
this.options._configuredOptions.tracer = 'opentracing-tracer-enabled';
|
|
1450
|
-
} else {
|
|
1451
|
-
this.tracer = null;
|
|
1452
|
-
}
|
|
1453
|
-
this.notifier && this.notifier.configure(this.options);
|
|
1454
|
-
this.telemeter && this.telemeter.configure(this.options);
|
|
1455
|
-
setStackTraceLimit(options);
|
|
1456
|
-
this.global(this.options);
|
|
1457
|
-
if (validateTracer(options.tracer)) {
|
|
1458
|
-
this.tracer = options.tracer;
|
|
1247
|
+
function urlIsNotBlockListed(logger) {
|
|
1248
|
+
return function (item, settings) {
|
|
1249
|
+
return !urlIsOnAList(item, settings, 'blocklist', logger);
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
function urlIsSafeListed(logger) {
|
|
1253
|
+
return function (item, settings) {
|
|
1254
|
+
return urlIsOnAList(item, settings, 'safelist', logger);
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
function matchFrames(trace, list, block) {
|
|
1258
|
+
if (!trace) {
|
|
1259
|
+
return !block;
|
|
1459
1260
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
var level = this._defaultLogLevel();
|
|
1464
|
-
return this._log(level, item);
|
|
1465
|
-
};
|
|
1466
|
-
Rollbar.prototype.debug = function (item) {
|
|
1467
|
-
this._log('debug', item);
|
|
1468
|
-
};
|
|
1469
|
-
Rollbar.prototype.info = function (item) {
|
|
1470
|
-
this._log('info', item);
|
|
1471
|
-
};
|
|
1472
|
-
Rollbar.prototype.warn = function (item) {
|
|
1473
|
-
this._log('warning', item);
|
|
1474
|
-
};
|
|
1475
|
-
Rollbar.prototype.warning = function (item) {
|
|
1476
|
-
this._log('warning', item);
|
|
1477
|
-
};
|
|
1478
|
-
Rollbar.prototype.error = function (item) {
|
|
1479
|
-
this._log('error', item);
|
|
1480
|
-
};
|
|
1481
|
-
Rollbar.prototype.critical = function (item) {
|
|
1482
|
-
this._log('critical', item);
|
|
1483
|
-
};
|
|
1484
|
-
Rollbar.prototype.wait = function (callback) {
|
|
1485
|
-
this.queue.wait(callback);
|
|
1486
|
-
};
|
|
1487
|
-
Rollbar.prototype.captureEvent = function (type, metadata, level) {
|
|
1488
|
-
return this.telemeter && this.telemeter.captureEvent(type, metadata, level);
|
|
1489
|
-
};
|
|
1490
|
-
Rollbar.prototype.captureDomContentLoaded = function (ts) {
|
|
1491
|
-
return this.telemeter && this.telemeter.captureDomContentLoaded(ts);
|
|
1492
|
-
};
|
|
1493
|
-
Rollbar.prototype.captureLoad = function (ts) {
|
|
1494
|
-
return this.telemeter && this.telemeter.captureLoad(ts);
|
|
1495
|
-
};
|
|
1496
|
-
Rollbar.prototype.buildJsonPayload = function (item) {
|
|
1497
|
-
return this.api.buildJsonPayload(item);
|
|
1498
|
-
};
|
|
1499
|
-
Rollbar.prototype.sendJsonPayload = function (jsonPayload) {
|
|
1500
|
-
this.api.postJsonPayload(jsonPayload);
|
|
1501
|
-
};
|
|
1502
|
-
|
|
1503
|
-
/* Internal */
|
|
1504
|
-
|
|
1505
|
-
Rollbar.prototype._log = function (defaultLevel, item) {
|
|
1506
|
-
var callback;
|
|
1507
|
-
if (item.callback) {
|
|
1508
|
-
callback = item.callback;
|
|
1509
|
-
delete item.callback;
|
|
1261
|
+
var frames = trace.frames;
|
|
1262
|
+
if (!frames || frames.length === 0) {
|
|
1263
|
+
return !block;
|
|
1510
1264
|
}
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1265
|
+
var frame, filename, url, urlRegex;
|
|
1266
|
+
var listLength = list.length;
|
|
1267
|
+
var frameLength = frames.length;
|
|
1268
|
+
for (var i = 0; i < frameLength; i++) {
|
|
1269
|
+
frame = frames[i];
|
|
1270
|
+
filename = frame.filename;
|
|
1271
|
+
if (!isType(filename, 'string')) {
|
|
1272
|
+
return !block;
|
|
1516
1273
|
}
|
|
1517
|
-
|
|
1274
|
+
for (var j = 0; j < listLength; j++) {
|
|
1275
|
+
url = list[j];
|
|
1276
|
+
urlRegex = new RegExp(url);
|
|
1277
|
+
if (urlRegex.test(filename)) {
|
|
1278
|
+
return true;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
return false;
|
|
1283
|
+
}
|
|
1284
|
+
function urlIsOnAList(item, settings, safeOrBlock, logger) {
|
|
1285
|
+
// safelist is the default
|
|
1286
|
+
var block = false;
|
|
1287
|
+
if (safeOrBlock === 'blocklist') {
|
|
1288
|
+
block = true;
|
|
1518
1289
|
}
|
|
1290
|
+
var list, traces;
|
|
1519
1291
|
try {
|
|
1520
|
-
|
|
1521
|
-
|
|
1292
|
+
list = block ? settings.hostBlockList : settings.hostSafeList;
|
|
1293
|
+
traces = get(item, 'body.trace_chain') || [get(item, 'body.trace')];
|
|
1522
1294
|
|
|
1523
|
-
//
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
telemeter._captureRollbarItem(item);
|
|
1528
|
-
item.telemetryEvents = telemeter.copyEvents() || [];
|
|
1295
|
+
// These two checks are important to come first as they are defaults
|
|
1296
|
+
// in case the list is missing or the trace is missing or not well-formed
|
|
1297
|
+
if (!list || list.length === 0) {
|
|
1298
|
+
return !block;
|
|
1529
1299
|
}
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
if (callback) {
|
|
1533
|
-
callback(e);
|
|
1300
|
+
if (traces.length === 0 || !traces[0]) {
|
|
1301
|
+
return !block;
|
|
1534
1302
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
var _this$tracing, _this$tracing2;
|
|
1540
|
-
var span = (_this$tracing = this.tracing) === null || _this$tracing === void 0 ? void 0 : _this$tracing.getSpan();
|
|
1541
|
-
var attributes = [{
|
|
1542
|
-
key: 'session_id',
|
|
1543
|
-
value: (_this$tracing2 = this.tracing) === null || _this$tracing2 === void 0 ? void 0 : _this$tracing2.sessionId
|
|
1544
|
-
}, {
|
|
1545
|
-
key: 'span_id',
|
|
1546
|
-
value: span === null || span === void 0 ? void 0 : span.spanId
|
|
1547
|
-
}, {
|
|
1548
|
-
key: 'trace_id',
|
|
1549
|
-
value: span === null || span === void 0 ? void 0 : span.traceId
|
|
1550
|
-
}];
|
|
1551
|
-
addItemAttributes(item.data, attributes);
|
|
1552
|
-
span === null || span === void 0 || span.addEvent('rollbar.occurrence', [{
|
|
1553
|
-
key: 'rollbar.occurrence.uuid',
|
|
1554
|
-
value: item.uuid
|
|
1555
|
-
}]);
|
|
1556
|
-
};
|
|
1557
|
-
Rollbar.prototype._defaultLogLevel = function () {
|
|
1558
|
-
return this.options.logLevel || 'debug';
|
|
1559
|
-
};
|
|
1560
|
-
Rollbar.prototype._sameAsLastError = function (item) {
|
|
1561
|
-
if (!item._isUncaught) {
|
|
1562
|
-
return false;
|
|
1563
|
-
}
|
|
1564
|
-
var itemHash = generateItemHash(item);
|
|
1565
|
-
if (this.lastErrorHash === itemHash) {
|
|
1566
|
-
return true;
|
|
1567
|
-
}
|
|
1568
|
-
this.lastError = item.err;
|
|
1569
|
-
this.lastErrorHash = itemHash;
|
|
1570
|
-
return false;
|
|
1571
|
-
};
|
|
1572
|
-
Rollbar.prototype._addTracingInfo = function (item) {
|
|
1573
|
-
// Tracer validation occurs in the constructor
|
|
1574
|
-
// or in the Rollbar.prototype.configure methods
|
|
1575
|
-
if (this.tracer) {
|
|
1576
|
-
// add rollbar occurrence uuid to span
|
|
1577
|
-
var span = this.tracer.scope().active();
|
|
1578
|
-
if (validateSpan(span)) {
|
|
1579
|
-
span.setTag('rollbar.error_uuid', item.uuid);
|
|
1580
|
-
span.setTag('rollbar.has_error', true);
|
|
1581
|
-
span.setTag('error', true);
|
|
1582
|
-
span.setTag('rollbar.item_url', "https://rollbar.com/item/uuid/?uuid=".concat(item.uuid));
|
|
1583
|
-
span.setTag('rollbar.occurrence_url', "https://rollbar.com/occurrence/uuid/?uuid=".concat(item.uuid));
|
|
1584
|
-
|
|
1585
|
-
// add span ID & trace ID to occurrence
|
|
1586
|
-
var opentracingSpanId = span.context().toSpanId();
|
|
1587
|
-
var opentracingTraceId = span.context().toTraceId();
|
|
1588
|
-
if (item.custom) {
|
|
1589
|
-
item.custom.opentracing_span_id = opentracingSpanId;
|
|
1590
|
-
item.custom.opentracing_trace_id = opentracingTraceId;
|
|
1591
|
-
} else {
|
|
1592
|
-
item.custom = {
|
|
1593
|
-
opentracing_span_id: opentracingSpanId,
|
|
1594
|
-
opentracing_trace_id: opentracingTraceId
|
|
1595
|
-
};
|
|
1303
|
+
var tracesLength = traces.length;
|
|
1304
|
+
for (var i = 0; i < tracesLength; i++) {
|
|
1305
|
+
if (matchFrames(traces[i], list, block)) {
|
|
1306
|
+
return true;
|
|
1596
1307
|
}
|
|
1597
1308
|
}
|
|
1309
|
+
} catch (e
|
|
1310
|
+
/* istanbul ignore next */) {
|
|
1311
|
+
if (block) {
|
|
1312
|
+
settings.hostBlockList = null;
|
|
1313
|
+
} else {
|
|
1314
|
+
settings.hostSafeList = null;
|
|
1315
|
+
}
|
|
1316
|
+
var listName = block ? 'hostBlockList' : 'hostSafeList';
|
|
1317
|
+
logger.error("Error while reading your configuration's " + listName + ' option. Removing custom ' + listName + '.', e);
|
|
1318
|
+
return !block;
|
|
1598
1319
|
}
|
|
1599
|
-
|
|
1600
|
-
function generateItemHash(item) {
|
|
1601
|
-
var message = item.message || '';
|
|
1602
|
-
var stack = (item.err || {}).stack || String(item.err);
|
|
1603
|
-
return message + '::' + stack;
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
// Node.js, Chrome, Safari, and some other browsers support this property
|
|
1607
|
-
// which globally sets the number of stack frames returned in an Error object.
|
|
1608
|
-
// If a browser can't use it, no harm done.
|
|
1609
|
-
function setStackTraceLimit(options) {
|
|
1610
|
-
if (options.stackTraceLimit) {
|
|
1611
|
-
Error.stackTraceLimit = options.stackTraceLimit;
|
|
1612
|
-
}
|
|
1320
|
+
return false;
|
|
1613
1321
|
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
}
|
|
1642
|
-
var spanContext = span.context();
|
|
1643
|
-
if (!spanContext || !spanContext.toSpanId || !spanContext.toTraceId || typeof spanContext.toSpanId !== 'function' || typeof spanContext.toTraceId !== 'function') {
|
|
1644
|
-
return false;
|
|
1645
|
-
}
|
|
1646
|
-
return true;
|
|
1647
|
-
}
|
|
1648
|
-
/* harmony default export */ const rollbar = (Rollbar);
|
|
1649
|
-
;// ./src/apiUtility.js
|
|
1650
|
-
|
|
1651
|
-
function buildPayload(data) {
|
|
1652
|
-
if (!isType(data.context, 'string')) {
|
|
1653
|
-
var contextResult = stringify(data.context);
|
|
1654
|
-
if (contextResult.error) {
|
|
1655
|
-
data.context = "Error: could not serialize 'context'";
|
|
1656
|
-
} else {
|
|
1657
|
-
data.context = contextResult.value || '';
|
|
1658
|
-
}
|
|
1659
|
-
if (data.context.length > 255) {
|
|
1660
|
-
data.context = data.context.substr(0, 255);
|
|
1322
|
+
function messageIsIgnored(logger) {
|
|
1323
|
+
return function (item, settings) {
|
|
1324
|
+
var i, j, ignoredMessages, len, messageIsIgnored, rIgnoredMessage, messages;
|
|
1325
|
+
try {
|
|
1326
|
+
messageIsIgnored = false;
|
|
1327
|
+
ignoredMessages = settings.ignoredMessages;
|
|
1328
|
+
if (!ignoredMessages || ignoredMessages.length === 0) {
|
|
1329
|
+
return true;
|
|
1330
|
+
}
|
|
1331
|
+
messages = messagesFromItem(item);
|
|
1332
|
+
if (messages.length === 0) {
|
|
1333
|
+
return true;
|
|
1334
|
+
}
|
|
1335
|
+
len = ignoredMessages.length;
|
|
1336
|
+
for (i = 0; i < len; i++) {
|
|
1337
|
+
rIgnoredMessage = new RegExp(ignoredMessages[i], 'gi');
|
|
1338
|
+
for (j = 0; j < messages.length; j++) {
|
|
1339
|
+
messageIsIgnored = rIgnoredMessage.test(messages[j]);
|
|
1340
|
+
if (messageIsIgnored) {
|
|
1341
|
+
return false;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
} catch (_e
|
|
1346
|
+
/* istanbul ignore next */) {
|
|
1347
|
+
settings.ignoredMessages = null;
|
|
1348
|
+
logger.error("Error while reading your configuration's ignoredMessages option. Removing custom ignoredMessages.");
|
|
1661
1349
|
}
|
|
1662
|
-
|
|
1663
|
-
return {
|
|
1664
|
-
data: data
|
|
1665
|
-
};
|
|
1666
|
-
}
|
|
1667
|
-
function getTransportFromOptions(options, defaults, url) {
|
|
1668
|
-
var hostname = defaults.hostname;
|
|
1669
|
-
var protocol = defaults.protocol;
|
|
1670
|
-
var port = defaults.port;
|
|
1671
|
-
var path = defaults.path;
|
|
1672
|
-
var search = defaults.search;
|
|
1673
|
-
var timeout = options.timeout;
|
|
1674
|
-
var transport = detectTransport(options);
|
|
1675
|
-
var proxy = options.proxy;
|
|
1676
|
-
if (options.endpoint) {
|
|
1677
|
-
var opts = url.parse(options.endpoint);
|
|
1678
|
-
hostname = opts.hostname;
|
|
1679
|
-
protocol = opts.protocol;
|
|
1680
|
-
port = opts.port;
|
|
1681
|
-
path = opts.pathname;
|
|
1682
|
-
search = opts.search;
|
|
1683
|
-
}
|
|
1684
|
-
return {
|
|
1685
|
-
timeout: timeout,
|
|
1686
|
-
hostname: hostname,
|
|
1687
|
-
protocol: protocol,
|
|
1688
|
-
port: port,
|
|
1689
|
-
path: path,
|
|
1690
|
-
search: search,
|
|
1691
|
-
proxy: proxy,
|
|
1692
|
-
transport: transport
|
|
1350
|
+
return true;
|
|
1693
1351
|
};
|
|
1694
1352
|
}
|
|
1695
|
-
function
|
|
1696
|
-
var
|
|
1697
|
-
var
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1353
|
+
function messagesFromItem(item) {
|
|
1354
|
+
var body = item.body;
|
|
1355
|
+
var messages = [];
|
|
1356
|
+
|
|
1357
|
+
// The payload schema only allows one of trace_chain, message, or trace.
|
|
1358
|
+
// However, existing test cases are based on having both trace and message present.
|
|
1359
|
+
// So here we preserve the ability to collect strings from any combination of these keys.
|
|
1360
|
+
if (body.trace_chain) {
|
|
1361
|
+
var traceChain = body.trace_chain;
|
|
1362
|
+
var _iterator = predicates_createForOfIteratorHelper(traceChain),
|
|
1363
|
+
_step;
|
|
1364
|
+
try {
|
|
1365
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1366
|
+
var trace = _step.value;
|
|
1367
|
+
messages.push(get(trace, 'exception.message'));
|
|
1368
|
+
}
|
|
1369
|
+
} catch (err) {
|
|
1370
|
+
_iterator.e(err);
|
|
1371
|
+
} finally {
|
|
1372
|
+
_iterator.f();
|
|
1373
|
+
}
|
|
1711
1374
|
}
|
|
1712
|
-
if (
|
|
1713
|
-
|
|
1714
|
-
hostname = transport.proxy.host || transport.proxy.hostname;
|
|
1715
|
-
port = transport.proxy.port;
|
|
1716
|
-
protocol = transport.proxy.protocol || protocol;
|
|
1375
|
+
if (body.trace) {
|
|
1376
|
+
messages.push(get(body, 'trace.exception.message'));
|
|
1717
1377
|
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
protocol: protocol,
|
|
1721
|
-
hostname: hostname,
|
|
1722
|
-
path: path,
|
|
1723
|
-
port: port,
|
|
1724
|
-
method: method,
|
|
1725
|
-
transport: transportAPI
|
|
1726
|
-
};
|
|
1727
|
-
}
|
|
1728
|
-
function appendPathToPath(base, path) {
|
|
1729
|
-
var baseTrailingSlash = /\/$/.test(base);
|
|
1730
|
-
var pathBeginningSlash = /^\//.test(path);
|
|
1731
|
-
if (baseTrailingSlash && pathBeginningSlash) {
|
|
1732
|
-
path = path.substring(1);
|
|
1733
|
-
} else if (!baseTrailingSlash && !pathBeginningSlash) {
|
|
1734
|
-
path = '/' + path;
|
|
1378
|
+
if (body.message) {
|
|
1379
|
+
messages.push(get(body, 'message.body'));
|
|
1735
1380
|
}
|
|
1736
|
-
return
|
|
1381
|
+
return messages;
|
|
1737
1382
|
}
|
|
1738
1383
|
|
|
1739
|
-
;// ./src/
|
|
1740
|
-
function
|
|
1741
|
-
function
|
|
1742
|
-
function
|
|
1743
|
-
function
|
|
1744
|
-
function
|
|
1745
|
-
function
|
|
1746
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == api_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(api_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
1747
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
1748
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
1749
|
-
|
|
1384
|
+
;// ./src/notifier.js
|
|
1385
|
+
function notifier_typeof(o) { "@babel/helpers - typeof"; return notifier_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, notifier_typeof(o); }
|
|
1386
|
+
function notifier_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1387
|
+
function notifier_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, notifier_toPropertyKey(o.key), o); } }
|
|
1388
|
+
function notifier_createClass(e, r, t) { return r && notifier_defineProperties(e.prototype, r), t && notifier_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1389
|
+
function notifier_toPropertyKey(t) { var i = notifier_toPrimitive(t, "string"); return "symbol" == notifier_typeof(i) ? i : i + ""; }
|
|
1390
|
+
function notifier_toPrimitive(t, r) { if ("object" != notifier_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != notifier_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1750
1391
|
|
|
1751
|
-
var api_defaultOptions = {
|
|
1752
|
-
hostname: 'api.rollbar.com',
|
|
1753
|
-
path: '/api/1/item/',
|
|
1754
|
-
search: null,
|
|
1755
|
-
version: '1',
|
|
1756
|
-
protocol: 'https:',
|
|
1757
|
-
port: 443
|
|
1758
|
-
};
|
|
1759
|
-
var OTLPDefaultOptions = {
|
|
1760
|
-
hostname: 'api.rollbar.com',
|
|
1761
|
-
path: '/api/1/session/',
|
|
1762
|
-
search: null,
|
|
1763
|
-
version: '1',
|
|
1764
|
-
protocol: 'https:',
|
|
1765
|
-
port: 443
|
|
1766
|
-
};
|
|
1767
1392
|
|
|
1768
|
-
|
|
1769
|
-
*
|
|
1770
|
-
*
|
|
1771
|
-
*
|
|
1772
|
-
* be instantiated when used so it can contain non-global options that may
|
|
1773
|
-
* be different for another instance of RollbarApi.
|
|
1774
|
-
*
|
|
1775
|
-
* @param options {
|
|
1776
|
-
* accessToken: the accessToken to use for posting items to rollbar
|
|
1777
|
-
* endpoint: an alternative endpoint to send errors to
|
|
1778
|
-
* must be a valid, fully qualified URL.
|
|
1779
|
-
* The default is: https://api.rollbar.com/api/1/item
|
|
1780
|
-
* proxy: if you wish to proxy requests provide an object
|
|
1781
|
-
* with the following keys:
|
|
1782
|
-
* host or hostname (required): foo.example.com
|
|
1783
|
-
* port (optional): 123
|
|
1784
|
-
* protocol (optional): https
|
|
1785
|
-
* }
|
|
1393
|
+
/*
|
|
1394
|
+
* Notifier - delegates between the client exposed API, the chain of transforms
|
|
1395
|
+
* necessary to turn an item into something that can be sent to Rollbar, and the
|
|
1396
|
+
* queue which handles the communcation with the Rollbar API servers.
|
|
1786
1397
|
*/
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1398
|
+
var Notifier = /*#__PURE__*/function () {
|
|
1399
|
+
/**
|
|
1400
|
+
*
|
|
1401
|
+
* @param {Object} queue - an object that conforms to the interface:
|
|
1402
|
+
* `addItem(item, callback)`
|
|
1403
|
+
* @param {Object} options - an object representing the options to be set for
|
|
1404
|
+
* this notifier, this should have any defaults already set by the caller
|
|
1405
|
+
*/
|
|
1406
|
+
function Notifier(queue, options) {
|
|
1407
|
+
notifier_classCallCheck(this, Notifier);
|
|
1408
|
+
this.queue = queue;
|
|
1409
|
+
this.options = options;
|
|
1410
|
+
this.transforms = [];
|
|
1411
|
+
this.diagnostic = {};
|
|
1412
|
+
}
|
|
1796
1413
|
|
|
1797
|
-
/**
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
return new Promise(function (resolve, reject) {
|
|
1814
|
-
self.transport.post({
|
|
1815
|
-
accessToken: accessToken,
|
|
1816
|
-
options: options,
|
|
1817
|
-
payload: payload,
|
|
1818
|
-
headers: headers,
|
|
1819
|
-
callback: function callback(err, resp) {
|
|
1820
|
-
return err ? reject(err) : resolve(resp);
|
|
1821
|
-
}
|
|
1822
|
-
});
|
|
1823
|
-
});
|
|
1824
|
-
};
|
|
1414
|
+
/**
|
|
1415
|
+
* configure - updates the options for this notifier with the passed in object
|
|
1416
|
+
*
|
|
1417
|
+
* @param {Object} options - an object which gets merged with the current
|
|
1418
|
+
* options set on this notifier
|
|
1419
|
+
* @returns this
|
|
1420
|
+
*/
|
|
1421
|
+
return notifier_createClass(Notifier, [{
|
|
1422
|
+
key: "configure",
|
|
1423
|
+
value: function configure(options) {
|
|
1424
|
+
var _this$queue;
|
|
1425
|
+
(_this$queue = this.queue) === null || _this$queue === void 0 || _this$queue.configure(options);
|
|
1426
|
+
var oldOptions = this.options;
|
|
1427
|
+
this.options = merge(oldOptions, options);
|
|
1428
|
+
return this;
|
|
1429
|
+
}
|
|
1825
1430
|
|
|
1826
|
-
/**
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
}
|
|
1431
|
+
/**
|
|
1432
|
+
* Adds a transform onto the end of the queue of transforms for this notifier
|
|
1433
|
+
*
|
|
1434
|
+
* @param {Function} transform - a function which takes three arguments:
|
|
1435
|
+
* - item: An Object representing the data to eventually be sent to Rollbar
|
|
1436
|
+
* - options: The current value of the options for this notifier
|
|
1437
|
+
* - callback: `function(err: (Null|Error), item: (Null|Object))` the
|
|
1438
|
+
* transform must call this callback with a null value for error if it
|
|
1439
|
+
* wants the processing chain to continue, otherwise with an error to
|
|
1440
|
+
* terminate the processing. The item should be the updated item after
|
|
1441
|
+
* this transform is finished modifying it.
|
|
1442
|
+
*/
|
|
1443
|
+
}, {
|
|
1444
|
+
key: "addTransform",
|
|
1445
|
+
value: function addTransform(transform) {
|
|
1446
|
+
if (isFunction(transform)) {
|
|
1447
|
+
this.transforms.push(transform);
|
|
1448
|
+
}
|
|
1449
|
+
return this;
|
|
1450
|
+
}
|
|
1846
1451
|
|
|
1847
|
-
/**
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
headers: headers
|
|
1869
|
-
});
|
|
1870
|
-
case 4:
|
|
1871
|
-
return _context.abrupt("return", _context.sent);
|
|
1872
|
-
case 5:
|
|
1873
|
-
case "end":
|
|
1874
|
-
return _context.stop();
|
|
1452
|
+
/**
|
|
1453
|
+
* The internal log function which applies the configured transforms and then
|
|
1454
|
+
* pushes onto the queue to be sent to the backend.
|
|
1455
|
+
*
|
|
1456
|
+
* @param {Object} item - An object with the following structure:
|
|
1457
|
+
* - message [String] - An optional string to be sent to rollbar
|
|
1458
|
+
* - error [Error] - An optional error
|
|
1459
|
+
* @param {Function} callback - A function of type `function(err, resp)` which
|
|
1460
|
+
* will be called with exactly one null argument and one non-null argument.
|
|
1461
|
+
* The callback will be called once, either during the transform stage if
|
|
1462
|
+
* an error occurs inside a transform, or in response to the communication
|
|
1463
|
+
* with the backend. The second argument will be the response from the
|
|
1464
|
+
* backend in case of success.
|
|
1465
|
+
*/
|
|
1466
|
+
}, {
|
|
1467
|
+
key: "log",
|
|
1468
|
+
value: function log(item, callback) {
|
|
1469
|
+
var _this = this;
|
|
1470
|
+
callback = isFunction(callback) ? callback : function () {};
|
|
1471
|
+
if (!this.options.enabled) {
|
|
1472
|
+
return callback(new Error('Rollbar is not enabled'), null);
|
|
1875
1473
|
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1474
|
+
this.queue.addPendingItem(item);
|
|
1475
|
+
var originalError = item.err;
|
|
1476
|
+
this._applyTransforms(item, function (err, i) {
|
|
1477
|
+
if (err) {
|
|
1478
|
+
_this.queue.removePendingItem(item);
|
|
1479
|
+
return callback(err, null);
|
|
1480
|
+
}
|
|
1481
|
+
_this.queue.addItem(i, callback, originalError, item);
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1882
1484
|
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
}
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1485
|
+
/* Internal */
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* Applies the transforms that have been added to this notifier sequentially.
|
|
1489
|
+
* See `addTransform` for more information.
|
|
1490
|
+
*
|
|
1491
|
+
* @param {Object} item - An item to be transformed
|
|
1492
|
+
* @param {Function} callback - A function of type `function(err, item)` which
|
|
1493
|
+
* will be called with a non-null error and a null item in the case of a
|
|
1494
|
+
* transform failure, or a null error and non-null item after all
|
|
1495
|
+
* transforms have been applied.
|
|
1496
|
+
*/
|
|
1497
|
+
}, {
|
|
1498
|
+
key: "_applyTransforms",
|
|
1499
|
+
value: function _applyTransforms(item, callback) {
|
|
1500
|
+
var transformIndex = -1;
|
|
1501
|
+
var transformsLength = this.transforms.length;
|
|
1502
|
+
var transforms = this.transforms;
|
|
1503
|
+
var options = this.options;
|
|
1504
|
+
var _next = function next(err, i) {
|
|
1505
|
+
if (err) {
|
|
1506
|
+
callback(err, null);
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
transformIndex++;
|
|
1510
|
+
if (transformIndex === transformsLength) {
|
|
1511
|
+
callback(null, i);
|
|
1512
|
+
return;
|
|
1513
|
+
}
|
|
1514
|
+
transforms[transformIndex](i, options, _next);
|
|
1515
|
+
};
|
|
1516
|
+
_next(null, item);
|
|
1899
1517
|
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1518
|
+
}]);
|
|
1519
|
+
}();
|
|
1520
|
+
|
|
1521
|
+
;// ./src/queue.js
|
|
1522
|
+
function queue_typeof(o) { "@babel/helpers - typeof"; return queue_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, queue_typeof(o); }
|
|
1523
|
+
function queue_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1524
|
+
function queue_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, queue_toPropertyKey(o.key), o); } }
|
|
1525
|
+
function queue_createClass(e, r, t) { return r && queue_defineProperties(e.prototype, r), t && queue_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1526
|
+
function queue_defineProperty(e, r, t) { return (r = queue_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
1527
|
+
function queue_toPropertyKey(t) { var i = queue_toPrimitive(t, "string"); return "symbol" == queue_typeof(i) ? i : i + ""; }
|
|
1528
|
+
function queue_toPrimitive(t, r) { if ("object" != queue_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != queue_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1529
|
+
|
|
1904
1530
|
|
|
1905
1531
|
/**
|
|
1906
|
-
*
|
|
1907
|
-
*
|
|
1908
|
-
*
|
|
1532
|
+
* Queue - an object which handles which handles a queue of items to be sent to Rollbar.
|
|
1533
|
+
* This object handles rate limiting via a passed in rate limiter, retries based on connection
|
|
1534
|
+
* errors, and filtering of items based on a set of configurable predicates. The communication to
|
|
1535
|
+
* the backend is performed via a given API object.
|
|
1909
1536
|
*/
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1537
|
+
var Queue = /*#__PURE__*/function () {
|
|
1538
|
+
/**
|
|
1539
|
+
* @param rateLimiter - An object which conforms to the interface
|
|
1540
|
+
* `rateLimiter.shouldSend(item) -> bool`
|
|
1541
|
+
* @param api - An object which conforms to the interface
|
|
1542
|
+
* `api.postItem(payload, function(err, response))`
|
|
1543
|
+
* @param logger - An object used to log verbose messages if desired
|
|
1544
|
+
* @param options - see `Queue.prototype.configure`
|
|
1545
|
+
* @param replay - Optional `Replay` for coordinating session replay with error occurrences
|
|
1546
|
+
*/
|
|
1547
|
+
function Queue(rateLimiter, api, logger, options, replay) {
|
|
1548
|
+
queue_classCallCheck(this, Queue);
|
|
1549
|
+
this.rateLimiter = rateLimiter;
|
|
1550
|
+
this.api = api;
|
|
1551
|
+
this.logger = logger;
|
|
1552
|
+
this.options = options;
|
|
1553
|
+
this.replay = replay;
|
|
1554
|
+
this.predicates = [];
|
|
1555
|
+
this.pendingItems = [];
|
|
1556
|
+
this.pendingRequests = [];
|
|
1557
|
+
this.retryQueue = [];
|
|
1558
|
+
this.retryHandle = null;
|
|
1559
|
+
this.waitCallback = null;
|
|
1560
|
+
this.waitIntervalID = null;
|
|
1921
1561
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
var _log = function log() {};
|
|
1937
|
-
var levels = {
|
|
1938
|
-
debug: 0,
|
|
1939
|
-
info: 1,
|
|
1940
|
-
warn: 2,
|
|
1941
|
-
error: 3,
|
|
1942
|
-
disable: 4
|
|
1943
|
-
};
|
|
1944
|
-
var logger = {
|
|
1945
|
-
error: function error() {
|
|
1946
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1947
|
-
args[_key] = arguments[_key];
|
|
1562
|
+
|
|
1563
|
+
/**
|
|
1564
|
+
* configure - updates the options this queue uses
|
|
1565
|
+
*
|
|
1566
|
+
* @param options
|
|
1567
|
+
*/
|
|
1568
|
+
return queue_createClass(Queue, [{
|
|
1569
|
+
key: "configure",
|
|
1570
|
+
value: function configure(options) {
|
|
1571
|
+
var _this$api;
|
|
1572
|
+
(_this$api = this.api) === null || _this$api === void 0 || _this$api.configure(options);
|
|
1573
|
+
var oldOptions = this.options;
|
|
1574
|
+
this.options = merge(oldOptions, options);
|
|
1575
|
+
return this;
|
|
1948
1576
|
}
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* addPredicate - adds a predicate to the end of the list of predicates for this queue
|
|
1580
|
+
*
|
|
1581
|
+
* @param predicate - function(item, options) -> (bool|{err: Error})
|
|
1582
|
+
* Returning true means that this predicate passes and the item is okay to go on the queue
|
|
1583
|
+
* Returning false means do not add the item to the queue, but it is not an error
|
|
1584
|
+
* Returning {err: Error} means do not add the item to the queue, and the given error explains why
|
|
1585
|
+
* Returning {err: undefined} is equivalent to returning true but don't do that
|
|
1586
|
+
*/
|
|
1587
|
+
}, {
|
|
1588
|
+
key: "addPredicate",
|
|
1589
|
+
value: function addPredicate(predicate) {
|
|
1590
|
+
if (isFunction(predicate)) {
|
|
1591
|
+
this.predicates.push(predicate);
|
|
1592
|
+
}
|
|
1593
|
+
return this;
|
|
1954
1594
|
}
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
args[_key3] = arguments[_key3];
|
|
1595
|
+
}, {
|
|
1596
|
+
key: "addPendingItem",
|
|
1597
|
+
value: function addPendingItem(item) {
|
|
1598
|
+
this.pendingItems.push(item);
|
|
1960
1599
|
}
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1600
|
+
}, {
|
|
1601
|
+
key: "removePendingItem",
|
|
1602
|
+
value: function removePendingItem(item) {
|
|
1603
|
+
var idx = this.pendingItems.indexOf(item);
|
|
1604
|
+
if (idx !== -1) {
|
|
1605
|
+
this.pendingItems.splice(idx, 1);
|
|
1606
|
+
}
|
|
1966
1607
|
}
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1608
|
+
|
|
1609
|
+
/**
|
|
1610
|
+
* addItem - Send an item to the Rollbar API if all of the predicates are satisfied
|
|
1611
|
+
*
|
|
1612
|
+
* @param item - Item instance with the payload to send to the backend
|
|
1613
|
+
* @param callback - function(error, repsonse) which will be called with the response from the API
|
|
1614
|
+
* in the case of a success, otherwise response will be null and error will have a value. If both
|
|
1615
|
+
* error and response are null then the item was stopped by a predicate which did not consider this
|
|
1616
|
+
* to be an error condition, but nonetheless did not send the item to the API.
|
|
1617
|
+
* @param originalError - The original error before any transformations that is to be logged if any
|
|
1618
|
+
* @param originalItem - The original item before transforms, used in pendingItems queue
|
|
1619
|
+
*/
|
|
1620
|
+
}, {
|
|
1621
|
+
key: "addItem",
|
|
1622
|
+
value: function addItem(item, callback, originalError, originalItem) {
|
|
1623
|
+
var _this = this;
|
|
1624
|
+
if (!callback || !isFunction(callback)) {
|
|
1625
|
+
callback = function callback() {
|
|
1626
|
+
return;
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
var data = item.data;
|
|
1630
|
+
var predicateResult = this._applyPredicates(data);
|
|
1631
|
+
if (predicateResult.stop) {
|
|
1632
|
+
this.removePendingItem(originalItem);
|
|
1633
|
+
callback(predicateResult.err);
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
this._maybeLog(data, originalError);
|
|
1637
|
+
this.removePendingItem(originalItem);
|
|
1638
|
+
if (!this.options.transmit) {
|
|
1639
|
+
callback(new Error('Transmit disabled'));
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
if (this.replay && data.body) {
|
|
1643
|
+
item.replayId = this.replay.capture(null, data.uuid, {
|
|
1644
|
+
type: 'occurrence',
|
|
1645
|
+
level: item.level
|
|
1646
|
+
});
|
|
1647
|
+
if (item.replayId) {
|
|
1648
|
+
addItemAttributes(item.data, [{
|
|
1649
|
+
key: 'replay_id',
|
|
1650
|
+
value: item.replayId
|
|
1651
|
+
}]);
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
this.pendingRequests.push(data);
|
|
1655
|
+
try {
|
|
1656
|
+
this._makeApiRequest(data, function (err, resp, headers) {
|
|
1657
|
+
_this._dequeuePendingRequest(data);
|
|
1658
|
+
if (item.replayId) {
|
|
1659
|
+
_this.replay.sendOrDiscardReplay(item.replayId, err, resp, headers);
|
|
1660
|
+
}
|
|
1661
|
+
callback(err, resp);
|
|
1662
|
+
});
|
|
1663
|
+
} catch (err) {
|
|
1664
|
+
this._dequeuePendingRequest(data);
|
|
1665
|
+
if (item.replayId) {
|
|
1666
|
+
var _this$replay;
|
|
1667
|
+
(_this$replay = this.replay) === null || _this$replay === void 0 || _this$replay.discard(item.replayId);
|
|
1668
|
+
}
|
|
1669
|
+
callback(err);
|
|
1670
|
+
}
|
|
1972
1671
|
}
|
|
1973
|
-
return _log('info', args);
|
|
1974
|
-
},
|
|
1975
|
-
init: function init(_ref) {
|
|
1976
|
-
var logLevel = _ref.logLevel;
|
|
1977
|
-
_log = function _log(level, args) {
|
|
1978
|
-
if (levels[level] < levels[logLevel]) return;
|
|
1979
|
-
args.unshift('Rollbar:');
|
|
1980
|
-
console[level].apply(console, args);
|
|
1981
|
-
};
|
|
1982
|
-
}
|
|
1983
|
-
};
|
|
1984
|
-
/* harmony default export */ const src_logger = (logger);
|
|
1985
|
-
;// ./src/defaults.js
|
|
1986
|
-
/**
|
|
1987
|
-
* Default options shared across platforms
|
|
1988
|
-
*/
|
|
1989
|
-
var version = '3.0.0-beta.5';
|
|
1990
|
-
var endpoint = 'api.rollbar.com/api/1/item/';
|
|
1991
|
-
var logLevel = 'debug';
|
|
1992
|
-
var reportLevel = 'debug';
|
|
1993
|
-
var uncaughtErrorLevel = 'error';
|
|
1994
|
-
var maxItems = 0;
|
|
1995
|
-
var itemsPerMin = 60;
|
|
1996
|
-
var commonScrubFields = ['pw', 'pass', 'passwd', 'password', 'secret', 'confirm_password', 'confirmPassword', 'password_confirmation', 'passwordConfirmation', 'access_token', 'accessToken', 'X-Rollbar-Access-Token', 'secret_key', 'secretKey', 'secretToken'];
|
|
1997
|
-
var apiScrubFields = ['api_key', 'authenticity_token', 'oauth_token', 'token', 'user_session_secret'];
|
|
1998
|
-
var requestScrubFields = ['request.session.csrf', 'request.session._csrf', 'request.params._csrf', 'request.cookie', 'request.cookies'];
|
|
1999
|
-
var commonScrubHeaders = ['authorization', 'www-authorization', 'http_authorization', 'omniauth.auth', 'cookie', 'oauth-access-token', 'x-access-token', 'x_csrf_token', 'http_x_csrf_token', 'x-csrf-token'];
|
|
2000
1672
|
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
1673
|
+
/**
|
|
1674
|
+
* wait - Stop any further errors from being added to the queue, and get called back when all items
|
|
1675
|
+
* currently processing have finished sending to the backend.
|
|
1676
|
+
*
|
|
1677
|
+
* @param callback - function() called when all pending items have been sent
|
|
1678
|
+
*/
|
|
1679
|
+
}, {
|
|
1680
|
+
key: "wait",
|
|
1681
|
+
value: function wait(callback) {
|
|
1682
|
+
var _this2 = this;
|
|
1683
|
+
if (!isFunction(callback)) {
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
this.waitCallback = callback;
|
|
1687
|
+
if (this._maybeCallWait()) {
|
|
1688
|
+
return;
|
|
1689
|
+
}
|
|
1690
|
+
if (this.waitIntervalID) {
|
|
1691
|
+
this.waitIntervalID = clearInterval(this.waitIntervalID);
|
|
1692
|
+
}
|
|
1693
|
+
this.waitIntervalID = setInterval(function () {
|
|
1694
|
+
_this2._maybeCallWait();
|
|
1695
|
+
}, 500);
|
|
1696
|
+
}
|
|
2021
1697
|
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
1698
|
+
/**
|
|
1699
|
+
* Sequentially applies the predicates that have been added to the queue to the
|
|
1700
|
+
* given item with the currently configured options.
|
|
1701
|
+
*
|
|
1702
|
+
* @param item - An item in the queue
|
|
1703
|
+
* @returns {stop: bool, err: (Error|null)} - stop being true means do not add item to the queue,
|
|
1704
|
+
* the error value should be passed up to a callbak if we are stopping.
|
|
1705
|
+
*/
|
|
1706
|
+
}, {
|
|
1707
|
+
key: "_applyPredicates",
|
|
1708
|
+
value: function _applyPredicates(item) {
|
|
1709
|
+
var p = null;
|
|
1710
|
+
for (var i = 0, len = this.predicates.length; i < len; i++) {
|
|
1711
|
+
p = this.predicates[i](item, this.options);
|
|
1712
|
+
if (!p || p.err !== undefined) {
|
|
1713
|
+
return {
|
|
1714
|
+
stop: true,
|
|
1715
|
+
err: p.err
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
return {
|
|
1720
|
+
stop: false,
|
|
1721
|
+
err: null
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
2026
1724
|
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
1725
|
+
/**
|
|
1726
|
+
* Send an item to Rollbar, callback when done, if there is an error make an
|
|
1727
|
+
* effort to retry if we are configured to do so.
|
|
1728
|
+
*
|
|
1729
|
+
* @param item - an item ready to send to the backend
|
|
1730
|
+
* @param callback - function(err, response)
|
|
1731
|
+
*/
|
|
1732
|
+
}, {
|
|
1733
|
+
key: "_makeApiRequest",
|
|
1734
|
+
value: function _makeApiRequest(item, callback) {
|
|
1735
|
+
var _this3 = this;
|
|
1736
|
+
var rateLimitResponse = this.rateLimiter.shouldSend(item);
|
|
1737
|
+
if (rateLimitResponse.shouldSend) {
|
|
1738
|
+
this.api.postItem(item, function (err, resp, headers) {
|
|
1739
|
+
if (err) {
|
|
1740
|
+
_this3._maybeRetry(err, item, callback);
|
|
1741
|
+
} else {
|
|
1742
|
+
callback(err, resp, headers);
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1745
|
+
} else if (rateLimitResponse.error) {
|
|
1746
|
+
callback(rateLimitResponse.error);
|
|
1747
|
+
} else {
|
|
1748
|
+
this.api.postItem(rateLimitResponse.payload, callback);
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
2033
1751
|
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
1752
|
+
// These are errors basically mean there is no internet connection
|
|
1753
|
+
}, {
|
|
1754
|
+
key: "_maybeRetry",
|
|
1755
|
+
value:
|
|
1756
|
+
/**
|
|
1757
|
+
* Given the error returned by the API, decide if we should retry or just callback
|
|
1758
|
+
* with the error.
|
|
1759
|
+
*
|
|
1760
|
+
* @param err - an error returned by the API transport
|
|
1761
|
+
* @param item - the item that was trying to be sent when this error occured
|
|
1762
|
+
* @param callback - function(err, response)
|
|
1763
|
+
*/
|
|
1764
|
+
function _maybeRetry(err, item, callback) {
|
|
1765
|
+
var shouldRetry = false;
|
|
1766
|
+
if (this.options.retryInterval) {
|
|
1767
|
+
for (var i = 0, len = Queue.RETRIABLE_ERRORS.length; i < len; i++) {
|
|
1768
|
+
if (err.code === Queue.RETRIABLE_ERRORS[i]) {
|
|
1769
|
+
shouldRetry = true;
|
|
1770
|
+
break;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
if (shouldRetry && isFiniteNumber(this.options.maxRetries)) {
|
|
1774
|
+
item.retries = item.retries ? item.retries + 1 : 1;
|
|
1775
|
+
if (item.retries > this.options.maxRetries) {
|
|
1776
|
+
shouldRetry = false;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
if (shouldRetry) {
|
|
1781
|
+
this._retryApiRequest(item, callback);
|
|
1782
|
+
} else {
|
|
1783
|
+
callback(err);
|
|
1784
|
+
}
|
|
2044
1785
|
}
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Add an item and a callback to a queue and possibly start a timer to process
|
|
1789
|
+
* that queue based on the retryInterval in the options for this queue.
|
|
1790
|
+
*
|
|
1791
|
+
* @param item - an item that failed to send due to an error we deem retriable
|
|
1792
|
+
* @param callback - function(err, response)
|
|
1793
|
+
*/
|
|
1794
|
+
}, {
|
|
1795
|
+
key: "_retryApiRequest",
|
|
1796
|
+
value: function _retryApiRequest(item, callback) {
|
|
1797
|
+
var _this4 = this;
|
|
1798
|
+
this.retryQueue.push({
|
|
1799
|
+
item: item,
|
|
1800
|
+
callback: callback
|
|
1801
|
+
});
|
|
1802
|
+
if (!this.retryHandle) {
|
|
1803
|
+
this.retryHandle = setInterval(function () {
|
|
1804
|
+
while (_this4.retryQueue.length) {
|
|
1805
|
+
var retryObject = _this4.retryQueue.shift();
|
|
1806
|
+
_this4._makeApiRequest(retryObject.item, retryObject.callback);
|
|
1807
|
+
}
|
|
1808
|
+
}, this.options.retryInterval);
|
|
2052
1809
|
}
|
|
2053
1810
|
}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* Removes the item from the pending request queue, this queue is used to
|
|
1814
|
+
* enable to functionality of providing a callback that clients can pass to `wait` to be notified
|
|
1815
|
+
* when the pending request queue has been emptied. This must be called when the API finishes
|
|
1816
|
+
* processing this item. If a `wait` callback is configured, it is called by this function.
|
|
1817
|
+
*
|
|
1818
|
+
* @param item - the item previously added to the pending request queue
|
|
1819
|
+
*/
|
|
1820
|
+
}, {
|
|
1821
|
+
key: "_dequeuePendingRequest",
|
|
1822
|
+
value: function _dequeuePendingRequest(item) {
|
|
1823
|
+
var idx = this.pendingRequests.indexOf(item);
|
|
1824
|
+
if (idx !== -1) {
|
|
1825
|
+
this.pendingRequests.splice(idx, 1);
|
|
1826
|
+
this._maybeCallWait();
|
|
1827
|
+
}
|
|
2057
1828
|
}
|
|
2058
|
-
}
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
|
-
|
|
1829
|
+
}, {
|
|
1830
|
+
key: "_maybeLog",
|
|
1831
|
+
value: function _maybeLog(data, originalError) {
|
|
1832
|
+
if (this.logger && this.options.verbose) {
|
|
1833
|
+
var message = originalError || get(data, 'body.trace.exception.message') || get(data, 'body.trace_chain.0.exception.message');
|
|
1834
|
+
if (message) {
|
|
1835
|
+
this.logger.error(message);
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
message = get(data, 'body.message.body');
|
|
1839
|
+
if (message) {
|
|
1840
|
+
this.logger.log(message);
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
}, {
|
|
1845
|
+
key: "_maybeCallWait",
|
|
1846
|
+
value: function _maybeCallWait() {
|
|
1847
|
+
if (isFunction(this.waitCallback) && this.pendingItems.length === 0 && this.pendingRequests.length === 0) {
|
|
1848
|
+
if (this.waitIntervalID) {
|
|
1849
|
+
this.waitIntervalID = clearInterval(this.waitIntervalID);
|
|
1850
|
+
}
|
|
1851
|
+
this.waitCallback();
|
|
1852
|
+
return true;
|
|
1853
|
+
}
|
|
1854
|
+
return false;
|
|
1855
|
+
}
|
|
1856
|
+
}]);
|
|
1857
|
+
}();
|
|
1858
|
+
queue_defineProperty(Queue, "RETRIABLE_ERRORS", ['ECONNRESET', 'ENOTFOUND', 'ESOCKETTIMEDOUT', 'ETIMEDOUT', 'ECONNREFUSED', 'EHOSTUNREACH', 'EPIPE', 'EAI_AGAIN']);
|
|
1859
|
+
/* harmony default export */ const queue = (Queue);
|
|
1860
|
+
;// ./src/rateLimiter.js
|
|
1861
|
+
function rateLimiter_typeof(o) { "@babel/helpers - typeof"; return rateLimiter_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, rateLimiter_typeof(o); }
|
|
1862
|
+
function _readOnlyError(r) { throw new TypeError('"' + r + '" is read-only'); }
|
|
1863
|
+
function rateLimiter_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
1864
|
+
function rateLimiter_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, rateLimiter_toPropertyKey(o.key), o); } }
|
|
1865
|
+
function rateLimiter_createClass(e, r, t) { return r && rateLimiter_defineProperties(e.prototype, r), t && rateLimiter_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
1866
|
+
function rateLimiter_defineProperty(e, r, t) { return (r = rateLimiter_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
1867
|
+
function rateLimiter_toPropertyKey(t) { var i = rateLimiter_toPrimitive(t, "string"); return "symbol" == rateLimiter_typeof(i) ? i : i + ""; }
|
|
1868
|
+
function rateLimiter_toPrimitive(t, r) { if ("object" != rateLimiter_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != rateLimiter_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1869
|
+
/*
|
|
1870
|
+
* RateLimiter - encapsulates the logic for counting items sent to Rollbar.
|
|
1871
|
+
*
|
|
1872
|
+
* @param options - the same options that are accepted by configureGlobal offered as a convenience
|
|
1873
|
+
*/
|
|
1874
|
+
var RateLimiter = /*#__PURE__*/function () {
|
|
1875
|
+
function RateLimiter() {
|
|
1876
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1877
|
+
rateLimiter_classCallCheck(this, RateLimiter);
|
|
1878
|
+
this.startTime = Date.now();
|
|
1879
|
+
this.counter = 0;
|
|
1880
|
+
this.perMinCounter = 0;
|
|
1881
|
+
this.platform = null;
|
|
1882
|
+
this.platformOptions = {};
|
|
1883
|
+
this.configureGlobal(options);
|
|
1884
|
+
}
|
|
2074
1885
|
|
|
1886
|
+
/*
|
|
1887
|
+
* configureGlobal - set the global rate limiter options
|
|
1888
|
+
*
|
|
1889
|
+
* @param options - Only the following values are recognized:
|
|
1890
|
+
* startTime: a timestamp of the form returned by (new Date()).getTime()
|
|
1891
|
+
* maxItems: the maximum items
|
|
1892
|
+
* itemsPerMinute: the max number of items to send in a given minute
|
|
1893
|
+
*/
|
|
1894
|
+
return rateLimiter_createClass(RateLimiter, [{
|
|
1895
|
+
key: "configureGlobal",
|
|
1896
|
+
value: function configureGlobal() {
|
|
1897
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1898
|
+
var startTime = options.startTime,
|
|
1899
|
+
maxItems = options.maxItems,
|
|
1900
|
+
itemsPerMinute = options.itemsPerMinute;
|
|
1901
|
+
if (startTime !== undefined) {
|
|
1902
|
+
RateLimiter.globalSettings.startTime = startTime;
|
|
1903
|
+
}
|
|
1904
|
+
if (maxItems !== undefined) {
|
|
1905
|
+
RateLimiter.globalSettings.maxItems = maxItems;
|
|
1906
|
+
}
|
|
1907
|
+
if (itemsPerMinute !== undefined) {
|
|
1908
|
+
RateLimiter.globalSettings.itemsPerMinute = itemsPerMinute;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
2075
1911
|
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
1912
|
+
/*
|
|
1913
|
+
* shouldSend - determine if we should send a given item based on rate limit settings
|
|
1914
|
+
*
|
|
1915
|
+
* @param item - the item we are about to send
|
|
1916
|
+
* @returns An object with the following structure:
|
|
1917
|
+
* error: (Error|null)
|
|
1918
|
+
* shouldSend: bool
|
|
1919
|
+
* payload: (Object|null)
|
|
1920
|
+
* If shouldSend is false, the item passed as a parameter should not be sent to Rollbar, and
|
|
1921
|
+
* exactly one of error or payload will be non-null. If error is non-null, the returned Error will
|
|
1922
|
+
* describe the situation, but it means that we were already over a rate limit (either globally or
|
|
1923
|
+
* per minute) when this item was checked. If error is null, and therefore payload is non-null, it
|
|
1924
|
+
* means this item put us over the global rate limit and the payload should be sent to Rollbar in
|
|
1925
|
+
* place of the passed in item.
|
|
1926
|
+
*/
|
|
1927
|
+
}, {
|
|
1928
|
+
key: "shouldSend",
|
|
1929
|
+
value: function shouldSend(item) {
|
|
1930
|
+
var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
|
|
1931
|
+
var elapsedTime = now - this.startTime;
|
|
1932
|
+
if (elapsedTime < 0 || elapsedTime >= 60000) {
|
|
1933
|
+
this.startTime = now;
|
|
1934
|
+
this.perMinCounter = 0;
|
|
1935
|
+
}
|
|
1936
|
+
var globalRateLimit = RateLimiter.globalSettings.maxItems;
|
|
1937
|
+
var globalRateLimitPerMin = RateLimiter.globalSettings.itemsPerMinute;
|
|
1938
|
+
if (checkRate(item, globalRateLimit, this.counter)) {
|
|
1939
|
+
return shouldSendValue(this.platform, this.platformOptions, "".concat(globalRateLimit, " max items reached"), false);
|
|
1940
|
+
}
|
|
1941
|
+
if (checkRate(item, globalRateLimitPerMin, this.perMinCounter)) {
|
|
1942
|
+
return shouldSendValue(this.platform, this.platformOptions, "".concat(globalRateLimitPerMin, " items per minute reached"), false);
|
|
1943
|
+
}
|
|
1944
|
+
this.counter += 1;
|
|
1945
|
+
this.perMinCounter += 1;
|
|
1946
|
+
var underGlobalLimit = !checkRate(item, globalRateLimit, this.counter);
|
|
1947
|
+
var perMinute = underGlobalLimit;
|
|
1948
|
+
var shouldSend = underGlobalLimit && !checkRate(item, globalRateLimitPerMin, this.perMinCounter);
|
|
1949
|
+
return shouldSendValue(this.platform, this.platformOptions, null, shouldSend, globalRateLimit, globalRateLimitPerMin, perMinute);
|
|
2096
1950
|
}
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
return [payload, stringify(payload, jsonBackup)];
|
|
2103
|
-
}
|
|
2104
|
-
function maybeTruncateValue(len, val) {
|
|
2105
|
-
if (!val) {
|
|
2106
|
-
return val;
|
|
2107
|
-
}
|
|
2108
|
-
if (val.length > len) {
|
|
2109
|
-
return val.slice(0, len - 3).concat('...');
|
|
2110
|
-
}
|
|
2111
|
-
return val;
|
|
2112
|
-
}
|
|
2113
|
-
function truncateStrings(len, payload, jsonBackup) {
|
|
2114
|
-
function truncator(k, v, seen) {
|
|
2115
|
-
switch (typeName(v)) {
|
|
2116
|
-
case 'string':
|
|
2117
|
-
return maybeTruncateValue(len, v);
|
|
2118
|
-
case 'object':
|
|
2119
|
-
case 'array':
|
|
2120
|
-
return utility_traverse(v, truncator, seen);
|
|
2121
|
-
default:
|
|
2122
|
-
return v;
|
|
1951
|
+
}, {
|
|
1952
|
+
key: "setPlatformOptions",
|
|
1953
|
+
value: function setPlatformOptions(platform, options) {
|
|
1954
|
+
this.platform = platform;
|
|
1955
|
+
this.platformOptions = options;
|
|
2123
1956
|
}
|
|
2124
|
-
}
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
return traceData;
|
|
1957
|
+
}]);
|
|
1958
|
+
}();
|
|
1959
|
+
/* Helpers */
|
|
1960
|
+
rateLimiter_defineProperty(RateLimiter, "globalSettings", {
|
|
1961
|
+
startTime: Date.now(),
|
|
1962
|
+
maxItems: undefined,
|
|
1963
|
+
itemsPerMinute: undefined
|
|
1964
|
+
});
|
|
1965
|
+
function checkRate(item, limit, counter) {
|
|
1966
|
+
return !item.ignoreRateLimit && limit >= 1 && counter > limit;
|
|
2135
1967
|
}
|
|
2136
|
-
function
|
|
2137
|
-
var
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
chain[i] = truncateTraceData(chain[i]);
|
|
2142
|
-
}
|
|
2143
|
-
} else if (body.trace) {
|
|
2144
|
-
body.trace = truncateTraceData(body.trace);
|
|
1968
|
+
function shouldSendValue(platform, options, error, shouldSend, globalRateLimit, limitPerMin, perMinute) {
|
|
1969
|
+
var payload = null;
|
|
1970
|
+
var errorResult = error ? new Error(error) : null;
|
|
1971
|
+
if (!errorResult && !shouldSend) {
|
|
1972
|
+
payload = rateLimitPayload(platform, options, globalRateLimit, limitPerMin, perMinute);
|
|
2145
1973
|
}
|
|
2146
|
-
return
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
1974
|
+
return {
|
|
1975
|
+
error: errorResult,
|
|
1976
|
+
shouldSend: shouldSend,
|
|
1977
|
+
payload: payload
|
|
1978
|
+
};
|
|
2150
1979
|
}
|
|
2151
|
-
function
|
|
2152
|
-
|
|
2153
|
-
var
|
|
2154
|
-
var
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
1980
|
+
function rateLimitPayload(platform, options, globalRateLimit, limitPerMin, perMinute) {
|
|
1981
|
+
var environment = options.environment || options.payload && options.payload.environment;
|
|
1982
|
+
var msg = perMinute ? 'item per minute limit reached, ignoring errors until timeout' : 'maxItems has been hit, ignoring errors until reset.';
|
|
1983
|
+
var item = {
|
|
1984
|
+
body: {
|
|
1985
|
+
message: {
|
|
1986
|
+
body: msg,
|
|
1987
|
+
extra: {
|
|
1988
|
+
maxItems: globalRateLimit,
|
|
1989
|
+
itemsPerMinute: limitPerMin
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
},
|
|
1993
|
+
language: 'javascript',
|
|
1994
|
+
environment: environment,
|
|
1995
|
+
notifier: {
|
|
1996
|
+
version: options.notifier && options.notifier.version || options.version
|
|
2161
1997
|
}
|
|
1998
|
+
};
|
|
1999
|
+
if (platform === 'browser') {
|
|
2000
|
+
item.platform = 'browser';
|
|
2001
|
+
item.framework = 'browser-js';
|
|
2002
|
+
item.notifier.name = 'rollbar-browser-js';
|
|
2003
|
+
} else if (platform === 'server') {
|
|
2004
|
+
item.framework = options.framework || 'node-js';
|
|
2005
|
+
item.notifier.name = options.notifier.name;
|
|
2006
|
+
} else if (platform === 'react-native') {
|
|
2007
|
+
item.framework = options.framework || 'react-native';
|
|
2008
|
+
item.notifier.name = options.notifier.name;
|
|
2162
2009
|
}
|
|
2163
|
-
return
|
|
2010
|
+
return item;
|
|
2164
2011
|
}
|
|
2165
|
-
/* harmony default export */ const
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
raw: raw,
|
|
2169
|
-
truncateFrames: truncateFrames,
|
|
2170
|
-
truncateStrings: truncateStrings,
|
|
2171
|
-
maybeTruncateValue: maybeTruncateValue
|
|
2172
|
-
});
|
|
2173
|
-
;// external "http"
|
|
2174
|
-
const external_http_namespaceObject = require("http");
|
|
2175
|
-
;// external "https"
|
|
2176
|
-
const external_https_namespaceObject = require("https");
|
|
2177
|
-
;// external "json-stringify-safe"
|
|
2178
|
-
const external_json_stringify_safe_namespaceObject = require("json-stringify-safe");
|
|
2179
|
-
;// ./src/server/transport.js
|
|
2012
|
+
/* harmony default export */ const rateLimiter = (RateLimiter);
|
|
2013
|
+
;// ./src/rollbar.js
|
|
2014
|
+
|
|
2180
2015
|
|
|
2181
2016
|
|
|
2182
2017
|
|
|
2183
2018
|
|
|
2019
|
+
/*
|
|
2020
|
+
* Rollbar - the interface to Rollbar
|
|
2021
|
+
*
|
|
2022
|
+
* @param options
|
|
2023
|
+
* @param api
|
|
2024
|
+
* @param logger
|
|
2025
|
+
*/
|
|
2026
|
+
function Rollbar(options, api, logger, telemeter, tracing, replay, platform) {
|
|
2027
|
+
this.options = merge(options);
|
|
2028
|
+
this.logger = logger;
|
|
2029
|
+
Rollbar.rateLimiter.configureGlobal(this.options);
|
|
2030
|
+
Rollbar.rateLimiter.setPlatformOptions(platform, this.options);
|
|
2031
|
+
this.api = api;
|
|
2032
|
+
this.queue = new queue(Rollbar.rateLimiter, api, logger, this.options, replay);
|
|
2033
|
+
this.tracing = tracing;
|
|
2034
|
+
|
|
2035
|
+
// Legacy OpenTracing support
|
|
2036
|
+
// This must happen before the Notifier is created
|
|
2037
|
+
var tracer = this.options.tracer || null;
|
|
2038
|
+
if (validateTracer(tracer)) {
|
|
2039
|
+
this.tracer = tracer;
|
|
2040
|
+
// set to a string for api response serialization
|
|
2041
|
+
this.options.tracer = 'opentracing-tracer-enabled';
|
|
2042
|
+
this.options._configuredOptions.tracer = 'opentracing-tracer-enabled';
|
|
2043
|
+
} else {
|
|
2044
|
+
this.tracer = null;
|
|
2045
|
+
}
|
|
2046
|
+
this.notifier = new Notifier(this.queue, this.options);
|
|
2047
|
+
this.telemeter = telemeter;
|
|
2048
|
+
setStackTraceLimit(options);
|
|
2049
|
+
this.lastError = null;
|
|
2050
|
+
this.lastErrorHash = 'none';
|
|
2051
|
+
}
|
|
2052
|
+
var rollbar_defaultOptions = {
|
|
2053
|
+
maxItems: 0,
|
|
2054
|
+
itemsPerMinute: 60
|
|
2055
|
+
};
|
|
2056
|
+
Rollbar.rateLimiter = new rateLimiter(rollbar_defaultOptions);
|
|
2057
|
+
Rollbar.prototype.global = function (options) {
|
|
2058
|
+
Rollbar.rateLimiter.configureGlobal(options);
|
|
2059
|
+
return this;
|
|
2060
|
+
};
|
|
2061
|
+
Rollbar.prototype.configure = function (options, payloadData) {
|
|
2062
|
+
var oldOptions = this.options;
|
|
2063
|
+
var payload = {};
|
|
2064
|
+
if (payloadData) {
|
|
2065
|
+
payload = {
|
|
2066
|
+
payload: payloadData
|
|
2067
|
+
};
|
|
2068
|
+
}
|
|
2069
|
+
this.options = merge(oldOptions, options, payload);
|
|
2184
2070
|
|
|
2071
|
+
// Legacy OpenTracing support
|
|
2072
|
+
// This must happen before the Notifier is configured
|
|
2073
|
+
var tracer = this.options.tracer || null;
|
|
2074
|
+
if (validateTracer(tracer)) {
|
|
2075
|
+
this.tracer = tracer;
|
|
2076
|
+
// set to a string for api response serialization
|
|
2077
|
+
this.options.tracer = 'opentracing-tracer-enabled';
|
|
2078
|
+
this.options._configuredOptions.tracer = 'opentracing-tracer-enabled';
|
|
2079
|
+
} else {
|
|
2080
|
+
this.tracer = null;
|
|
2081
|
+
}
|
|
2082
|
+
this.notifier && this.notifier.configure(this.options);
|
|
2083
|
+
this.telemeter && this.telemeter.configure(this.options);
|
|
2084
|
+
setStackTraceLimit(options);
|
|
2085
|
+
this.global(this.options);
|
|
2086
|
+
if (validateTracer(options.tracer)) {
|
|
2087
|
+
this.tracer = options.tracer;
|
|
2088
|
+
}
|
|
2089
|
+
return this;
|
|
2090
|
+
};
|
|
2091
|
+
Rollbar.prototype.log = function (item) {
|
|
2092
|
+
var level = this._defaultLogLevel();
|
|
2093
|
+
return this._log(level, item);
|
|
2094
|
+
};
|
|
2095
|
+
Rollbar.prototype.debug = function (item) {
|
|
2096
|
+
this._log('debug', item);
|
|
2097
|
+
};
|
|
2098
|
+
Rollbar.prototype.info = function (item) {
|
|
2099
|
+
this._log('info', item);
|
|
2100
|
+
};
|
|
2101
|
+
Rollbar.prototype.warn = function (item) {
|
|
2102
|
+
this._log('warning', item);
|
|
2103
|
+
};
|
|
2104
|
+
Rollbar.prototype.warning = function (item) {
|
|
2105
|
+
this._log('warning', item);
|
|
2106
|
+
};
|
|
2107
|
+
Rollbar.prototype.error = function (item) {
|
|
2108
|
+
this._log('error', item);
|
|
2109
|
+
};
|
|
2110
|
+
Rollbar.prototype.critical = function (item) {
|
|
2111
|
+
this._log('critical', item);
|
|
2112
|
+
};
|
|
2113
|
+
Rollbar.prototype.wait = function (callback) {
|
|
2114
|
+
this.queue.wait(callback);
|
|
2115
|
+
};
|
|
2116
|
+
Rollbar.prototype.captureEvent = function (type, metadata, level) {
|
|
2117
|
+
return this.telemeter && this.telemeter.captureEvent(type, metadata, level);
|
|
2118
|
+
};
|
|
2119
|
+
Rollbar.prototype.captureDomContentLoaded = function (ts) {
|
|
2120
|
+
return this.telemeter && this.telemeter.captureDomContentLoaded(ts);
|
|
2121
|
+
};
|
|
2122
|
+
Rollbar.prototype.captureLoad = function (ts) {
|
|
2123
|
+
return this.telemeter && this.telemeter.captureLoad(ts);
|
|
2124
|
+
};
|
|
2125
|
+
Rollbar.prototype.buildJsonPayload = function (item) {
|
|
2126
|
+
return this.api.buildJsonPayload(item);
|
|
2127
|
+
};
|
|
2128
|
+
Rollbar.prototype.sendJsonPayload = function (jsonPayload) {
|
|
2129
|
+
this.api.postJsonPayload(jsonPayload);
|
|
2130
|
+
};
|
|
2185
2131
|
|
|
2186
|
-
|
|
2132
|
+
/* Internal */
|
|
2187
2133
|
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
* protocol
|
|
2194
|
-
* path
|
|
2195
|
-
* port
|
|
2196
|
-
* method
|
|
2197
|
-
* }
|
|
2198
|
-
*
|
|
2199
|
-
* params is an object containing key/value pairs to be
|
|
2200
|
-
* appended to the path as 'key=value&key=value'
|
|
2201
|
-
*
|
|
2202
|
-
* payload is an unserialized object
|
|
2203
|
-
*/
|
|
2204
|
-
function Transport() {
|
|
2205
|
-
this.rateLimitExpires = 0;
|
|
2206
|
-
}
|
|
2207
|
-
Transport.prototype.get = function (accessToken, options, params, callback, transportFactory) {
|
|
2208
|
-
var t;
|
|
2209
|
-
if (!callback || !isFunction(callback)) {
|
|
2210
|
-
callback = function callback() {};
|
|
2134
|
+
Rollbar.prototype._log = function (defaultLevel, item) {
|
|
2135
|
+
var callback;
|
|
2136
|
+
if (item.callback) {
|
|
2137
|
+
callback = item.callback;
|
|
2138
|
+
delete item.callback;
|
|
2211
2139
|
}
|
|
2212
|
-
options
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2140
|
+
if (this.options.ignoreDuplicateErrors && this._sameAsLastError(item)) {
|
|
2141
|
+
if (callback) {
|
|
2142
|
+
var error = new Error('ignored identical item');
|
|
2143
|
+
error.item = item;
|
|
2144
|
+
callback(error);
|
|
2145
|
+
}
|
|
2146
|
+
return;
|
|
2219
2147
|
}
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2148
|
+
try {
|
|
2149
|
+
item.level = item.level || defaultLevel;
|
|
2150
|
+
this._addItemAttributes(item);
|
|
2151
|
+
|
|
2152
|
+
// Legacy OpenTracing support
|
|
2153
|
+
this._addTracingInfo(item);
|
|
2154
|
+
var telemeter = this.telemeter;
|
|
2155
|
+
if (telemeter) {
|
|
2156
|
+
telemeter._captureRollbarItem(item);
|
|
2157
|
+
item.telemetryEvents = telemeter.copyEvents() || [];
|
|
2158
|
+
}
|
|
2159
|
+
this.notifier.log(item, callback);
|
|
2160
|
+
} catch (e) {
|
|
2161
|
+
if (callback) {
|
|
2162
|
+
callback(e);
|
|
2163
|
+
}
|
|
2164
|
+
this.logger.error(e);
|
|
2223
2165
|
}
|
|
2224
|
-
var req = t.request(options, function (resp) {
|
|
2225
|
-
this.handleResponse(resp, callback);
|
|
2226
|
-
}.bind(this));
|
|
2227
|
-
req.on('error', function (err) {
|
|
2228
|
-
callback(err);
|
|
2229
|
-
});
|
|
2230
|
-
req.end();
|
|
2231
2166
|
};
|
|
2232
|
-
|
|
2233
|
-
var
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
}
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
}
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
if (stringifyResult.error) {
|
|
2251
|
-
src_logger.error('Problem stringifying payload. Giving up');
|
|
2252
|
-
return callback(stringifyResult.error);
|
|
2253
|
-
}
|
|
2254
|
-
var writeData = stringifyResult.value;
|
|
2255
|
-
options.headers = _headers(accessToken, options, writeData);
|
|
2256
|
-
if (transportFactory) {
|
|
2257
|
-
t = transportFactory(options);
|
|
2258
|
-
} else {
|
|
2259
|
-
t = _transport(options);
|
|
2260
|
-
}
|
|
2261
|
-
if (!t) {
|
|
2262
|
-
src_logger.error('Unknown transport based on given protocol: ' + options.protocol);
|
|
2263
|
-
return callback(new Error('Unknown transport'));
|
|
2264
|
-
}
|
|
2265
|
-
var req = t.request(options, function (resp) {
|
|
2266
|
-
this.handleResponse(resp, _wrapPostCallback(callback));
|
|
2267
|
-
}.bind(this));
|
|
2268
|
-
req.on('error', function (err) {
|
|
2269
|
-
callback(err);
|
|
2270
|
-
});
|
|
2271
|
-
if (writeData) {
|
|
2272
|
-
req.write(writeData);
|
|
2167
|
+
Rollbar.prototype._addItemAttributes = function (item) {
|
|
2168
|
+
var _this$tracing, _this$tracing2;
|
|
2169
|
+
var span = (_this$tracing = this.tracing) === null || _this$tracing === void 0 ? void 0 : _this$tracing.getSpan();
|
|
2170
|
+
var attributes = [{
|
|
2171
|
+
key: 'session_id',
|
|
2172
|
+
value: (_this$tracing2 = this.tracing) === null || _this$tracing2 === void 0 ? void 0 : _this$tracing2.sessionId
|
|
2173
|
+
}, {
|
|
2174
|
+
key: 'span_id',
|
|
2175
|
+
value: span === null || span === void 0 ? void 0 : span.spanId
|
|
2176
|
+
}, {
|
|
2177
|
+
key: 'trace_id',
|
|
2178
|
+
value: span === null || span === void 0 ? void 0 : span.traceId
|
|
2179
|
+
}];
|
|
2180
|
+
if (item._isUncaught) {
|
|
2181
|
+
attributes.push({
|
|
2182
|
+
key: 'is_uncaught',
|
|
2183
|
+
value: 'true'
|
|
2184
|
+
});
|
|
2273
2185
|
}
|
|
2274
|
-
|
|
2186
|
+
addItemAttributes(item.data, attributes);
|
|
2187
|
+
span === null || span === void 0 || span.addEvent('rollbar.occurrence', [{
|
|
2188
|
+
key: 'rollbar.occurrence.uuid',
|
|
2189
|
+
value: item.uuid
|
|
2190
|
+
}]);
|
|
2275
2191
|
};
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
var remainingSeconds = Math.min(MAX_RATE_LIMIT_INTERVAL, resp.headers['x-rate-limit-remaining-seconds'] || 0);
|
|
2279
|
-
var currentTime = _currentTime();
|
|
2280
|
-
if (resp.statusCode === 429 && remaining === 0) {
|
|
2281
|
-
this.rateLimitExpires = currentTime + remainingSeconds;
|
|
2282
|
-
} else {
|
|
2283
|
-
this.rateLimitExpires = currentTime;
|
|
2284
|
-
}
|
|
2192
|
+
Rollbar.prototype._defaultLogLevel = function () {
|
|
2193
|
+
return this.options.logLevel || 'debug';
|
|
2285
2194
|
};
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2195
|
+
Rollbar.prototype._sameAsLastError = function (item) {
|
|
2196
|
+
if (!item._isUncaught) {
|
|
2197
|
+
return false;
|
|
2198
|
+
}
|
|
2199
|
+
var itemHash = generateItemHash(item);
|
|
2200
|
+
if (this.lastErrorHash === itemHash) {
|
|
2201
|
+
return true;
|
|
2202
|
+
}
|
|
2203
|
+
this.lastError = item.err;
|
|
2204
|
+
this.lastErrorHash = itemHash;
|
|
2205
|
+
return false;
|
|
2297
2206
|
};
|
|
2207
|
+
Rollbar.prototype._addTracingInfo = function (item) {
|
|
2208
|
+
// Tracer validation occurs in the constructor
|
|
2209
|
+
// or in the Rollbar.prototype.configure methods
|
|
2210
|
+
if (this.tracer) {
|
|
2211
|
+
// add rollbar occurrence uuid to span
|
|
2212
|
+
var span = this.tracer.scope().active();
|
|
2213
|
+
if (validateSpan(span)) {
|
|
2214
|
+
span.setTag('rollbar.error_uuid', item.uuid);
|
|
2215
|
+
span.setTag('rollbar.has_error', true);
|
|
2216
|
+
span.setTag('error', true);
|
|
2217
|
+
span.setTag('rollbar.item_url', "https://rollbar.com/item/uuid/?uuid=".concat(item.uuid));
|
|
2218
|
+
span.setTag('rollbar.occurrence_url', "https://rollbar.com/occurrence/uuid/?uuid=".concat(item.uuid));
|
|
2298
2219
|
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2220
|
+
// add span ID & trace ID to occurrence
|
|
2221
|
+
var opentracingSpanId = span.context().toSpanId();
|
|
2222
|
+
var opentracingTraceId = span.context().toTraceId();
|
|
2223
|
+
if (item.custom) {
|
|
2224
|
+
item.custom.opentracing_span_id = opentracingSpanId;
|
|
2225
|
+
item.custom.opentracing_trace_id = opentracingTraceId;
|
|
2226
|
+
} else {
|
|
2227
|
+
item.custom = {
|
|
2228
|
+
opentracing_span_id: opentracingSpanId,
|
|
2229
|
+
opentracing_trace_id: opentracingTraceId
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2309
2232
|
}
|
|
2310
2233
|
}
|
|
2311
|
-
|
|
2312
|
-
|
|
2234
|
+
};
|
|
2235
|
+
function generateItemHash(item) {
|
|
2236
|
+
var message = item.message || '';
|
|
2237
|
+
var stack = (item.err || {}).stack || String(item.err);
|
|
2238
|
+
return message + '::' + stack;
|
|
2313
2239
|
}
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2240
|
+
|
|
2241
|
+
// Node.js, Chrome, Safari, and some other browsers support this property
|
|
2242
|
+
// which globally sets the number of stack frames returned in an Error object.
|
|
2243
|
+
// If a browser can't use it, no harm done.
|
|
2244
|
+
function setStackTraceLimit(options) {
|
|
2245
|
+
if (options.stackTraceLimit) {
|
|
2246
|
+
Error.stackTraceLimit = options.stackTraceLimit;
|
|
2247
|
+
}
|
|
2319
2248
|
}
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2249
|
+
|
|
2250
|
+
/**
|
|
2251
|
+
* Validate the Tracer object provided to the Client
|
|
2252
|
+
* is valid for our Opentracing use case.
|
|
2253
|
+
* @param {opentracer.Tracer} tracer
|
|
2254
|
+
*/
|
|
2255
|
+
function validateTracer(tracer) {
|
|
2256
|
+
if (!tracer) {
|
|
2257
|
+
return false;
|
|
2325
2258
|
}
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
src_logger.error('Received error: ' + data.message);
|
|
2329
|
-
return callback(new Error('Api error: ' + (data.message || 'Unknown error')));
|
|
2259
|
+
if (!tracer.scope || typeof tracer.scope !== 'function') {
|
|
2260
|
+
return false;
|
|
2330
2261
|
}
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
return callback(err);
|
|
2337
|
-
}
|
|
2338
|
-
if (data.result && data.result.uuid) {
|
|
2339
|
-
src_logger.log(['Successful api response.', ' Link: https://rollbar.com/occurrence/uuid/?uuid=' + data.result.uuid].join(''));
|
|
2340
|
-
} else {
|
|
2341
|
-
src_logger.log('Successful api response');
|
|
2342
|
-
}
|
|
2343
|
-
callback(null, data.result);
|
|
2344
|
-
};
|
|
2262
|
+
var scope = tracer.scope();
|
|
2263
|
+
if (!scope || !scope.active || typeof scope.active !== 'function') {
|
|
2264
|
+
return false;
|
|
2265
|
+
}
|
|
2266
|
+
return true;
|
|
2345
2267
|
}
|
|
2346
|
-
|
|
2347
|
-
|
|
2268
|
+
|
|
2269
|
+
/**
|
|
2270
|
+
* Validate the Span object provided
|
|
2271
|
+
* @param {opentracer.Span} span
|
|
2272
|
+
*/
|
|
2273
|
+
function validateSpan(span) {
|
|
2274
|
+
if (!span || !span.context || typeof span.context !== 'function') {
|
|
2275
|
+
return false;
|
|
2276
|
+
}
|
|
2277
|
+
var spanContext = span.context();
|
|
2278
|
+
if (!spanContext || !spanContext.toSpanId || !spanContext.toTraceId || typeof spanContext.toSpanId !== 'function' || typeof spanContext.toTraceId !== 'function') {
|
|
2279
|
+
return false;
|
|
2280
|
+
}
|
|
2281
|
+
return true;
|
|
2348
2282
|
}
|
|
2349
|
-
/* harmony default export */ const
|
|
2350
|
-
;// external "url"
|
|
2351
|
-
const external_url_namespaceObject = require("url");
|
|
2283
|
+
/* harmony default export */ const rollbar = (Rollbar);
|
|
2352
2284
|
;// ./src/telemetry.js
|
|
2353
2285
|
var _excluded = ["otelAttributes"];
|
|
2354
2286
|
function telemetry_typeof(o) { "@babel/helpers - typeof"; return telemetry_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, telemetry_typeof(o); }
|
|
@@ -2374,7 +2306,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2374
2306
|
var _this$tracing;
|
|
2375
2307
|
telemetry_classCallCheck(this, Telemeter);
|
|
2376
2308
|
this.queue = [];
|
|
2377
|
-
this.options =
|
|
2309
|
+
this.options = merge(options);
|
|
2378
2310
|
var maxTelemetryEvents = this.options.maxTelemetryEvents || MAX_EVENTS;
|
|
2379
2311
|
this.maxQueueSize = Math.max(0, Math.min(maxTelemetryEvents, MAX_EVENTS));
|
|
2380
2312
|
this.tracing = tracing;
|
|
@@ -2384,7 +2316,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2384
2316
|
key: "configure",
|
|
2385
2317
|
value: function configure(options) {
|
|
2386
2318
|
var oldOptions = this.options;
|
|
2387
|
-
this.options =
|
|
2319
|
+
this.options = merge(oldOptions, options);
|
|
2388
2320
|
var maxTelemetryEvents = this.options.maxTelemetryEvents || MAX_EVENTS;
|
|
2389
2321
|
var newMaxEvents = Math.max(0, Math.min(maxTelemetryEvents, MAX_EVENTS));
|
|
2390
2322
|
var deleteCount = 0;
|
|
@@ -2406,7 +2338,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2406
2338
|
events.splice(i, 1);
|
|
2407
2339
|
}
|
|
2408
2340
|
}
|
|
2409
|
-
} catch (
|
|
2341
|
+
} catch (_e) {
|
|
2410
2342
|
this.options.filterTelemetry = null;
|
|
2411
2343
|
}
|
|
2412
2344
|
}
|
|
@@ -2418,7 +2350,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2418
2350
|
|
|
2419
2351
|
// Remove internal keys from output
|
|
2420
2352
|
events = events.map(function (_ref) {
|
|
2421
|
-
var
|
|
2353
|
+
var _otelAttributes = _ref.otelAttributes,
|
|
2422
2354
|
event = _objectWithoutProperties(_ref, _excluded);
|
|
2423
2355
|
return event;
|
|
2424
2356
|
});
|
|
@@ -2441,7 +2373,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2441
2373
|
var e = {
|
|
2442
2374
|
level: getLevel(type, level),
|
|
2443
2375
|
type: type,
|
|
2444
|
-
timestamp_ms: timestamp ||
|
|
2376
|
+
timestamp_ms: timestamp || now(),
|
|
2445
2377
|
body: metadata,
|
|
2446
2378
|
source: 'client'
|
|
2447
2379
|
};
|
|
@@ -2455,7 +2387,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2455
2387
|
if (isFunction(this.options.filterTelemetry) && this.options.filterTelemetry(e)) {
|
|
2456
2388
|
return false;
|
|
2457
2389
|
}
|
|
2458
|
-
} catch (
|
|
2390
|
+
} catch (_exc) {
|
|
2459
2391
|
this.options.filterTelemetry = null;
|
|
2460
2392
|
}
|
|
2461
2393
|
this.push(e);
|
|
@@ -2489,25 +2421,16 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2489
2421
|
}, {
|
|
2490
2422
|
key: "captureLog",
|
|
2491
2423
|
value: function captureLog(message, level, rollbarUUID, timestamp) {
|
|
2492
|
-
var
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
}, (_this$telemetrySpan2 = this.telemetrySpan) === null || _this$telemetrySpan2 === void 0 ? void 0 : _this$telemetrySpan2.addEvent('rollbar-occurrence-event', otelAttributes, fromMillis(timestamp));
|
|
2503
|
-
} else {
|
|
2504
|
-
var _this$telemetrySpan3;
|
|
2505
|
-
otelAttributes = {
|
|
2506
|
-
message: message,
|
|
2507
|
-
level: level
|
|
2508
|
-
};
|
|
2509
|
-
(_this$telemetrySpan3 = this.telemetrySpan) === null || _this$telemetrySpan3 === void 0 || _this$telemetrySpan3.addEvent('rollbar-log-event', otelAttributes, fromMillis(timestamp));
|
|
2510
|
-
}
|
|
2424
|
+
var _this$telemetrySpan2;
|
|
2425
|
+
var event = rollbarUUID ? 'rollbar-occurrence-event' : 'rollbar-log-event';
|
|
2426
|
+
var otelAttributes = telemetry_objectSpread({
|
|
2427
|
+
message: message,
|
|
2428
|
+
level: level
|
|
2429
|
+
}, rollbarUUID ? {
|
|
2430
|
+
type: 'message',
|
|
2431
|
+
uuid: rollbarUUID
|
|
2432
|
+
} : {});
|
|
2433
|
+
(_this$telemetrySpan2 = this.telemetrySpan) === null || _this$telemetrySpan2 === void 0 || _this$telemetrySpan2.addEvent(event, otelAttributes, fromMillis(timestamp));
|
|
2511
2434
|
return this.capture('log', {
|
|
2512
2435
|
message: message
|
|
2513
2436
|
}, level, rollbarUUID, timestamp, otelAttributes);
|
|
@@ -2515,7 +2438,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2515
2438
|
}, {
|
|
2516
2439
|
key: "captureNetwork",
|
|
2517
2440
|
value: function captureNetwork(metadata, subtype, rollbarUUID, requestData) {
|
|
2518
|
-
var _metadata$response, _this$
|
|
2441
|
+
var _metadata$response, _metadata$response2, _this$telemetrySpan3;
|
|
2519
2442
|
subtype = subtype || 'xhr';
|
|
2520
2443
|
metadata.subtype = metadata.subtype || subtype;
|
|
2521
2444
|
if (requestData) {
|
|
@@ -2532,7 +2455,15 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2532
2455
|
'response.headers': JSON.stringify(((_metadata$response = metadata.response) === null || _metadata$response === void 0 ? void 0 : _metadata$response.headers) || {}),
|
|
2533
2456
|
'response.timeUnixNano': endTimeNano.toString()
|
|
2534
2457
|
};
|
|
2535
|
-
|
|
2458
|
+
var requestBody = metadata.request;
|
|
2459
|
+
var responseBody = (_metadata$response2 = metadata.response) === null || _metadata$response2 === void 0 ? void 0 : _metadata$response2.body;
|
|
2460
|
+
if (requestBody) {
|
|
2461
|
+
otelAttributes['request.body'] = JSON.stringify(requestBody);
|
|
2462
|
+
}
|
|
2463
|
+
if (responseBody) {
|
|
2464
|
+
otelAttributes['response.body'] = JSON.stringify(responseBody);
|
|
2465
|
+
}
|
|
2466
|
+
(_this$telemetrySpan3 = this.telemetrySpan) === null || _this$telemetrySpan3 === void 0 || _this$telemetrySpan3.addEvent('rollbar-network-event', otelAttributes, fromMillis(metadata.start_time_ms));
|
|
2536
2467
|
return this.capture('network', metadata, level, rollbarUUID, metadata.start_time_ms, otelAttributes);
|
|
2537
2468
|
}
|
|
2538
2469
|
}, {
|
|
@@ -2564,7 +2495,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2564
2495
|
}, {
|
|
2565
2496
|
key: "captureInput",
|
|
2566
2497
|
value: function captureInput(_ref2) {
|
|
2567
|
-
var _this$
|
|
2498
|
+
var _this$telemetrySpan4;
|
|
2568
2499
|
var type = _ref2.type,
|
|
2569
2500
|
isSynthetic = _ref2.isSynthetic,
|
|
2570
2501
|
element = _ref2.element,
|
|
@@ -2588,13 +2519,13 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2588
2519
|
if (event) {
|
|
2589
2520
|
return this._updateRepeatedEvent(event, otelAttributes, timestamp);
|
|
2590
2521
|
}
|
|
2591
|
-
(_this$
|
|
2522
|
+
(_this$telemetrySpan4 = this.telemetrySpan) === null || _this$telemetrySpan4 === void 0 || _this$telemetrySpan4.addEvent(name, otelAttributes, fromMillis(timestamp));
|
|
2592
2523
|
return this.capture('dom', metadata, 'info', null, timestamp, otelAttributes);
|
|
2593
2524
|
}
|
|
2594
2525
|
}, {
|
|
2595
2526
|
key: "captureClick",
|
|
2596
2527
|
value: function captureClick(_ref3) {
|
|
2597
|
-
var _this$
|
|
2528
|
+
var _this$telemetrySpan5;
|
|
2598
2529
|
var type = _ref3.type,
|
|
2599
2530
|
isSynthetic = _ref3.isSynthetic,
|
|
2600
2531
|
element = _ref3.element,
|
|
@@ -2615,7 +2546,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2615
2546
|
if (event) {
|
|
2616
2547
|
return this._updateRepeatedEvent(event, otelAttributes, timestamp);
|
|
2617
2548
|
}
|
|
2618
|
-
(_this$
|
|
2549
|
+
(_this$telemetrySpan5 = this.telemetrySpan) === null || _this$telemetrySpan5 === void 0 || _this$telemetrySpan5.addEvent(name, otelAttributes, fromMillis(timestamp));
|
|
2619
2550
|
return this.capture('dom', metadata, 'info', null, timestamp, otelAttributes);
|
|
2620
2551
|
}
|
|
2621
2552
|
}, {
|
|
@@ -2648,7 +2579,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2648
2579
|
}, {
|
|
2649
2580
|
key: "captureFocus",
|
|
2650
2581
|
value: function captureFocus(_ref4) {
|
|
2651
|
-
var _this$
|
|
2582
|
+
var _this$telemetrySpan6;
|
|
2652
2583
|
var type = _ref4.type,
|
|
2653
2584
|
isSynthetic = _ref4.isSynthetic,
|
|
2654
2585
|
element = _ref4.element,
|
|
@@ -2664,13 +2595,13 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2664
2595
|
isSynthetic: isSynthetic,
|
|
2665
2596
|
element: element
|
|
2666
2597
|
};
|
|
2667
|
-
(_this$
|
|
2598
|
+
(_this$telemetrySpan6 = this.telemetrySpan) === null || _this$telemetrySpan6 === void 0 || _this$telemetrySpan6.addEvent(name, otelAttributes, fromMillis(timestamp));
|
|
2668
2599
|
return this.capture('dom', metadata, 'info', null, timestamp, otelAttributes);
|
|
2669
2600
|
}
|
|
2670
2601
|
}, {
|
|
2671
2602
|
key: "captureResize",
|
|
2672
2603
|
value: function captureResize(_ref5) {
|
|
2673
|
-
var _this$
|
|
2604
|
+
var _this$telemetrySpan7;
|
|
2674
2605
|
var type = _ref5.type,
|
|
2675
2606
|
isSynthetic = _ref5.isSynthetic,
|
|
2676
2607
|
width = _ref5.width,
|
|
@@ -2696,13 +2627,13 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2696
2627
|
if (event) {
|
|
2697
2628
|
return this._updateRepeatedEvent(event, otelAttributes, timestamp);
|
|
2698
2629
|
}
|
|
2699
|
-
(_this$
|
|
2630
|
+
(_this$telemetrySpan7 = this.telemetrySpan) === null || _this$telemetrySpan7 === void 0 || _this$telemetrySpan7.addEvent(name, otelAttributes, fromMillis(timestamp));
|
|
2700
2631
|
return this.capture('dom', metadata, 'info', null, timestamp, otelAttributes);
|
|
2701
2632
|
}
|
|
2702
2633
|
}, {
|
|
2703
2634
|
key: "captureDragDrop",
|
|
2704
2635
|
value: function captureDragDrop(_ref6) {
|
|
2705
|
-
var _this$
|
|
2636
|
+
var _this$telemetrySpan8;
|
|
2706
2637
|
var type = _ref6.type,
|
|
2707
2638
|
isSynthetic = _ref6.isSynthetic,
|
|
2708
2639
|
element = _ref6.element,
|
|
@@ -2749,14 +2680,14 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2749
2680
|
mediaTypes: mediaTypes
|
|
2750
2681
|
});
|
|
2751
2682
|
}
|
|
2752
|
-
(_this$
|
|
2683
|
+
(_this$telemetrySpan8 = this.telemetrySpan) === null || _this$telemetrySpan8 === void 0 || _this$telemetrySpan8.addEvent(name, otelAttributes, fromMillis(timestamp));
|
|
2753
2684
|
return this.capture('dom', metadata, 'info', null, timestamp, otelAttributes);
|
|
2754
2685
|
}
|
|
2755
2686
|
}, {
|
|
2756
2687
|
key: "captureNavigation",
|
|
2757
2688
|
value: function captureNavigation(from, to, rollbarUUID, timestamp) {
|
|
2758
|
-
var _this$
|
|
2759
|
-
(_this$
|
|
2689
|
+
var _this$telemetrySpan9;
|
|
2690
|
+
(_this$telemetrySpan9 = this.telemetrySpan) === null || _this$telemetrySpan9 === void 0 || _this$telemetrySpan9.addEvent('rollbar-navigation-event', {
|
|
2760
2691
|
'previous.url.full': from,
|
|
2761
2692
|
'url.full': to
|
|
2762
2693
|
}, fromMillis(timestamp));
|
|
@@ -2790,7 +2721,7 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2790
2721
|
}, {
|
|
2791
2722
|
key: "captureConnectivityChange",
|
|
2792
2723
|
value: function captureConnectivityChange(_ref7) {
|
|
2793
|
-
var _this$
|
|
2724
|
+
var _this$telemetrySpan0;
|
|
2794
2725
|
var type = _ref7.type,
|
|
2795
2726
|
isSynthetic = _ref7.isSynthetic,
|
|
2796
2727
|
timestamp = _ref7.timestamp;
|
|
@@ -2803,48 +2734,374 @@ var Telemeter = /*#__PURE__*/function () {
|
|
|
2803
2734
|
type: type,
|
|
2804
2735
|
isSynthetic: isSynthetic
|
|
2805
2736
|
};
|
|
2806
|
-
(_this$
|
|
2737
|
+
(_this$telemetrySpan0 = this.telemetrySpan) === null || _this$telemetrySpan0 === void 0 || _this$telemetrySpan0.addEvent(name, otelAttributes, fromMillis(timestamp));
|
|
2807
2738
|
return this.capture('connectivity', metadata, 'info', null, timestamp, otelAttributes);
|
|
2808
2739
|
}
|
|
2809
2740
|
|
|
2810
|
-
// Only intended to be used internally by the notifier
|
|
2811
|
-
}, {
|
|
2812
|
-
key: "_captureRollbarItem",
|
|
2813
|
-
value: function _captureRollbarItem(item) {
|
|
2814
|
-
if (!this.options.includeItemsInTelemetry) {
|
|
2815
|
-
return;
|
|
2816
|
-
}
|
|
2817
|
-
if (item.err) {
|
|
2818
|
-
return this.captureError(item.err, item.level, item.uuid, item.timestamp);
|
|
2819
|
-
}
|
|
2820
|
-
if (item.message) {
|
|
2821
|
-
return this.captureLog(item.message, item.level, item.uuid, item.timestamp);
|
|
2822
|
-
}
|
|
2823
|
-
if (item.custom) {
|
|
2824
|
-
return this.capture('log', item.custom, item.level, item.uuid, item.timestamp);
|
|
2741
|
+
// Only intended to be used internally by the notifier
|
|
2742
|
+
}, {
|
|
2743
|
+
key: "_captureRollbarItem",
|
|
2744
|
+
value: function _captureRollbarItem(item) {
|
|
2745
|
+
if (!this.options.includeItemsInTelemetry) {
|
|
2746
|
+
return;
|
|
2747
|
+
}
|
|
2748
|
+
if (item.err) {
|
|
2749
|
+
return this.captureError(item.err, item.level, item.uuid, item.timestamp);
|
|
2750
|
+
}
|
|
2751
|
+
if (item.message) {
|
|
2752
|
+
return this.captureLog(item.message, item.level, item.uuid, item.timestamp);
|
|
2753
|
+
}
|
|
2754
|
+
if (item.custom) {
|
|
2755
|
+
return this.capture('log', item.custom, item.level, item.uuid, item.timestamp);
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
}, {
|
|
2759
|
+
key: "push",
|
|
2760
|
+
value: function push(e) {
|
|
2761
|
+
this.queue.push(e);
|
|
2762
|
+
if (this.queue.length > this.maxQueueSize) {
|
|
2763
|
+
this.queue.shift();
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
}]);
|
|
2767
|
+
}();
|
|
2768
|
+
function getLevel(type, level) {
|
|
2769
|
+
if (level) {
|
|
2770
|
+
return level;
|
|
2771
|
+
}
|
|
2772
|
+
var defaultLevel = {
|
|
2773
|
+
error: 'error',
|
|
2774
|
+
manual: 'info'
|
|
2775
|
+
};
|
|
2776
|
+
return defaultLevel[type] || 'info';
|
|
2777
|
+
}
|
|
2778
|
+
/* harmony default export */ const telemetry = (Telemeter);
|
|
2779
|
+
;// ./src/transforms.js
|
|
2780
|
+
|
|
2781
|
+
function itemToPayload(item, options, callback) {
|
|
2782
|
+
if (item._isUncaught) {
|
|
2783
|
+
item.data._isUncaught = true;
|
|
2784
|
+
}
|
|
2785
|
+
if (item._originalArgs) {
|
|
2786
|
+
item.data._originalArgs = item._originalArgs;
|
|
2787
|
+
}
|
|
2788
|
+
callback(null, item);
|
|
2789
|
+
}
|
|
2790
|
+
function addPayloadOptions(item, options, callback) {
|
|
2791
|
+
var payloadOptions = options.payload || {};
|
|
2792
|
+
if (payloadOptions.body) {
|
|
2793
|
+
delete payloadOptions.body;
|
|
2794
|
+
}
|
|
2795
|
+
item.data = merge(item.data, payloadOptions);
|
|
2796
|
+
callback(null, item);
|
|
2797
|
+
}
|
|
2798
|
+
function addTelemetryData(item, options, callback) {
|
|
2799
|
+
if (item.telemetryEvents) {
|
|
2800
|
+
set(item, 'data.body.telemetry', item.telemetryEvents);
|
|
2801
|
+
}
|
|
2802
|
+
callback(null, item);
|
|
2803
|
+
}
|
|
2804
|
+
function addMessageWithError(item, options, callback) {
|
|
2805
|
+
if (!item.message) {
|
|
2806
|
+
callback(null, item);
|
|
2807
|
+
return;
|
|
2808
|
+
}
|
|
2809
|
+
var tracePath = 'data.body.trace_chain.0';
|
|
2810
|
+
var trace = get(item, tracePath);
|
|
2811
|
+
if (!trace) {
|
|
2812
|
+
tracePath = 'data.body.trace';
|
|
2813
|
+
trace = get(item, tracePath);
|
|
2814
|
+
}
|
|
2815
|
+
if (trace) {
|
|
2816
|
+
if (!(trace.exception && trace.exception.description)) {
|
|
2817
|
+
set(item, tracePath + '.exception.description', item.message);
|
|
2818
|
+
callback(null, item);
|
|
2819
|
+
return;
|
|
2820
|
+
}
|
|
2821
|
+
var extra = get(item, tracePath + '.extra') || {};
|
|
2822
|
+
var newExtra = merge(extra, {
|
|
2823
|
+
message: item.message
|
|
2824
|
+
});
|
|
2825
|
+
set(item, tracePath + '.extra', newExtra);
|
|
2826
|
+
}
|
|
2827
|
+
callback(null, item);
|
|
2828
|
+
}
|
|
2829
|
+
function userTransform(logger) {
|
|
2830
|
+
return function (item, options, callback) {
|
|
2831
|
+
var newItem = merge(item);
|
|
2832
|
+
var response = null;
|
|
2833
|
+
try {
|
|
2834
|
+
if (isFunction(options.transform)) {
|
|
2835
|
+
response = options.transform(newItem.data, item);
|
|
2836
|
+
}
|
|
2837
|
+
} catch (e) {
|
|
2838
|
+
options.transform = null;
|
|
2839
|
+
logger.error('Error while calling custom transform() function. Removing custom transform().', e);
|
|
2840
|
+
callback(null, item);
|
|
2841
|
+
return;
|
|
2842
|
+
}
|
|
2843
|
+
if (isPromise(response)) {
|
|
2844
|
+
response.then(function (promisedItem) {
|
|
2845
|
+
if (promisedItem) {
|
|
2846
|
+
newItem.data = promisedItem;
|
|
2847
|
+
}
|
|
2848
|
+
callback(null, newItem);
|
|
2849
|
+
}, function (error) {
|
|
2850
|
+
callback(error, item);
|
|
2851
|
+
});
|
|
2852
|
+
} else {
|
|
2853
|
+
callback(null, newItem);
|
|
2854
|
+
}
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2857
|
+
function addConfigToPayload(item, options, callback) {
|
|
2858
|
+
if (!options.sendConfig) {
|
|
2859
|
+
return callback(null, item);
|
|
2860
|
+
}
|
|
2861
|
+
var configKey = '_rollbarConfig';
|
|
2862
|
+
var custom = get(item, 'data.custom') || {};
|
|
2863
|
+
custom[configKey] = options;
|
|
2864
|
+
item.data.custom = custom;
|
|
2865
|
+
callback(null, item);
|
|
2866
|
+
}
|
|
2867
|
+
function addFunctionOption(options, name) {
|
|
2868
|
+
if (isFunction(options[name])) {
|
|
2869
|
+
options[name] = options[name].toString();
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
function addConfiguredOptions(item, options, callback) {
|
|
2873
|
+
var configuredOptions = options._configuredOptions;
|
|
2874
|
+
|
|
2875
|
+
// These must be stringified or they'll get dropped during serialization.
|
|
2876
|
+
addFunctionOption(configuredOptions, 'transform');
|
|
2877
|
+
addFunctionOption(configuredOptions, 'checkIgnore');
|
|
2878
|
+
addFunctionOption(configuredOptions, 'onSendCallback');
|
|
2879
|
+
delete configuredOptions.accessToken;
|
|
2880
|
+
item.data.notifier.configured_options = configuredOptions;
|
|
2881
|
+
callback(null, item);
|
|
2882
|
+
}
|
|
2883
|
+
function addDiagnosticKeys(item, options, callback) {
|
|
2884
|
+
var diagnostic = merge(item.notifier.client.notifier.diagnostic, item.diagnostic);
|
|
2885
|
+
if (get(item, 'err._isAnonymous')) {
|
|
2886
|
+
diagnostic.is_anonymous = true;
|
|
2887
|
+
}
|
|
2888
|
+
if (item._isUncaught) {
|
|
2889
|
+
diagnostic.is_uncaught = item._isUncaught;
|
|
2890
|
+
}
|
|
2891
|
+
if (item.err) {
|
|
2892
|
+
try {
|
|
2893
|
+
diagnostic.raw_error = {
|
|
2894
|
+
message: item.err.message,
|
|
2895
|
+
name: item.err.name,
|
|
2896
|
+
constructor_name: item.err.constructor && item.err.constructor.name,
|
|
2897
|
+
filename: item.err.fileName,
|
|
2898
|
+
line: item.err.lineNumber,
|
|
2899
|
+
column: item.err.columnNumber,
|
|
2900
|
+
stack: item.err.stack
|
|
2901
|
+
};
|
|
2902
|
+
} catch (e) {
|
|
2903
|
+
diagnostic.raw_error = {
|
|
2904
|
+
failed: String(e)
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
item.data.notifier.diagnostic = merge(item.data.notifier.diagnostic, diagnostic);
|
|
2909
|
+
callback(null, item);
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
;// ./src/utility/traverse.js
|
|
2913
|
+
|
|
2914
|
+
function traverse(obj, func, seen) {
|
|
2915
|
+
var k, v, i;
|
|
2916
|
+
var isObj = isType(obj, 'object');
|
|
2917
|
+
var isArray = isType(obj, 'array');
|
|
2918
|
+
var keys = [];
|
|
2919
|
+
var seenIndex;
|
|
2920
|
+
|
|
2921
|
+
// Best might be to use Map here with `obj` as the keys, but we want to support IE < 11.
|
|
2922
|
+
seen = seen || {
|
|
2923
|
+
obj: [],
|
|
2924
|
+
mapped: []
|
|
2925
|
+
};
|
|
2926
|
+
if (isObj) {
|
|
2927
|
+
seenIndex = seen.obj.indexOf(obj);
|
|
2928
|
+
if (isObj && seenIndex !== -1) {
|
|
2929
|
+
// Prefer the mapped object if there is one.
|
|
2930
|
+
return seen.mapped[seenIndex] || seen.obj[seenIndex];
|
|
2931
|
+
}
|
|
2932
|
+
seen.obj.push(obj);
|
|
2933
|
+
seenIndex = seen.obj.length - 1;
|
|
2934
|
+
}
|
|
2935
|
+
if (isObj) {
|
|
2936
|
+
for (k in obj) {
|
|
2937
|
+
if (hasOwn(obj, k)) {
|
|
2938
|
+
keys.push(k);
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
} else if (isArray) {
|
|
2942
|
+
for (i = 0; i < obj.length; ++i) {
|
|
2943
|
+
keys.push(i);
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
var result = isObj ? {} : [];
|
|
2947
|
+
var same = true;
|
|
2948
|
+
for (i = 0; i < keys.length; ++i) {
|
|
2949
|
+
k = keys[i];
|
|
2950
|
+
v = obj[k];
|
|
2951
|
+
result[k] = func(k, v, seen);
|
|
2952
|
+
same = same && result[k] === obj[k];
|
|
2953
|
+
}
|
|
2954
|
+
if (isObj && !same) {
|
|
2955
|
+
seen.mapped[seenIndex] = result;
|
|
2956
|
+
}
|
|
2957
|
+
return !same ? result : obj;
|
|
2958
|
+
}
|
|
2959
|
+
/* harmony default export */ const utility_traverse = (traverse);
|
|
2960
|
+
;// ./src/truncation.js
|
|
2961
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || truncation_unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2962
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
2963
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
2964
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
2965
|
+
function truncation_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = truncation_unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2966
|
+
function truncation_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return truncation_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? truncation_arrayLikeToArray(r, a) : void 0; } }
|
|
2967
|
+
function truncation_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
2968
|
+
|
|
2969
|
+
|
|
2970
|
+
function raw(payload, jsonBackup) {
|
|
2971
|
+
return [payload, stringify(payload, jsonBackup)];
|
|
2972
|
+
}
|
|
2973
|
+
function selectFrames(frames, range) {
|
|
2974
|
+
var len = frames.length;
|
|
2975
|
+
if (len > range * 2) {
|
|
2976
|
+
return frames.slice(0, range).concat(frames.slice(len - range));
|
|
2977
|
+
}
|
|
2978
|
+
return frames;
|
|
2979
|
+
}
|
|
2980
|
+
function truncateFrames(payload, jsonBackup, range) {
|
|
2981
|
+
range = typeof range === 'undefined' ? 30 : range;
|
|
2982
|
+
var body = payload.data.body;
|
|
2983
|
+
var frames;
|
|
2984
|
+
if (body.trace_chain) {
|
|
2985
|
+
var chain = body.trace_chain;
|
|
2986
|
+
var _iterator = truncation_createForOfIteratorHelper(chain),
|
|
2987
|
+
_step;
|
|
2988
|
+
try {
|
|
2989
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2990
|
+
var trace = _step.value;
|
|
2991
|
+
frames = trace.frames;
|
|
2992
|
+
frames = selectFrames(frames, range);
|
|
2993
|
+
trace.frames = frames;
|
|
2825
2994
|
}
|
|
2995
|
+
} catch (err) {
|
|
2996
|
+
_iterator.e(err);
|
|
2997
|
+
} finally {
|
|
2998
|
+
_iterator.f();
|
|
2826
2999
|
}
|
|
2827
|
-
}
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
3000
|
+
} else if (body.trace) {
|
|
3001
|
+
frames = body.trace.frames;
|
|
3002
|
+
frames = selectFrames(frames, range);
|
|
3003
|
+
body.trace.frames = frames;
|
|
3004
|
+
}
|
|
3005
|
+
return [payload, stringify(payload, jsonBackup)];
|
|
3006
|
+
}
|
|
3007
|
+
function maybeTruncateValue(len, val) {
|
|
3008
|
+
if (!val) {
|
|
3009
|
+
return val;
|
|
3010
|
+
}
|
|
3011
|
+
if (val.length > len) {
|
|
3012
|
+
return val.slice(0, len - 3).concat('...');
|
|
3013
|
+
}
|
|
3014
|
+
return val;
|
|
3015
|
+
}
|
|
3016
|
+
function truncateStrings(len, payload, jsonBackup) {
|
|
3017
|
+
function truncator(k, v, seen) {
|
|
3018
|
+
switch (typeName(v)) {
|
|
3019
|
+
case 'string':
|
|
3020
|
+
return maybeTruncateValue(len, v);
|
|
3021
|
+
case 'object':
|
|
3022
|
+
case 'array':
|
|
3023
|
+
return utility_traverse(v, truncator, seen);
|
|
3024
|
+
default:
|
|
3025
|
+
return v;
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
payload = utility_traverse(payload, truncator);
|
|
3029
|
+
return [payload, stringify(payload, jsonBackup)];
|
|
3030
|
+
}
|
|
3031
|
+
function truncateTraceData(traceData) {
|
|
3032
|
+
if (traceData.exception) {
|
|
3033
|
+
delete traceData.exception.description;
|
|
3034
|
+
traceData.exception.message = maybeTruncateValue(255, traceData.exception.message);
|
|
3035
|
+
}
|
|
3036
|
+
traceData.frames = selectFrames(traceData.frames, 1);
|
|
3037
|
+
return traceData;
|
|
3038
|
+
}
|
|
3039
|
+
function minBody(payload, jsonBackup) {
|
|
3040
|
+
var body = payload.data.body;
|
|
3041
|
+
if (body.trace_chain) {
|
|
3042
|
+
var chain = body.trace_chain;
|
|
3043
|
+
var _iterator2 = truncation_createForOfIteratorHelper(chain.entries()),
|
|
3044
|
+
_step2;
|
|
3045
|
+
try {
|
|
3046
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
3047
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
3048
|
+
index = _step2$value[0],
|
|
3049
|
+
trace = _step2$value[1];
|
|
3050
|
+
chain[index] = truncateTraceData(trace);
|
|
2833
3051
|
}
|
|
3052
|
+
} catch (err) {
|
|
3053
|
+
_iterator2.e(err);
|
|
3054
|
+
} finally {
|
|
3055
|
+
_iterator2.f();
|
|
2834
3056
|
}
|
|
2835
|
-
}
|
|
2836
|
-
|
|
2837
|
-
function getLevel(type, level) {
|
|
2838
|
-
if (level) {
|
|
2839
|
-
return level;
|
|
3057
|
+
} else if (body.trace) {
|
|
3058
|
+
body.trace = truncateTraceData(body.trace);
|
|
2840
3059
|
}
|
|
2841
|
-
|
|
2842
|
-
error: 'error',
|
|
2843
|
-
manual: 'info'
|
|
2844
|
-
};
|
|
2845
|
-
return defaultLevel[type] || 'info';
|
|
3060
|
+
return [payload, stringify(payload, jsonBackup)];
|
|
2846
3061
|
}
|
|
2847
|
-
|
|
3062
|
+
function needsTruncation(payload, maxSize) {
|
|
3063
|
+
return maxByteSize(payload) > maxSize;
|
|
3064
|
+
}
|
|
3065
|
+
function truncate(payload, jsonBackup, maxSize) {
|
|
3066
|
+
maxSize = typeof maxSize === 'undefined' ? 512 * 1024 : maxSize;
|
|
3067
|
+
var strategies = [raw, truncateFrames, truncateStrings.bind(null, 1024), truncateStrings.bind(null, 512), truncateStrings.bind(null, 256), minBody];
|
|
3068
|
+
var strategy, results, result;
|
|
3069
|
+
while (strategy = strategies.shift()) {
|
|
3070
|
+
results = strategy(payload, jsonBackup);
|
|
3071
|
+
payload = results[0];
|
|
3072
|
+
result = results[1];
|
|
3073
|
+
if (result.error || !needsTruncation(result.value, maxSize)) {
|
|
3074
|
+
return result;
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
return result;
|
|
3078
|
+
}
|
|
3079
|
+
/* harmony default export */ const truncation = ({
|
|
3080
|
+
truncate: truncate,
|
|
3081
|
+
/* for testing */
|
|
3082
|
+
raw: raw,
|
|
3083
|
+
truncateFrames: truncateFrames,
|
|
3084
|
+
truncateStrings: truncateStrings,
|
|
3085
|
+
maybeTruncateValue: maybeTruncateValue
|
|
3086
|
+
});
|
|
3087
|
+
;// ./src/server/defaults.js
|
|
3088
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || defaults_unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
3089
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3090
|
+
function defaults_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return defaults_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? defaults_arrayLikeToArray(r, a) : void 0; } }
|
|
3091
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
3092
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return defaults_arrayLikeToArray(r); }
|
|
3093
|
+
function defaults_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
3094
|
+
/**
|
|
3095
|
+
* Default server-side application options
|
|
3096
|
+
*/
|
|
3097
|
+
|
|
3098
|
+
var notifierName = 'node_rollbar';
|
|
3099
|
+
var scrubHeaders = commonScrubHeaders;
|
|
3100
|
+
var scrubFields = [].concat(_toConsumableArray(commonScrubFields), _toConsumableArray(apiScrubFields), _toConsumableArray(requestScrubFields));
|
|
3101
|
+
;// external "http"
|
|
3102
|
+
const external_http_namespaceObject = require("http");
|
|
3103
|
+
;// external "https"
|
|
3104
|
+
const external_https_namespaceObject = require("https");
|
|
2848
3105
|
;// ./src/utility/replace.js
|
|
2849
3106
|
function replace(obj, name, replacement, replacements, type) {
|
|
2850
3107
|
var orig = obj[name];
|
|
@@ -2880,7 +3137,7 @@ function mergeOptions(input, options, cb) {
|
|
|
2880
3137
|
cb = options;
|
|
2881
3138
|
options = input || {};
|
|
2882
3139
|
} else {
|
|
2883
|
-
options =
|
|
3140
|
+
options = merge(input || {}, options);
|
|
2884
3141
|
}
|
|
2885
3142
|
return {
|
|
2886
3143
|
options: options,
|
|
@@ -2947,7 +3204,7 @@ function Instrumenter(options, telemeter, rollbar) {
|
|
|
2947
3204
|
if (!isType(autoInstrument, 'object')) {
|
|
2948
3205
|
autoInstrument = telemetry_defaults;
|
|
2949
3206
|
}
|
|
2950
|
-
this.autoInstrument =
|
|
3207
|
+
this.autoInstrument = merge(telemetry_defaults, autoInstrument);
|
|
2951
3208
|
}
|
|
2952
3209
|
this.telemeter = telemeter;
|
|
2953
3210
|
this.rollbar = rollbar;
|
|
@@ -2958,16 +3215,16 @@ function Instrumenter(options, telemeter, rollbar) {
|
|
|
2958
3215
|
};
|
|
2959
3216
|
}
|
|
2960
3217
|
Instrumenter.prototype.configure = function (options) {
|
|
2961
|
-
this.options =
|
|
3218
|
+
this.options = merge(this.options, options);
|
|
2962
3219
|
var autoInstrument = options.autoInstrument;
|
|
2963
|
-
var oldSettings =
|
|
3220
|
+
var oldSettings = merge(this.autoInstrument);
|
|
2964
3221
|
if (options.enabled === false || autoInstrument === false) {
|
|
2965
3222
|
this.autoInstrument = {};
|
|
2966
3223
|
} else {
|
|
2967
3224
|
if (!isType(autoInstrument, 'object')) {
|
|
2968
3225
|
autoInstrument = telemetry_defaults;
|
|
2969
3226
|
}
|
|
2970
|
-
this.autoInstrument =
|
|
3227
|
+
this.autoInstrument = merge(telemetry_defaults, autoInstrument);
|
|
2971
3228
|
}
|
|
2972
3229
|
this.instrument(oldSettings);
|
|
2973
3230
|
};
|
|
@@ -2991,30 +3248,33 @@ Instrumenter.prototype.instrumentNetwork = function () {
|
|
|
2991
3248
|
utility_replace(external_https_namespaceObject, 'request', networkRequestWrapper.bind(this), this.replacements, 'network');
|
|
2992
3249
|
};
|
|
2993
3250
|
function networkRequestWrapper(orig) {
|
|
3251
|
+
var _this = this;
|
|
2994
3252
|
var telemeter = this.telemeter;
|
|
2995
|
-
|
|
2996
|
-
|
|
3253
|
+
return function () {
|
|
3254
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3255
|
+
args[_key] = arguments[_key];
|
|
3256
|
+
}
|
|
3257
|
+
var url = args[0],
|
|
3258
|
+
options = args[1],
|
|
3259
|
+
cb = args[2];
|
|
2997
3260
|
var mergedOptions = mergeOptions(url, options, cb);
|
|
2998
3261
|
var metadata = {
|
|
2999
3262
|
method: mergedOptions.options.method || 'GET',
|
|
3000
3263
|
url: constructUrl(mergedOptions.options),
|
|
3001
3264
|
status_code: null,
|
|
3002
|
-
start_time_ms:
|
|
3265
|
+
start_time_ms: now(),
|
|
3003
3266
|
end_time_ms: null
|
|
3004
3267
|
};
|
|
3005
|
-
if (
|
|
3268
|
+
if (_this.autoInstrument.networkRequestHeaders) {
|
|
3006
3269
|
metadata.request_headers = mergedOptions.options.headers;
|
|
3007
3270
|
}
|
|
3008
3271
|
telemeter.captureNetwork(metadata, 'http');
|
|
3009
|
-
|
|
3010
|
-
// Call the original method with the original arguments and wrapped callback.
|
|
3011
|
-
var wrappedArgs = Array.from(arguments);
|
|
3012
|
-
var wrappedCallback = responseCallbackWrapper(self.autoInstrument, metadata, mergedOptions.cb);
|
|
3272
|
+
var wrappedCallback = responseCallbackWrapper(_this.autoInstrument, metadata, mergedOptions.cb);
|
|
3013
3273
|
if (mergedOptions.cb) {
|
|
3014
|
-
|
|
3274
|
+
args.pop();
|
|
3015
3275
|
}
|
|
3016
|
-
|
|
3017
|
-
var req = orig.apply(external_https_namespaceObject,
|
|
3276
|
+
args.push(wrappedCallback);
|
|
3277
|
+
var req = orig.apply(external_https_namespaceObject, args);
|
|
3018
3278
|
req.on('error', function (err) {
|
|
3019
3279
|
metadata.status_code = 0;
|
|
3020
3280
|
metadata.error = [err.name, err.message].join(': ');
|
|
@@ -3024,7 +3284,7 @@ function networkRequestWrapper(orig) {
|
|
|
3024
3284
|
}
|
|
3025
3285
|
function responseCallbackWrapper(options, metadata, callback) {
|
|
3026
3286
|
return function (res) {
|
|
3027
|
-
metadata.end_time_ms =
|
|
3287
|
+
metadata.end_time_ms = now();
|
|
3028
3288
|
metadata.status_code = res.statusCode;
|
|
3029
3289
|
metadata.response = {};
|
|
3030
3290
|
if (options.networkResponseHeaders) {
|
|
@@ -3035,47 +3295,189 @@ function responseCallbackWrapper(options, metadata, callback) {
|
|
|
3035
3295
|
}
|
|
3036
3296
|
};
|
|
3037
3297
|
}
|
|
3038
|
-
Instrumenter.prototype.captureNetwork = function (metadata, subtype, rollbarUUID) {
|
|
3039
|
-
return this.telemeter.captureNetwork(metadata, subtype, rollbarUUID);
|
|
3040
|
-
};
|
|
3041
|
-
Instrumenter.prototype.deinstrumentConsole = function () {
|
|
3042
|
-
restore(this.replacements, 'log');
|
|
3043
|
-
};
|
|
3044
|
-
Instrumenter.prototype.instrumentConsole = function () {
|
|
3045
|
-
var telemeter = this.telemeter;
|
|
3046
|
-
var stdout = process.stdout;
|
|
3047
|
-
utility_replace(stdout, 'write', function (orig) {
|
|
3048
|
-
return function (string) {
|
|
3049
|
-
telemeter.captureLog(string, 'info');
|
|
3050
|
-
return orig.apply(stdout, arguments);
|
|
3051
|
-
};
|
|
3052
|
-
}, this.replacements, 'log');
|
|
3053
|
-
var stderr = process.stderr;
|
|
3054
|
-
utility_replace(stderr, 'write', function (orig) {
|
|
3055
|
-
return function (string) {
|
|
3056
|
-
telemeter.captureLog(string, 'error');
|
|
3057
|
-
return orig.apply(stderr, arguments);
|
|
3058
|
-
};
|
|
3059
|
-
}, this.replacements, 'log');
|
|
3060
|
-
};
|
|
3061
|
-
function restore(replacements, type) {
|
|
3062
|
-
var b;
|
|
3063
|
-
while (replacements[type].length) {
|
|
3064
|
-
b = replacements[type].shift();
|
|
3065
|
-
b[0][b[1]] = b[2];
|
|
3298
|
+
Instrumenter.prototype.captureNetwork = function (metadata, subtype, rollbarUUID) {
|
|
3299
|
+
return this.telemeter.captureNetwork(metadata, subtype, rollbarUUID);
|
|
3300
|
+
};
|
|
3301
|
+
Instrumenter.prototype.deinstrumentConsole = function () {
|
|
3302
|
+
restore(this.replacements, 'log');
|
|
3303
|
+
};
|
|
3304
|
+
Instrumenter.prototype.instrumentConsole = function () {
|
|
3305
|
+
var telemeter = this.telemeter;
|
|
3306
|
+
var stdout = process.stdout;
|
|
3307
|
+
utility_replace(stdout, 'write', function (orig) {
|
|
3308
|
+
return function (string) {
|
|
3309
|
+
telemeter.captureLog(string, 'info');
|
|
3310
|
+
return orig.apply(stdout, arguments);
|
|
3311
|
+
};
|
|
3312
|
+
}, this.replacements, 'log');
|
|
3313
|
+
var stderr = process.stderr;
|
|
3314
|
+
utility_replace(stderr, 'write', function (orig) {
|
|
3315
|
+
return function (string) {
|
|
3316
|
+
telemeter.captureLog(string, 'error');
|
|
3317
|
+
return orig.apply(stderr, arguments);
|
|
3318
|
+
};
|
|
3319
|
+
}, this.replacements, 'log');
|
|
3320
|
+
};
|
|
3321
|
+
function restore(replacements, type) {
|
|
3322
|
+
var b;
|
|
3323
|
+
while (replacements[type].length) {
|
|
3324
|
+
b = replacements[type].shift();
|
|
3325
|
+
b[0][b[1]] = b[2];
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
/* harmony default export */ const server_telemetry = (Instrumenter);
|
|
3329
|
+
;// external "async"
|
|
3330
|
+
const external_async_namespaceObject = require("async");
|
|
3331
|
+
;// external "request-ip"
|
|
3332
|
+
const external_request_ip_namespaceObject = require("request-ip");
|
|
3333
|
+
;// ./src/scrub.js
|
|
3334
|
+
function scrub_slicedToArray(r, e) { return scrub_arrayWithHoles(r) || scrub_iterableToArrayLimit(r, e) || scrub_unsupportedIterableToArray(r, e) || scrub_nonIterableRest(); }
|
|
3335
|
+
function scrub_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3336
|
+
function scrub_iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
3337
|
+
function scrub_arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
3338
|
+
function scrub_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = scrub_unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
3339
|
+
function scrub_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return scrub_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? scrub_arrayLikeToArray(r, a) : void 0; } }
|
|
3340
|
+
function scrub_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
3341
|
+
|
|
3342
|
+
|
|
3343
|
+
function scrub(data, scrubFields, scrubPaths) {
|
|
3344
|
+
scrubFields = scrubFields || [];
|
|
3345
|
+
if (scrubPaths) {
|
|
3346
|
+
var _iterator = scrub_createForOfIteratorHelper(scrubPaths),
|
|
3347
|
+
_step;
|
|
3348
|
+
try {
|
|
3349
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
3350
|
+
var path = _step.value;
|
|
3351
|
+
scrubPath(data, path);
|
|
3352
|
+
}
|
|
3353
|
+
} catch (err) {
|
|
3354
|
+
_iterator.e(err);
|
|
3355
|
+
} finally {
|
|
3356
|
+
_iterator.f();
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
var paramRes = _getScrubFieldRegexs(scrubFields);
|
|
3360
|
+
var queryRes = _getScrubQueryParamRegexs(scrubFields);
|
|
3361
|
+
function redactQueryParam(dummy0, paramPart) {
|
|
3362
|
+
return paramPart + redact();
|
|
3363
|
+
}
|
|
3364
|
+
function paramScrubber(v) {
|
|
3365
|
+
if (isType(v, 'string')) {
|
|
3366
|
+
var _iterator2 = scrub_createForOfIteratorHelper(queryRes),
|
|
3367
|
+
_step2;
|
|
3368
|
+
try {
|
|
3369
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
3370
|
+
var regex = _step2.value;
|
|
3371
|
+
v = v.replace(regex, redactQueryParam);
|
|
3372
|
+
}
|
|
3373
|
+
} catch (err) {
|
|
3374
|
+
_iterator2.e(err);
|
|
3375
|
+
} finally {
|
|
3376
|
+
_iterator2.f();
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
return v;
|
|
3380
|
+
}
|
|
3381
|
+
function valScrubber(k, v) {
|
|
3382
|
+
var _iterator3 = scrub_createForOfIteratorHelper(paramRes),
|
|
3383
|
+
_step3;
|
|
3384
|
+
try {
|
|
3385
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
3386
|
+
var regex = _step3.value;
|
|
3387
|
+
if (regex.test(k)) {
|
|
3388
|
+
v = redact();
|
|
3389
|
+
break;
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
} catch (err) {
|
|
3393
|
+
_iterator3.e(err);
|
|
3394
|
+
} finally {
|
|
3395
|
+
_iterator3.f();
|
|
3396
|
+
}
|
|
3397
|
+
return v;
|
|
3398
|
+
}
|
|
3399
|
+
function scrubber(k, v, seen) {
|
|
3400
|
+
var tmpV = valScrubber(k, v);
|
|
3401
|
+
if (tmpV === v) {
|
|
3402
|
+
if (isType(v, 'object') || isType(v, 'array')) {
|
|
3403
|
+
return utility_traverse(v, scrubber, seen);
|
|
3404
|
+
}
|
|
3405
|
+
return paramScrubber(tmpV);
|
|
3406
|
+
} else {
|
|
3407
|
+
return tmpV;
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
return utility_traverse(data, scrubber);
|
|
3411
|
+
}
|
|
3412
|
+
function scrubPath(obj, path) {
|
|
3413
|
+
var keys = path.split('.');
|
|
3414
|
+
var last = keys.length - 1;
|
|
3415
|
+
try {
|
|
3416
|
+
var _iterator4 = scrub_createForOfIteratorHelper(keys.entries()),
|
|
3417
|
+
_step4;
|
|
3418
|
+
try {
|
|
3419
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
3420
|
+
var _step4$value = scrub_slicedToArray(_step4.value, 2),
|
|
3421
|
+
index = _step4$value[0],
|
|
3422
|
+
key = _step4$value[1];
|
|
3423
|
+
if (index < last) {
|
|
3424
|
+
obj = obj[key];
|
|
3425
|
+
} else {
|
|
3426
|
+
obj[key] = redact();
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
} catch (err) {
|
|
3430
|
+
_iterator4.e(err);
|
|
3431
|
+
} finally {
|
|
3432
|
+
_iterator4.f();
|
|
3433
|
+
}
|
|
3434
|
+
} catch (_e) {
|
|
3435
|
+
// Missing key is OK;
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
function _getScrubFieldRegexs(scrubFields) {
|
|
3439
|
+
var ret = [];
|
|
3440
|
+
var _iterator5 = scrub_createForOfIteratorHelper(scrubFields),
|
|
3441
|
+
_step5;
|
|
3442
|
+
try {
|
|
3443
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
3444
|
+
var field = _step5.value;
|
|
3445
|
+
var pat = '^\\[?(%5[bB])?' + field + '\\[?(%5[bB])?\\]?(%5[dD])?$';
|
|
3446
|
+
ret.push(new RegExp(pat, 'i'));
|
|
3447
|
+
}
|
|
3448
|
+
} catch (err) {
|
|
3449
|
+
_iterator5.e(err);
|
|
3450
|
+
} finally {
|
|
3451
|
+
_iterator5.f();
|
|
3452
|
+
}
|
|
3453
|
+
return ret;
|
|
3454
|
+
}
|
|
3455
|
+
function _getScrubQueryParamRegexs(scrubFields) {
|
|
3456
|
+
var ret = [];
|
|
3457
|
+
var _iterator6 = scrub_createForOfIteratorHelper(scrubFields),
|
|
3458
|
+
_step6;
|
|
3459
|
+
try {
|
|
3460
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
3461
|
+
var field = _step6.value;
|
|
3462
|
+
var pat = '\\[?(%5[bB])?' + field + '\\[?(%5[bB])?\\]?(%5[dD])?';
|
|
3463
|
+
ret.push(new RegExp('(' + pat + '=)([^&\\n]+)', 'igm'));
|
|
3464
|
+
}
|
|
3465
|
+
} catch (err) {
|
|
3466
|
+
_iterator6.e(err);
|
|
3467
|
+
} finally {
|
|
3468
|
+
_iterator6.f();
|
|
3066
3469
|
}
|
|
3470
|
+
return ret;
|
|
3067
3471
|
}
|
|
3068
|
-
/* harmony default export */ const
|
|
3069
|
-
;// external "async"
|
|
3070
|
-
const external_async_namespaceObject = require("async");
|
|
3472
|
+
/* harmony default export */ const src_scrub = (scrub);
|
|
3071
3473
|
;// external "fs"
|
|
3072
3474
|
const external_fs_namespaceObject = require("fs");
|
|
3073
3475
|
;// external "lru-cache"
|
|
3074
3476
|
const external_lru_cache_namespaceObject = require("lru-cache");
|
|
3075
|
-
;// external "source-map"
|
|
3076
|
-
const external_source_map_namespaceObject = require("source-map");
|
|
3077
3477
|
;// external "path"
|
|
3078
3478
|
const external_path_namespaceObject = require("path");
|
|
3479
|
+
;// external "source-map"
|
|
3480
|
+
const external_source_map_namespaceObject = require("source-map");
|
|
3079
3481
|
;// ./src/server/sourceMap/stackTrace.js
|
|
3080
3482
|
|
|
3081
3483
|
|
|
@@ -3122,7 +3524,7 @@ function retrieveFile(path) {
|
|
|
3122
3524
|
if (external_fs_namespaceObject.existsSync(path)) {
|
|
3123
3525
|
contents = external_fs_namespaceObject.readFileSync(path, 'utf8');
|
|
3124
3526
|
}
|
|
3125
|
-
} catch (
|
|
3527
|
+
} catch (_er) {
|
|
3126
3528
|
/* ignore any errors */
|
|
3127
3529
|
}
|
|
3128
3530
|
return fileContentsCache[path] = contents;
|
|
@@ -3133,10 +3535,10 @@ function retrieveFile(path) {
|
|
|
3133
3535
|
function supportRelativeURL(file, url) {
|
|
3134
3536
|
if (!file) return url;
|
|
3135
3537
|
var dir = external_path_namespaceObject.dirname(file);
|
|
3136
|
-
var match = /^\w+:\/\/[
|
|
3538
|
+
var match = /^\w+:\/\/[^/]*/.exec(dir);
|
|
3137
3539
|
var protocol = match ? match[0] : '';
|
|
3138
3540
|
var startPath = dir.slice(protocol.length);
|
|
3139
|
-
if (protocol && /^\/\w
|
|
3541
|
+
if (protocol && /^\/\w:/.test(startPath)) {
|
|
3140
3542
|
// handle file:///C:/ paths
|
|
3141
3543
|
protocol += '/';
|
|
3142
3544
|
return protocol + external_path_namespaceObject.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/');
|
|
@@ -3148,7 +3550,7 @@ function retrieveSourceMapURL(source) {
|
|
|
3148
3550
|
|
|
3149
3551
|
// Get the URL of the source map
|
|
3150
3552
|
fileData = retrieveFile(source);
|
|
3151
|
-
var re = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([
|
|
3553
|
+
var re = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*(?:\*\/)[ \t]*$)/gm;
|
|
3152
3554
|
// Keep executing the search to find the *last* sourceMappingURL to avoid
|
|
3153
3555
|
// picking up sourceMappingURLs from comments, strings, etc.
|
|
3154
3556
|
var lastMatch, match;
|
|
@@ -3394,8 +3796,8 @@ function parseFrameLine(line, callback) {
|
|
|
3394
3796
|
function shouldReadFrameFile(frameFilename, callback) {
|
|
3395
3797
|
var isValidFilename, isCached, isPending;
|
|
3396
3798
|
isValidFilename = frameFilename[0] === '/' || frameFilename[0] === '.';
|
|
3397
|
-
isCached =
|
|
3398
|
-
isPending =
|
|
3799
|
+
isCached = Boolean(cache.get(frameFilename));
|
|
3800
|
+
isPending = Boolean(pendingReads[frameFilename]);
|
|
3399
3801
|
callback(null, isValidFilename && !isCached && !isPending);
|
|
3400
3802
|
}
|
|
3401
3803
|
function readFileLines(filename, callback) {
|
|
@@ -3555,96 +3957,13 @@ function parseStack(stack, options, item, callback) {
|
|
|
3555
3957
|
}
|
|
3556
3958
|
frames.reverse();
|
|
3557
3959
|
external_async_namespaceObject.filter(frames, function (frame, callback) {
|
|
3558
|
-
callback(null,
|
|
3960
|
+
callback(null, Boolean(frame));
|
|
3559
3961
|
}, function (err, results) {
|
|
3560
3962
|
if (err) return callback(err);
|
|
3561
3963
|
gatherContexts(results, callback);
|
|
3562
3964
|
});
|
|
3563
3965
|
});
|
|
3564
3966
|
}
|
|
3565
|
-
;// external "request-ip"
|
|
3566
|
-
const external_request_ip_namespaceObject = require("request-ip");
|
|
3567
|
-
;// ./src/scrub.js
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
function scrub(data, scrubFields, scrubPaths) {
|
|
3571
|
-
scrubFields = scrubFields || [];
|
|
3572
|
-
if (scrubPaths) {
|
|
3573
|
-
for (var i = 0; i < scrubPaths.length; ++i) {
|
|
3574
|
-
scrubPath(data, scrubPaths[i]);
|
|
3575
|
-
}
|
|
3576
|
-
}
|
|
3577
|
-
var paramRes = _getScrubFieldRegexs(scrubFields);
|
|
3578
|
-
var queryRes = _getScrubQueryParamRegexs(scrubFields);
|
|
3579
|
-
function redactQueryParam(dummy0, paramPart) {
|
|
3580
|
-
return paramPart + redact();
|
|
3581
|
-
}
|
|
3582
|
-
function paramScrubber(v) {
|
|
3583
|
-
var i;
|
|
3584
|
-
if (isType(v, 'string')) {
|
|
3585
|
-
for (i = 0; i < queryRes.length; ++i) {
|
|
3586
|
-
v = v.replace(queryRes[i], redactQueryParam);
|
|
3587
|
-
}
|
|
3588
|
-
}
|
|
3589
|
-
return v;
|
|
3590
|
-
}
|
|
3591
|
-
function valScrubber(k, v) {
|
|
3592
|
-
var i;
|
|
3593
|
-
for (i = 0; i < paramRes.length; ++i) {
|
|
3594
|
-
if (paramRes[i].test(k)) {
|
|
3595
|
-
v = redact();
|
|
3596
|
-
break;
|
|
3597
|
-
}
|
|
3598
|
-
}
|
|
3599
|
-
return v;
|
|
3600
|
-
}
|
|
3601
|
-
function scrubber(k, v, seen) {
|
|
3602
|
-
var tmpV = valScrubber(k, v);
|
|
3603
|
-
if (tmpV === v) {
|
|
3604
|
-
if (isType(v, 'object') || isType(v, 'array')) {
|
|
3605
|
-
return utility_traverse(v, scrubber, seen);
|
|
3606
|
-
}
|
|
3607
|
-
return paramScrubber(tmpV);
|
|
3608
|
-
} else {
|
|
3609
|
-
return tmpV;
|
|
3610
|
-
}
|
|
3611
|
-
}
|
|
3612
|
-
return utility_traverse(data, scrubber);
|
|
3613
|
-
}
|
|
3614
|
-
function scrubPath(obj, path) {
|
|
3615
|
-
var keys = path.split('.');
|
|
3616
|
-
var last = keys.length - 1;
|
|
3617
|
-
try {
|
|
3618
|
-
for (var i = 0; i <= last; ++i) {
|
|
3619
|
-
if (i < last) {
|
|
3620
|
-
obj = obj[keys[i]];
|
|
3621
|
-
} else {
|
|
3622
|
-
obj[keys[i]] = redact();
|
|
3623
|
-
}
|
|
3624
|
-
}
|
|
3625
|
-
} catch (e) {
|
|
3626
|
-
// Missing key is OK;
|
|
3627
|
-
}
|
|
3628
|
-
}
|
|
3629
|
-
function _getScrubFieldRegexs(scrubFields) {
|
|
3630
|
-
var ret = [];
|
|
3631
|
-
var pat;
|
|
3632
|
-
for (var i = 0; i < scrubFields.length; ++i) {
|
|
3633
|
-
pat = '^\\[?(%5[bB])?' + scrubFields[i] + '\\[?(%5[bB])?\\]?(%5[dD])?$';
|
|
3634
|
-
ret.push(new RegExp(pat, 'i'));
|
|
3635
|
-
}
|
|
3636
|
-
return ret;
|
|
3637
|
-
}
|
|
3638
|
-
function _getScrubQueryParamRegexs(scrubFields) {
|
|
3639
|
-
var ret = [];
|
|
3640
|
-
var pat;
|
|
3641
|
-
for (var i = 0; i < scrubFields.length; ++i) {
|
|
3642
|
-
pat = '\\[?(%5[bB])?' + scrubFields[i] + '\\[?(%5[bB])?\\]?(%5[dD])?';
|
|
3643
|
-
ret.push(new RegExp('(' + pat + '=)([^&\\n]+)', 'igm'));
|
|
3644
|
-
}
|
|
3645
|
-
return ret;
|
|
3646
|
-
}
|
|
3647
|
-
/* harmony default export */ const src_scrub = (scrub);
|
|
3648
3967
|
;// ./src/server/transforms.js
|
|
3649
3968
|
|
|
3650
3969
|
|
|
@@ -3653,6 +3972,7 @@ function _getScrubQueryParamRegexs(scrubFields) {
|
|
|
3653
3972
|
|
|
3654
3973
|
|
|
3655
3974
|
function baseData(item, options, callback) {
|
|
3975
|
+
var _item$data;
|
|
3656
3976
|
var environment = options.payload && options.payload.environment || options.environment;
|
|
3657
3977
|
var data = {
|
|
3658
3978
|
timestamp: Math.round(item.timestamp / 1000),
|
|
@@ -3662,7 +3982,8 @@ function baseData(item, options, callback) {
|
|
|
3662
3982
|
framework: item.framework || options.framework,
|
|
3663
3983
|
uuid: item.uuid,
|
|
3664
3984
|
notifier: JSON.parse(JSON.stringify(options.notifier)),
|
|
3665
|
-
custom: item.custom
|
|
3985
|
+
custom: item.custom,
|
|
3986
|
+
attributes: (_item$data = item.data) === null || _item$data === void 0 ? void 0 : _item$data.attributes
|
|
3666
3987
|
};
|
|
3667
3988
|
if (options.codeVersion) {
|
|
3668
3989
|
data.code_version = options.codeVersion;
|
|
@@ -3671,7 +3992,7 @@ function baseData(item, options, callback) {
|
|
|
3671
3992
|
}
|
|
3672
3993
|
var props = Object.getOwnPropertyNames(item.custom || {});
|
|
3673
3994
|
props.forEach(function (name) {
|
|
3674
|
-
if (!data
|
|
3995
|
+
if (!hasOwn(data, name)) {
|
|
3675
3996
|
data[name] = item.custom[name];
|
|
3676
3997
|
}
|
|
3677
3998
|
});
|
|
@@ -3762,7 +4083,7 @@ function addRequestData(item, options, callback) {
|
|
|
3762
4083
|
try {
|
|
3763
4084
|
routePath = req.app._router.matchRequest(req).path;
|
|
3764
4085
|
item.data.context = baseUrl && baseUrl.length ? baseUrl + routePath : routePath;
|
|
3765
|
-
} catch (
|
|
4086
|
+
} catch (_ignore) {
|
|
3766
4087
|
// Ignored
|
|
3767
4088
|
}
|
|
3768
4089
|
}
|
|
@@ -3912,7 +4233,7 @@ function _buildRequestData(req) {
|
|
|
3912
4233
|
var bodyParams = {};
|
|
3913
4234
|
if (isIterable(body)) {
|
|
3914
4235
|
for (var k in body) {
|
|
3915
|
-
if (
|
|
4236
|
+
if (hasOwn(body, k)) {
|
|
3916
4237
|
bodyParams[k] = body[k];
|
|
3917
4238
|
}
|
|
3918
4239
|
}
|
|
@@ -3924,305 +4245,177 @@ function _buildRequestData(req) {
|
|
|
3924
4245
|
return data;
|
|
3925
4246
|
}
|
|
3926
4247
|
|
|
3927
|
-
;// ./src/
|
|
4248
|
+
;// ./src/server/transport.js
|
|
3928
4249
|
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
4250
|
+
|
|
4251
|
+
|
|
4252
|
+
|
|
4253
|
+
|
|
4254
|
+
|
|
4255
|
+
var MAX_RATE_LIMIT_INTERVAL = 60;
|
|
4256
|
+
|
|
4257
|
+
/*
|
|
4258
|
+
* accessToken may be embedded in payload but that should not be assumed
|
|
4259
|
+
*
|
|
4260
|
+
* options: {
|
|
4261
|
+
* hostname
|
|
4262
|
+
* protocol
|
|
4263
|
+
* path
|
|
4264
|
+
* port
|
|
4265
|
+
* method
|
|
4266
|
+
* }
|
|
4267
|
+
*
|
|
4268
|
+
* params is an object containing key/value pairs to be
|
|
4269
|
+
* appended to the path as 'key=value&key=value'
|
|
4270
|
+
*
|
|
4271
|
+
* payload is an unserialized object
|
|
4272
|
+
*/
|
|
4273
|
+
function Transport() {
|
|
4274
|
+
this.rateLimitExpires = 0;
|
|
3937
4275
|
}
|
|
3938
|
-
function
|
|
3939
|
-
var
|
|
3940
|
-
if (
|
|
3941
|
-
|
|
4276
|
+
Transport.prototype.get = function (accessToken, options, params, callback, transportFactory) {
|
|
4277
|
+
var t;
|
|
4278
|
+
if (!callback || !isFunction(callback)) {
|
|
4279
|
+
callback = function callback() {};
|
|
3942
4280
|
}
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
4281
|
+
options = options || {};
|
|
4282
|
+
addParamsAndAccessTokenToPath(accessToken, options, params);
|
|
4283
|
+
options.headers = _headers(accessToken, options);
|
|
4284
|
+
if (transportFactory) {
|
|
4285
|
+
t = transportFactory(options);
|
|
4286
|
+
} else {
|
|
4287
|
+
t = _transport(options);
|
|
3949
4288
|
}
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
if (!item.message) {
|
|
3954
|
-
callback(null, item);
|
|
3955
|
-
return;
|
|
4289
|
+
if (!t) {
|
|
4290
|
+
src_logger.error('Unknown transport based on given protocol: ' + options.protocol);
|
|
4291
|
+
return callback(new Error('Unknown transport'));
|
|
3956
4292
|
}
|
|
3957
|
-
var
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
4293
|
+
var req = t.request(options, function (resp) {
|
|
4294
|
+
this.handleResponse(resp, callback);
|
|
4295
|
+
}.bind(this));
|
|
4296
|
+
req.on('error', function (err) {
|
|
4297
|
+
callback(err);
|
|
4298
|
+
});
|
|
4299
|
+
req.end();
|
|
4300
|
+
};
|
|
4301
|
+
Transport.prototype.post = function (_ref) {
|
|
4302
|
+
var accessToken = _ref.accessToken,
|
|
4303
|
+
options = _ref.options,
|
|
4304
|
+
payload = _ref.payload,
|
|
4305
|
+
callback = _ref.callback,
|
|
4306
|
+
transportFactory = _ref.transportFactory;
|
|
4307
|
+
var t;
|
|
4308
|
+
if (!callback || !isFunction(callback)) {
|
|
4309
|
+
callback = function callback() {};
|
|
3962
4310
|
}
|
|
3963
|
-
if (
|
|
3964
|
-
|
|
3965
|
-
set(item, tracePath + '.exception.description', item.message);
|
|
3966
|
-
callback(null, item);
|
|
3967
|
-
return;
|
|
3968
|
-
}
|
|
3969
|
-
var extra = get(item, tracePath + '.extra') || {};
|
|
3970
|
-
var newExtra = src_merge(extra, {
|
|
3971
|
-
message: item.message
|
|
3972
|
-
});
|
|
3973
|
-
set(item, tracePath + '.extra', newExtra);
|
|
4311
|
+
if (_currentTime() < this.rateLimitExpires) {
|
|
4312
|
+
return callback(new Error('Exceeded rate limit'));
|
|
3974
4313
|
}
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
return function (item, options, callback) {
|
|
3979
|
-
var newItem = src_merge(item);
|
|
3980
|
-
var response = null;
|
|
3981
|
-
try {
|
|
3982
|
-
if (isFunction(options.transform)) {
|
|
3983
|
-
response = options.transform(newItem.data, item);
|
|
3984
|
-
}
|
|
3985
|
-
} catch (e) {
|
|
3986
|
-
options.transform = null;
|
|
3987
|
-
logger.error('Error while calling custom transform() function. Removing custom transform().', e);
|
|
3988
|
-
callback(null, item);
|
|
3989
|
-
return;
|
|
3990
|
-
}
|
|
3991
|
-
if (isPromise(response)) {
|
|
3992
|
-
response.then(function (promisedItem) {
|
|
3993
|
-
if (promisedItem) {
|
|
3994
|
-
newItem.data = promisedItem;
|
|
3995
|
-
}
|
|
3996
|
-
callback(null, newItem);
|
|
3997
|
-
}, function (error) {
|
|
3998
|
-
callback(error, item);
|
|
3999
|
-
});
|
|
4000
|
-
} else {
|
|
4001
|
-
callback(null, newItem);
|
|
4002
|
-
}
|
|
4003
|
-
};
|
|
4004
|
-
}
|
|
4005
|
-
function addConfigToPayload(item, options, callback) {
|
|
4006
|
-
if (!options.sendConfig) {
|
|
4007
|
-
return callback(null, item);
|
|
4314
|
+
options = options || {};
|
|
4315
|
+
if (!payload) {
|
|
4316
|
+
return callback(new Error('Cannot send empty request'));
|
|
4008
4317
|
}
|
|
4009
|
-
var
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
if (
|
|
4017
|
-
|
|
4318
|
+
var stringifyResult = truncation.truncate(payload, external_json_stringify_safe_namespaceObject);
|
|
4319
|
+
if (stringifyResult.error) {
|
|
4320
|
+
src_logger.error('Problem stringifying payload. Giving up');
|
|
4321
|
+
return callback(stringifyResult.error);
|
|
4322
|
+
}
|
|
4323
|
+
var writeData = stringifyResult.value;
|
|
4324
|
+
options.headers = _headers(accessToken, options, writeData);
|
|
4325
|
+
if (transportFactory) {
|
|
4326
|
+
t = transportFactory(options);
|
|
4327
|
+
} else {
|
|
4328
|
+
t = _transport(options);
|
|
4018
4329
|
}
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
// These must be stringified or they'll get dropped during serialization.
|
|
4024
|
-
addFunctionOption(configuredOptions, 'transform');
|
|
4025
|
-
addFunctionOption(configuredOptions, 'checkIgnore');
|
|
4026
|
-
addFunctionOption(configuredOptions, 'onSendCallback');
|
|
4027
|
-
delete configuredOptions.accessToken;
|
|
4028
|
-
item.data.notifier.configured_options = configuredOptions;
|
|
4029
|
-
callback(null, item);
|
|
4030
|
-
}
|
|
4031
|
-
function addDiagnosticKeys(item, options, callback) {
|
|
4032
|
-
var diagnostic = src_merge(item.notifier.client.notifier.diagnostic, item.diagnostic);
|
|
4033
|
-
if (get(item, 'err._isAnonymous')) {
|
|
4034
|
-
diagnostic.is_anonymous = true;
|
|
4330
|
+
if (!t) {
|
|
4331
|
+
src_logger.error('Unknown transport based on given protocol: ' + options.protocol);
|
|
4332
|
+
return callback(new Error('Unknown transport'));
|
|
4035
4333
|
}
|
|
4036
|
-
|
|
4037
|
-
|
|
4334
|
+
var req = t.request(options, function (resp) {
|
|
4335
|
+
this.handleResponse(resp, _wrapPostCallback(callback));
|
|
4336
|
+
}.bind(this));
|
|
4337
|
+
req.on('error', function (err) {
|
|
4338
|
+
callback(err);
|
|
4339
|
+
});
|
|
4340
|
+
if (writeData) {
|
|
4341
|
+
req.write(writeData);
|
|
4038
4342
|
}
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
};
|
|
4050
|
-
} catch (e) {
|
|
4051
|
-
diagnostic.raw_error = {
|
|
4052
|
-
failed: String(e)
|
|
4053
|
-
};
|
|
4054
|
-
}
|
|
4343
|
+
req.end();
|
|
4344
|
+
};
|
|
4345
|
+
Transport.prototype.updateRateLimit = function (resp) {
|
|
4346
|
+
var remaining = parseInt(resp.headers['x-rate-limit-remaining'] || 0);
|
|
4347
|
+
var remainingSeconds = Math.min(MAX_RATE_LIMIT_INTERVAL, resp.headers['x-rate-limit-remaining-seconds'] || 0);
|
|
4348
|
+
var currentTime = _currentTime();
|
|
4349
|
+
if (resp.statusCode === 429 && remaining === 0) {
|
|
4350
|
+
this.rateLimitExpires = currentTime + remainingSeconds;
|
|
4351
|
+
} else {
|
|
4352
|
+
this.rateLimitExpires = currentTime;
|
|
4055
4353
|
}
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4354
|
+
};
|
|
4355
|
+
Transport.prototype.handleResponse = function (resp, callback) {
|
|
4356
|
+
this.updateRateLimit(resp);
|
|
4357
|
+
var respData = [];
|
|
4358
|
+
resp.setEncoding('utf8');
|
|
4359
|
+
resp.on('data', function (chunk) {
|
|
4360
|
+
respData.push(chunk);
|
|
4361
|
+
});
|
|
4362
|
+
resp.on('end', function () {
|
|
4363
|
+
respData = respData.join('');
|
|
4364
|
+
_parseApiResponse(respData, callback);
|
|
4365
|
+
});
|
|
4366
|
+
};
|
|
4059
4367
|
|
|
4060
|
-
|
|
4368
|
+
/** Helpers **/
|
|
4061
4369
|
|
|
4062
|
-
function
|
|
4063
|
-
var
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
var reportLevelVal = LEVELS[reportLevel] || 0;
|
|
4067
|
-
if (levelVal < reportLevelVal) {
|
|
4068
|
-
return false;
|
|
4069
|
-
}
|
|
4070
|
-
return true;
|
|
4071
|
-
}
|
|
4072
|
-
function userCheckIgnore(logger) {
|
|
4073
|
-
return function (item, settings) {
|
|
4074
|
-
var isUncaught = !!item._isUncaught;
|
|
4075
|
-
delete item._isUncaught;
|
|
4076
|
-
var args = item._originalArgs;
|
|
4077
|
-
delete item._originalArgs;
|
|
4078
|
-
try {
|
|
4079
|
-
if (isFunction(settings.onSendCallback)) {
|
|
4080
|
-
settings.onSendCallback(isUncaught, args, item);
|
|
4081
|
-
}
|
|
4082
|
-
} catch (e) {
|
|
4083
|
-
settings.onSendCallback = null;
|
|
4084
|
-
logger.error('Error while calling onSendCallback, removing', e);
|
|
4085
|
-
}
|
|
4370
|
+
function _headers(accessToken, options, data) {
|
|
4371
|
+
var headers = options && options.headers || {};
|
|
4372
|
+
headers['Content-Type'] = 'application/json';
|
|
4373
|
+
if (data) {
|
|
4086
4374
|
try {
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
} catch (e) {
|
|
4091
|
-
settings.checkIgnore = null;
|
|
4092
|
-
logger.error('Error while calling custom checkIgnore(), removing', e);
|
|
4375
|
+
headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
|
4376
|
+
} catch (_e) {
|
|
4377
|
+
src_logger.error('Could not get the content length of the data');
|
|
4093
4378
|
}
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
function urlIsNotBlockListed(logger) {
|
|
4098
|
-
return function (item, settings) {
|
|
4099
|
-
return !urlIsOnAList(item, settings, 'blocklist', logger);
|
|
4100
|
-
};
|
|
4379
|
+
}
|
|
4380
|
+
headers['X-Rollbar-Access-Token'] = accessToken;
|
|
4381
|
+
return headers;
|
|
4101
4382
|
}
|
|
4102
|
-
function
|
|
4103
|
-
return
|
|
4104
|
-
|
|
4105
|
-
|
|
4383
|
+
function _transport(options) {
|
|
4384
|
+
return {
|
|
4385
|
+
'http:': external_http_namespaceObject,
|
|
4386
|
+
'https:': external_https_namespaceObject
|
|
4387
|
+
}[options.protocol];
|
|
4106
4388
|
}
|
|
4107
|
-
function
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
if (!frames || frames.length === 0) {
|
|
4113
|
-
return !block;
|
|
4389
|
+
function _parseApiResponse(data, callback) {
|
|
4390
|
+
var parsedData = jsonParse(data);
|
|
4391
|
+
if (parsedData.error) {
|
|
4392
|
+
src_logger.error('Could not parse api response, err: ' + parsedData.error);
|
|
4393
|
+
return callback(parsedData.error);
|
|
4114
4394
|
}
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
frame = frames[i];
|
|
4120
|
-
filename = frame.filename;
|
|
4121
|
-
if (!isType(filename, 'string')) {
|
|
4122
|
-
return !block;
|
|
4123
|
-
}
|
|
4124
|
-
for (var j = 0; j < listLength; j++) {
|
|
4125
|
-
url = list[j];
|
|
4126
|
-
urlRegex = new RegExp(url);
|
|
4127
|
-
if (urlRegex.test(filename)) {
|
|
4128
|
-
return true;
|
|
4129
|
-
}
|
|
4130
|
-
}
|
|
4395
|
+
data = parsedData.value;
|
|
4396
|
+
if (data.err) {
|
|
4397
|
+
src_logger.error('Received error: ' + data.message);
|
|
4398
|
+
return callback(new Error('Api error: ' + (data.message || 'Unknown error')));
|
|
4131
4399
|
}
|
|
4132
|
-
|
|
4400
|
+
callback(null, data);
|
|
4133
4401
|
}
|
|
4134
|
-
function
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
block = true;
|
|
4139
|
-
}
|
|
4140
|
-
var list, traces;
|
|
4141
|
-
try {
|
|
4142
|
-
list = block ? settings.hostBlockList : settings.hostSafeList;
|
|
4143
|
-
traces = get(item, 'body.trace_chain') || [get(item, 'body.trace')];
|
|
4144
|
-
|
|
4145
|
-
// These two checks are important to come first as they are defaults
|
|
4146
|
-
// in case the list is missing or the trace is missing or not well-formed
|
|
4147
|
-
if (!list || list.length === 0) {
|
|
4148
|
-
return !block;
|
|
4149
|
-
}
|
|
4150
|
-
if (traces.length === 0 || !traces[0]) {
|
|
4151
|
-
return !block;
|
|
4152
|
-
}
|
|
4153
|
-
var tracesLength = traces.length;
|
|
4154
|
-
for (var i = 0; i < tracesLength; i++) {
|
|
4155
|
-
if (matchFrames(traces[i], list, block)) {
|
|
4156
|
-
return true;
|
|
4157
|
-
}
|
|
4402
|
+
function _wrapPostCallback(callback) {
|
|
4403
|
+
return function (err, data) {
|
|
4404
|
+
if (err) {
|
|
4405
|
+
return callback(err);
|
|
4158
4406
|
}
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
if (block) {
|
|
4162
|
-
settings.hostBlockList = null;
|
|
4407
|
+
if (data.result && data.result.uuid) {
|
|
4408
|
+
src_logger.log(['Successful api response.', ' Link: https://rollbar.com/occurrence/uuid/?uuid=' + data.result.uuid].join(''));
|
|
4163
4409
|
} else {
|
|
4164
|
-
|
|
4165
|
-
}
|
|
4166
|
-
var listName = block ? 'hostBlockList' : 'hostSafeList';
|
|
4167
|
-
logger.error("Error while reading your configuration's " + listName + ' option. Removing custom ' + listName + '.', e);
|
|
4168
|
-
return !block;
|
|
4169
|
-
}
|
|
4170
|
-
return false;
|
|
4171
|
-
}
|
|
4172
|
-
function messageIsIgnored(logger) {
|
|
4173
|
-
return function (item, settings) {
|
|
4174
|
-
var i, j, ignoredMessages, len, messageIsIgnored, rIgnoredMessage, messages;
|
|
4175
|
-
try {
|
|
4176
|
-
messageIsIgnored = false;
|
|
4177
|
-
ignoredMessages = settings.ignoredMessages;
|
|
4178
|
-
if (!ignoredMessages || ignoredMessages.length === 0) {
|
|
4179
|
-
return true;
|
|
4180
|
-
}
|
|
4181
|
-
messages = messagesFromItem(item);
|
|
4182
|
-
if (messages.length === 0) {
|
|
4183
|
-
return true;
|
|
4184
|
-
}
|
|
4185
|
-
len = ignoredMessages.length;
|
|
4186
|
-
for (i = 0; i < len; i++) {
|
|
4187
|
-
rIgnoredMessage = new RegExp(ignoredMessages[i], 'gi');
|
|
4188
|
-
for (j = 0; j < messages.length; j++) {
|
|
4189
|
-
messageIsIgnored = rIgnoredMessage.test(messages[j]);
|
|
4190
|
-
if (messageIsIgnored) {
|
|
4191
|
-
return false;
|
|
4192
|
-
}
|
|
4193
|
-
}
|
|
4194
|
-
}
|
|
4195
|
-
} catch (e
|
|
4196
|
-
/* istanbul ignore next */) {
|
|
4197
|
-
settings.ignoredMessages = null;
|
|
4198
|
-
logger.error("Error while reading your configuration's ignoredMessages option. Removing custom ignoredMessages.");
|
|
4410
|
+
src_logger.log('Successful api response');
|
|
4199
4411
|
}
|
|
4200
|
-
|
|
4412
|
+
callback(null, data.result);
|
|
4201
4413
|
};
|
|
4202
4414
|
}
|
|
4203
|
-
function
|
|
4204
|
-
|
|
4205
|
-
var messages = [];
|
|
4206
|
-
|
|
4207
|
-
// The payload schema only allows one of trace_chain, message, or trace.
|
|
4208
|
-
// However, existing test cases are based on having both trace and message present.
|
|
4209
|
-
// So here we preserve the ability to collect strings from any combination of these keys.
|
|
4210
|
-
if (body.trace_chain) {
|
|
4211
|
-
var traceChain = body.trace_chain;
|
|
4212
|
-
for (var i = 0; i < traceChain.length; i++) {
|
|
4213
|
-
var trace = traceChain[i];
|
|
4214
|
-
messages.push(get(trace, 'exception.message'));
|
|
4215
|
-
}
|
|
4216
|
-
}
|
|
4217
|
-
if (body.trace) {
|
|
4218
|
-
messages.push(get(body, 'trace.exception.message'));
|
|
4219
|
-
}
|
|
4220
|
-
if (body.message) {
|
|
4221
|
-
messages.push(get(body, 'message.body'));
|
|
4222
|
-
}
|
|
4223
|
-
return messages;
|
|
4415
|
+
function _currentTime() {
|
|
4416
|
+
return Math.floor(Date.now() / 1000);
|
|
4224
4417
|
}
|
|
4225
|
-
|
|
4418
|
+
/* harmony default export */ const server_transport = (Transport);
|
|
4226
4419
|
;// ./src/server/rollbar.js
|
|
4227
4420
|
|
|
4228
4421
|
|
|
@@ -4551,69 +4744,70 @@ rollbar_Rollbar.prototype.lambdaHandler = function (handler, timeoutHandler) {
|
|
|
4551
4744
|
return this.syncLambdaHandler(handler, timeoutHandler);
|
|
4552
4745
|
};
|
|
4553
4746
|
rollbar_Rollbar.prototype.asyncLambdaHandler = function (handler, timeoutHandler) {
|
|
4554
|
-
var
|
|
4747
|
+
var _this = this;
|
|
4555
4748
|
var _timeoutHandler = function _timeoutHandler(event, context) {
|
|
4556
4749
|
var message = 'Function timed out';
|
|
4557
4750
|
var custom = {
|
|
4558
4751
|
originalEvent: event,
|
|
4559
4752
|
originalRequestId: context.awsRequestId
|
|
4560
4753
|
};
|
|
4561
|
-
|
|
4754
|
+
_this.error(message, custom);
|
|
4562
4755
|
};
|
|
4563
|
-
var shouldReportTimeouts =
|
|
4564
|
-
|
|
4756
|
+
var shouldReportTimeouts = this.options.captureLambdaTimeouts;
|
|
4757
|
+
var rollbarAsyncLambdaHandler = function rollbarAsyncLambdaHandler(event, context) {
|
|
4565
4758
|
return new Promise(function (resolve, reject) {
|
|
4566
|
-
|
|
4759
|
+
_this.lambdaContext = context;
|
|
4567
4760
|
if (shouldReportTimeouts) {
|
|
4568
4761
|
var timeoutCb = (timeoutHandler || _timeoutHandler).bind(null, event, context);
|
|
4569
|
-
|
|
4762
|
+
_this.lambdaTimeoutHandle = setTimeout(timeoutCb, context.getRemainingTimeInMillis() - 1000);
|
|
4570
4763
|
}
|
|
4571
4764
|
handler(event, context).then(function (resp) {
|
|
4572
|
-
|
|
4573
|
-
clearTimeout(
|
|
4765
|
+
_this.wait(function () {
|
|
4766
|
+
clearTimeout(_this.lambdaTimeoutHandle);
|
|
4574
4767
|
resolve(resp);
|
|
4575
4768
|
});
|
|
4576
4769
|
}).catch(function (err) {
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
clearTimeout(
|
|
4770
|
+
_this.error(err);
|
|
4771
|
+
_this.wait(function () {
|
|
4772
|
+
clearTimeout(_this.lambdaTimeoutHandle);
|
|
4580
4773
|
reject(err);
|
|
4581
4774
|
});
|
|
4582
4775
|
});
|
|
4583
4776
|
});
|
|
4584
4777
|
};
|
|
4778
|
+
return rollbarAsyncLambdaHandler;
|
|
4585
4779
|
};
|
|
4586
4780
|
rollbar_Rollbar.prototype.syncLambdaHandler = function (handler, timeoutHandler) {
|
|
4587
|
-
var
|
|
4781
|
+
var _this2 = this;
|
|
4588
4782
|
var _timeoutHandler = function _timeoutHandler(event, context, _cb) {
|
|
4589
4783
|
var message = 'Function timed out';
|
|
4590
4784
|
var custom = {
|
|
4591
4785
|
originalEvent: event,
|
|
4592
4786
|
originalRequestId: context.awsRequestId
|
|
4593
4787
|
};
|
|
4594
|
-
|
|
4788
|
+
_this2.error(message, custom);
|
|
4595
4789
|
};
|
|
4596
|
-
var shouldReportTimeouts =
|
|
4790
|
+
var shouldReportTimeouts = this.options.captureLambdaTimeouts;
|
|
4597
4791
|
return function (event, context, callback) {
|
|
4598
|
-
|
|
4792
|
+
_this2.lambdaContext = context;
|
|
4599
4793
|
if (shouldReportTimeouts) {
|
|
4600
4794
|
var timeoutCb = (timeoutHandler || _timeoutHandler).bind(null, event, context, callback);
|
|
4601
|
-
|
|
4795
|
+
_this2.lambdaTimeoutHandle = setTimeout(timeoutCb, context.getRemainingTimeInMillis() - 1000);
|
|
4602
4796
|
}
|
|
4603
4797
|
try {
|
|
4604
4798
|
handler(event, context, function (err, resp) {
|
|
4605
4799
|
if (err) {
|
|
4606
|
-
|
|
4800
|
+
_this2.error(err);
|
|
4607
4801
|
}
|
|
4608
|
-
|
|
4609
|
-
clearTimeout(
|
|
4802
|
+
_this2.wait(function () {
|
|
4803
|
+
clearTimeout(_this2.lambdaTimeoutHandle);
|
|
4610
4804
|
callback(err, resp);
|
|
4611
4805
|
});
|
|
4612
4806
|
});
|
|
4613
4807
|
} catch (err) {
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
clearTimeout(
|
|
4808
|
+
_this2.error(err);
|
|
4809
|
+
_this2.wait(function () {
|
|
4810
|
+
clearTimeout(_this2.lambdaTimeoutHandle);
|
|
4617
4811
|
throw err;
|
|
4618
4812
|
});
|
|
4619
4813
|
}
|
|
@@ -4768,7 +4962,7 @@ rollbar_Rollbar.prototype.setupUnhandledCapture = function () {
|
|
|
4768
4962
|
}
|
|
4769
4963
|
};
|
|
4770
4964
|
rollbar_Rollbar.prototype.handleUncaughtExceptions = function () {
|
|
4771
|
-
var exitOnUncaught =
|
|
4965
|
+
var exitOnUncaught = Boolean(this.options.exitOnUncaughtException);
|
|
4772
4966
|
delete this.options.exitOnUncaughtException;
|
|
4773
4967
|
addOrReplaceRollbarHandler('uncaughtException', function (err) {
|
|
4774
4968
|
if (!this.options.captureUncaught && !this.options.handleUncaughtExceptions) {
|