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