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
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import id from './id.js';
|
|
2
|
+
|
|
3
|
+
const SESSION_KEY = 'RollbarSession';
|
|
4
|
+
|
|
5
|
+
export class Session {
|
|
6
|
+
constructor(tracing, options) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
this.tracing = tracing;
|
|
9
|
+
this.window = tracing.window;
|
|
10
|
+
this.session = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
init() {
|
|
14
|
+
if (this.session) {
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
return this.getSession() || this.createSession();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getSession() {
|
|
21
|
+
try {
|
|
22
|
+
const serializedSession = this.window.sessionStorage.getItem(SESSION_KEY);
|
|
23
|
+
|
|
24
|
+
if (!serializedSession) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.session = JSON.parse(serializedSession);
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
createSession() {
|
|
36
|
+
this.session = {
|
|
37
|
+
id: id.gen(),
|
|
38
|
+
createdAt: Date.now(),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return this.setSession(this.session);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
setSession(session) {
|
|
45
|
+
const sessionString = JSON.stringify(session);
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
this.window.sessionStorage.setItem(SESSION_KEY, sessionString);
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import hrtime from './hrtime.js';
|
|
2
|
+
|
|
3
|
+
export class Span {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.initReadableSpan(options);
|
|
6
|
+
|
|
7
|
+
this.spanProcessor = options.spanProcessor;
|
|
8
|
+
this.spanProcessor.onStart(this, options.context);
|
|
9
|
+
|
|
10
|
+
if (options.attributes) {
|
|
11
|
+
this.setAttributes(options.attributes);
|
|
12
|
+
}
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
initReadableSpan(options) {
|
|
17
|
+
this.span = {
|
|
18
|
+
name: options.name,
|
|
19
|
+
kind: options.kind,
|
|
20
|
+
spanContext: options.spanContext,
|
|
21
|
+
parentSpanId: options.parentSpanId,
|
|
22
|
+
startTime: options.startTime || hrtime.now(),
|
|
23
|
+
endTime: [0, 0],
|
|
24
|
+
status: { code: 0, message: '' },
|
|
25
|
+
attributes: { 'session.id': options.session.id },
|
|
26
|
+
links: [],
|
|
27
|
+
events: [],
|
|
28
|
+
duration: 0,
|
|
29
|
+
ended: false,
|
|
30
|
+
resource: options.resource,
|
|
31
|
+
instrumentationScope: options.scope,
|
|
32
|
+
droppedAttributesCount: 0,
|
|
33
|
+
droppedEventsCount: 0,
|
|
34
|
+
droppedLinksCount: 0,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
spanContext() {
|
|
39
|
+
return this.span.spanContext;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get spanId() {
|
|
43
|
+
return this.span.spanContext.spanId;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get traceId() {
|
|
47
|
+
return this.span.spanContext.traceId;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
setAttribute(key, value) {
|
|
51
|
+
if (value == null || this.ended) return this;
|
|
52
|
+
if (key.length === 0) return this;
|
|
53
|
+
|
|
54
|
+
this.span.attributes[key] = value;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setAttributes(attributes) {
|
|
59
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
60
|
+
this.setAttribute(k, v);
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
addEvent(name, attributes = {}, time) {
|
|
66
|
+
if (this.span.ended) return this;
|
|
67
|
+
|
|
68
|
+
this.span.events.push({
|
|
69
|
+
name,
|
|
70
|
+
attributes,
|
|
71
|
+
time: time || hrtime.now(),
|
|
72
|
+
droppedAttributesCount: 0,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
isRecording() {
|
|
79
|
+
return this.span.ended === false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
end(attributes, time) {
|
|
83
|
+
if (attributes) this.setAttributes(attributes);
|
|
84
|
+
this.span.endTime = time || hrtime.now();
|
|
85
|
+
this.span.ended = true;
|
|
86
|
+
this.spanProcessor.onEnd(this);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export() {
|
|
90
|
+
return this.span;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class SpanProcessor {
|
|
2
|
+
constructor(exporter) {
|
|
3
|
+
this.exporter = exporter;
|
|
4
|
+
this.pendingSpans = new Map()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
onStart(span, _parentContext) {
|
|
8
|
+
this.pendingSpans.set(span.span.spanContext.spanId, span);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
onEnd(span) {
|
|
12
|
+
this.exporter.export([span.export()])
|
|
13
|
+
this.pendingSpans.delete(span.span.spanContext.spanId);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -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/transforms.js
CHANGED
|
@@ -42,19 +42,19 @@ function addMessageWithError(item, options, callback) {
|
|
|
42
42
|
}
|
|
43
43
|
if (trace) {
|
|
44
44
|
if (!(trace.exception && trace.exception.description)) {
|
|
45
|
-
_.set(item, tracePath+'.exception.description', item.message);
|
|
45
|
+
_.set(item, tracePath + '.exception.description', item.message);
|
|
46
46
|
callback(null, item);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
var extra = _.get(item, tracePath+'.extra') || {};
|
|
50
|
-
var newExtra =
|
|
51
|
-
_.set(item, tracePath+'.extra', newExtra);
|
|
49
|
+
var extra = _.get(item, tracePath + '.extra') || {};
|
|
50
|
+
var newExtra = _.merge(extra, { message: item.message });
|
|
51
|
+
_.set(item, tracePath + '.extra', newExtra);
|
|
52
52
|
}
|
|
53
53
|
callback(null, item);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function userTransform(logger) {
|
|
57
|
-
return function(item, options, callback) {
|
|
57
|
+
return function (item, options, callback) {
|
|
58
58
|
var newItem = _.merge(item);
|
|
59
59
|
var response = null;
|
|
60
60
|
try {
|
|
@@ -63,23 +63,29 @@ function userTransform(logger) {
|
|
|
63
63
|
}
|
|
64
64
|
} catch (e) {
|
|
65
65
|
options.transform = null;
|
|
66
|
-
logger.error(
|
|
66
|
+
logger.error(
|
|
67
|
+
'Error while calling custom transform() function. Removing custom transform().',
|
|
68
|
+
e,
|
|
69
|
+
);
|
|
67
70
|
callback(null, item);
|
|
68
71
|
return;
|
|
69
72
|
}
|
|
70
|
-
if(_.isPromise(response)) {
|
|
71
|
-
response.then(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
if (_.isPromise(response)) {
|
|
74
|
+
response.then(
|
|
75
|
+
function (promisedItem) {
|
|
76
|
+
if (promisedItem) {
|
|
77
|
+
newItem.data = promisedItem;
|
|
78
|
+
}
|
|
79
|
+
callback(null, newItem);
|
|
80
|
+
},
|
|
81
|
+
function (error) {
|
|
82
|
+
callback(error, item);
|
|
83
|
+
},
|
|
84
|
+
);
|
|
79
85
|
} else {
|
|
80
86
|
callback(null, newItem);
|
|
81
87
|
}
|
|
82
|
-
}
|
|
88
|
+
};
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
function addConfigToPayload(item, options, callback) {
|
|
@@ -94,7 +100,7 @@ function addConfigToPayload(item, options, callback) {
|
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
function addFunctionOption(options, name) {
|
|
97
|
-
if(_.isFunction(options[name])) {
|
|
103
|
+
if (_.isFunction(options[name])) {
|
|
98
104
|
options[name] = options[name].toString();
|
|
99
105
|
}
|
|
100
106
|
}
|
|
@@ -113,7 +119,10 @@ function addConfiguredOptions(item, options, callback) {
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
function addDiagnosticKeys(item, options, callback) {
|
|
116
|
-
var diagnostic = _.merge(
|
|
122
|
+
var diagnostic = _.merge(
|
|
123
|
+
item.notifier.client.notifier.diagnostic,
|
|
124
|
+
item.diagnostic,
|
|
125
|
+
);
|
|
117
126
|
|
|
118
127
|
if (_.get(item, 'err._isAnonymous')) {
|
|
119
128
|
diagnostic.is_anonymous = true;
|
|
@@ -132,14 +141,17 @@ function addDiagnosticKeys(item, options, callback) {
|
|
|
132
141
|
filename: item.err.fileName,
|
|
133
142
|
line: item.err.lineNumber,
|
|
134
143
|
column: item.err.columnNumber,
|
|
135
|
-
stack: item.err.stack
|
|
144
|
+
stack: item.err.stack,
|
|
136
145
|
};
|
|
137
146
|
} catch (e) {
|
|
138
147
|
diagnostic.raw_error = { failed: String(e) };
|
|
139
148
|
}
|
|
140
149
|
}
|
|
141
150
|
|
|
142
|
-
item.data.notifier.diagnostic = _.merge(
|
|
151
|
+
item.data.notifier.diagnostic = _.merge(
|
|
152
|
+
item.data.notifier.diagnostic,
|
|
153
|
+
diagnostic,
|
|
154
|
+
);
|
|
143
155
|
callback(null, item);
|
|
144
156
|
}
|
|
145
157
|
|
|
@@ -151,5 +163,5 @@ module.exports = {
|
|
|
151
163
|
userTransform: userTransform,
|
|
152
164
|
addConfigToPayload: addConfigToPayload,
|
|
153
165
|
addConfiguredOptions: addConfiguredOptions,
|
|
154
|
-
addDiagnosticKeys: addDiagnosticKeys
|
|
166
|
+
addDiagnosticKeys: addDiagnosticKeys,
|
|
155
167
|
};
|
package/src/truncation.js
CHANGED
|
@@ -14,7 +14,7 @@ function selectFrames(frames, range) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function truncateFrames(payload, jsonBackup, range) {
|
|
17
|
-
range =
|
|
17
|
+
range = typeof range === 'undefined' ? 30 : range;
|
|
18
18
|
var body = payload.data.body;
|
|
19
19
|
var frames;
|
|
20
20
|
if (body.trace_chain) {
|
|
@@ -61,7 +61,10 @@ function truncateStrings(len, payload, jsonBackup) {
|
|
|
61
61
|
function truncateTraceData(traceData) {
|
|
62
62
|
if (traceData.exception) {
|
|
63
63
|
delete traceData.exception.description;
|
|
64
|
-
traceData.exception.message = maybeTruncateValue(
|
|
64
|
+
traceData.exception.message = maybeTruncateValue(
|
|
65
|
+
255,
|
|
66
|
+
traceData.exception.message,
|
|
67
|
+
);
|
|
65
68
|
}
|
|
66
69
|
traceData.frames = selectFrames(traceData.frames, 1);
|
|
67
70
|
return traceData;
|
|
@@ -85,14 +88,14 @@ function needsTruncation(payload, maxSize) {
|
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
function truncate(payload, jsonBackup, maxSize) {
|
|
88
|
-
maxSize =
|
|
91
|
+
maxSize = typeof maxSize === 'undefined' ? 512 * 1024 : maxSize;
|
|
89
92
|
var strategies = [
|
|
90
93
|
raw,
|
|
91
94
|
truncateFrames,
|
|
92
95
|
truncateStrings.bind(null, 1024),
|
|
93
96
|
truncateStrings.bind(null, 512),
|
|
94
97
|
truncateStrings.bind(null, 256),
|
|
95
|
-
minBody
|
|
98
|
+
minBody,
|
|
96
99
|
];
|
|
97
100
|
var strategy, results, result;
|
|
98
101
|
|
|
@@ -114,5 +117,5 @@ module.exports = {
|
|
|
114
117
|
raw: raw,
|
|
115
118
|
truncateFrames: truncateFrames,
|
|
116
119
|
truncateStrings: truncateStrings,
|
|
117
|
-
maybeTruncateValue: maybeTruncateValue
|
|
120
|
+
maybeTruncateValue: maybeTruncateValue,
|
|
118
121
|
};
|
package/src/utility/headers.js
CHANGED
|
@@ -18,77 +18,77 @@ function headers(headers) {
|
|
|
18
18
|
|
|
19
19
|
function normalizeName(name) {
|
|
20
20
|
if (typeof name !== 'string') {
|
|
21
|
-
name = String(name)
|
|
21
|
+
name = String(name);
|
|
22
22
|
}
|
|
23
|
-
return name.toLowerCase()
|
|
23
|
+
return name.toLowerCase();
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function normalizeValue(value) {
|
|
27
27
|
if (typeof value !== 'string') {
|
|
28
|
-
value = String(value)
|
|
28
|
+
value = String(value);
|
|
29
29
|
}
|
|
30
|
-
return value
|
|
30
|
+
return value;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function iteratorFor(items) {
|
|
34
34
|
var iterator = {
|
|
35
|
-
next: function() {
|
|
36
|
-
var value = items.shift()
|
|
37
|
-
return {done: value === undefined, value: value}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
35
|
+
next: function () {
|
|
36
|
+
var value = items.shift();
|
|
37
|
+
return { done: value === undefined, value: value };
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
40
|
|
|
41
|
-
return iterator
|
|
41
|
+
return iterator;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function FetchHeaders(headers) {
|
|
45
|
-
this.map = {}
|
|
45
|
+
this.map = {};
|
|
46
46
|
|
|
47
47
|
if (headers instanceof FetchHeaders) {
|
|
48
|
-
headers.forEach(function(value, name) {
|
|
49
|
-
this.append(name, value)
|
|
50
|
-
}, this)
|
|
48
|
+
headers.forEach(function (value, name) {
|
|
49
|
+
this.append(name, value);
|
|
50
|
+
}, this);
|
|
51
51
|
} else if (Array.isArray(headers)) {
|
|
52
|
-
headers.forEach(function(header) {
|
|
53
|
-
this.append(header[0], header[1])
|
|
54
|
-
}, this)
|
|
52
|
+
headers.forEach(function (header) {
|
|
53
|
+
this.append(header[0], header[1]);
|
|
54
|
+
}, this);
|
|
55
55
|
} else if (headers) {
|
|
56
|
-
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
|
57
|
-
this.append(name, headers[name])
|
|
58
|
-
}, this)
|
|
56
|
+
Object.getOwnPropertyNames(headers).forEach(function (name) {
|
|
57
|
+
this.append(name, headers[name]);
|
|
58
|
+
}, this);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
FetchHeaders.prototype.append = function(name, value) {
|
|
63
|
-
name = normalizeName(name)
|
|
64
|
-
value = normalizeValue(value)
|
|
65
|
-
var oldValue = this.map[name]
|
|
66
|
-
this.map[name] = oldValue ? oldValue + ', ' + value : value
|
|
67
|
-
}
|
|
62
|
+
FetchHeaders.prototype.append = function (name, value) {
|
|
63
|
+
name = normalizeName(name);
|
|
64
|
+
value = normalizeValue(value);
|
|
65
|
+
var oldValue = this.map[name];
|
|
66
|
+
this.map[name] = oldValue ? oldValue + ', ' + value : value;
|
|
67
|
+
};
|
|
68
68
|
|
|
69
|
-
FetchHeaders.prototype.get = function(name) {
|
|
70
|
-
name = normalizeName(name)
|
|
71
|
-
return this.has(name) ? this.map[name] : null
|
|
72
|
-
}
|
|
69
|
+
FetchHeaders.prototype.get = function (name) {
|
|
70
|
+
name = normalizeName(name);
|
|
71
|
+
return this.has(name) ? this.map[name] : null;
|
|
72
|
+
};
|
|
73
73
|
|
|
74
|
-
FetchHeaders.prototype.has = function(name) {
|
|
75
|
-
return this.map.hasOwnProperty(normalizeName(name))
|
|
76
|
-
}
|
|
74
|
+
FetchHeaders.prototype.has = function (name) {
|
|
75
|
+
return this.map.hasOwnProperty(normalizeName(name));
|
|
76
|
+
};
|
|
77
77
|
|
|
78
|
-
FetchHeaders.prototype.forEach = function(callback, thisArg) {
|
|
78
|
+
FetchHeaders.prototype.forEach = function (callback, thisArg) {
|
|
79
79
|
for (var name in this.map) {
|
|
80
80
|
if (this.map.hasOwnProperty(name)) {
|
|
81
|
-
callback.call(thisArg, this.map[name], name, this)
|
|
81
|
+
callback.call(thisArg, this.map[name], name, this);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
}
|
|
84
|
+
};
|
|
85
85
|
|
|
86
|
-
FetchHeaders.prototype.entries = function() {
|
|
87
|
-
var items = []
|
|
88
|
-
this.forEach(function(value, name) {
|
|
89
|
-
items.push([name, value])
|
|
90
|
-
})
|
|
91
|
-
return iteratorFor(items)
|
|
92
|
-
}
|
|
86
|
+
FetchHeaders.prototype.entries = function () {
|
|
87
|
+
var items = [];
|
|
88
|
+
this.forEach(function (value, name) {
|
|
89
|
+
items.push([name, value]);
|
|
90
|
+
});
|
|
91
|
+
return iteratorFor(items);
|
|
92
|
+
};
|
|
93
93
|
|
|
94
94
|
module.exports = headers;
|
package/src/utility/traverse.js
CHANGED
|
@@ -8,7 +8,7 @@ function traverse(obj, func, seen) {
|
|
|
8
8
|
var seenIndex;
|
|
9
9
|
|
|
10
10
|
// Best might be to use Map here with `obj` as the keys, but we want to support IE < 11.
|
|
11
|
-
seen = seen || { obj: [], mapped: []};
|
|
11
|
+
seen = seen || { obj: [], mapped: [] };
|
|
12
12
|
|
|
13
13
|
if (isObj) {
|
|
14
14
|
seenIndex = seen.obj.indexOf(obj);
|