rollbar 2.26.4 → 3.0.0-alpha.2
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/.claude/settings.local.json +3 -0
- package/.cursor/rules/guidelines.mdc +154 -0
- package/.github/workflows/ci.yml +4 -6
- package/CLAUDE.local.md +297 -0
- package/CLAUDE.md +201 -0
- package/CLAUDE.testrunner.md +470 -0
- package/Gruntfile.js +59 -16
- package/Makefile +3 -3
- package/SECURITY.md +5 -0
- package/babel.config.json +9 -0
- package/codex.md +148 -0
- package/dist/plugins/jquery.min.js +1 -1
- package/dist/rollbar.js +19332 -6596
- 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 +19332 -6596
- package/dist/rollbar.named-amd.js.map +1 -1
- package/dist/rollbar.named-amd.min.js +2 -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 +19319 -6581
- package/dist/rollbar.noconflict.umd.js.map +1 -1
- package/dist/rollbar.noconflict.umd.min.js +2 -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 +19333 -6597
- package/dist/rollbar.umd.js.map +1 -1
- package/dist/rollbar.umd.min.js +2 -1
- package/dist/rollbar.umd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.umd.min.js.map +1 -1
- package/eslint.config.mjs +33 -0
- package/karma.conf.js +5 -14
- package/package.json +19 -20
- package/src/api.js +57 -4
- package/src/apiUtility.js +2 -3
- package/src/browser/core.js +37 -9
- package/src/browser/replay/defaults.js +70 -0
- package/src/browser/replay/recorder.js +194 -0
- package/src/browser/replay/replayMap.js +195 -0
- package/src/browser/rollbar.js +11 -7
- package/src/browser/telemetry.js +3 -3
- package/src/browser/transport/fetch.js +17 -4
- package/src/browser/transport/xhr.js +17 -1
- package/src/browser/transport.js +11 -8
- package/src/defaults.js +1 -1
- package/src/queue.js +65 -4
- package/src/react-native/rollbar.js +1 -1
- package/src/rollbar.js +52 -10
- package/src/server/rollbar.js +3 -2
- package/src/telemetry.js +76 -11
- 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/utility.js +34 -0
- package/test/api.test.js +57 -12
- package/test/apiUtility.test.js +5 -6
- package/test/browser.core.test.js +1 -10
- package/test/browser.domUtility.test.js +1 -1
- package/test/browser.predicates.test.js +1 -1
- package/test/browser.replay.recorder.test.js +430 -0
- package/test/browser.rollbar.test.js +58 -12
- package/test/browser.telemetry.test.js +1 -1
- package/test/browser.transforms.test.js +20 -13
- package/test/browser.transport.test.js +5 -4
- package/test/browser.url.test.js +1 -1
- 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 +1 -1
- package/test/predicates.test.js +1 -1
- package/test/queue.test.js +1 -1
- package/test/rateLimiter.test.js +1 -1
- package/test/react-native.rollbar.test.js +1 -1
- package/test/react-native.transforms.test.js +2 -2
- package/test/react-native.transport.test.js +3 -3
- 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 +132 -1
- 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 +2 -2
- package/test/truncation.test.js +2 -2
- package/test/utility.test.js +44 -6
- package/webpack.config.js +6 -44
- package/.eslintignore +0 -7
- package/test/server.lambda.test.js +0 -194
- package/test/server.locals.test.js +0 -1068
- package/test/server.parser.test.js +0 -78
- package/test/server.predicates.test.js +0 -91
- package/test/server.rollbar.test.js +0 -728
- package/test/server.telemetry.test.js +0 -443
- package/test/server.transforms.test.js +0 -1193
- package/test/server.transport.test.js +0 -269
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Span } from './span.js';
|
|
2
|
+
import id from './id.js';
|
|
3
|
+
|
|
4
|
+
export class Tracer {
|
|
5
|
+
constructor(tracing, spanProcessor) {
|
|
6
|
+
this.spanProcessor = spanProcessor;
|
|
7
|
+
this.tracing = tracing;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
startSpan(
|
|
11
|
+
name,
|
|
12
|
+
options = {},
|
|
13
|
+
context = this.tracing.contextManager.active()
|
|
14
|
+
) {
|
|
15
|
+
const parentSpan = this.tracing.getSpan(context);
|
|
16
|
+
const parentSpanContext = parentSpan?.spanContext();
|
|
17
|
+
const spanId = id.gen(8);
|
|
18
|
+
let traceId;
|
|
19
|
+
let traceFlags = 0;
|
|
20
|
+
let traceState = null;
|
|
21
|
+
let parentSpanId;
|
|
22
|
+
if (parentSpanContext) {
|
|
23
|
+
traceId = parentSpanContext.traceId;
|
|
24
|
+
traceState = parentSpanContext.traceState;
|
|
25
|
+
parentSpanId = parentSpanContext.spanId;
|
|
26
|
+
} else {
|
|
27
|
+
traceId = id.gen(16);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const kind = 0;
|
|
31
|
+
const spanContext = { traceId, spanId, traceFlags, traceState };
|
|
32
|
+
|
|
33
|
+
const span = new Span({
|
|
34
|
+
resource: this.tracing.resource,
|
|
35
|
+
scope: this.tracing.scope,
|
|
36
|
+
session: this.tracing.session.session,
|
|
37
|
+
context,
|
|
38
|
+
spanContext,
|
|
39
|
+
name,
|
|
40
|
+
kind,
|
|
41
|
+
parentSpanId,
|
|
42
|
+
spanProcessor: this.spanProcessor,
|
|
43
|
+
});
|
|
44
|
+
return span;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ContextManager, createContextKey } from './contextManager.js';
|
|
2
|
+
import { Session } from './session.js';
|
|
3
|
+
import { SpanExporter } from './exporter.js';
|
|
4
|
+
import { SpanProcessor } from './spanProcessor.js';
|
|
5
|
+
import { Tracer } from './tracer.js';
|
|
6
|
+
import id from './id.js';
|
|
7
|
+
|
|
8
|
+
const SPAN_KEY = createContextKey('Rollbar Context Key SPAN');
|
|
9
|
+
|
|
10
|
+
export default class Tracing {
|
|
11
|
+
constructor(gWindow, options) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
this.window = gWindow;
|
|
14
|
+
|
|
15
|
+
this.session = new Session(this, options);
|
|
16
|
+
this.createTracer();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
initSession() {
|
|
20
|
+
if (this.session) {
|
|
21
|
+
this.session.init();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get sessionId() {
|
|
26
|
+
if (this.session) {
|
|
27
|
+
return this.session.session.id;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get resource() {
|
|
33
|
+
return {
|
|
34
|
+
attributes: {
|
|
35
|
+
...(this.options.resource || {}),
|
|
36
|
+
'rollbar.environment':
|
|
37
|
+
this.options.payload?.environment ?? this.options.environment,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get scope() {
|
|
43
|
+
return {
|
|
44
|
+
name: 'rollbar-browser-js',
|
|
45
|
+
version: this.options.version,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
idGen(bytes = 16) {
|
|
50
|
+
return id.gen(bytes);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
createTracer() {
|
|
54
|
+
this.contextManager = new ContextManager();
|
|
55
|
+
this.exporter = new SpanExporter();
|
|
56
|
+
this.spanProcessor = new SpanProcessor(this.exporter);
|
|
57
|
+
this.tracer = new Tracer(this, this.spanProcessor);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
getTracer() {
|
|
61
|
+
return this.tracer;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getSpan(context = this.contextManager.active()) {
|
|
65
|
+
return context.getValue(SPAN_KEY);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setSpan(context = this.contextManager.active(), span) {
|
|
69
|
+
return context.setValue(SPAN_KEY, span);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
startSpan(name, options = {}, context = this.contextManager.active()) {
|
|
73
|
+
return this.tracer.startSpan(name, options, context);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
with(context, fn, thisArg, ...args) {
|
|
77
|
+
return this.contextManager.with(context, fn, thisArg, ...args);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
withSpan(name, options, fn, thisArg) {
|
|
81
|
+
const span = this.startSpan(name, options);
|
|
82
|
+
return this.with(
|
|
83
|
+
this.setSpan(this.contextManager.active(), span),
|
|
84
|
+
fn,
|
|
85
|
+
thisArg,
|
|
86
|
+
span,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
package/src/utility.js
CHANGED
|
@@ -167,6 +167,15 @@ function isPromise(p) {
|
|
|
167
167
|
return isObject(p) && isType(p.then, 'function');
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
/**
|
|
171
|
+
* isBrowser - a convenience function for checking if the code is running in a browser
|
|
172
|
+
*
|
|
173
|
+
* @returns true if the code is running in a browser environment
|
|
174
|
+
*/
|
|
175
|
+
function isBrowser() {
|
|
176
|
+
return typeof window !== 'undefined';
|
|
177
|
+
}
|
|
178
|
+
|
|
170
179
|
function redact() {
|
|
171
180
|
return '********';
|
|
172
181
|
}
|
|
@@ -535,6 +544,8 @@ function createItem(args, logger, notifier, requestKeys, lambdaContext) {
|
|
|
535
544
|
uuid: uuid4(),
|
|
536
545
|
};
|
|
537
546
|
|
|
547
|
+
item.data = item.data || {};
|
|
548
|
+
|
|
538
549
|
setCustomItemKeys(item, custom);
|
|
539
550
|
|
|
540
551
|
if (requestKeys && request) {
|
|
@@ -632,6 +643,26 @@ function createTelemetryEvent(args) {
|
|
|
632
643
|
return event;
|
|
633
644
|
}
|
|
634
645
|
|
|
646
|
+
function addItemAttributes(itemData, attributes) {
|
|
647
|
+
itemData.attributes = itemData.attributes || [];
|
|
648
|
+
for (const a of attributes) {
|
|
649
|
+
if (a.value === undefined) {
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
itemData.attributes.push(a);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function getItemAttribute(itemData, key) {
|
|
657
|
+
const attributes = itemData.attributes || [];
|
|
658
|
+
for (let i = 0; i < attributes.length; ++i) {
|
|
659
|
+
if (attributes[i].key === key) {
|
|
660
|
+
return attributes[i].value;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return undefined;
|
|
664
|
+
}
|
|
665
|
+
|
|
635
666
|
/*
|
|
636
667
|
* get - given an obj/array and a keypath, return the value at that keypath or
|
|
637
668
|
* undefined if not possible.
|
|
@@ -785,6 +816,8 @@ module.exports = {
|
|
|
785
816
|
createItem: createItem,
|
|
786
817
|
addErrorContext: addErrorContext,
|
|
787
818
|
createTelemetryEvent: createTelemetryEvent,
|
|
819
|
+
addItemAttributes: addItemAttributes,
|
|
820
|
+
getItemAttribute: getItemAttribute,
|
|
788
821
|
filterIp: filterIp,
|
|
789
822
|
formatArgsAsString: formatArgsAsString,
|
|
790
823
|
formatUrl: formatUrl,
|
|
@@ -799,6 +832,7 @@ module.exports = {
|
|
|
799
832
|
isString: isString,
|
|
800
833
|
isType: isType,
|
|
801
834
|
isPromise: isPromise,
|
|
835
|
+
isBrowser: isBrowser,
|
|
802
836
|
jsonParse: jsonParse,
|
|
803
837
|
LEVELS: LEVELS,
|
|
804
838
|
makeUnhandledStackInfo: makeUnhandledStackInfo,
|
package/test/api.test.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
/* globals it */
|
|
4
4
|
/* globals sinon */
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import API from '../src/api.js';
|
|
7
|
+
import utility from '../src/utility.js';
|
|
8
8
|
utility.setupJSON();
|
|
9
9
|
|
|
10
10
|
function TestTransportGenerator() {
|
|
@@ -34,10 +34,9 @@ describe('Api()', function () {
|
|
|
34
34
|
expect(false).to.be.ok();
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
|
-
var backup = null;
|
|
38
37
|
var accessToken = 'abc123';
|
|
39
38
|
var options = { accessToken: accessToken };
|
|
40
|
-
var api = new API(options, transport, url
|
|
39
|
+
var api = new API(options, transport, url);
|
|
41
40
|
// I know this is testing internal state but it
|
|
42
41
|
// is the most expedient way to do this
|
|
43
42
|
expect(api.accessToken).to.eql(accessToken);
|
|
@@ -60,10 +59,9 @@ describe('Api()', function () {
|
|
|
60
59
|
};
|
|
61
60
|
},
|
|
62
61
|
};
|
|
63
|
-
var backup = null;
|
|
64
62
|
var accessToken = 'abc123';
|
|
65
63
|
var options = { accessToken: accessToken, endpoint: endpoint };
|
|
66
|
-
var api = new API(options, transport, url
|
|
64
|
+
var api = new API(options, transport, url);
|
|
67
65
|
expect(api.accessToken).to.eql(accessToken);
|
|
68
66
|
expect(api.transportOptions.hostname).to.eql('woo.foo.com');
|
|
69
67
|
expect(api.transportOptions.path).to.match(/\/api\/42/);
|
|
@@ -81,10 +79,9 @@ describe('postItem', function () {
|
|
|
81
79
|
expect(false).to.be.ok();
|
|
82
80
|
},
|
|
83
81
|
};
|
|
84
|
-
var backup = null;
|
|
85
82
|
var accessToken = 'abc123';
|
|
86
83
|
var options = { accessToken: accessToken };
|
|
87
|
-
var api = new API(options, transport, url
|
|
84
|
+
var api = new API(options, transport, url);
|
|
88
85
|
|
|
89
86
|
var data = { a: 1 };
|
|
90
87
|
api.postItem(data, function (err, resp) {
|
|
@@ -93,7 +90,6 @@ describe('postItem', function () {
|
|
|
93
90
|
expect(transport.postArgs.length).to.eql(1);
|
|
94
91
|
expect(transport.postArgs[0][0]).to.eql(accessToken);
|
|
95
92
|
expect(transport.postArgs[0][1].path).to.match(/\/item\//);
|
|
96
|
-
expect(transport.postArgs[0][2].access_token).to.eql(accessToken);
|
|
97
93
|
expect(transport.postArgs[0][2].data.a).to.eql(1);
|
|
98
94
|
done();
|
|
99
95
|
});
|
|
@@ -106,10 +102,9 @@ describe('postItem', function () {
|
|
|
106
102
|
expect(false).to.be.ok();
|
|
107
103
|
},
|
|
108
104
|
};
|
|
109
|
-
var backup = null;
|
|
110
105
|
var accessToken = 'abc123';
|
|
111
106
|
var options = { accessToken: accessToken };
|
|
112
|
-
var api = new API(options, transport, url
|
|
107
|
+
var api = new API(options, transport, url);
|
|
113
108
|
|
|
114
109
|
var data = { a: 1, context: { some: [1, 2, 'stuff'] } };
|
|
115
110
|
api.postItem(data, function (err, resp) {
|
|
@@ -119,7 +114,6 @@ describe('postItem', function () {
|
|
|
119
114
|
expect(transport.postArgs[0][0]).to.eql(accessToken);
|
|
120
115
|
expect(transport.postArgs[0][1].path).to.match(/\/item\//);
|
|
121
116
|
expect(transport.postArgs[0][1].method).to.eql('POST');
|
|
122
|
-
expect(transport.postArgs[0][2].access_token).to.eql(accessToken);
|
|
123
117
|
expect(transport.postArgs[0][2].data.a).to.eql(1);
|
|
124
118
|
expect(transport.postArgs[0][2].data.context).to.eql(
|
|
125
119
|
'{"some":[1,2,"stuff"]}',
|
|
@@ -128,3 +122,54 @@ describe('postItem', function () {
|
|
|
128
122
|
});
|
|
129
123
|
});
|
|
130
124
|
});
|
|
125
|
+
|
|
126
|
+
describe('postSpans', function () {
|
|
127
|
+
let transport;
|
|
128
|
+
|
|
129
|
+
beforeEach(function () {
|
|
130
|
+
// Create mock transport
|
|
131
|
+
transport = {
|
|
132
|
+
post: sinon
|
|
133
|
+
.stub()
|
|
134
|
+
.callsFake((accessToken, options, payload, callback) => {
|
|
135
|
+
callback(null, { result: 'ok' });
|
|
136
|
+
}),
|
|
137
|
+
postJsonPayload: sinon.stub(),
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
afterEach(function () {
|
|
142
|
+
sinon.restore();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should call post on the transport object', async function () {
|
|
146
|
+
const urllib = await import('../src/browser/url.js');
|
|
147
|
+
const response = 'yes';
|
|
148
|
+
const url = {
|
|
149
|
+
parse: function (e) {
|
|
150
|
+
expect(false).to.be.ok();
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
const accessToken = 'abc123';
|
|
154
|
+
const options = {
|
|
155
|
+
accessToken: accessToken,
|
|
156
|
+
tracing: {
|
|
157
|
+
enabled: true,
|
|
158
|
+
endpoint: 'https://api.rollbar.com/api/1/session/',
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
const api = new API(options, transport, urllib);
|
|
162
|
+
|
|
163
|
+
const data = { a: 1 };
|
|
164
|
+
await api.postSpans(data)
|
|
165
|
+
|
|
166
|
+
expect(transport.post.called).to.be.true;
|
|
167
|
+
|
|
168
|
+
expect(transport.post.callCount).to.eql(1);
|
|
169
|
+
expect(transport.post.firstCall.args.length).to.eql(4);
|
|
170
|
+
expect(transport.post.firstCall.args[0]).to.eql(accessToken);
|
|
171
|
+
expect(transport.post.firstCall.args[1].path).to.match(/\/session\//);
|
|
172
|
+
expect(transport.post.firstCall.args[1].method).to.eql('POST');
|
|
173
|
+
expect(transport.post.firstCall.args[2].a).to.eql(1);
|
|
174
|
+
});
|
|
175
|
+
});
|
package/test/apiUtility.test.js
CHANGED
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
/* globals it */
|
|
4
4
|
/* globals sinon */
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import u from '../src/apiUtility.js';
|
|
7
|
+
import utility from '../src/utility.js';
|
|
8
8
|
utility.setupJSON();
|
|
9
9
|
|
|
10
10
|
describe('buildPayload', function () {
|
|
11
11
|
it('should package up the input into a payload', function () {
|
|
12
12
|
var token = 'abc123';
|
|
13
13
|
var data = { context: 'not an object', other: 'stuff' };
|
|
14
|
-
var payload = u.buildPayload(
|
|
14
|
+
var payload = u.buildPayload(data);
|
|
15
15
|
|
|
16
|
-
expect(payload.access_token).to.eql(token);
|
|
17
16
|
expect(payload.data).to.eql(data);
|
|
18
17
|
});
|
|
19
18
|
it('should stringify context', function () {
|
|
@@ -23,7 +22,7 @@ describe('buildPayload', function () {
|
|
|
23
22
|
context: context,
|
|
24
23
|
other: 'stuff',
|
|
25
24
|
};
|
|
26
|
-
var payload = u.buildPayload(
|
|
25
|
+
var payload = u.buildPayload(data);
|
|
27
26
|
|
|
28
27
|
expect(payload.data.context).to.not.eql(context);
|
|
29
28
|
expect(payload.data.context).to.eql('{"a":1,"b":"other"}');
|
|
@@ -38,7 +37,7 @@ describe('buildPayload', function () {
|
|
|
38
37
|
context: context,
|
|
39
38
|
other: 'stuff',
|
|
40
39
|
};
|
|
41
|
-
var payload = u.buildPayload(
|
|
40
|
+
var payload = u.buildPayload(data);
|
|
42
41
|
|
|
43
42
|
expect(payload.data.context).to.not.eql(context);
|
|
44
43
|
expect(payload.data.context.length).to.eql(255);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/* globals sinon */
|
|
5
5
|
|
|
6
6
|
// Use minimal browser package, with no optional components added.
|
|
7
|
-
|
|
7
|
+
import Rollbar from '../src/browser/core.js';
|
|
8
8
|
|
|
9
9
|
describe('options.captureUncaught', function () {
|
|
10
10
|
beforeEach(function (done) {
|
|
@@ -47,7 +47,6 @@ describe('options.captureUncaught', function () {
|
|
|
47
47
|
|
|
48
48
|
var body = JSON.parse(server.requests[0].requestBody);
|
|
49
49
|
|
|
50
|
-
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
|
|
51
50
|
expect(body.data.body.trace.exception.message).to.eql('test error');
|
|
52
51
|
expect(body.data.notifier.diagnostic.raw_error.message).to.eql(
|
|
53
52
|
'test error',
|
|
@@ -95,7 +94,6 @@ describe('options.captureUncaught', function () {
|
|
|
95
94
|
|
|
96
95
|
var body = JSON.parse(server.requests[0].requestBody);
|
|
97
96
|
|
|
98
|
-
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
|
|
99
97
|
expect(body.data.body.trace.exception.message).to.eql('test error');
|
|
100
98
|
expect(body.data.notifier.diagnostic.is_anonymous).to.not.be.ok();
|
|
101
99
|
|
|
@@ -149,7 +147,6 @@ describe('options.captureUncaught', function () {
|
|
|
149
147
|
|
|
150
148
|
var body = JSON.parse(server.requests[0].requestBody);
|
|
151
149
|
|
|
152
|
-
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
|
|
153
150
|
expect(body.data.body.trace.exception.message).to.eql('anon error');
|
|
154
151
|
expect(body.data.notifier.diagnostic.is_anonymous).to.eql(true);
|
|
155
152
|
|
|
@@ -190,7 +187,6 @@ describe('options.captureUncaught', function () {
|
|
|
190
187
|
|
|
191
188
|
var body = JSON.parse(server.requests[0].requestBody);
|
|
192
189
|
|
|
193
|
-
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
|
|
194
190
|
expect(body.data.body.trace.exception.message).to.eql('test error');
|
|
195
191
|
|
|
196
192
|
// karma doesn't unload the browser between tests, so the onerror handler
|
|
@@ -231,7 +227,6 @@ describe('options.captureUncaught', function () {
|
|
|
231
227
|
|
|
232
228
|
var body = JSON.parse(server.requests[0].requestBody);
|
|
233
229
|
|
|
234
|
-
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
|
|
235
230
|
expect(body.data.body.trace.exception.message).to.eql('test error');
|
|
236
231
|
|
|
237
232
|
// karma doesn't unload the browser between tests, so the onerror handler
|
|
@@ -263,7 +258,6 @@ describe('options.captureUncaught', function () {
|
|
|
263
258
|
|
|
264
259
|
var body = JSON.parse(server.requests[0].requestBody);
|
|
265
260
|
|
|
266
|
-
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
|
|
267
261
|
expect(body.data.body.trace_chain[0].exception.message).to.eql(
|
|
268
262
|
'test DOMException',
|
|
269
263
|
);
|
|
@@ -300,7 +294,6 @@ describe('options.captureUncaught', function () {
|
|
|
300
294
|
|
|
301
295
|
var body = JSON.parse(server.requests[0].requestBody);
|
|
302
296
|
|
|
303
|
-
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
|
|
304
297
|
expect(body.data.body.trace.exception.message).to.eql('deep stack error');
|
|
305
298
|
expect(body.data.body.trace.frames.length).to.be.above(20);
|
|
306
299
|
|
|
@@ -354,7 +347,6 @@ describe('options.captureUnhandledRejections', function () {
|
|
|
354
347
|
|
|
355
348
|
var body = JSON.parse(server.requests[0].requestBody);
|
|
356
349
|
|
|
357
|
-
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
|
|
358
350
|
expect(body.data.body.trace.exception.message).to.eql('test reject');
|
|
359
351
|
expect(body.data.notifier.diagnostic.is_uncaught).to.eql(true);
|
|
360
352
|
|
|
@@ -389,7 +381,6 @@ describe('options.captureUnhandledRejections', function () {
|
|
|
389
381
|
|
|
390
382
|
var body = JSON.parse(server.requests[0].requestBody);
|
|
391
383
|
|
|
392
|
-
expect(body.access_token).to.eql('POST_CLIENT_ITEM_TOKEN');
|
|
393
384
|
expect(body.data.body.trace.exception.message).to.eql('test reject');
|
|
394
385
|
|
|
395
386
|
server.requests.length = 0;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* globals it */
|
|
4
4
|
/* globals sinon */
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import * as p from '../src/browser/predicates.js';
|
|
7
7
|
|
|
8
8
|
describe('checkIgnore', function () {
|
|
9
9
|
it('should return false if is ajax and ignoring ajax errors is on', function () {
|