@sentry/browser 7.0.0-alpha.1 → 7.0.0-beta.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/README.md +2 -3
- package/cjs/client.js +130 -83
- package/cjs/client.js.map +1 -1
- package/cjs/eventbuilder.js +225 -167
- package/cjs/eventbuilder.js.map +1 -1
- package/cjs/exports.js +55 -47
- package/cjs/exports.js.map +1 -1
- package/cjs/flags.js +7 -3
- package/cjs/flags.js.map +1 -1
- package/cjs/helpers.js +122 -130
- package/cjs/helpers.js.map +1 -1
- package/cjs/index.js +78 -13
- package/cjs/index.js.map +1 -1
- package/cjs/integrations/breadcrumbs.js +223 -192
- package/cjs/integrations/breadcrumbs.js.map +1 -1
- package/cjs/integrations/dedupe.js +183 -142
- package/cjs/integrations/dedupe.js.map +1 -1
- package/cjs/integrations/globalhandlers.js +211 -171
- package/cjs/integrations/globalhandlers.js.map +1 -1
- package/cjs/integrations/httpcontext.js +51 -0
- package/cjs/integrations/httpcontext.js.map +1 -0
- package/cjs/integrations/index.js +18 -14
- package/cjs/integrations/index.js.map +1 -1
- package/cjs/integrations/linkederrors.js +79 -51
- package/cjs/integrations/linkederrors.js.map +1 -1
- package/cjs/integrations/trycatch.js +245 -216
- package/cjs/integrations/trycatch.js.map +1 -1
- package/cjs/sdk.js +168 -114
- package/cjs/sdk.js.map +1 -1
- package/cjs/stack-parsers.js +134 -84
- package/cjs/stack-parsers.js.map +1 -1
- package/cjs/transports/fetch.js +34 -80
- package/cjs/transports/fetch.js.map +1 -1
- package/cjs/transports/index.js +10 -14
- package/cjs/transports/index.js.map +1 -1
- package/cjs/transports/utils.js +57 -53
- package/cjs/transports/utils.js.map +1 -1
- package/cjs/transports/xhr.js +53 -63
- package/cjs/transports/xhr.js.map +1 -1
- package/esm/client.js +128 -82
- package/esm/client.js.map +1 -1
- package/esm/eventbuilder.js +218 -160
- package/esm/eventbuilder.js.map +1 -1
- package/esm/exports.js +12 -7
- package/esm/exports.js.map +1 -1
- package/esm/flags.js +5 -2
- package/esm/flags.js.map +1 -1
- package/esm/helpers.js +120 -127
- package/esm/helpers.js.map +1 -1
- package/esm/index.js +28 -10
- package/esm/index.js.map +1 -1
- package/esm/integrations/breadcrumbs.js +219 -190
- package/esm/integrations/breadcrumbs.js.map +1 -1
- package/esm/integrations/dedupe.js +180 -140
- package/esm/integrations/dedupe.js.map +1 -1
- package/esm/integrations/globalhandlers.js +208 -169
- package/esm/integrations/globalhandlers.js.map +1 -1
- package/esm/integrations/httpcontext.js +49 -0
- package/esm/integrations/httpcontext.js.map +1 -0
- package/esm/integrations/index.js +7 -7
- package/esm/integrations/index.js.map +1 -1
- package/esm/integrations/linkederrors.js +76 -49
- package/esm/integrations/linkederrors.js.map +1 -1
- package/esm/integrations/trycatch.js +242 -214
- package/esm/integrations/trycatch.js.map +1 -1
- package/esm/sdk.js +164 -111
- package/esm/sdk.js.map +1 -1
- package/esm/stack-parsers.js +126 -83
- package/esm/stack-parsers.js.map +1 -1
- package/esm/transports/fetch.js +32 -79
- package/esm/transports/fetch.js.map +1 -1
- package/esm/transports/index.js +3 -7
- package/esm/transports/index.js.map +1 -1
- package/esm/transports/utils.js +56 -52
- package/esm/transports/utils.js.map +1 -1
- package/esm/transports/xhr.js +51 -62
- package/esm/transports/xhr.js.map +1 -1
- package/package.json +4 -4
- package/types/client.d.ts +24 -18
- package/types/client.d.ts.map +1 -1
- package/types/eventbuilder.d.ts +1 -1
- package/types/exports.d.ts +5 -5
- package/types/exports.d.ts.map +1 -1
- package/types/helpers.d.ts +0 -5
- package/types/helpers.d.ts.map +1 -1
- package/types/index.d.ts +2 -3
- package/types/index.d.ts.map +1 -1
- package/types/integrations/breadcrumbs.d.ts +6 -7
- package/types/integrations/breadcrumbs.d.ts.map +1 -1
- package/types/integrations/globalhandlers.d.ts.map +1 -1
- package/types/integrations/{useragent.d.ts → httpcontext.d.ts} +3 -3
- package/types/integrations/httpcontext.d.ts.map +1 -0
- package/types/integrations/index.d.ts +1 -1
- package/types/integrations/index.d.ts.map +1 -1
- package/types/integrations/linkederrors.d.ts.map +1 -1
- package/types/sdk.d.ts +4 -4
- package/types/sdk.d.ts.map +1 -1
- package/types/stack-parsers.d.ts +7 -6
- package/types/stack-parsers.d.ts.map +1 -1
- package/types/transports/fetch.d.ts +6 -15
- package/types/transports/fetch.d.ts.map +1 -1
- package/types/transports/index.d.ts +2 -6
- package/types/transports/index.d.ts.map +1 -1
- package/types/transports/types.d.ts +10 -0
- package/types/transports/types.d.ts.map +1 -0
- package/types/transports/utils.d.ts +1 -1
- package/types/transports/utils.d.ts.map +1 -1
- package/types/transports/xhr.d.ts +6 -10
- package/types/transports/xhr.d.ts.map +1 -1
- package/cjs/client.d.ts +0 -58
- package/cjs/client.d.ts.map +0 -1
- package/cjs/eventbuilder.d.ts +0 -37
- package/cjs/eventbuilder.d.ts.map +0 -1
- package/cjs/exports.d.ts +0 -10
- package/cjs/exports.d.ts.map +0 -1
- package/cjs/flags.d.ts +0 -3
- package/cjs/flags.d.ts.map +0 -1
- package/cjs/helpers.d.ts +0 -52
- package/cjs/helpers.d.ts.map +0 -1
- package/cjs/index.d.ts +0 -16
- package/cjs/index.d.ts.map +0 -1
- package/cjs/integrations/breadcrumbs.d.ts +0 -47
- package/cjs/integrations/breadcrumbs.d.ts.map +0 -1
- package/cjs/integrations/dedupe.d.ts +0 -21
- package/cjs/integrations/dedupe.d.ts.map +0 -1
- package/cjs/integrations/globalhandlers.d.ts +0 -30
- package/cjs/integrations/globalhandlers.d.ts.map +0 -1
- package/cjs/integrations/index.d.ts +0 -7
- package/cjs/integrations/index.d.ts.map +0 -1
- package/cjs/integrations/linkederrors.d.ts +0 -42
- package/cjs/integrations/linkederrors.d.ts.map +0 -1
- package/cjs/integrations/trycatch.d.ts +0 -33
- package/cjs/integrations/trycatch.d.ts.map +0 -1
- package/cjs/integrations/useragent.d.ts +0 -17
- package/cjs/integrations/useragent.d.ts.map +0 -1
- package/cjs/integrations/useragent.js +0 -42
- package/cjs/integrations/useragent.js.map +0 -1
- package/cjs/sdk.d.ts +0 -112
- package/cjs/sdk.d.ts.map +0 -1
- package/cjs/stack-parsers.d.ts +0 -8
- package/cjs/stack-parsers.d.ts.map +0 -1
- package/cjs/transports/base.d.ts +0 -65
- package/cjs/transports/base.d.ts.map +0 -1
- package/cjs/transports/base.js +0 -141
- package/cjs/transports/base.js.map +0 -1
- package/cjs/transports/fetch.d.ts +0 -17
- package/cjs/transports/fetch.d.ts.map +0 -1
- package/cjs/transports/index.d.ts +0 -7
- package/cjs/transports/index.d.ts.map +0 -1
- package/cjs/transports/new-fetch.d.ts +0 -10
- package/cjs/transports/new-fetch.d.ts.map +0 -1
- package/cjs/transports/new-fetch.js +0 -27
- package/cjs/transports/new-fetch.js.map +0 -1
- package/cjs/transports/new-xhr.d.ts +0 -11
- package/cjs/transports/new-xhr.d.ts.map +0 -1
- package/cjs/transports/new-xhr.js +0 -46
- package/cjs/transports/new-xhr.js.map +0 -1
- package/cjs/transports/setup.d.ts +0 -22
- package/cjs/transports/setup.d.ts.map +0 -1
- package/cjs/transports/setup.js +0 -44
- package/cjs/transports/setup.js.map +0 -1
- package/cjs/transports/utils.d.ts +0 -48
- package/cjs/transports/utils.d.ts.map +0 -1
- package/cjs/transports/xhr.d.ts +0 -11
- package/cjs/transports/xhr.d.ts.map +0 -1
- package/cjs/version.d.ts +0 -2
- package/cjs/version.d.ts.map +0 -1
- package/cjs/version.js +0 -4
- package/cjs/version.js.map +0 -1
- package/esm/client.d.ts +0 -58
- package/esm/client.d.ts.map +0 -1
- package/esm/eventbuilder.d.ts +0 -37
- package/esm/eventbuilder.d.ts.map +0 -1
- package/esm/exports.d.ts +0 -10
- package/esm/exports.d.ts.map +0 -1
- package/esm/flags.d.ts +0 -3
- package/esm/flags.d.ts.map +0 -1
- package/esm/helpers.d.ts +0 -52
- package/esm/helpers.d.ts.map +0 -1
- package/esm/index.d.ts +0 -16
- package/esm/index.d.ts.map +0 -1
- package/esm/integrations/breadcrumbs.d.ts +0 -47
- package/esm/integrations/breadcrumbs.d.ts.map +0 -1
- package/esm/integrations/dedupe.d.ts +0 -21
- package/esm/integrations/dedupe.d.ts.map +0 -1
- package/esm/integrations/globalhandlers.d.ts +0 -30
- package/esm/integrations/globalhandlers.d.ts.map +0 -1
- package/esm/integrations/index.d.ts +0 -7
- package/esm/integrations/index.d.ts.map +0 -1
- package/esm/integrations/linkederrors.d.ts +0 -42
- package/esm/integrations/linkederrors.d.ts.map +0 -1
- package/esm/integrations/trycatch.d.ts +0 -33
- package/esm/integrations/trycatch.d.ts.map +0 -1
- package/esm/integrations/useragent.d.ts +0 -17
- package/esm/integrations/useragent.d.ts.map +0 -1
- package/esm/integrations/useragent.js +0 -41
- package/esm/integrations/useragent.js.map +0 -1
- package/esm/sdk.d.ts +0 -112
- package/esm/sdk.d.ts.map +0 -1
- package/esm/stack-parsers.d.ts +0 -8
- package/esm/stack-parsers.d.ts.map +0 -1
- package/esm/transports/base.d.ts +0 -65
- package/esm/transports/base.d.ts.map +0 -1
- package/esm/transports/base.js +0 -140
- package/esm/transports/base.js.map +0 -1
- package/esm/transports/fetch.d.ts +0 -17
- package/esm/transports/fetch.d.ts.map +0 -1
- package/esm/transports/index.d.ts +0 -7
- package/esm/transports/index.d.ts.map +0 -1
- package/esm/transports/new-fetch.d.ts +0 -10
- package/esm/transports/new-fetch.d.ts.map +0 -1
- package/esm/transports/new-fetch.js +0 -25
- package/esm/transports/new-fetch.js.map +0 -1
- package/esm/transports/new-xhr.d.ts +0 -11
- package/esm/transports/new-xhr.d.ts.map +0 -1
- package/esm/transports/new-xhr.js +0 -44
- package/esm/transports/new-xhr.js.map +0 -1
- package/esm/transports/setup.d.ts +0 -22
- package/esm/transports/setup.d.ts.map +0 -1
- package/esm/transports/setup.js +0 -42
- package/esm/transports/setup.js.map +0 -1
- package/esm/transports/utils.d.ts +0 -48
- package/esm/transports/utils.d.ts.map +0 -1
- package/esm/transports/xhr.d.ts +0 -11
- package/esm/transports/xhr.d.ts.map +0 -1
- package/esm/version.d.ts +0 -2
- package/esm/version.d.ts.map +0 -1
- package/esm/version.js +0 -3
- package/esm/version.js.map +0 -1
- package/types/integrations/useragent.d.ts.map +0 -1
- package/types/transports/base.d.ts +0 -65
- package/types/transports/base.d.ts.map +0 -1
- package/types/transports/new-fetch.d.ts +0 -10
- package/types/transports/new-fetch.d.ts.map +0 -1
- package/types/transports/new-xhr.d.ts +0 -11
- package/types/transports/new-xhr.d.ts.map +0 -1
- package/types/transports/setup.d.ts +0 -22
- package/types/transports/setup.d.ts.map +0 -1
- package/types/version.d.ts +0 -2
- package/types/version.d.ts.map +0 -1
|
@@ -1,62 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { getCurrentHub, addGlobalEventProcessor } from '@sentry/core';
|
|
2
|
+
import { isInstanceOf } from '@sentry/utils';
|
|
3
|
+
import { exceptionFromError } from '../eventbuilder.js';
|
|
4
|
+
|
|
5
5
|
var DEFAULT_KEY = 'cause';
|
|
6
6
|
var DEFAULT_LIMIT = 5;
|
|
7
|
+
|
|
7
8
|
/** Adds SDK info to an event. */
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
class LinkedErrors {
|
|
10
|
+
/**
|
|
11
|
+
* @inheritDoc
|
|
12
|
+
*/
|
|
13
|
+
static __initStatic() {this.id = 'LinkedErrors';}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
__init() {this.name = LinkedErrors.id;}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
constructor(options = {}) {;LinkedErrors.prototype.__init.call(this);
|
|
34
|
+
this._key = options.key || DEFAULT_KEY;
|
|
35
|
+
this._limit = options.limit || DEFAULT_LIMIT;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
*/
|
|
41
|
+
setupOnce() {
|
|
42
|
+
var client = getCurrentHub().getClient();
|
|
43
|
+
if (!client) {
|
|
44
|
+
return;
|
|
20
45
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
addGlobalEventProcessor(function (event, hint) {
|
|
29
|
-
var self = getCurrentHub().getIntegration(LinkedErrors);
|
|
30
|
-
return self ? _handler(parser, self._key, self._limit, event, hint) : event;
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* @inheritDoc
|
|
35
|
-
*/
|
|
36
|
-
LinkedErrors.id = 'LinkedErrors';
|
|
37
|
-
return LinkedErrors;
|
|
38
|
-
}());
|
|
39
|
-
export { LinkedErrors };
|
|
46
|
+
addGlobalEventProcessor((event, hint) => {
|
|
47
|
+
var self = getCurrentHub().getIntegration(LinkedErrors);
|
|
48
|
+
return self ? _handler(client.getOptions().stackParser, self._key, self._limit, event, hint) : event;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
} LinkedErrors.__initStatic();
|
|
52
|
+
|
|
40
53
|
/**
|
|
41
54
|
* @inheritDoc
|
|
42
55
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
function _handler(
|
|
57
|
+
parser,
|
|
58
|
+
key,
|
|
59
|
+
limit,
|
|
60
|
+
event,
|
|
61
|
+
hint,
|
|
62
|
+
) {
|
|
63
|
+
if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {
|
|
49
64
|
return event;
|
|
65
|
+
}
|
|
66
|
+
var linkedErrors = _walkErrorTree(parser, limit, hint.originalException , key);
|
|
67
|
+
event.exception.values = [...linkedErrors, ...event.exception.values];
|
|
68
|
+
return event;
|
|
50
69
|
}
|
|
70
|
+
|
|
51
71
|
/**
|
|
52
72
|
* JSDOC
|
|
53
73
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
function _walkErrorTree(
|
|
75
|
+
parser,
|
|
76
|
+
limit,
|
|
77
|
+
error,
|
|
78
|
+
key,
|
|
79
|
+
stack = [],
|
|
80
|
+
) {
|
|
81
|
+
if (!isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {
|
|
82
|
+
return stack;
|
|
83
|
+
}
|
|
84
|
+
var exception = exceptionFromError(parser, error[key]);
|
|
85
|
+
return _walkErrorTree(parser, limit, error[key], key, [exception, ...stack]);
|
|
61
86
|
}
|
|
62
|
-
|
|
87
|
+
|
|
88
|
+
export { LinkedErrors, _handler, _walkErrorTree };
|
|
89
|
+
//# sourceMappingURL=linkederrors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkederrors.js","
|
|
1
|
+
{"version":3,"file":"linkederrors.js","sources":["../../../../src/integrations/linkederrors.ts"],"sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';\nimport { Event, EventHint, Exception, ExtendedError, Integration, StackParser } from '@sentry/types';\nimport { isInstanceOf } from '@sentry/utils';\n\nimport { BrowserClient } from '../client';\nimport { exceptionFromError } from '../eventbuilder';\n\nconst DEFAULT_KEY = 'cause';\nconst DEFAULT_LIMIT = 5;\n\ninterface LinkedErrorsOptions {\n key: string;\n limit: number;\n}\n\n/** Adds SDK info to an event. */\nexport class LinkedErrors implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'LinkedErrors';\n\n /**\n * @inheritDoc\n */\n public readonly name: string = LinkedErrors.id;\n\n /**\n * @inheritDoc\n */\n private readonly _key: LinkedErrorsOptions['key'];\n\n /**\n * @inheritDoc\n */\n private readonly _limit: LinkedErrorsOptions['limit'];\n\n /**\n * @inheritDoc\n */\n public constructor(options: Partial<LinkedErrorsOptions> = {}) {\n this._key = options.key || DEFAULT_KEY;\n this._limit = options.limit || DEFAULT_LIMIT;\n }\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n const client = getCurrentHub().getClient<BrowserClient>();\n if (!client) {\n return;\n }\n addGlobalEventProcessor((event: Event, hint?: EventHint) => {\n const self = getCurrentHub().getIntegration(LinkedErrors);\n return self ? _handler(client.getOptions().stackParser, self._key, self._limit, event, hint) : event;\n });\n }\n}\n\n/**\n * @inheritDoc\n */\nexport function _handler(\n parser: StackParser,\n key: string,\n limit: number,\n event: Event,\n hint?: EventHint,\n): Event | null {\n if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {\n return event;\n }\n const linkedErrors = _walkErrorTree(parser, limit, hint.originalException as ExtendedError, key);\n event.exception.values = [...linkedErrors, ...event.exception.values];\n return event;\n}\n\n/**\n * JSDOC\n */\nexport function _walkErrorTree(\n parser: StackParser,\n limit: number,\n error: ExtendedError,\n key: string,\n stack: Exception[] = [],\n): Exception[] {\n if (!isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {\n return stack;\n }\n const exception = exceptionFromError(parser, error[key]);\n return _walkErrorTree(parser, limit, error[key], key, [exception, ...stack]);\n}\n"],"names":[],"mappings":";;;;AAOA;AACA;;AAOA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
|
|
@@ -1,236 +1,264 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { getGlobalObject, fill, getFunctionName, getOriginalFunction } from '@sentry/utils';
|
|
2
|
+
import { wrap } from '../helpers.js';
|
|
3
|
+
|
|
4
4
|
var DEFAULT_EVENT_TARGET = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
5
|
+
'EventTarget',
|
|
6
|
+
'Window',
|
|
7
|
+
'Node',
|
|
8
|
+
'ApplicationCache',
|
|
9
|
+
'AudioTrackList',
|
|
10
|
+
'ChannelMergerNode',
|
|
11
|
+
'CryptoOperation',
|
|
12
|
+
'EventSource',
|
|
13
|
+
'FileReader',
|
|
14
|
+
'HTMLUnknownElement',
|
|
15
|
+
'IDBDatabase',
|
|
16
|
+
'IDBRequest',
|
|
17
|
+
'IDBTransaction',
|
|
18
|
+
'KeyOperation',
|
|
19
|
+
'MediaController',
|
|
20
|
+
'MessagePort',
|
|
21
|
+
'ModalWindow',
|
|
22
|
+
'Notification',
|
|
23
|
+
'SVGElementInstance',
|
|
24
|
+
'Screen',
|
|
25
|
+
'TextTrack',
|
|
26
|
+
'TextTrackCue',
|
|
27
|
+
'TextTrackList',
|
|
28
|
+
'WebSocket',
|
|
29
|
+
'WebSocketWorker',
|
|
30
|
+
'Worker',
|
|
31
|
+
'XMLHttpRequest',
|
|
32
|
+
'XMLHttpRequestEventTarget',
|
|
33
|
+
'XMLHttpRequestUpload',
|
|
34
34
|
];
|
|
35
|
+
|
|
35
36
|
/** Wrap timer functions and event targets to catch errors and provide better meta data */
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {
|
|
63
|
-
fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
|
|
64
|
-
}
|
|
65
|
-
var eventTargetOption = this._options.eventTarget;
|
|
66
|
-
if (eventTargetOption) {
|
|
67
|
-
var eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;
|
|
68
|
-
eventTarget.forEach(_wrapEventTarget);
|
|
69
|
-
}
|
|
37
|
+
class TryCatch {
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
*/
|
|
41
|
+
static __initStatic() {this.id = 'TryCatch';}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @inheritDoc
|
|
45
|
+
*/
|
|
46
|
+
__init() {this.name = TryCatch.id;}
|
|
47
|
+
|
|
48
|
+
/** JSDoc */
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @inheritDoc
|
|
53
|
+
*/
|
|
54
|
+
constructor(options) {;TryCatch.prototype.__init.call(this);
|
|
55
|
+
this._options = {
|
|
56
|
+
XMLHttpRequest: true,
|
|
57
|
+
eventTarget: true,
|
|
58
|
+
requestAnimationFrame: true,
|
|
59
|
+
setInterval: true,
|
|
60
|
+
setTimeout: true,
|
|
61
|
+
...options,
|
|
70
62
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Wrap timer functions and event targets to catch errors
|
|
67
|
+
* and provide better metadata.
|
|
68
|
+
*/
|
|
69
|
+
setupOnce() {
|
|
70
|
+
var global = getGlobalObject();
|
|
71
|
+
|
|
72
|
+
if (this._options.setTimeout) {
|
|
73
|
+
fill(global, 'setTimeout', _wrapTimeFunction);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (this._options.setInterval) {
|
|
77
|
+
fill(global, 'setInterval', _wrapTimeFunction);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (this._options.requestAnimationFrame) {
|
|
81
|
+
fill(global, 'requestAnimationFrame', _wrapRAF);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {
|
|
85
|
+
fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var eventTargetOption = this._options.eventTarget;
|
|
89
|
+
if (eventTargetOption) {
|
|
90
|
+
var eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;
|
|
91
|
+
eventTarget.forEach(_wrapEventTarget);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
} TryCatch.__initStatic();
|
|
95
|
+
|
|
78
96
|
/** JSDoc */
|
|
79
97
|
function _wrapTimeFunction(original) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
type: 'instrument',
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
return original.apply(this, args);
|
|
95
|
-
};
|
|
98
|
+
return function ( ...args) {
|
|
99
|
+
var originalCallback = args[0];
|
|
100
|
+
args[0] = wrap(originalCallback, {
|
|
101
|
+
mechanism: {
|
|
102
|
+
data: { function: getFunctionName(original) },
|
|
103
|
+
handled: true,
|
|
104
|
+
type: 'instrument',
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
return original.apply(this, args);
|
|
108
|
+
};
|
|
96
109
|
}
|
|
110
|
+
|
|
97
111
|
/** JSDoc */
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
112
|
function _wrapRAF(original) {
|
|
100
|
-
|
|
101
|
-
return function (callback) {
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
113
|
+
return function ( callback) {
|
|
103
114
|
return original.apply(this, [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
wrap(callback, {
|
|
116
|
+
mechanism: {
|
|
117
|
+
data: {
|
|
118
|
+
function: 'requestAnimationFrame',
|
|
119
|
+
handler: getFunctionName(original),
|
|
120
|
+
},
|
|
121
|
+
handled: true,
|
|
122
|
+
type: 'instrument',
|
|
123
|
+
},
|
|
124
|
+
}),
|
|
125
|
+
]);
|
|
126
|
+
};
|
|
116
127
|
}
|
|
128
|
+
|
|
117
129
|
/** JSDoc */
|
|
118
130
|
function _wrapXHR(originalSend) {
|
|
119
|
-
|
|
120
|
-
return function () {
|
|
121
|
-
var args = [];
|
|
122
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
123
|
-
args[_i] = arguments[_i];
|
|
124
|
-
}
|
|
125
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
131
|
+
return function ( ...args) {
|
|
126
132
|
var xhr = this;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
var xmlHttpRequestProps = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];
|
|
134
|
+
|
|
135
|
+
xmlHttpRequestProps.forEach(prop => {
|
|
136
|
+
if (prop in xhr && typeof xhr[prop] === 'function') {
|
|
131
137
|
fill(xhr, prop, function (original) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
138
|
+
var wrapOptions = {
|
|
139
|
+
mechanism: {
|
|
140
|
+
data: {
|
|
141
|
+
function: prop,
|
|
142
|
+
handler: getFunctionName(original),
|
|
143
|
+
},
|
|
144
|
+
handled: true,
|
|
145
|
+
type: 'instrument',
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// If Instrument integration has been called before TryCatch, get the name of original function
|
|
150
|
+
var originalFunction = getOriginalFunction(original);
|
|
151
|
+
if (originalFunction) {
|
|
152
|
+
wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Otherwise wrap directly
|
|
156
|
+
return wrap(original, wrapOptions);
|
|
151
157
|
});
|
|
152
|
-
|
|
153
|
-
};
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return originalSend.apply(this, args);
|
|
162
|
+
};
|
|
154
163
|
}
|
|
164
|
+
|
|
155
165
|
/** JSDoc */
|
|
156
166
|
function _wrapEventTarget(target) {
|
|
157
|
-
|
|
158
|
-
var global = getGlobalObject();
|
|
159
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
167
|
+
var global = getGlobalObject() ;
|
|
160
168
|
var proto = global[target] && global[target].prototype;
|
|
161
|
-
|
|
169
|
+
|
|
162
170
|
if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
fill(proto, 'addEventListener', function (original)
|
|
175
|
+
|
|
176
|
+
{
|
|
177
|
+
return function (
|
|
178
|
+
|
|
179
|
+
eventName,
|
|
180
|
+
fn,
|
|
181
|
+
options,
|
|
182
|
+
) {
|
|
183
|
+
try {
|
|
184
|
+
if (typeof fn.handleEvent === 'function') {
|
|
185
|
+
fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
|
|
186
|
+
mechanism: {
|
|
187
|
+
data: {
|
|
188
|
+
function: 'handleEvent',
|
|
189
|
+
handler: getFunctionName(fn),
|
|
190
|
+
target,
|
|
191
|
+
},
|
|
192
|
+
handled: true,
|
|
193
|
+
type: 'instrument',
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
} catch (err) {
|
|
198
|
+
// can sometimes get 'Permission denied to access property "handle Event'
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return original.apply(this, [
|
|
202
|
+
eventName,
|
|
203
|
+
wrap(fn , {
|
|
204
|
+
mechanism: {
|
|
205
|
+
data: {
|
|
206
|
+
function: 'addEventListener',
|
|
207
|
+
handler: getFunctionName(fn),
|
|
208
|
+
target,
|
|
209
|
+
},
|
|
210
|
+
handled: true,
|
|
211
|
+
type: 'instrument',
|
|
212
|
+
},
|
|
213
|
+
}),
|
|
214
|
+
options,
|
|
215
|
+
]);
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
fill(
|
|
220
|
+
proto,
|
|
221
|
+
'removeEventListener',
|
|
222
|
+
function (
|
|
223
|
+
originalRemoveEventListener,
|
|
224
|
+
) {
|
|
225
|
+
return function (
|
|
226
|
+
|
|
227
|
+
eventName,
|
|
228
|
+
fn,
|
|
229
|
+
options,
|
|
230
|
+
) {
|
|
231
|
+
/**
|
|
232
|
+
* There are 2 possible scenarios here:
|
|
233
|
+
*
|
|
234
|
+
* 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified
|
|
235
|
+
* method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function
|
|
236
|
+
* as a pass-through, and call original `removeEventListener` with it.
|
|
237
|
+
*
|
|
238
|
+
* 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using
|
|
239
|
+
* our wrapped version of `addEventListener`, which internally calls `wrap` helper.
|
|
240
|
+
* This helper "wraps" whole callback inside a try/catch statement, and attached appropriate metadata to it,
|
|
241
|
+
* in order for us to make a distinction between wrapped/non-wrapped functions possible.
|
|
242
|
+
* If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.
|
|
243
|
+
*
|
|
244
|
+
* When someone adds a handler prior to initialization, and then do it again, but after,
|
|
245
|
+
* then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible
|
|
246
|
+
* to get rid of the initial handler and it'd stick there forever.
|
|
247
|
+
*/
|
|
248
|
+
var wrappedEventHandler = fn ;
|
|
249
|
+
try {
|
|
250
|
+
var originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;
|
|
251
|
+
if (originalEventHandler) {
|
|
252
|
+
originalRemoveEventListener.call(this, eventName, originalEventHandler, options);
|
|
253
|
+
}
|
|
254
|
+
} catch (e) {
|
|
255
|
+
// ignore, accessing __sentry_wrapped__ will throw in some Selenium environments
|
|
256
|
+
}
|
|
257
|
+
return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
);
|
|
235
261
|
}
|
|
236
|
-
|
|
262
|
+
|
|
263
|
+
export { TryCatch };
|
|
264
|
+
//# sourceMappingURL=trycatch.js.map
|