rollbar 2.26.3 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/guidelines.mdc +154 -0
- package/.github/workflows/ci.yml +32 -12
- package/.lgtm.yml +7 -7
- package/.prettierignore +18 -0
- package/.vscode/settings.json +39 -0
- package/CHANGELOG.md +121 -35
- package/CLAUDE.md +201 -0
- package/Gruntfile.js +101 -48
- package/Makefile +3 -3
- package/README.md +2 -4
- package/SECURITY.md +5 -0
- package/babel.config.json +9 -0
- package/bower.json +1 -3
- package/codex.md +148 -0
- package/defaults.js +17 -5
- package/dist/plugins/jquery.min.js +1 -1
- package/dist/rollbar.js +18748 -5375
- package/dist/rollbar.js.map +1 -1
- package/dist/rollbar.min.js +2 -1
- package/dist/rollbar.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.min.js.map +1 -1
- package/dist/rollbar.named-amd.js +19368 -6000
- package/dist/rollbar.named-amd.js.map +1 -1
- package/dist/rollbar.named-amd.min.js +3 -1
- package/dist/rollbar.named-amd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.named-amd.min.js.map +1 -1
- package/dist/rollbar.noconflict.umd.js +18749 -5380
- package/dist/rollbar.noconflict.umd.js.map +1 -1
- package/dist/rollbar.noconflict.umd.min.js +3 -1
- package/dist/rollbar.noconflict.umd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.noconflict.umd.min.js.map +1 -1
- package/dist/rollbar.snippet.js +1 -1
- package/dist/rollbar.umd.js +19367 -6000
- package/dist/rollbar.umd.js.map +1 -1
- package/dist/rollbar.umd.min.js +3 -1
- package/dist/rollbar.umd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.umd.min.js.map +1 -1
- package/docs/extension-exceptions.md +35 -30
- package/docs/migration_v0_to_v1.md +41 -38
- package/eslint.config.mjs +33 -0
- package/get_versions.js +33 -0
- package/index.d.ts +270 -231
- package/karma.conf.js +18 -27
- package/package.json +21 -21
- package/prettier.config.js +7 -0
- package/src/api.js +78 -14
- package/src/apiUtility.js +14 -11
- package/src/browser/core.js +138 -72
- package/src/browser/defaults/scrubFields.js +3 -3
- package/src/browser/detection.js +7 -8
- package/src/browser/domUtility.js +18 -8
- package/src/browser/globalSetup.js +12 -6
- package/src/browser/logger.js +1 -1
- package/src/browser/plugins/jquery.js +35 -35
- package/src/browser/predicates.js +1 -1
- package/src/browser/replay/defaults.js +71 -0
- package/src/browser/replay/recorder.js +193 -0
- package/src/browser/replay/replayMap.js +195 -0
- package/src/browser/rollbar.js +12 -8
- package/src/browser/rollbarWrapper.js +8 -5
- package/src/browser/shim.js +43 -19
- package/src/browser/snippet_callback.js +6 -4
- package/src/browser/telemetry.js +573 -361
- package/src/browser/transforms.js +46 -27
- package/src/browser/transport/fetch.js +26 -14
- package/src/browser/transport/xhr.js +41 -14
- package/src/browser/transport.js +93 -33
- package/src/browser/url.js +16 -8
- package/src/browser/wrapGlobals.js +27 -8
- package/src/defaults.js +3 -3
- package/src/errorParser.js +14 -11
- package/src/merge.js +32 -23
- package/src/notifier.js +16 -13
- package/src/predicates.js +43 -23
- package/src/queue.js +133 -40
- package/src/rateLimiter.js +59 -18
- package/src/react-native/logger.js +1 -1
- package/src/react-native/rollbar.js +59 -55
- package/src/react-native/transforms.js +13 -9
- package/src/react-native/transport.js +44 -34
- package/src/rollbar.js +72 -21
- package/src/scrub.js +0 -1
- package/src/server/locals.js +69 -39
- package/src/server/logger.js +4 -4
- package/src/server/parser.js +72 -47
- package/src/server/rollbar.js +135 -56
- package/src/server/sourceMap/stackTrace.js +33 -18
- package/src/server/telemetry/urlHelpers.js +9 -11
- package/src/server/telemetry.js +68 -45
- package/src/server/transforms.js +37 -21
- package/src/server/transport.js +62 -32
- package/src/telemetry.js +162 -33
- package/src/tracing/context.js +24 -0
- package/src/tracing/contextManager.js +37 -0
- package/src/tracing/defaults.js +7 -0
- package/src/tracing/exporter.js +188 -0
- package/src/tracing/hrtime.js +98 -0
- package/src/tracing/id.js +24 -0
- package/src/tracing/session.js +55 -0
- package/src/tracing/span.js +92 -0
- package/src/tracing/spanProcessor.js +15 -0
- package/src/tracing/tracer.js +46 -0
- package/src/tracing/tracing.js +89 -0
- package/src/transforms.js +33 -21
- package/src/truncation.js +8 -5
- package/src/utility/headers.js +43 -43
- package/src/utility/replace.js +9 -0
- package/src/utility/traverse.js +1 -1
- package/src/utility.js +123 -52
- package/test/api.test.js +88 -41
- package/test/apiUtility.test.js +48 -50
- package/test/browser.core.test.js +142 -141
- package/test/browser.domUtility.test.js +53 -36
- package/test/browser.predicates.test.js +14 -14
- package/test/browser.replay.recorder.test.js +416 -0
- package/test/browser.rollbar.test.js +655 -515
- package/test/browser.telemetry.test.js +46 -39
- package/test/browser.transforms.test.js +164 -139
- package/test/browser.transport.test.js +59 -50
- package/test/browser.url.test.js +13 -12
- package/test/fixtures/locals.fixtures.js +245 -126
- package/test/fixtures/replay/index.js +20 -0
- package/test/fixtures/replay/payloads.fixtures.js +229 -0
- package/test/fixtures/replay/rrwebEvents.fixtures.js +251 -0
- package/test/fixtures/replay/rrwebSyntheticEvents.fixtures.js +328 -0
- package/test/notifier.test.js +91 -79
- package/test/predicates.test.js +261 -215
- package/test/queue.test.js +231 -215
- package/test/rateLimiter.test.js +51 -43
- package/test/react-native.rollbar.test.js +150 -116
- package/test/react-native.transforms.test.js +23 -25
- package/test/react-native.transport.test.js +26 -14
- package/test/replay/index.js +2 -0
- package/test/replay/integration/api.spans.test.js +136 -0
- package/test/replay/integration/e2e.test.js +228 -0
- package/test/replay/integration/index.js +9 -0
- package/test/replay/integration/queue.replayMap.test.js +332 -0
- package/test/replay/integration/replayMap.test.js +163 -0
- package/test/replay/integration/sessionRecording.test.js +390 -0
- package/test/replay/unit/api.postSpans.test.js +150 -0
- package/test/replay/unit/index.js +7 -0
- package/test/replay/unit/queue.replayMap.test.js +225 -0
- package/test/replay/unit/replayMap.test.js +348 -0
- package/test/replay/util/index.js +5 -0
- package/test/replay/util/mockRecordFn.js +80 -0
- package/test/server.lambda.mocha.test.mjs +172 -0
- package/test/server.locals.constructor.mocha.test.mjs +80 -0
- package/test/server.locals.error-handling.mocha.test.mjs +387 -0
- package/test/server.locals.merge.mocha.test.mjs +267 -0
- package/test/server.locals.test-utils.mjs +114 -0
- package/test/server.parser.mocha.test.mjs +87 -0
- package/test/server.predicates.mocha.test.mjs +63 -0
- package/test/server.rollbar.constructor.mocha.test.mjs +199 -0
- package/test/server.rollbar.handlers.mocha.test.mjs +253 -0
- package/test/server.rollbar.logging.mocha.test.mjs +326 -0
- package/test/server.rollbar.misc.mocha.test.mjs +44 -0
- package/test/server.rollbar.test-utils.mjs +57 -0
- package/test/server.telemetry.mocha.test.mjs +377 -0
- package/test/server.transforms.data.mocha.test.mjs +163 -0
- package/test/server.transforms.error.mocha.test.mjs +199 -0
- package/test/server.transforms.request.mocha.test.mjs +208 -0
- package/test/server.transforms.scrub.mocha.test.mjs +140 -0
- package/test/server.transforms.sourcemaps.mocha.test.mjs +122 -0
- package/test/server.transforms.test-utils.mjs +62 -0
- package/test/server.transport.mocha.test.mjs +269 -0
- package/test/telemetry.test.js +178 -38
- package/test/tracing/contextManager.test.js +28 -0
- package/test/tracing/exporter.toPayload.test.js +400 -0
- package/test/tracing/id.test.js +24 -0
- package/test/tracing/span.test.js +183 -0
- package/test/tracing/spanProcessor.test.js +73 -0
- package/test/tracing/tracing.test.js +105 -0
- package/test/transforms.test.js +70 -68
- package/test/truncation.test.js +57 -55
- package/test/utility.test.js +310 -228
- package/webpack.config.js +36 -70
- package/.eslintignore +0 -7
- package/.gitmodules +0 -3
- package/test/server.lambda.test.js +0 -177
- package/test/server.locals.test.js +0 -841
- package/test/server.parser.test.js +0 -72
- package/test/server.predicates.test.js +0 -89
- package/test/server.rollbar.test.js +0 -676
- package/test/server.telemetry.test.js +0 -318
- package/test/server.transforms.test.js +0 -1099
- package/test/server.transport.test.js +0 -201
package/src/browser/core.js
CHANGED
|
@@ -12,32 +12,63 @@ var sharedTransforms = require('../transforms');
|
|
|
12
12
|
var predicates = require('./predicates');
|
|
13
13
|
var sharedPredicates = require('../predicates');
|
|
14
14
|
var errorParser = require('../errorParser');
|
|
15
|
+
const recorderDefaults = require('./replay/defaults').default;
|
|
16
|
+
const tracingDefaults = require('../tracing/defaults').default;
|
|
17
|
+
const ReplayMap = require('./replay/replayMap').default;
|
|
15
18
|
|
|
16
19
|
function Rollbar(options, client) {
|
|
17
20
|
this.options = _.handleOptions(defaultOptions, options, null, logger);
|
|
18
21
|
this.options._configuredOptions = options;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
const Telemeter = this.components.telemeter;
|
|
23
|
+
const Instrumenter = this.components.instrumenter;
|
|
24
|
+
const polyfillJSON = this.components.polyfillJSON;
|
|
22
25
|
this.wrapGlobals = this.components.wrapGlobals;
|
|
23
26
|
this.scrub = this.components.scrub;
|
|
24
|
-
|
|
27
|
+
const truncation = this.components.truncation;
|
|
28
|
+
const Tracing = this.components.tracing;
|
|
29
|
+
const Recorder = this.components.recorder;
|
|
30
|
+
|
|
31
|
+
const transport = new Transport(truncation);
|
|
32
|
+
const api = new API(this.options, transport, urllib, truncation);
|
|
33
|
+
if (Tracing) {
|
|
34
|
+
this.tracing = new Tracing(_gWindow(), this.options);
|
|
35
|
+
this.tracing.initSession();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (Recorder && _.isBrowser()) {
|
|
39
|
+
const recorderOptions = this.options.recorder;
|
|
40
|
+
this.recorder = new Recorder(recorderOptions);
|
|
41
|
+
this.replayMap = new ReplayMap({
|
|
42
|
+
recorder: this.recorder,
|
|
43
|
+
api: api,
|
|
44
|
+
tracing: this.tracing
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (recorderOptions.enabled && recorderOptions.autoStart) {
|
|
48
|
+
this.recorder.start();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
25
51
|
|
|
26
|
-
var transport = new Transport(truncation);
|
|
27
|
-
var api = new API(this.options, transport, urllib, truncation);
|
|
28
52
|
if (Telemeter) {
|
|
29
|
-
this.telemeter = new Telemeter(this.options);
|
|
53
|
+
this.telemeter = new Telemeter(this.options, this.tracing);
|
|
30
54
|
}
|
|
31
|
-
this.client =
|
|
55
|
+
this.client =
|
|
56
|
+
client || new Client(this.options, api, logger, this.telemeter, this.tracing, this.replayMap, 'browser');
|
|
32
57
|
var gWindow = _gWindow();
|
|
33
|
-
var gDocument =
|
|
58
|
+
var gDocument = typeof document != 'undefined' && document;
|
|
34
59
|
this.isChrome = gWindow.chrome && gWindow.chrome.runtime; // check .runtime to avoid Edge browsers
|
|
35
60
|
this.anonymousErrorsPending = 0;
|
|
36
61
|
addTransformsToNotifier(this.client.notifier, this, gWindow);
|
|
37
62
|
addPredicatesToQueue(this.client.queue);
|
|
38
63
|
this.setupUnhandledCapture();
|
|
39
64
|
if (Instrumenter) {
|
|
40
|
-
this.instrumenter = new Instrumenter(
|
|
65
|
+
this.instrumenter = new Instrumenter(
|
|
66
|
+
this.options,
|
|
67
|
+
this.client.telemeter,
|
|
68
|
+
this,
|
|
69
|
+
gWindow,
|
|
70
|
+
gDocument,
|
|
71
|
+
);
|
|
41
72
|
this.instrumenter.instrument();
|
|
42
73
|
}
|
|
43
74
|
_.setupJSON(polyfillJSON);
|
|
@@ -47,7 +78,7 @@ function Rollbar(options, client) {
|
|
|
47
78
|
}
|
|
48
79
|
|
|
49
80
|
var _instance = null;
|
|
50
|
-
Rollbar.init = function(options, client) {
|
|
81
|
+
Rollbar.init = function (options, client) {
|
|
51
82
|
if (_instance) {
|
|
52
83
|
return _instance.global(options).configure(options);
|
|
53
84
|
}
|
|
@@ -57,9 +88,9 @@ Rollbar.init = function(options, client) {
|
|
|
57
88
|
|
|
58
89
|
Rollbar.prototype.components = {};
|
|
59
90
|
|
|
60
|
-
Rollbar.setComponents = function(components) {
|
|
91
|
+
Rollbar.setComponents = function (components) {
|
|
61
92
|
Rollbar.prototype.components = components;
|
|
62
|
-
}
|
|
93
|
+
};
|
|
63
94
|
|
|
64
95
|
function handleUninitialized(maybeCallback) {
|
|
65
96
|
var message = 'Rollbar is not initialized';
|
|
@@ -69,11 +100,11 @@ function handleUninitialized(maybeCallback) {
|
|
|
69
100
|
}
|
|
70
101
|
}
|
|
71
102
|
|
|
72
|
-
Rollbar.prototype.global = function(options) {
|
|
103
|
+
Rollbar.prototype.global = function (options) {
|
|
73
104
|
this.client.global(options);
|
|
74
105
|
return this;
|
|
75
106
|
};
|
|
76
|
-
Rollbar.global = function(options) {
|
|
107
|
+
Rollbar.global = function (options) {
|
|
77
108
|
if (_instance) {
|
|
78
109
|
return _instance.global(options);
|
|
79
110
|
} else {
|
|
@@ -81,20 +112,27 @@ Rollbar.global = function(options) {
|
|
|
81
112
|
}
|
|
82
113
|
};
|
|
83
114
|
|
|
84
|
-
Rollbar.prototype.configure = function(options, payloadData) {
|
|
115
|
+
Rollbar.prototype.configure = function (options, payloadData) {
|
|
85
116
|
var oldOptions = this.options;
|
|
86
117
|
var payload = {};
|
|
87
118
|
if (payloadData) {
|
|
88
|
-
payload = {payload: payloadData};
|
|
119
|
+
payload = { payload: payloadData };
|
|
89
120
|
}
|
|
121
|
+
|
|
90
122
|
this.options = _.handleOptions(oldOptions, options, payload, logger);
|
|
91
|
-
this.options._configuredOptions = _.handleOptions(
|
|
123
|
+
this.options._configuredOptions = _.handleOptions(
|
|
124
|
+
oldOptions._configuredOptions,
|
|
125
|
+
options,
|
|
126
|
+
payload,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
this.recorder?.configure(this.options);
|
|
92
130
|
this.client.configure(this.options, payloadData);
|
|
93
131
|
this.instrumenter && this.instrumenter.configure(this.options);
|
|
94
132
|
this.setupUnhandledCapture();
|
|
95
133
|
return this;
|
|
96
134
|
};
|
|
97
|
-
Rollbar.configure = function(options, payloadData) {
|
|
135
|
+
Rollbar.configure = function (options, payloadData) {
|
|
98
136
|
if (_instance) {
|
|
99
137
|
return _instance.configure(options, payloadData);
|
|
100
138
|
} else {
|
|
@@ -102,10 +140,10 @@ Rollbar.configure = function(options, payloadData) {
|
|
|
102
140
|
}
|
|
103
141
|
};
|
|
104
142
|
|
|
105
|
-
Rollbar.prototype.lastError = function() {
|
|
143
|
+
Rollbar.prototype.lastError = function () {
|
|
106
144
|
return this.client.lastError;
|
|
107
145
|
};
|
|
108
|
-
Rollbar.lastError = function() {
|
|
146
|
+
Rollbar.lastError = function () {
|
|
109
147
|
if (_instance) {
|
|
110
148
|
return _instance.lastError();
|
|
111
149
|
} else {
|
|
@@ -113,13 +151,13 @@ Rollbar.lastError = function() {
|
|
|
113
151
|
}
|
|
114
152
|
};
|
|
115
153
|
|
|
116
|
-
Rollbar.prototype.log = function() {
|
|
154
|
+
Rollbar.prototype.log = function () {
|
|
117
155
|
var item = this._createItem(arguments);
|
|
118
156
|
var uuid = item.uuid;
|
|
119
157
|
this.client.log(item);
|
|
120
|
-
return {uuid: uuid};
|
|
158
|
+
return { uuid: uuid };
|
|
121
159
|
};
|
|
122
|
-
Rollbar.log = function() {
|
|
160
|
+
Rollbar.log = function () {
|
|
123
161
|
if (_instance) {
|
|
124
162
|
return _instance.log.apply(_instance, arguments);
|
|
125
163
|
} else {
|
|
@@ -128,13 +166,13 @@ Rollbar.log = function() {
|
|
|
128
166
|
}
|
|
129
167
|
};
|
|
130
168
|
|
|
131
|
-
Rollbar.prototype.debug = function() {
|
|
169
|
+
Rollbar.prototype.debug = function () {
|
|
132
170
|
var item = this._createItem(arguments);
|
|
133
171
|
var uuid = item.uuid;
|
|
134
172
|
this.client.debug(item);
|
|
135
|
-
return {uuid: uuid};
|
|
173
|
+
return { uuid: uuid };
|
|
136
174
|
};
|
|
137
|
-
Rollbar.debug = function() {
|
|
175
|
+
Rollbar.debug = function () {
|
|
138
176
|
if (_instance) {
|
|
139
177
|
return _instance.debug.apply(_instance, arguments);
|
|
140
178
|
} else {
|
|
@@ -143,13 +181,13 @@ Rollbar.debug = function() {
|
|
|
143
181
|
}
|
|
144
182
|
};
|
|
145
183
|
|
|
146
|
-
Rollbar.prototype.info = function() {
|
|
184
|
+
Rollbar.prototype.info = function () {
|
|
147
185
|
var item = this._createItem(arguments);
|
|
148
186
|
var uuid = item.uuid;
|
|
149
187
|
this.client.info(item);
|
|
150
|
-
return {uuid: uuid};
|
|
188
|
+
return { uuid: uuid };
|
|
151
189
|
};
|
|
152
|
-
Rollbar.info = function() {
|
|
190
|
+
Rollbar.info = function () {
|
|
153
191
|
if (_instance) {
|
|
154
192
|
return _instance.info.apply(_instance, arguments);
|
|
155
193
|
} else {
|
|
@@ -158,13 +196,13 @@ Rollbar.info = function() {
|
|
|
158
196
|
}
|
|
159
197
|
};
|
|
160
198
|
|
|
161
|
-
Rollbar.prototype.warn = function() {
|
|
199
|
+
Rollbar.prototype.warn = function () {
|
|
162
200
|
var item = this._createItem(arguments);
|
|
163
201
|
var uuid = item.uuid;
|
|
164
202
|
this.client.warn(item);
|
|
165
|
-
return {uuid: uuid};
|
|
203
|
+
return { uuid: uuid };
|
|
166
204
|
};
|
|
167
|
-
Rollbar.warn = function() {
|
|
205
|
+
Rollbar.warn = function () {
|
|
168
206
|
if (_instance) {
|
|
169
207
|
return _instance.warn.apply(_instance, arguments);
|
|
170
208
|
} else {
|
|
@@ -173,13 +211,13 @@ Rollbar.warn = function() {
|
|
|
173
211
|
}
|
|
174
212
|
};
|
|
175
213
|
|
|
176
|
-
Rollbar.prototype.warning = function() {
|
|
214
|
+
Rollbar.prototype.warning = function () {
|
|
177
215
|
var item = this._createItem(arguments);
|
|
178
216
|
var uuid = item.uuid;
|
|
179
217
|
this.client.warning(item);
|
|
180
|
-
return {uuid: uuid};
|
|
218
|
+
return { uuid: uuid };
|
|
181
219
|
};
|
|
182
|
-
Rollbar.warning = function() {
|
|
220
|
+
Rollbar.warning = function () {
|
|
183
221
|
if (_instance) {
|
|
184
222
|
return _instance.warning.apply(_instance, arguments);
|
|
185
223
|
} else {
|
|
@@ -188,13 +226,13 @@ Rollbar.warning = function() {
|
|
|
188
226
|
}
|
|
189
227
|
};
|
|
190
228
|
|
|
191
|
-
Rollbar.prototype.error = function() {
|
|
229
|
+
Rollbar.prototype.error = function () {
|
|
192
230
|
var item = this._createItem(arguments);
|
|
193
231
|
var uuid = item.uuid;
|
|
194
232
|
this.client.error(item);
|
|
195
|
-
return {uuid: uuid};
|
|
233
|
+
return { uuid: uuid };
|
|
196
234
|
};
|
|
197
|
-
Rollbar.error = function() {
|
|
235
|
+
Rollbar.error = function () {
|
|
198
236
|
if (_instance) {
|
|
199
237
|
return _instance.error.apply(_instance, arguments);
|
|
200
238
|
} else {
|
|
@@ -203,13 +241,13 @@ Rollbar.error = function() {
|
|
|
203
241
|
}
|
|
204
242
|
};
|
|
205
243
|
|
|
206
|
-
Rollbar.prototype.critical = function() {
|
|
244
|
+
Rollbar.prototype.critical = function () {
|
|
207
245
|
var item = this._createItem(arguments);
|
|
208
246
|
var uuid = item.uuid;
|
|
209
247
|
this.client.critical(item);
|
|
210
|
-
return {uuid: uuid};
|
|
248
|
+
return { uuid: uuid };
|
|
211
249
|
};
|
|
212
|
-
Rollbar.critical = function() {
|
|
250
|
+
Rollbar.critical = function () {
|
|
213
251
|
if (_instance) {
|
|
214
252
|
return _instance.critical.apply(_instance, arguments);
|
|
215
253
|
} else {
|
|
@@ -218,10 +256,10 @@ Rollbar.critical = function() {
|
|
|
218
256
|
}
|
|
219
257
|
};
|
|
220
258
|
|
|
221
|
-
Rollbar.prototype.buildJsonPayload = function(item) {
|
|
259
|
+
Rollbar.prototype.buildJsonPayload = function (item) {
|
|
222
260
|
return this.client.buildJsonPayload(item);
|
|
223
261
|
};
|
|
224
|
-
Rollbar.buildJsonPayload = function() {
|
|
262
|
+
Rollbar.buildJsonPayload = function () {
|
|
225
263
|
if (_instance) {
|
|
226
264
|
return _instance.buildJsonPayload.apply(_instance, arguments);
|
|
227
265
|
} else {
|
|
@@ -229,10 +267,10 @@ Rollbar.buildJsonPayload = function() {
|
|
|
229
267
|
}
|
|
230
268
|
};
|
|
231
269
|
|
|
232
|
-
Rollbar.prototype.sendJsonPayload = function(jsonPayload) {
|
|
270
|
+
Rollbar.prototype.sendJsonPayload = function (jsonPayload) {
|
|
233
271
|
return this.client.sendJsonPayload(jsonPayload);
|
|
234
272
|
};
|
|
235
|
-
Rollbar.sendJsonPayload = function() {
|
|
273
|
+
Rollbar.sendJsonPayload = function () {
|
|
236
274
|
if (_instance) {
|
|
237
275
|
return _instance.sendJsonPayload.apply(_instance, arguments);
|
|
238
276
|
} else {
|
|
@@ -240,7 +278,7 @@ Rollbar.sendJsonPayload = function() {
|
|
|
240
278
|
}
|
|
241
279
|
};
|
|
242
280
|
|
|
243
|
-
Rollbar.prototype.setupUnhandledCapture = function() {
|
|
281
|
+
Rollbar.prototype.setupUnhandledCapture = function () {
|
|
244
282
|
var gWindow = _gWindow();
|
|
245
283
|
|
|
246
284
|
if (!this.unhandledExceptionsInitialized) {
|
|
@@ -253,14 +291,24 @@ Rollbar.prototype.setupUnhandledCapture = function() {
|
|
|
253
291
|
}
|
|
254
292
|
}
|
|
255
293
|
if (!this.unhandledRejectionsInitialized) {
|
|
256
|
-
if (
|
|
294
|
+
if (
|
|
295
|
+
this.options.captureUnhandledRejections ||
|
|
296
|
+
this.options.handleUnhandledRejections
|
|
297
|
+
) {
|
|
257
298
|
globals.captureUnhandledRejections(gWindow, this);
|
|
258
299
|
this.unhandledRejectionsInitialized = true;
|
|
259
300
|
}
|
|
260
301
|
}
|
|
261
302
|
};
|
|
262
303
|
|
|
263
|
-
Rollbar.prototype.handleUncaughtException = function(
|
|
304
|
+
Rollbar.prototype.handleUncaughtException = function (
|
|
305
|
+
message,
|
|
306
|
+
url,
|
|
307
|
+
lineno,
|
|
308
|
+
colno,
|
|
309
|
+
error,
|
|
310
|
+
context,
|
|
311
|
+
) {
|
|
264
312
|
if (!this.options.captureUncaught && !this.options.handleUncaughtExceptions) {
|
|
265
313
|
return;
|
|
266
314
|
}
|
|
@@ -269,7 +317,12 @@ Rollbar.prototype.handleUncaughtException = function(message, url, lineno, colno
|
|
|
269
317
|
// If error is undefined, we have a different caller.
|
|
270
318
|
// Chrome also sends errors from web workers with null error, but does not invoke
|
|
271
319
|
// prepareStackTrace() for these. Test for empty url to skip them.
|
|
272
|
-
if (
|
|
320
|
+
if (
|
|
321
|
+
this.options.inspectAnonymousErrors &&
|
|
322
|
+
this.isChrome &&
|
|
323
|
+
error === null &&
|
|
324
|
+
url === ''
|
|
325
|
+
) {
|
|
273
326
|
return 'anonymous';
|
|
274
327
|
}
|
|
275
328
|
|
|
@@ -282,7 +335,7 @@ Rollbar.prototype.handleUncaughtException = function(message, url, lineno, colno
|
|
|
282
335
|
error,
|
|
283
336
|
'onerror',
|
|
284
337
|
'uncaught exception',
|
|
285
|
-
errorParser
|
|
338
|
+
errorParser,
|
|
286
339
|
);
|
|
287
340
|
if (_.isError(error)) {
|
|
288
341
|
item = this._createItem([message, error, context]);
|
|
@@ -311,13 +364,13 @@ Rollbar.prototype.handleUncaughtException = function(message, url, lineno, colno
|
|
|
311
364
|
*
|
|
312
365
|
* In config options, set inspectAnonymousErrors to enable.
|
|
313
366
|
*/
|
|
314
|
-
Rollbar.prototype.handleAnonymousErrors = function() {
|
|
367
|
+
Rollbar.prototype.handleAnonymousErrors = function () {
|
|
315
368
|
if (!this.options.inspectAnonymousErrors || !this.isChrome) {
|
|
316
369
|
return;
|
|
317
370
|
}
|
|
318
371
|
|
|
319
372
|
var r = this;
|
|
320
|
-
function prepareStackTrace(error, _stack) {
|
|
373
|
+
function prepareStackTrace(error, _stack) {
|
|
321
374
|
if (r.options.inspectAnonymousErrors) {
|
|
322
375
|
if (r.anonymousErrorsPending) {
|
|
323
376
|
// This is the only known way to detect that onerror saw an anonymous error.
|
|
@@ -355,10 +408,13 @@ Rollbar.prototype.handleAnonymousErrors = function() {
|
|
|
355
408
|
this.options.inspectAnonymousErrors = false;
|
|
356
409
|
this.error('anonymous error handler failed', e);
|
|
357
410
|
}
|
|
358
|
-
}
|
|
411
|
+
};
|
|
359
412
|
|
|
360
|
-
Rollbar.prototype.handleUnhandledRejection = function(reason, promise) {
|
|
361
|
-
if (
|
|
413
|
+
Rollbar.prototype.handleUnhandledRejection = function (reason, promise) {
|
|
414
|
+
if (
|
|
415
|
+
!this.options.captureUnhandledRejections &&
|
|
416
|
+
!this.options.handleUnhandledRejections
|
|
417
|
+
) {
|
|
362
418
|
return;
|
|
363
419
|
}
|
|
364
420
|
|
|
@@ -373,7 +429,8 @@ Rollbar.prototype.handleUnhandledRejection = function(reason, promise) {
|
|
|
373
429
|
}
|
|
374
430
|
}
|
|
375
431
|
}
|
|
376
|
-
var context =
|
|
432
|
+
var context =
|
|
433
|
+
(reason && reason._rollbarContext) || (promise && promise._rollbarContext);
|
|
377
434
|
|
|
378
435
|
var item;
|
|
379
436
|
if (_.isError(reason)) {
|
|
@@ -388,7 +445,7 @@ Rollbar.prototype.handleUnhandledRejection = function(reason, promise) {
|
|
|
388
445
|
null,
|
|
389
446
|
'unhandledrejection',
|
|
390
447
|
'',
|
|
391
|
-
errorParser
|
|
448
|
+
errorParser,
|
|
392
449
|
);
|
|
393
450
|
}
|
|
394
451
|
item.level = this.options.uncaughtErrorLevel;
|
|
@@ -398,13 +455,15 @@ Rollbar.prototype.handleUnhandledRejection = function(reason, promise) {
|
|
|
398
455
|
this.client.log(item);
|
|
399
456
|
};
|
|
400
457
|
|
|
401
|
-
Rollbar.prototype.wrap = function(f, context, _before) {
|
|
458
|
+
Rollbar.prototype.wrap = function (f, context, _before) {
|
|
402
459
|
try {
|
|
403
460
|
var ctxFn;
|
|
404
|
-
if(_.isFunction(context)) {
|
|
461
|
+
if (_.isFunction(context)) {
|
|
405
462
|
ctxFn = context;
|
|
406
463
|
} else {
|
|
407
|
-
ctxFn = function() {
|
|
464
|
+
ctxFn = function () {
|
|
465
|
+
return context || {};
|
|
466
|
+
};
|
|
408
467
|
}
|
|
409
468
|
|
|
410
469
|
if (!_.isFunction(f)) {
|
|
@@ -422,7 +481,7 @@ Rollbar.prototype.wrap = function(f, context, _before) {
|
|
|
422
481
|
}
|
|
423
482
|
try {
|
|
424
483
|
return f.apply(this, arguments);
|
|
425
|
-
} catch(exc) {
|
|
484
|
+
} catch (exc) {
|
|
426
485
|
var e = exc;
|
|
427
486
|
if (e && window._rollbarWrappedError !== e) {
|
|
428
487
|
if (_.isType(e, 'string')) {
|
|
@@ -454,7 +513,7 @@ Rollbar.prototype.wrap = function(f, context, _before) {
|
|
|
454
513
|
return f;
|
|
455
514
|
}
|
|
456
515
|
};
|
|
457
|
-
Rollbar.wrap = function(f, context) {
|
|
516
|
+
Rollbar.wrap = function (f, context) {
|
|
458
517
|
if (_instance) {
|
|
459
518
|
return _instance.wrap(f, context);
|
|
460
519
|
} else {
|
|
@@ -462,11 +521,11 @@ Rollbar.wrap = function(f, context) {
|
|
|
462
521
|
}
|
|
463
522
|
};
|
|
464
523
|
|
|
465
|
-
Rollbar.prototype.captureEvent = function() {
|
|
524
|
+
Rollbar.prototype.captureEvent = function () {
|
|
466
525
|
var event = _.createTelemetryEvent(arguments);
|
|
467
526
|
return this.client.captureEvent(event.type, event.metadata, event.level);
|
|
468
527
|
};
|
|
469
|
-
Rollbar.captureEvent = function() {
|
|
528
|
+
Rollbar.captureEvent = function () {
|
|
470
529
|
if (_instance) {
|
|
471
530
|
return _instance.captureEvent.apply(_instance, arguments);
|
|
472
531
|
} else {
|
|
@@ -475,14 +534,14 @@ Rollbar.captureEvent = function() {
|
|
|
475
534
|
};
|
|
476
535
|
|
|
477
536
|
// The following two methods are used internally and are not meant for public use
|
|
478
|
-
Rollbar.prototype.captureDomContentLoaded = function(e, ts) {
|
|
537
|
+
Rollbar.prototype.captureDomContentLoaded = function (e, ts) {
|
|
479
538
|
if (!ts) {
|
|
480
539
|
ts = new Date();
|
|
481
540
|
}
|
|
482
541
|
return this.client.captureDomContentLoaded(ts);
|
|
483
542
|
};
|
|
484
543
|
|
|
485
|
-
Rollbar.prototype.captureLoad = function(e, ts) {
|
|
544
|
+
Rollbar.prototype.captureLoad = function (e, ts) {
|
|
486
545
|
if (!ts) {
|
|
487
546
|
ts = new Date();
|
|
488
547
|
}
|
|
@@ -522,11 +581,13 @@ function addPredicatesToQueue(queue) {
|
|
|
522
581
|
.addPredicate(sharedPredicates.messageIsIgnored(logger));
|
|
523
582
|
}
|
|
524
583
|
|
|
525
|
-
Rollbar.prototype.loadFull = function() {
|
|
526
|
-
logger.info(
|
|
584
|
+
Rollbar.prototype.loadFull = function () {
|
|
585
|
+
logger.info(
|
|
586
|
+
'Unexpected Rollbar.loadFull() called on a Notifier instance. This can happen when Rollbar is loaded multiple times.',
|
|
587
|
+
);
|
|
527
588
|
};
|
|
528
589
|
|
|
529
|
-
Rollbar.prototype._createItem = function(args) {
|
|
590
|
+
Rollbar.prototype._createItem = function (args) {
|
|
530
591
|
return _.createItem(args, logger, this);
|
|
531
592
|
};
|
|
532
593
|
|
|
@@ -540,7 +601,10 @@ function _getFirstFunction(args) {
|
|
|
540
601
|
}
|
|
541
602
|
|
|
542
603
|
function _gWindow() {
|
|
543
|
-
return (
|
|
604
|
+
return (
|
|
605
|
+
(typeof window != 'undefined' && window) ||
|
|
606
|
+
(typeof self != 'undefined' && self)
|
|
607
|
+
);
|
|
544
608
|
}
|
|
545
609
|
|
|
546
610
|
var defaults = require('../defaults');
|
|
@@ -561,7 +625,9 @@ var defaultOptions = {
|
|
|
561
625
|
captureIp: true,
|
|
562
626
|
inspectAnonymousErrors: true,
|
|
563
627
|
ignoreDuplicateErrors: true,
|
|
564
|
-
wrapGlobalEventHandlers: false
|
|
628
|
+
wrapGlobalEventHandlers: false,
|
|
629
|
+
recorder: recorderDefaults,
|
|
630
|
+
tracing: tracingDefaults,
|
|
565
631
|
};
|
|
566
632
|
|
|
567
633
|
module.exports = Rollbar;
|
package/src/browser/detection.js
CHANGED
|
@@ -6,25 +6,24 @@
|
|
|
6
6
|
// Will return an integer on IE (i.e. 8)
|
|
7
7
|
// Will return undefined otherwise
|
|
8
8
|
function getIEVersion() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
var undef;
|
|
10
|
+
if (typeof document === 'undefined') {
|
|
11
|
+
return undef;
|
|
12
|
+
}
|
|
13
13
|
|
|
14
14
|
var v = 3,
|
|
15
15
|
div = document.createElement('div'),
|
|
16
16
|
all = div.getElementsByTagName('i');
|
|
17
17
|
|
|
18
18
|
while (
|
|
19
|
-
div.innerHTML = '<!--[if gt IE ' +
|
|
20
|
-
|
|
21
|
-
);
|
|
19
|
+
((div.innerHTML = '<!--[if gt IE ' + ++v + ']><i></i><![endif]-->'), all[0])
|
|
20
|
+
);
|
|
22
21
|
|
|
23
22
|
return v > 4 ? v : undef;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
var Detection = {
|
|
27
|
-
ieVersion: getIEVersion
|
|
26
|
+
ieVersion: getIEVersion,
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
module.exports = Detection;
|
|
@@ -45,12 +45,16 @@ function treeToArray(elem) {
|
|
|
45
45
|
|
|
46
46
|
function elementArrayToString(a) {
|
|
47
47
|
var MAX_LENGTH = 80;
|
|
48
|
-
var separator = ' > ',
|
|
49
|
-
|
|
48
|
+
var separator = ' > ',
|
|
49
|
+
separatorLength = separator.length;
|
|
50
|
+
var out = [],
|
|
51
|
+
len = 0,
|
|
52
|
+
nextStr,
|
|
53
|
+
totalLength;
|
|
50
54
|
|
|
51
55
|
for (var i = a.length - 1; i >= 0; i--) {
|
|
52
56
|
nextStr = descriptionToString(a[i]);
|
|
53
|
-
totalLength = len +
|
|
57
|
+
totalLength = len + out.length * separatorLength + nextStr.length;
|
|
54
58
|
if (i < a.length - 1 && totalLength >= MAX_LENGTH + 3) {
|
|
55
59
|
out.unshift('...');
|
|
56
60
|
break;
|
|
@@ -73,7 +77,9 @@ function descriptionToString(desc) {
|
|
|
73
77
|
out.push('.' + desc.classes.join('.'));
|
|
74
78
|
}
|
|
75
79
|
for (var i = 0; i < desc.attributes.length; i++) {
|
|
76
|
-
out.push(
|
|
80
|
+
out.push(
|
|
81
|
+
'[' + desc.attributes[i].key + '="' + desc.attributes[i].value + '"]',
|
|
82
|
+
);
|
|
77
83
|
}
|
|
78
84
|
|
|
79
85
|
return out.join('');
|
|
@@ -98,13 +104,17 @@ function describeElement(elem) {
|
|
|
98
104
|
if (!elem || !elem.tagName) {
|
|
99
105
|
return null;
|
|
100
106
|
}
|
|
101
|
-
var out = {},
|
|
107
|
+
var out = {},
|
|
108
|
+
className,
|
|
109
|
+
key,
|
|
110
|
+
attr,
|
|
111
|
+
i;
|
|
102
112
|
out.tagName = elem.tagName.toLowerCase();
|
|
103
113
|
if (elem.id) {
|
|
104
114
|
out.id = elem.id;
|
|
105
115
|
}
|
|
106
116
|
className = elem.className;
|
|
107
|
-
if (className &&
|
|
117
|
+
if (className && typeof className === 'string') {
|
|
108
118
|
out.classes = className.split(/\s+/);
|
|
109
119
|
}
|
|
110
120
|
var attributes = ['type', 'name', 'title', 'alt'];
|
|
@@ -113,7 +123,7 @@ function describeElement(elem) {
|
|
|
113
123
|
key = attributes[i];
|
|
114
124
|
attr = elem.getAttribute(key);
|
|
115
125
|
if (attr) {
|
|
116
|
-
out.attributes.push({key: key, value: attr});
|
|
126
|
+
out.attributes.push({ key: key, value: attr });
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
return out;
|
|
@@ -126,5 +136,5 @@ module.exports = {
|
|
|
126
136
|
treeToArray: treeToArray,
|
|
127
137
|
getElementFromEvent: getElementFromEvent,
|
|
128
138
|
isDescribedElement: isDescribedElement,
|
|
129
|
-
getElementType: getElementType
|
|
139
|
+
getElementType: getElementType,
|
|
130
140
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
function captureUncaughtExceptions(window, handler, shim) {
|
|
2
|
-
if (!window) {
|
|
2
|
+
if (!window) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
3
5
|
var oldOnError;
|
|
4
6
|
|
|
5
7
|
if (typeof handler._rollbarOldOnError === 'function') {
|
|
@@ -14,7 +16,7 @@ function captureUncaughtExceptions(window, handler, shim) {
|
|
|
14
16
|
|
|
15
17
|
handler.handleAnonymousErrors();
|
|
16
18
|
|
|
17
|
-
var fn = function() {
|
|
19
|
+
var fn = function () {
|
|
18
20
|
var args = Array.prototype.slice.call(arguments, 0);
|
|
19
21
|
_rollbarWindowOnError(window, handler, oldOnError, args);
|
|
20
22
|
};
|
|
@@ -50,9 +52,14 @@ function _rollbarWindowOnError(window, r, old, args) {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
function captureUnhandledRejections(window, handler, shim) {
|
|
53
|
-
if (!window) {
|
|
55
|
+
if (!window) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
54
58
|
|
|
55
|
-
if (
|
|
59
|
+
if (
|
|
60
|
+
typeof window._rollbarURH === 'function' &&
|
|
61
|
+
window._rollbarURH.belongsToShim
|
|
62
|
+
) {
|
|
56
63
|
window.removeEventListener('unhandledrejection', window._rollbarURH);
|
|
57
64
|
}
|
|
58
65
|
|
|
@@ -90,8 +97,7 @@ function captureUnhandledRejections(window, handler, shim) {
|
|
|
90
97
|
window.addEventListener('unhandledrejection', rejectionHandler);
|
|
91
98
|
}
|
|
92
99
|
|
|
93
|
-
|
|
94
100
|
module.exports = {
|
|
95
101
|
captureUncaughtExceptions: captureUncaughtExceptions,
|
|
96
|
-
captureUnhandledRejections: captureUnhandledRejections
|
|
102
|
+
captureUnhandledRejections: captureUnhandledRejections,
|
|
97
103
|
};
|
package/src/browser/logger.js
CHANGED