@sentry/browser 7.0.0-beta.0 → 7.0.0-beta.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/README.md +2 -3
- package/cjs/client.js +125 -102
- package/cjs/client.js.map +1 -1
- package/cjs/eventbuilder.js +225 -165
- package/cjs/eventbuilder.js.map +1 -1
- package/cjs/exports.js +55 -59
- package/cjs/exports.js.map +1 -1
- package/cjs/flags.js +7 -3
- package/cjs/flags.js.map +1 -1
- package/cjs/helpers.js +123 -96
- package/cjs/helpers.js.map +1 -1
- package/cjs/index.js +77 -10
- package/cjs/index.js.map +1 -1
- package/cjs/integrations/breadcrumbs.js +222 -174
- package/cjs/integrations/breadcrumbs.js.map +1 -1
- package/cjs/integrations/dedupe.js +184 -142
- package/cjs/integrations/dedupe.js.map +1 -1
- package/cjs/integrations/globalhandlers.js +211 -170
- 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 +81 -50
- package/cjs/integrations/linkederrors.js.map +1 -1
- package/cjs/integrations/trycatch.js +247 -208
- package/cjs/integrations/trycatch.js.map +1 -1
- package/cjs/sdk.js +166 -125
- package/cjs/sdk.js.map +1 -1
- package/cjs/stack-parsers.js +143 -93
- package/cjs/stack-parsers.js.map +1 -1
- package/cjs/transports/fetch.js +30 -15
- package/cjs/transports/fetch.js.map +1 -1
- package/cjs/transports/index.js +10 -6
- package/cjs/transports/index.js.map +1 -1
- package/cjs/transports/utils.js +56 -51
- package/cjs/transports/utils.js.map +1 -1
- package/cjs/transports/xhr.js +40 -30
- package/cjs/transports/xhr.js.map +1 -1
- package/esm/client.js +124 -101
- package/esm/client.js.map +1 -1
- package/esm/eventbuilder.js +218 -158
- package/esm/eventbuilder.js.map +1 -1
- package/esm/exports.js +12 -8
- package/esm/exports.js.map +1 -1
- package/esm/flags.js +5 -2
- package/esm/flags.js.map +1 -1
- package/esm/helpers.js +122 -95
- package/esm/helpers.js.map +1 -1
- package/esm/index.js +27 -7
- package/esm/index.js.map +1 -1
- package/esm/integrations/breadcrumbs.js +218 -171
- package/esm/integrations/breadcrumbs.js.map +1 -1
- package/esm/integrations/dedupe.js +181 -139
- package/esm/integrations/dedupe.js.map +1 -1
- package/esm/integrations/globalhandlers.js +208 -167
- 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 +77 -46
- package/esm/integrations/linkederrors.js.map +1 -1
- package/esm/integrations/trycatch.js +244 -205
- package/esm/integrations/trycatch.js.map +1 -1
- package/esm/sdk.js +163 -123
- package/esm/sdk.js.map +1 -1
- package/esm/stack-parsers.js +134 -91
- package/esm/stack-parsers.js.map +1 -1
- package/esm/transports/fetch.js +28 -13
- package/esm/transports/fetch.js.map +1 -1
- package/esm/transports/index.js +3 -3
- package/esm/transports/index.js.map +1 -1
- package/esm/transports/utils.js +55 -50
- package/esm/transports/utils.js.map +1 -1
- package/esm/transports/xhr.js +38 -28
- package/esm/transports/xhr.js.map +1 -1
- package/package.json +4 -4
- package/types/client.d.ts +3 -2
- package/types/client.d.ts.map +1 -1
- package/types/exports.d.ts +3 -4
- package/types/exports.d.ts.map +1 -1
- package/types/index.d.ts +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/sdk.d.ts +2 -2
- package/types/sdk.d.ts.map +1 -1
- package/types/transports/fetch.d.ts +3 -5
- package/types/transports/fetch.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/xhr.d.ts +3 -7
- package/types/transports/xhr.d.ts.map +1 -1
- package/cjs/client.d.ts +0 -63
- 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 -11
- 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 -47
- package/cjs/helpers.d.ts.map +0 -1
- package/cjs/index.d.ts +0 -15
- package/cjs/index.d.ts.map +0 -1
- package/cjs/integrations/breadcrumbs.d.ts +0 -46
- 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 -40
- 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 -9
- package/cjs/stack-parsers.d.ts.map +0 -1
- package/cjs/transports/fetch.d.ts +0 -10
- package/cjs/transports/fetch.d.ts.map +0 -1
- package/cjs/transports/index.d.ts +0 -3
- package/cjs/transports/index.d.ts.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 -63
- 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 -11
- 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 -47
- package/esm/helpers.d.ts.map +0 -1
- package/esm/index.d.ts +0 -15
- package/esm/index.d.ts.map +0 -1
- package/esm/integrations/breadcrumbs.d.ts +0 -46
- 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 -38
- 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 -9
- package/esm/stack-parsers.d.ts.map +0 -1
- package/esm/transports/fetch.d.ts +0 -10
- package/esm/transports/fetch.d.ts.map +0 -1
- package/esm/transports/index.d.ts +0 -3
- package/esm/transports/index.d.ts.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/version.d.ts +0 -2
- package/types/version.d.ts.map +0 -1
|
@@ -1,58 +1,89 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCurrentHub, addGlobalEventProcessor } from '@sentry/core';
|
|
2
2
|
import { isInstanceOf } from '@sentry/utils';
|
|
3
|
-
import { exceptionFromError } from '../eventbuilder';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { exceptionFromError } from '../eventbuilder.js';
|
|
4
|
+
|
|
5
|
+
var DEFAULT_KEY = 'cause';
|
|
6
|
+
var DEFAULT_LIMIT = 5;
|
|
7
|
+
|
|
6
8
|
/** Adds SDK info to an event. */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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;
|
|
18
45
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
addGlobalEventProcessor((event, hint) => {
|
|
28
|
-
const self = getCurrentHub().getIntegration(LinkedErrors);
|
|
29
|
-
return self ? _handler(client.getOptions().stackParser, self._key, self._limit, event, hint) : event;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
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
|
+
|
|
33
53
|
/**
|
|
34
54
|
* @inheritDoc
|
|
35
55
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const linkedErrors = _walkErrorTree(parser, limit, hint.originalException, key);
|
|
45
|
-
event.exception.values = [...linkedErrors, ...event.exception.values];
|
|
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)) {
|
|
46
64
|
return event;
|
|
65
|
+
}
|
|
66
|
+
var linkedErrors = _walkErrorTree(parser, limit, hint.originalException , key);
|
|
67
|
+
event.exception.values = [...linkedErrors, ...event.exception.values];
|
|
68
|
+
return event;
|
|
47
69
|
}
|
|
70
|
+
|
|
48
71
|
/**
|
|
49
72
|
* JSDOC
|
|
50
73
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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]);
|
|
57
86
|
}
|
|
58
|
-
|
|
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,225 +1,264 @@
|
|
|
1
|
-
import { fill, getFunctionName,
|
|
2
|
-
import { wrap } from '../helpers';
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
1
|
+
import { getGlobalObject, fill, getFunctionName, getOriginalFunction } from '@sentry/utils';
|
|
2
|
+
import { wrap } from '../helpers.js';
|
|
3
|
+
|
|
4
|
+
var DEFAULT_EVENT_TARGET = [
|
|
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',
|
|
33
34
|
];
|
|
35
|
+
|
|
34
36
|
/** Wrap timer functions and event targets to catch errors and provide better meta data */
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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,
|
|
62
|
+
};
|
|
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);
|
|
45
74
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
setupOnce() {
|
|
51
|
-
const global = getGlobalObject();
|
|
52
|
-
if (this._options.setTimeout) {
|
|
53
|
-
fill(global, 'setTimeout', _wrapTimeFunction);
|
|
54
|
-
}
|
|
55
|
-
if (this._options.setInterval) {
|
|
56
|
-
fill(global, 'setInterval', _wrapTimeFunction);
|
|
57
|
-
}
|
|
58
|
-
if (this._options.requestAnimationFrame) {
|
|
59
|
-
fill(global, 'requestAnimationFrame', _wrapRAF);
|
|
60
|
-
}
|
|
61
|
-
if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {
|
|
62
|
-
fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
|
|
63
|
-
}
|
|
64
|
-
const eventTargetOption = this._options.eventTarget;
|
|
65
|
-
if (eventTargetOption) {
|
|
66
|
-
const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;
|
|
67
|
-
eventTarget.forEach(_wrapEventTarget);
|
|
68
|
-
}
|
|
75
|
+
|
|
76
|
+
if (this._options.setInterval) {
|
|
77
|
+
fill(global, 'setInterval', _wrapTimeFunction);
|
|
69
78
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
|
|
75
96
|
/** JSDoc */
|
|
76
97
|
function _wrapTimeFunction(original) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
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
|
+
};
|
|
89
109
|
}
|
|
110
|
+
|
|
90
111
|
/** JSDoc */
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
112
|
function _wrapRAF(original) {
|
|
93
|
-
|
|
94
|
-
return function (callback) {
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
113
|
+
return function ( callback) {
|
|
96
114
|
return original.apply(this, [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
+
};
|
|
109
127
|
}
|
|
128
|
+
|
|
110
129
|
/** JSDoc */
|
|
111
130
|
function _wrapXHR(originalSend) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (prop in xhr && typeof xhr[prop] === 'function') {
|
|
119
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
+
return function ( ...args) {
|
|
132
|
+
var xhr = this;
|
|
133
|
+
var xmlHttpRequestProps = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];
|
|
134
|
+
|
|
135
|
+
xmlHttpRequestProps.forEach(prop => {
|
|
136
|
+
if (prop in xhr && typeof xhr[prop] === 'function') {
|
|
120
137
|
fill(xhr, prop, function (original) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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);
|
|
140
157
|
});
|
|
141
|
-
|
|
142
|
-
};
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return originalSend.apply(this, args);
|
|
162
|
+
};
|
|
143
163
|
}
|
|
164
|
+
|
|
144
165
|
/** JSDoc */
|
|
145
166
|
function _wrapEventTarget(target) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const proto = global[target] && global[target].prototype;
|
|
150
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
|
|
167
|
+
var global = getGlobalObject() ;
|
|
168
|
+
var proto = global[target] && global[target].prototype;
|
|
169
|
+
|
|
151
170
|
if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
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
|
+
);
|
|
224
261
|
}
|
|
225
|
-
|
|
262
|
+
|
|
263
|
+
export { TryCatch };
|
|
264
|
+
//# sourceMappingURL=trycatch.js.map
|