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/src/browser/telemetry.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-this-alias */
|
|
2
|
+
// TODO(matux): refactor to remove no-this-alias disable
|
|
3
|
+
|
|
4
|
+
import logger from '../logger.js';
|
|
5
|
+
import scrub from '../scrub.js';
|
|
2
6
|
import headers from '../utility/headers.js';
|
|
3
7
|
import replace from '../utility/replace.js';
|
|
4
|
-
import
|
|
5
|
-
|
|
8
|
+
import * as _ from '../utility.js';
|
|
9
|
+
|
|
6
10
|
import * as domUtil from './domUtility.js';
|
|
11
|
+
import * as urlparser from './url.js';
|
|
7
12
|
|
|
8
13
|
const defaults = {
|
|
9
14
|
network: true,
|
|
@@ -98,8 +103,8 @@ class Instrumenter {
|
|
|
98
103
|
|
|
99
104
|
configureScrubbing() {
|
|
100
105
|
const options = this.options;
|
|
101
|
-
this.scrubTelemetryInputs =
|
|
102
|
-
options.scrubTelemetryInputs ?? options.replay?.maskAllInputs
|
|
106
|
+
this.scrubTelemetryInputs = Boolean(
|
|
107
|
+
options.scrubTelemetryInputs ?? options.replay?.maskAllInputs,
|
|
103
108
|
);
|
|
104
109
|
this.telemetryScrubber = options.telemetryScrubber;
|
|
105
110
|
this.defaultValueScrubber = defaultValueScrubber(options.scrubFields);
|
|
@@ -326,7 +331,7 @@ class Instrumenter {
|
|
|
326
331
|
headers[h] = xhr.getResponseHeader(h);
|
|
327
332
|
}
|
|
328
333
|
}
|
|
329
|
-
} catch (
|
|
334
|
+
} catch (_e) {
|
|
330
335
|
/* we ignore the errors here that could come from different
|
|
331
336
|
* browser issues with the xhr methods */
|
|
332
337
|
}
|
|
@@ -335,7 +340,7 @@ class Instrumenter {
|
|
|
335
340
|
if (self.autoInstrument.networkResponseBody) {
|
|
336
341
|
try {
|
|
337
342
|
body = xhr.responseText;
|
|
338
|
-
} catch (
|
|
343
|
+
} catch (_e) {
|
|
339
344
|
/* ignore errors from reading responseText */
|
|
340
345
|
}
|
|
341
346
|
}
|
|
@@ -372,7 +377,7 @@ class Instrumenter {
|
|
|
372
377
|
xhr.__rollbar_event.level =
|
|
373
378
|
self.telemeter.levelFromStatus(code);
|
|
374
379
|
self.errorOnHttpStatus(xhr.__rollbar_xhr);
|
|
375
|
-
} catch (
|
|
380
|
+
} catch (_e) {
|
|
376
381
|
/* ignore possible exception from xhr.status */
|
|
377
382
|
}
|
|
378
383
|
}
|
|
@@ -413,7 +418,7 @@ class Instrumenter {
|
|
|
413
418
|
this._window,
|
|
414
419
|
'fetch',
|
|
415
420
|
function (orig) {
|
|
416
|
-
return function (
|
|
421
|
+
return function (_fn, _t) {
|
|
417
422
|
const args = [...arguments];
|
|
418
423
|
const input = args[0];
|
|
419
424
|
let method = 'GET';
|
|
@@ -584,7 +589,7 @@ class Instrumenter {
|
|
|
584
589
|
outHeaders[h] = inHeaders.get(h);
|
|
585
590
|
}
|
|
586
591
|
}
|
|
587
|
-
} catch (
|
|
592
|
+
} catch (_e) {
|
|
588
593
|
/* ignore probable IE errors */
|
|
589
594
|
}
|
|
590
595
|
return outHeaders;
|
|
@@ -629,6 +634,7 @@ class Instrumenter {
|
|
|
629
634
|
const c = this._window.console;
|
|
630
635
|
|
|
631
636
|
function wrapConsole(method) {
|
|
637
|
+
// eslint-disable-next-line strict
|
|
632
638
|
'use strict'; // See https://github.com/rollbar/rollbar.js/pull/778
|
|
633
639
|
|
|
634
640
|
const orig = c[method];
|
|
@@ -659,7 +665,6 @@ class Instrumenter {
|
|
|
659
665
|
}
|
|
660
666
|
|
|
661
667
|
instrumentDom() {
|
|
662
|
-
const self = this;
|
|
663
668
|
this.addListener(
|
|
664
669
|
'dom',
|
|
665
670
|
this._window,
|
|
@@ -701,12 +706,12 @@ class Instrumenter {
|
|
|
701
706
|
contentLoaded: this.handleContentLoaded,
|
|
702
707
|
}[name].call(this, evt);
|
|
703
708
|
} catch (exc) {
|
|
704
|
-
|
|
709
|
+
logger.log(`${name} handler error`, evt, exc, exc.stack);
|
|
705
710
|
}
|
|
706
711
|
}
|
|
707
712
|
|
|
708
|
-
handleContentLoaded(
|
|
709
|
-
|
|
713
|
+
handleContentLoaded(_evt) {
|
|
714
|
+
this.rollbar.triggerReplay({
|
|
710
715
|
type: 'navigation',
|
|
711
716
|
path: new URL(this._location.href).pathname,
|
|
712
717
|
});
|
|
@@ -738,13 +743,12 @@ class Instrumenter {
|
|
|
738
743
|
});
|
|
739
744
|
}
|
|
740
745
|
|
|
741
|
-
handleForm(
|
|
746
|
+
handleForm(_evt) {
|
|
742
747
|
// TODO: implement form event handling
|
|
743
|
-
const type = evt.type;
|
|
744
|
-
const elementString = evt.target?.window
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
console.log('handleForm', type, elementString, evt);
|
|
748
|
+
//const type = evt.type;
|
|
749
|
+
//const elementString = evt.target?.window
|
|
750
|
+
// ? 'window'
|
|
751
|
+
// : domUtil.elementString(evt.target);
|
|
748
752
|
}
|
|
749
753
|
|
|
750
754
|
handleResize(evt) {
|
|
@@ -928,7 +932,7 @@ class Instrumenter {
|
|
|
928
932
|
return function () {
|
|
929
933
|
const url = arguments.length > 2 ? arguments[2] : undefined;
|
|
930
934
|
if (url) {
|
|
931
|
-
self.handleUrlChange(self._lastHref, url
|
|
935
|
+
self.handleUrlChange(self._lastHref, String(url));
|
|
932
936
|
}
|
|
933
937
|
return orig.apply(this, arguments);
|
|
934
938
|
};
|
|
@@ -956,7 +960,7 @@ class Instrumenter {
|
|
|
956
960
|
from = parsedFrom.path + (parsedFrom.hash || '');
|
|
957
961
|
}
|
|
958
962
|
this.telemeter.captureNavigation(from, to, null, _.now());
|
|
959
|
-
|
|
963
|
+
this.rollbar.triggerReplay({
|
|
960
964
|
type: 'navigation',
|
|
961
965
|
path: to,
|
|
962
966
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as _ from '../utility.js';
|
|
2
1
|
import errorParser from '../errorParser.js';
|
|
3
2
|
import logger from '../logger.js';
|
|
3
|
+
import * as _ from '../utility.js';
|
|
4
4
|
|
|
5
5
|
function handleDomException(item, options, callback) {
|
|
6
6
|
if (item.err && errorParser.Stack(item.err).name === 'DOMException') {
|
|
@@ -181,9 +181,9 @@ function addBodyMessage(item, options, callback) {
|
|
|
181
181
|
callback(null, item);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
function stackFromItem(item) {
|
|
184
|
+
function stackFromItem(item, stackInfo = null) {
|
|
185
185
|
// Transform a TraceKit stackInfo object into a Rollbar trace
|
|
186
|
-
|
|
186
|
+
let stack = (stackInfo || item.stackInfo).stack;
|
|
187
187
|
if (
|
|
188
188
|
stack &&
|
|
189
189
|
stack.length === 0 &&
|
|
@@ -230,7 +230,7 @@ function addBodyTrace(item, options, callback) {
|
|
|
230
230
|
function buildTrace(item, stackInfo, options) {
|
|
231
231
|
var description = item && item.data.description;
|
|
232
232
|
var custom = item && item.custom;
|
|
233
|
-
var stack = stackFromItem(item);
|
|
233
|
+
var stack = stackFromItem(item, stackInfo);
|
|
234
234
|
|
|
235
235
|
var guess = errorParser.guessErrorClass(stackInfo.message);
|
|
236
236
|
var className = errorClass(stackInfo, guess[0], options);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*global XDomainRequest*/
|
|
2
2
|
|
|
3
|
-
import * as _ from '../../utility.js';
|
|
4
3
|
import logger from '../../logger.js';
|
|
4
|
+
import * as _ from '../../utility.js';
|
|
5
5
|
|
|
6
6
|
function makeXhrRequest({
|
|
7
7
|
accessToken,
|
|
@@ -97,7 +97,7 @@ function makeXhrRequest({
|
|
|
97
97
|
|
|
98
98
|
request.onreadystatechange = onreadystatechange;
|
|
99
99
|
request.send(payload);
|
|
100
|
-
} catch (
|
|
100
|
+
} catch (_e1) {
|
|
101
101
|
// Sending using the normal xmlhttprequest object didn't work, try XDomainRequest
|
|
102
102
|
if (typeof XDomainRequest !== 'undefined') {
|
|
103
103
|
// Assume we are in a really old browser which has a bunch of limitations:
|
|
@@ -121,7 +121,7 @@ function makeXhrRequest({
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
var xdomainrequest = new XDomainRequest();
|
|
124
|
-
xdomainrequest.onprogress =
|
|
124
|
+
xdomainrequest.onprogress = () => {};
|
|
125
125
|
xdomainrequest.ontimeout = function () {
|
|
126
126
|
var msg = 'Request timed out';
|
|
127
127
|
var code = 'ETIMEDOUT';
|
|
@@ -169,7 +169,7 @@ function _createXMLHTTPObject() {
|
|
|
169
169
|
try {
|
|
170
170
|
xmlhttp = factories[i]();
|
|
171
171
|
break;
|
|
172
|
-
} catch (
|
|
172
|
+
} catch (_e) {
|
|
173
173
|
// pass
|
|
174
174
|
}
|
|
175
175
|
}
|
package/src/browser/transport.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _ from '../utility.js';
|
|
2
|
+
|
|
2
3
|
import makeFetchRequest from './transport/fetch.js';
|
|
3
4
|
import makeXhrRequest from './transport/xhr.js';
|
|
4
5
|
|
|
@@ -32,7 +33,7 @@ Transport.prototype.get = function (
|
|
|
32
33
|
requestFactory,
|
|
33
34
|
) {
|
|
34
35
|
if (!callback || !_.isFunction(callback)) {
|
|
35
|
-
callback =
|
|
36
|
+
callback = () => {};
|
|
36
37
|
}
|
|
37
38
|
_.addParamsAndAccessTokenToPath(accessToken, options, params);
|
|
38
39
|
|
|
@@ -58,7 +59,7 @@ Transport.prototype.post = function ({
|
|
|
58
59
|
requestFactory,
|
|
59
60
|
}) {
|
|
60
61
|
if (!callback || !_.isFunction(callback)) {
|
|
61
|
-
callback =
|
|
62
|
+
callback = () => {};
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
if (!payload) {
|
|
@@ -76,14 +77,13 @@ Transport.prototype.post = function ({
|
|
|
76
77
|
return callback(stringifyResult.error);
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
var payload = stringifyResult.value;
|
|
80
80
|
var method = 'POST';
|
|
81
81
|
var url = _.formatUrl(options);
|
|
82
82
|
this._makeZoneRequest({
|
|
83
83
|
accessToken,
|
|
84
84
|
url,
|
|
85
85
|
method,
|
|
86
|
-
payload,
|
|
86
|
+
payload: stringifyResult.value,
|
|
87
87
|
headers,
|
|
88
88
|
callback,
|
|
89
89
|
requestFactory,
|
|
@@ -100,7 +100,7 @@ Transport.prototype.postJsonPayload = function (
|
|
|
100
100
|
requestFactory,
|
|
101
101
|
) {
|
|
102
102
|
if (!callback || !_.isFunction(callback)) {
|
|
103
|
-
callback =
|
|
103
|
+
callback = () => {};
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
var method = 'POST';
|
|
@@ -122,8 +122,8 @@ Transport.prototype.postJsonPayload = function (
|
|
|
122
122
|
// This is equivalent to `NgZone.runOutsideAngular` in Angular.
|
|
123
123
|
Transport.prototype._makeZoneRequest = function () {
|
|
124
124
|
var gWindow =
|
|
125
|
-
(typeof window
|
|
126
|
-
(typeof self
|
|
125
|
+
(typeof window !== 'undefined' && window) ||
|
|
126
|
+
(typeof self !== 'undefined' && self);
|
|
127
127
|
// Whenever zone.js is loaded and `Zone` is exposed globally, access
|
|
128
128
|
// the root zone to ensure that requests are always made within it.
|
|
129
129
|
// This approach is framework-agnostic, regardless of which
|
|
@@ -132,9 +132,8 @@ Transport.prototype._makeZoneRequest = function () {
|
|
|
132
132
|
var args = Array.prototype.slice.call(arguments);
|
|
133
133
|
|
|
134
134
|
if (rootZone) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
self._makeRequest.apply(undefined, args);
|
|
135
|
+
rootZone.run(() => {
|
|
136
|
+
this._makeRequest.apply(undefined, args);
|
|
138
137
|
});
|
|
139
138
|
} else {
|
|
140
139
|
this._makeRequest.apply(undefined, args);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { hasOwn } from '../utility.js';
|
|
2
|
+
|
|
1
3
|
function wrapGlobals(window, handler, shim) {
|
|
2
4
|
if (!window) {
|
|
3
5
|
return;
|
|
@@ -18,10 +20,7 @@ function wrapGlobals(window, handler, shim) {
|
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
function _extendListenerPrototype(handler, prototype, shim) {
|
|
21
|
-
if (
|
|
22
|
-
prototype.hasOwnProperty &&
|
|
23
|
-
prototype.hasOwnProperty('addEventListener')
|
|
24
|
-
) {
|
|
23
|
+
if (hasOwn(prototype, 'addEventListener')) {
|
|
25
24
|
var oldAddEventListener = prototype.addEventListener;
|
|
26
25
|
while (
|
|
27
26
|
oldAddEventListener._rollbarOldAdd &&
|
package/src/defaults.js
CHANGED
package/src/errorParser.js
CHANGED
package/src/logger.js
CHANGED
package/src/notifier.js
CHANGED
|
@@ -1,122 +1,124 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { merge, isFunction } from './utility.js';
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
|
-
* Notifier -
|
|
5
|
-
*
|
|
4
|
+
* Notifier - delegates between the client exposed API, the chain of transforms
|
|
5
|
+
* necessary to turn an item into something that can be sent to Rollbar, and the
|
|
6
6
|
* queue which handles the communcation with the Rollbar API servers.
|
|
7
|
-
*
|
|
8
|
-
* @param queue - an object that conforms to the interface: addItem(item, callback)
|
|
9
|
-
* @param options - an object representing the options to be set for this notifier, this should have
|
|
10
|
-
* any defaults already set by the caller
|
|
11
7
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Notifier.prototype.configure = function (options) {
|
|
26
|
-
this.queue && this.queue.configure(options);
|
|
27
|
-
var oldOptions = this.options;
|
|
28
|
-
this.options = _.merge(oldOptions, options);
|
|
29
|
-
return this;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/*
|
|
33
|
-
* addTransform - adds a transform onto the end of the queue of transforms for this notifier
|
|
34
|
-
*
|
|
35
|
-
* @param transform - a function which takes three arguments:
|
|
36
|
-
* * item: An Object representing the data to eventually be sent to Rollbar
|
|
37
|
-
* * options: The current value of the options for this notifier
|
|
38
|
-
* * callback: function(err: (Null|Error), item: (Null|Object)) the transform must call this
|
|
39
|
-
* callback with a null value for error if it wants the processing chain to continue, otherwise
|
|
40
|
-
* with an error to terminate the processing. The item should be the updated item after this
|
|
41
|
-
* transform is finished modifying it.
|
|
42
|
-
*/
|
|
43
|
-
Notifier.prototype.addTransform = function (transform) {
|
|
44
|
-
if (_.isFunction(transform)) {
|
|
45
|
-
this.transforms.push(transform);
|
|
8
|
+
export default class Notifier {
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} queue - an object that conforms to the interface:
|
|
12
|
+
* `addItem(item, callback)`
|
|
13
|
+
* @param {Object} options - an object representing the options to be set for
|
|
14
|
+
* this notifier, this should have any defaults already set by the caller
|
|
15
|
+
*/
|
|
16
|
+
constructor(queue, options) {
|
|
17
|
+
this.queue = queue;
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.transforms = [];
|
|
20
|
+
this.diagnostic = {};
|
|
46
21
|
}
|
|
47
|
-
return this;
|
|
48
|
-
};
|
|
49
22
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*/
|
|
63
|
-
Notifier.prototype.log = function (item, callback) {
|
|
64
|
-
if (!callback || !_.isFunction(callback)) {
|
|
65
|
-
callback = function () {};
|
|
23
|
+
/**
|
|
24
|
+
* configure - updates the options for this notifier with the passed in object
|
|
25
|
+
*
|
|
26
|
+
* @param {Object} options - an object which gets merged with the current
|
|
27
|
+
* options set on this notifier
|
|
28
|
+
* @returns this
|
|
29
|
+
*/
|
|
30
|
+
configure(options) {
|
|
31
|
+
this.queue?.configure(options);
|
|
32
|
+
const oldOptions = this.options;
|
|
33
|
+
this.options = merge(oldOptions, options);
|
|
34
|
+
return this;
|
|
66
35
|
}
|
|
67
36
|
|
|
68
|
-
|
|
69
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Adds a transform onto the end of the queue of transforms for this notifier
|
|
39
|
+
*
|
|
40
|
+
* @param {Function} transform - a function which takes three arguments:
|
|
41
|
+
* - item: An Object representing the data to eventually be sent to Rollbar
|
|
42
|
+
* - options: The current value of the options for this notifier
|
|
43
|
+
* - callback: `function(err: (Null|Error), item: (Null|Object))` the
|
|
44
|
+
* transform must call this callback with a null value for error if it
|
|
45
|
+
* wants the processing chain to continue, otherwise with an error to
|
|
46
|
+
* terminate the processing. The item should be the updated item after
|
|
47
|
+
* this transform is finished modifying it.
|
|
48
|
+
*/
|
|
49
|
+
addTransform(transform) {
|
|
50
|
+
if (isFunction(transform)) {
|
|
51
|
+
this.transforms.push(transform);
|
|
52
|
+
}
|
|
53
|
+
return this;
|
|
70
54
|
}
|
|
71
55
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
/**
|
|
57
|
+
* The internal log function which applies the configured transforms and then
|
|
58
|
+
* pushes onto the queue to be sent to the backend.
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} item - An object with the following structure:
|
|
61
|
+
* - message [String] - An optional string to be sent to rollbar
|
|
62
|
+
* - error [Error] - An optional error
|
|
63
|
+
* @param {Function} callback - A function of type `function(err, resp)` which
|
|
64
|
+
* will be called with exactly one null argument and one non-null argument.
|
|
65
|
+
* The callback will be called once, either during the transform stage if
|
|
66
|
+
* an error occurs inside a transform, or in response to the communication
|
|
67
|
+
* with the backend. The second argument will be the response from the
|
|
68
|
+
* backend in case of success.
|
|
69
|
+
*/
|
|
70
|
+
log(item, callback) {
|
|
71
|
+
callback = isFunction(callback) ? callback : () => {};
|
|
72
|
+
|
|
73
|
+
if (!this.options.enabled) {
|
|
74
|
+
return callback(new Error('Rollbar is not enabled'), null);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this.queue.addPendingItem(item);
|
|
78
|
+
const originalError = item.err;
|
|
79
|
+
this._applyTransforms(item, (err, i) => {
|
|
77
80
|
if (err) {
|
|
78
81
|
this.queue.removePendingItem(item);
|
|
79
82
|
return callback(err, null);
|
|
80
83
|
}
|
|
81
84
|
this.queue.addItem(i, callback, originalError, item);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/* Internal */
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
87
|
|
|
88
|
-
/*
|
|
89
|
-
* _applyTransforms - Applies the transforms that have been added to this notifier sequentially. See
|
|
90
|
-
* `addTransform` for more information.
|
|
91
|
-
*
|
|
92
|
-
* @param item - An item to be transformed
|
|
93
|
-
* @param callback - A function of type function(err, item) which will be called with a non-null
|
|
94
|
-
* error and a null item in the case of a transform failure, or a null error and non-null item after
|
|
95
|
-
* all transforms have been applied.
|
|
96
|
-
*/
|
|
97
|
-
Notifier.prototype._applyTransforms = function (item, callback) {
|
|
98
|
-
var transformIndex = -1;
|
|
99
|
-
var transformsLength = this.transforms.length;
|
|
100
|
-
var transforms = this.transforms;
|
|
101
|
-
var options = this.options;
|
|
88
|
+
/* Internal */
|
|
102
89
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Applies the transforms that have been added to this notifier sequentially.
|
|
92
|
+
* See `addTransform` for more information.
|
|
93
|
+
*
|
|
94
|
+
* @param {Object} item - An item to be transformed
|
|
95
|
+
* @param {Function} callback - A function of type `function(err, item)` which
|
|
96
|
+
* will be called with a non-null error and a null item in the case of a
|
|
97
|
+
* transform failure, or a null error and non-null item after all
|
|
98
|
+
* transforms have been applied.
|
|
99
|
+
*/
|
|
100
|
+
_applyTransforms(item, callback) {
|
|
101
|
+
let transformIndex = -1;
|
|
102
|
+
const transformsLength = this.transforms.length;
|
|
103
|
+
const transforms = this.transforms;
|
|
104
|
+
const options = this.options;
|
|
108
105
|
|
|
109
|
-
|
|
106
|
+
const next = (err, i) => {
|
|
107
|
+
if (err) {
|
|
108
|
+
callback(err, null);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
callback(null, i);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
112
|
+
transformIndex++;
|
|
115
113
|
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
if (transformIndex === transformsLength) {
|
|
115
|
+
callback(null, i);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
};
|
|
119
|
+
transforms[transformIndex](i, options, next);
|
|
120
|
+
};
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
next(null, item);
|
|
123
|
+
}
|
|
124
|
+
}
|
package/src/predicates.js
CHANGED
|
@@ -14,7 +14,7 @@ function checkLevel(item, settings) {
|
|
|
14
14
|
|
|
15
15
|
function userCheckIgnore(logger) {
|
|
16
16
|
return function (item, settings) {
|
|
17
|
-
var isUncaught =
|
|
17
|
+
var isUncaught = Boolean(item._isUncaught);
|
|
18
18
|
delete item._isUncaught;
|
|
19
19
|
var args = item._originalArgs;
|
|
20
20
|
delete item._originalArgs;
|
|
@@ -168,7 +168,7 @@ function messageIsIgnored(logger) {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
} catch (
|
|
171
|
-
|
|
171
|
+
_e
|
|
172
172
|
/* istanbul ignore next */
|
|
173
173
|
) {
|
|
174
174
|
settings.ignoredMessages = null;
|
|
@@ -190,8 +190,7 @@ function messagesFromItem(item) {
|
|
|
190
190
|
// So here we preserve the ability to collect strings from any combination of these keys.
|
|
191
191
|
if (body.trace_chain) {
|
|
192
192
|
var traceChain = body.trace_chain;
|
|
193
|
-
for (
|
|
194
|
-
var trace = traceChain[i];
|
|
193
|
+
for (const trace of traceChain) {
|
|
195
194
|
messages.push(_.get(trace, 'exception.message'));
|
|
196
195
|
}
|
|
197
196
|
}
|