@sentry/browser 7.0.0-alpha.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 +130 -68
- package/cjs/client.js.map +1 -1
- package/cjs/eventbuilder.js +227 -168
- package/cjs/eventbuilder.js.map +1 -1
- package/cjs/exports.js +55 -42
- 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 -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 -193
- package/cjs/integrations/breadcrumbs.js.map +1 -1
- package/cjs/integrations/dedupe.js +183 -143
- package/cjs/integrations/dedupe.js.map +1 -1
- package/cjs/integrations/globalhandlers.js +212 -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 -48
- 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 -108
- package/cjs/sdk.js.map +1 -1
- package/cjs/stack-parsers.js +134 -83
- 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 -12
- package/cjs/transports/index.js.map +1 -1
- package/cjs/transports/utils.js +57 -52
- 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 -67
- package/esm/client.js.map +1 -1
- package/esm/eventbuilder.js +218 -159
- 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 +121 -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 -191
- package/esm/integrations/breadcrumbs.js.map +1 -1
- package/esm/integrations/dedupe.js +180 -141
- package/esm/integrations/dedupe.js.map +1 -1
- package/esm/integrations/globalhandlers.js +209 -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 +75 -45
- 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 -105
- package/esm/sdk.js.map +1 -1
- package/esm/stack-parsers.js +126 -82
- 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 -6
- package/esm/transports/index.js.map +1 -1
- package/esm/transports/utils.js +56 -51
- 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 -5
- package/types/client.d.ts +42 -11
- package/types/client.d.ts.map +1 -1
- package/types/eventbuilder.d.ts +10 -12
- package/types/eventbuilder.d.ts.map +1 -1
- package/types/exports.d.ts +7 -6
- 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/dedupe.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 +3 -3
- package/types/integrations/linkederrors.d.ts.map +1 -1
- package/types/sdk.d.ts +5 -5
- package/types/sdk.d.ts.map +1 -1
- package/types/stack-parsers.d.ts +8 -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 -5
- 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.map +1 -1
- package/types/transports/xhr.d.ts +6 -10
- package/types/transports/xhr.d.ts.map +1 -1
- package/cjs/backend.d.ts +0 -39
- package/cjs/backend.d.ts.map +0 -1
- package/cjs/backend.js +0 -58
- package/cjs/backend.js.map +0 -1
- package/cjs/client.d.ts +0 -33
- package/cjs/client.d.ts.map +0 -1
- package/cjs/eventbuilder.d.ts +0 -39
- package/cjs/eventbuilder.d.ts.map +0 -1
- package/cjs/exports.d.ts +0 -9
- 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 -7
- 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 -6
- 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/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/backend.d.ts +0 -39
- package/esm/backend.d.ts.map +0 -1
- package/esm/backend.js +0 -57
- package/esm/backend.js.map +0 -1
- package/esm/client.d.ts +0 -33
- package/esm/client.d.ts.map +0 -1
- package/esm/eventbuilder.d.ts +0 -39
- package/esm/eventbuilder.d.ts.map +0 -1
- package/esm/exports.d.ts +0 -9
- 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 -7
- 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 -6
- 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/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/backend.d.ts +0 -39
- package/types/backend.d.ts.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/version.d.ts +0 -2
- package/types/version.d.ts.map +0 -1
package/esm/eventbuilder.js
CHANGED
|
@@ -1,210 +1,269 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { addExceptionMechanism, addExceptionTypeValue, createStackParser, extractExceptionKeysForMessage, isDOMError, isDOMException, isError, isErrorEvent, isEvent, isPlainObject, normalizeToSize, resolvedSyncPromise, } from '@sentry/utils';
|
|
4
|
-
import { chromeStackParser, geckoStackParser, opera10StackParser, opera11StackParser, winjsStackParser, } from './stack-parsers';
|
|
1
|
+
import { isEvent, extractExceptionKeysForMessage, normalizeToSize, addExceptionMechanism, resolvedSyncPromise, isErrorEvent, isDOMError, isDOMException, addExceptionTypeValue, isError, isPlainObject } from '@sentry/utils';
|
|
2
|
+
|
|
5
3
|
/**
|
|
6
|
-
* This function creates an exception from
|
|
7
|
-
* @param stacktrace TraceKitStackTrace that will be converted to an exception
|
|
8
|
-
* @hidden
|
|
4
|
+
* This function creates an exception from a JavaScript Error
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
function exceptionFromError(stackParser, ex) {
|
|
7
|
+
// Get the frames first since Opera can lose the stack if we touch anything else first
|
|
8
|
+
var frames = parseStackFrames(stackParser, ex);
|
|
9
|
+
|
|
10
|
+
var exception = {
|
|
11
|
+
type: ex && ex.name,
|
|
12
|
+
value: extractMessage(ex),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
if (frames.length) {
|
|
16
|
+
exception.stacktrace = { frames };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (exception.type === undefined && exception.value === '') {
|
|
20
|
+
exception.value = 'Unrecoverable error caught';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return exception;
|
|
24
24
|
}
|
|
25
|
+
|
|
25
26
|
/**
|
|
26
27
|
* @hidden
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
function eventFromPlainObject(
|
|
30
|
+
stackParser,
|
|
31
|
+
exception,
|
|
32
|
+
syntheticException,
|
|
33
|
+
isUnhandledRejection,
|
|
34
|
+
) {
|
|
35
|
+
var event = {
|
|
36
|
+
exception: {
|
|
37
|
+
values: [
|
|
38
|
+
{
|
|
39
|
+
type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error',
|
|
40
|
+
value: `Non-Error ${
|
|
41
|
+
isUnhandledRejection ? 'promise rejection' : 'exception'
|
|
42
|
+
} captured with keys: ${extractExceptionKeysForMessage(exception)}`,
|
|
40
43
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
extra: {
|
|
47
|
+
__serialized__: normalizeToSize(exception),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (syntheticException) {
|
|
52
|
+
var frames = parseStackFrames(stackParser, syntheticException);
|
|
53
|
+
if (frames.length) {
|
|
54
|
+
// event.exception.values[0] has been set above
|
|
55
|
+
(event.exception ).values[0].stacktrace = { frames };
|
|
47
56
|
}
|
|
48
|
-
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return event;
|
|
49
60
|
}
|
|
61
|
+
|
|
50
62
|
/**
|
|
51
63
|
* @hidden
|
|
52
64
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
function eventFromError(stackParser, ex) {
|
|
66
|
+
return {
|
|
67
|
+
exception: {
|
|
68
|
+
values: [exceptionFromError(stackParser, ex)],
|
|
69
|
+
},
|
|
70
|
+
};
|
|
59
71
|
}
|
|
72
|
+
|
|
60
73
|
/** Parses stack frames from an error */
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
+
function parseStackFrames(
|
|
75
|
+
stackParser,
|
|
76
|
+
ex,
|
|
77
|
+
) {
|
|
78
|
+
// Access and store the stacktrace property before doing ANYTHING
|
|
79
|
+
// else to it because Opera is not very good at providing it
|
|
80
|
+
// reliably in other circumstances.
|
|
81
|
+
var stacktrace = ex.stacktrace || ex.stack || '';
|
|
82
|
+
|
|
83
|
+
var popSize = getPopSize(ex);
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
return stackParser(stacktrace, popSize);
|
|
87
|
+
} catch (e) {
|
|
88
|
+
// no-empty
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return [];
|
|
74
92
|
}
|
|
93
|
+
|
|
75
94
|
// Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
|
|
76
95
|
var reactMinifiedRegexp = /Minified React error #\d+;/i;
|
|
96
|
+
|
|
77
97
|
function getPopSize(ex) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
if (reactMinifiedRegexp.test(ex.message)) {
|
|
83
|
-
return 1;
|
|
84
|
-
}
|
|
98
|
+
if (ex) {
|
|
99
|
+
if (typeof ex.framesToPop === 'number') {
|
|
100
|
+
return ex.framesToPop;
|
|
85
101
|
}
|
|
86
|
-
|
|
102
|
+
|
|
103
|
+
if (reactMinifiedRegexp.test(ex.message)) {
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return 0;
|
|
87
109
|
}
|
|
110
|
+
|
|
88
111
|
/**
|
|
89
112
|
* There are cases where stacktrace.message is an Event object
|
|
90
113
|
* https://github.com/getsentry/sentry-javascript/issues/1949
|
|
91
114
|
* In this specific case we try to extract stacktrace.message.error.message
|
|
92
115
|
*/
|
|
93
116
|
function extractMessage(ex) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
117
|
+
var message = ex && ex.message;
|
|
118
|
+
if (!message) {
|
|
119
|
+
return 'No error message';
|
|
120
|
+
}
|
|
121
|
+
if (message.error && typeof message.error.message === 'string') {
|
|
122
|
+
return message.error.message;
|
|
123
|
+
}
|
|
124
|
+
return message;
|
|
102
125
|
}
|
|
126
|
+
|
|
103
127
|
/**
|
|
104
128
|
* Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.
|
|
105
129
|
* @hidden
|
|
106
130
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
131
|
+
function eventFromException(
|
|
132
|
+
stackParser,
|
|
133
|
+
exception,
|
|
134
|
+
hint,
|
|
135
|
+
attachStacktrace,
|
|
136
|
+
) {
|
|
137
|
+
var syntheticException = (hint && hint.syntheticException) || undefined;
|
|
138
|
+
var event = eventFromUnknownInput(stackParser, exception, syntheticException, attachStacktrace);
|
|
139
|
+
addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
|
|
140
|
+
event.level = 'error';
|
|
141
|
+
if (hint && hint.event_id) {
|
|
142
|
+
event.event_id = hint.event_id;
|
|
143
|
+
}
|
|
144
|
+
return resolvedSyncPromise(event);
|
|
116
145
|
}
|
|
146
|
+
|
|
117
147
|
/**
|
|
118
148
|
* Builds and Event from a Message
|
|
119
149
|
* @hidden
|
|
120
150
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
151
|
+
function eventFromMessage(
|
|
152
|
+
stackParser,
|
|
153
|
+
message,
|
|
154
|
+
level = 'info',
|
|
155
|
+
hint,
|
|
156
|
+
attachStacktrace,
|
|
157
|
+
) {
|
|
158
|
+
var syntheticException = (hint && hint.syntheticException) || undefined;
|
|
159
|
+
var event = eventFromString(stackParser, message, syntheticException, attachStacktrace);
|
|
160
|
+
event.level = level;
|
|
161
|
+
if (hint && hint.event_id) {
|
|
162
|
+
event.event_id = hint.event_id;
|
|
163
|
+
}
|
|
164
|
+
return resolvedSyncPromise(event);
|
|
130
165
|
}
|
|
166
|
+
|
|
131
167
|
/**
|
|
132
168
|
* @hidden
|
|
133
169
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
170
|
+
function eventFromUnknownInput(
|
|
171
|
+
stackParser,
|
|
172
|
+
exception,
|
|
173
|
+
syntheticException,
|
|
174
|
+
attachStacktrace,
|
|
175
|
+
isUnhandledRejection,
|
|
176
|
+
) {
|
|
177
|
+
let event;
|
|
178
|
+
|
|
179
|
+
if (isErrorEvent(exception ) && (exception ).error) {
|
|
180
|
+
// If it is an ErrorEvent with `error` property, extract it to get actual Error
|
|
181
|
+
var errorEvent = exception ;
|
|
182
|
+
return eventFromError(stackParser, errorEvent.error );
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name
|
|
186
|
+
// and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be
|
|
187
|
+
// `Error`s, but that's not the case in IE11, so in that case we treat it the same as we do a `DOMError`.
|
|
188
|
+
//
|
|
189
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/DOMError
|
|
190
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException
|
|
191
|
+
// https://webidl.spec.whatwg.org/#es-DOMException-specialness
|
|
192
|
+
if (isDOMError(exception ) || isDOMException(exception )) {
|
|
193
|
+
var domException = exception ;
|
|
194
|
+
|
|
195
|
+
if ('stack' in (exception )) {
|
|
196
|
+
event = eventFromError(stackParser, exception );
|
|
197
|
+
} else {
|
|
198
|
+
var name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');
|
|
199
|
+
var message = domException.message ? `${name}: ${domException.message}` : name;
|
|
200
|
+
event = eventFromString(stackParser, message, syntheticException, attachStacktrace);
|
|
201
|
+
addExceptionTypeValue(event, message);
|
|
140
202
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// `Error`s, but that's not the case in IE11, so in that case we treat it the same as we do a `DOMError`.
|
|
144
|
-
//
|
|
145
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/DOMError
|
|
146
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException
|
|
147
|
-
// https://webidl.spec.whatwg.org/#es-DOMException-specialness
|
|
148
|
-
if (isDOMError(exception) || isDOMException(exception)) {
|
|
149
|
-
var domException = exception;
|
|
150
|
-
if ('stack' in exception) {
|
|
151
|
-
event = eventFromError(exception);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
var name_1 = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');
|
|
155
|
-
var message = domException.message ? name_1 + ": " + domException.message : name_1;
|
|
156
|
-
event = eventFromString(message, syntheticException, attachStacktrace);
|
|
157
|
-
addExceptionTypeValue(event, message);
|
|
158
|
-
}
|
|
159
|
-
if ('code' in domException) {
|
|
160
|
-
event.tags = __assign(__assign({}, event.tags), { 'DOMException.code': "" + domException.code });
|
|
161
|
-
}
|
|
162
|
-
return event;
|
|
203
|
+
if ('code' in domException) {
|
|
204
|
+
event.tags = { ...event.tags, 'DOMException.code': `${domException.code}` };
|
|
163
205
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return event;
|
|
178
|
-
}
|
|
179
|
-
// If none of previous checks were valid, then it means that it's not:
|
|
180
|
-
// - an instance of DOMError
|
|
181
|
-
// - an instance of DOMException
|
|
182
|
-
// - an instance of Event
|
|
183
|
-
// - an instance of Error
|
|
184
|
-
// - a valid ErrorEvent (one with an error property)
|
|
185
|
-
// - a plain Object
|
|
186
|
-
//
|
|
187
|
-
// So bail out and capture it as a simple message:
|
|
188
|
-
event = eventFromString(exception, syntheticException, attachStacktrace);
|
|
189
|
-
addExceptionTypeValue(event, "" + exception, undefined);
|
|
206
|
+
|
|
207
|
+
return event;
|
|
208
|
+
}
|
|
209
|
+
if (isError(exception)) {
|
|
210
|
+
// we have a real Error object, do nothing
|
|
211
|
+
return eventFromError(stackParser, exception);
|
|
212
|
+
}
|
|
213
|
+
if (isPlainObject(exception) || isEvent(exception)) {
|
|
214
|
+
// If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize
|
|
215
|
+
// it manually. This will allow us to group events based on top-level keys which is much better than creating a new
|
|
216
|
+
// group on any key/value change.
|
|
217
|
+
var objectException = exception ;
|
|
218
|
+
event = eventFromPlainObject(stackParser, objectException, syntheticException, isUnhandledRejection);
|
|
190
219
|
addExceptionMechanism(event, {
|
|
191
|
-
|
|
220
|
+
synthetic: true,
|
|
192
221
|
});
|
|
193
222
|
return event;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// If none of previous checks were valid, then it means that it's not:
|
|
226
|
+
// - an instance of DOMError
|
|
227
|
+
// - an instance of DOMException
|
|
228
|
+
// - an instance of Event
|
|
229
|
+
// - an instance of Error
|
|
230
|
+
// - a valid ErrorEvent (one with an error property)
|
|
231
|
+
// - a plain Object
|
|
232
|
+
//
|
|
233
|
+
// So bail out and capture it as a simple message:
|
|
234
|
+
event = eventFromString(stackParser, exception , syntheticException, attachStacktrace);
|
|
235
|
+
addExceptionTypeValue(event, `${exception}`, undefined);
|
|
236
|
+
addExceptionMechanism(event, {
|
|
237
|
+
synthetic: true,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
return event;
|
|
194
241
|
}
|
|
242
|
+
|
|
195
243
|
/**
|
|
196
244
|
* @hidden
|
|
197
245
|
*/
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
246
|
+
function eventFromString(
|
|
247
|
+
stackParser,
|
|
248
|
+
input,
|
|
249
|
+
syntheticException,
|
|
250
|
+
attachStacktrace,
|
|
251
|
+
) {
|
|
252
|
+
var event = {
|
|
253
|
+
message: input,
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
if (attachStacktrace && syntheticException) {
|
|
257
|
+
var frames = parseStackFrames(stackParser, syntheticException);
|
|
258
|
+
if (frames.length) {
|
|
259
|
+
event.exception = {
|
|
260
|
+
values: [{ value: input, stacktrace: { frames } }],
|
|
261
|
+
};
|
|
207
262
|
}
|
|
208
|
-
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return event;
|
|
209
266
|
}
|
|
210
|
-
|
|
267
|
+
|
|
268
|
+
export { eventFromError, eventFromException, eventFromMessage, eventFromPlainObject, eventFromString, eventFromUnknownInput, exceptionFromError, parseStackFrames };
|
|
269
|
+
//# sourceMappingURL=eventbuilder.js.map
|
package/esm/eventbuilder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventbuilder.js","sourceRoot":"","sources":["../../../src/eventbuilder.ts"],"names":[],"mappings":";AAAA,OAAO,EAA+B,QAAQ,EAAc,MAAM,eAAe,CAAC;AAClF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,8BAA8B,EAC9B,UAAU,EACV,cAAc,EACd,OAAO,EACP,YAAY,EACZ,OAAO,EACP,aAAa,EACb,eAAe,EACf,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAS;IAC1C,sFAAsF;IACtF,IAAM,MAAM,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAEpC,IAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,IAAI;QACnB,KAAK,EAAE,cAAc,CAAC,EAAE,CAAC;KAC1B,CAAC;IAEF,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,SAAS,CAAC,UAAU,GAAG,EAAE,MAAM,QAAA,EAAE,CAAC;KACnC;IAED,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,KAAK,EAAE,EAAE;QAC1D,SAAS,CAAC,KAAK,GAAG,4BAA4B,CAAC;KAChD;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAAkC,EAClC,kBAA0B,EAC1B,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AG,SAAW,EAAE,SAAS,CAAC,CAAC;IACxD,qBAAqB,CAAC,KAAK,EAAE;QAC3B,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,kBAA0B,EAAE,gBAA0B;IACnG,IAAM,KAAK,GAAU;QACnB,OAAO,EAAE,KAAK;KACf,CAAC;IAEF,IAAI,gBAAgB,IAAI,kBAAkB,EAAE;QAC1C,IAAM,QAAM,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;QACpD,IAAI,QAAM,CAAC,MAAM,EAAE;YACjB,KAAK,CAAC,UAAU,GAAG,EAAE,MAAM,UAAA,EAAE,CAAC;SAC/B;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { Event, EventHint, Exception, Severity, StackFrame } from '@sentry/types';\nimport {\n addExceptionMechanism,\n addExceptionTypeValue,\n createStackParser,\n extractExceptionKeysForMessage,\n isDOMError,\n isDOMException,\n isError,\n isErrorEvent,\n isEvent,\n isPlainObject,\n normalizeToSize,\n resolvedSyncPromise,\n} from '@sentry/utils';\n\nimport {\n chromeStackParser,\n geckoStackParser,\n opera10StackParser,\n opera11StackParser,\n winjsStackParser,\n} from './stack-parsers';\n\n/**\n * This function creates an exception from an TraceKitStackTrace\n * @param stacktrace TraceKitStackTrace that will be converted to an exception\n * @hidden\n */\nexport function exceptionFromError(ex: Error): Exception {\n // Get the frames first since Opera can lose the stack if we touch anything else first\n const frames = parseStackFrames(ex);\n\n const exception: Exception = {\n type: ex && ex.name,\n value: extractMessage(ex),\n };\n\n if (frames.length) {\n exception.stacktrace = { frames };\n }\n\n if (exception.type === undefined && exception.value === '') {\n exception.value = 'Unrecoverable error caught';\n }\n\n return exception;\n}\n\n/**\n * @hidden\n */\nexport function eventFromPlainObject(\n exception: Record<string, unknown>,\n syntheticException?: Error,\n isUnhandledRejection?: boolean,\n): Event {\n const event: Event = {\n exception: {\n values: [\n {\n type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error',\n value: `Non-Error ${\n isUnhandledRejection ? 'promise rejection' : 'exception'\n } captured with keys: ${extractExceptionKeysForMessage(exception)}`,\n },\n ],\n },\n extra: {\n __serialized__: normalizeToSize(exception),\n },\n };\n\n if (syntheticException) {\n const frames = parseStackFrames(syntheticException);\n if (frames.length) {\n event.stacktrace = { frames };\n }\n }\n\n return event;\n}\n\n/**\n * @hidden\n */\nexport function eventFromError(ex: Error): Event {\n return {\n exception: {\n values: [exceptionFromError(ex)],\n },\n };\n}\n\n/** Parses stack frames from an error */\nexport function parseStackFrames(ex: Error & { framesToPop?: number; stacktrace?: string }): StackFrame[] {\n // Access and store the stacktrace property before doing ANYTHING\n // else to it because Opera is not very good at providing it\n // reliably in other circumstances.\n const stacktrace = ex.stacktrace || ex.stack || '';\n\n const popSize = getPopSize(ex);\n\n try {\n return createStackParser(\n opera10StackParser,\n opera11StackParser,\n chromeStackParser,\n winjsStackParser,\n geckoStackParser,\n )(stacktrace, popSize);\n } catch (e) {\n // no-empty\n }\n\n return [];\n}\n\n// Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108\nconst reactMinifiedRegexp = /Minified React error #\\d+;/i;\n\nfunction getPopSize(ex: Error & { framesToPop?: number }): number {\n if (ex) {\n if (typeof ex.framesToPop === 'number') {\n return ex.framesToPop;\n }\n\n if (reactMinifiedRegexp.test(ex.message)) {\n return 1;\n }\n }\n\n return 0;\n}\n\n/**\n * There are cases where stacktrace.message is an Event object\n * https://github.com/getsentry/sentry-javascript/issues/1949\n * In this specific case we try to extract stacktrace.message.error.message\n */\nfunction extractMessage(ex: Error & { message: { error?: Error } }): string {\n const message = ex && ex.message;\n if (!message) {\n return 'No error message';\n }\n if (message.error && typeof message.error.message === 'string') {\n return message.error.message;\n }\n return message;\n}\n\n/**\n * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.\n * @hidden\n */\nexport function eventFromException(\n exception: unknown,\n hint?: EventHint,\n attachStacktrace?: boolean,\n): PromiseLike<Event> {\n const syntheticException = (hint && hint.syntheticException) || undefined;\n const event = eventFromUnknownInput(exception, syntheticException, attachStacktrace);\n addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }\n event.level = Severity.Error;\n if (hint && hint.event_id) {\n event.event_id = hint.event_id;\n }\n return resolvedSyncPromise(event);\n}\n\n/**\n * Builds and Event from a Message\n * @hidden\n */\nexport function eventFromMessage(\n message: string,\n level: Severity = Severity.Info,\n hint?: EventHint,\n attachStacktrace?: boolean,\n): PromiseLike<Event> {\n const syntheticException = (hint && hint.syntheticException) || undefined;\n const event = eventFromString(message, syntheticException, attachStacktrace);\n event.level = level;\n if (hint && hint.event_id) {\n event.event_id = hint.event_id;\n }\n return resolvedSyncPromise(event);\n}\n\n/**\n * @hidden\n */\nexport function eventFromUnknownInput(\n exception: unknown,\n syntheticException?: Error,\n attachStacktrace?: boolean,\n isUnhandledRejection?: boolean,\n): Event {\n let event: Event;\n\n if (isErrorEvent(exception as ErrorEvent) && (exception as ErrorEvent).error) {\n // If it is an ErrorEvent with `error` property, extract it to get actual Error\n const errorEvent = exception as ErrorEvent;\n return eventFromError(errorEvent.error as Error);\n }\n\n // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name\n // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be\n // `Error`s, but that's not the case in IE11, so in that case we treat it the same as we do a `DOMError`.\n //\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMError\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMException\n // https://webidl.spec.whatwg.org/#es-DOMException-specialness\n if (isDOMError(exception as DOMError) || isDOMException(exception as DOMException)) {\n const domException = exception as DOMException;\n\n if ('stack' in (exception as Error)) {\n event = eventFromError(exception as Error);\n } else {\n const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');\n const message = domException.message ? `${name}: ${domException.message}` : name;\n event = eventFromString(message, syntheticException, attachStacktrace);\n addExceptionTypeValue(event, message);\n }\n if ('code' in domException) {\n event.tags = { ...event.tags, 'DOMException.code': `${domException.code}` };\n }\n\n return event;\n }\n if (isError(exception)) {\n // we have a real Error object, do nothing\n return eventFromError(exception);\n }\n if (isPlainObject(exception) || isEvent(exception)) {\n // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize\n // it manually. This will allow us to group events based on top-level keys which is much better than creating a new\n // group on any key/value change.\n const objectException = exception as Record<string, unknown>;\n event = eventFromPlainObject(objectException, syntheticException, isUnhandledRejection);\n addExceptionMechanism(event, {\n synthetic: true,\n });\n return event;\n }\n\n // If none of previous checks were valid, then it means that it's not:\n // - an instance of DOMError\n // - an instance of DOMException\n // - an instance of Event\n // - an instance of Error\n // - a valid ErrorEvent (one with an error property)\n // - a plain Object\n //\n // So bail out and capture it as a simple message:\n event = eventFromString(exception as string, syntheticException, attachStacktrace);\n addExceptionTypeValue(event, `${exception}`, undefined);\n addExceptionMechanism(event, {\n synthetic: true,\n });\n\n return event;\n}\n\n/**\n * @hidden\n */\nexport function eventFromString(input: string, syntheticException?: Error, attachStacktrace?: boolean): Event {\n const event: Event = {\n message: input,\n };\n\n if (attachStacktrace && syntheticException) {\n const frames = parseStackFrames(syntheticException);\n if (frames.length) {\n event.stacktrace = { frames };\n }\n }\n\n return event;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"eventbuilder.js","sources":["../../../src/eventbuilder.ts"],"sourcesContent":["import { Event, EventHint, Exception, Severity, SeverityLevel, StackFrame, StackParser } from '@sentry/types';\nimport {\n addExceptionMechanism,\n addExceptionTypeValue,\n extractExceptionKeysForMessage,\n isDOMError,\n isDOMException,\n isError,\n isErrorEvent,\n isEvent,\n isPlainObject,\n normalizeToSize,\n resolvedSyncPromise,\n} from '@sentry/utils';\n\n/**\n * This function creates an exception from a JavaScript Error\n */\nexport function exceptionFromError(stackParser: StackParser, ex: Error): Exception {\n // Get the frames first since Opera can lose the stack if we touch anything else first\n const frames = parseStackFrames(stackParser, ex);\n\n const exception: Exception = {\n type: ex && ex.name,\n value: extractMessage(ex),\n };\n\n if (frames.length) {\n exception.stacktrace = { frames };\n }\n\n if (exception.type === undefined && exception.value === '') {\n exception.value = 'Unrecoverable error caught';\n }\n\n return exception;\n}\n\n/**\n * @hidden\n */\nexport function eventFromPlainObject(\n stackParser: StackParser,\n exception: Record<string, unknown>,\n syntheticException?: Error,\n isUnhandledRejection?: boolean,\n): Event {\n const event: Event = {\n exception: {\n values: [\n {\n type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error',\n value: `Non-Error ${\n isUnhandledRejection ? 'promise rejection' : 'exception'\n } captured with keys: ${extractExceptionKeysForMessage(exception)}`,\n },\n ],\n },\n extra: {\n __serialized__: normalizeToSize(exception),\n },\n };\n\n if (syntheticException) {\n const frames = parseStackFrames(stackParser, syntheticException);\n if (frames.length) {\n // event.exception.values[0] has been set above\n (event.exception as { values: Exception[] }).values[0].stacktrace = { frames };\n }\n }\n\n return event;\n}\n\n/**\n * @hidden\n */\nexport function eventFromError(stackParser: StackParser, ex: Error): Event {\n return {\n exception: {\n values: [exceptionFromError(stackParser, ex)],\n },\n };\n}\n\n/** Parses stack frames from an error */\nexport function parseStackFrames(\n stackParser: StackParser,\n ex: Error & { framesToPop?: number; stacktrace?: string },\n): StackFrame[] {\n // Access and store the stacktrace property before doing ANYTHING\n // else to it because Opera is not very good at providing it\n // reliably in other circumstances.\n const stacktrace = ex.stacktrace || ex.stack || '';\n\n const popSize = getPopSize(ex);\n\n try {\n return stackParser(stacktrace, popSize);\n } catch (e) {\n // no-empty\n }\n\n return [];\n}\n\n// Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108\nconst reactMinifiedRegexp = /Minified React error #\\d+;/i;\n\nfunction getPopSize(ex: Error & { framesToPop?: number }): number {\n if (ex) {\n if (typeof ex.framesToPop === 'number') {\n return ex.framesToPop;\n }\n\n if (reactMinifiedRegexp.test(ex.message)) {\n return 1;\n }\n }\n\n return 0;\n}\n\n/**\n * There are cases where stacktrace.message is an Event object\n * https://github.com/getsentry/sentry-javascript/issues/1949\n * In this specific case we try to extract stacktrace.message.error.message\n */\nfunction extractMessage(ex: Error & { message: { error?: Error } }): string {\n const message = ex && ex.message;\n if (!message) {\n return 'No error message';\n }\n if (message.error && typeof message.error.message === 'string') {\n return message.error.message;\n }\n return message;\n}\n\n/**\n * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.\n * @hidden\n */\nexport function eventFromException(\n stackParser: StackParser,\n exception: unknown,\n hint?: EventHint,\n attachStacktrace?: boolean,\n): PromiseLike<Event> {\n const syntheticException = (hint && hint.syntheticException) || undefined;\n const event = eventFromUnknownInput(stackParser, exception, syntheticException, attachStacktrace);\n addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }\n event.level = 'error';\n if (hint && hint.event_id) {\n event.event_id = hint.event_id;\n }\n return resolvedSyncPromise(event);\n}\n\n/**\n * Builds and Event from a Message\n * @hidden\n */\nexport function eventFromMessage(\n stackParser: StackParser,\n message: string,\n // eslint-disable-next-line deprecation/deprecation\n level: Severity | SeverityLevel = 'info',\n hint?: EventHint,\n attachStacktrace?: boolean,\n): PromiseLike<Event> {\n const syntheticException = (hint && hint.syntheticException) || undefined;\n const event = eventFromString(stackParser, message, syntheticException, attachStacktrace);\n event.level = level;\n if (hint && hint.event_id) {\n event.event_id = hint.event_id;\n }\n return resolvedSyncPromise(event);\n}\n\n/**\n * @hidden\n */\nexport function eventFromUnknownInput(\n stackParser: StackParser,\n exception: unknown,\n syntheticException?: Error,\n attachStacktrace?: boolean,\n isUnhandledRejection?: boolean,\n): Event {\n let event: Event;\n\n if (isErrorEvent(exception as ErrorEvent) && (exception as ErrorEvent).error) {\n // If it is an ErrorEvent with `error` property, extract it to get actual Error\n const errorEvent = exception as ErrorEvent;\n return eventFromError(stackParser, errorEvent.error as Error);\n }\n\n // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name\n // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be\n // `Error`s, but that's not the case in IE11, so in that case we treat it the same as we do a `DOMError`.\n //\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMError\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMException\n // https://webidl.spec.whatwg.org/#es-DOMException-specialness\n if (isDOMError(exception as DOMError) || isDOMException(exception as DOMException)) {\n const domException = exception as DOMException;\n\n if ('stack' in (exception as Error)) {\n event = eventFromError(stackParser, exception as Error);\n } else {\n const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');\n const message = domException.message ? `${name}: ${domException.message}` : name;\n event = eventFromString(stackParser, message, syntheticException, attachStacktrace);\n addExceptionTypeValue(event, message);\n }\n if ('code' in domException) {\n event.tags = { ...event.tags, 'DOMException.code': `${domException.code}` };\n }\n\n return event;\n }\n if (isError(exception)) {\n // we have a real Error object, do nothing\n return eventFromError(stackParser, exception);\n }\n if (isPlainObject(exception) || isEvent(exception)) {\n // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize\n // it manually. This will allow us to group events based on top-level keys which is much better than creating a new\n // group on any key/value change.\n const objectException = exception as Record<string, unknown>;\n event = eventFromPlainObject(stackParser, objectException, syntheticException, isUnhandledRejection);\n addExceptionMechanism(event, {\n synthetic: true,\n });\n return event;\n }\n\n // If none of previous checks were valid, then it means that it's not:\n // - an instance of DOMError\n // - an instance of DOMException\n // - an instance of Event\n // - an instance of Error\n // - a valid ErrorEvent (one with an error property)\n // - a plain Object\n //\n // So bail out and capture it as a simple message:\n event = eventFromString(stackParser, exception as string, syntheticException, attachStacktrace);\n addExceptionTypeValue(event, `${exception}`, undefined);\n addExceptionMechanism(event, {\n synthetic: true,\n });\n\n return event;\n}\n\n/**\n * @hidden\n */\nexport function eventFromString(\n stackParser: StackParser,\n input: string,\n syntheticException?: Error,\n attachStacktrace?: boolean,\n): Event {\n const event: Event = {\n message: input,\n };\n\n if (attachStacktrace && syntheticException) {\n const frames = parseStackFrames(stackParser, syntheticException);\n if (frames.length) {\n event.exception = {\n values: [{ value: input, stacktrace: { frames } }],\n };\n }\n }\n\n return event;\n}\n"],"names":[],"mappings":";;AAeA;AACA;AACA;;AAEA;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;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;;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;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;AACA;AACA;;AAEA;AACA;AACA;AAEA;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;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;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;AACA;AACA;AACA;;;;"}
|
package/esm/exports.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
export { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDialog,
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export { FunctionToString, Hub, InboundFilters, SDK_VERSION, Scope, addBreadcrumb, addGlobalEventProcessor, captureEvent, captureException, captureMessage, configureScope, createTransport, getCurrentHub, getHubFromCarrier, makeMain, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, withScope } from '@sentry/core';
|
|
2
|
+
export { BrowserClient } from './client.js';
|
|
3
|
+
import './transports/index.js';
|
|
4
|
+
export { chromeStackLineParser, defaultStackLineParsers, defaultStackParser, geckoStackLineParser, opera10StackLineParser, opera11StackLineParser, winjsStackLineParser } from './stack-parsers.js';
|
|
5
|
+
export { close, defaultIntegrations, flush, forceLoad, init, lastEventId, onLoad, showReportDialog, wrap } from './sdk.js';
|
|
6
|
+
import './integrations/index.js';
|
|
7
|
+
|
|
8
|
+
;
|
|
9
|
+
|
|
10
|
+
;
|
|
11
|
+
;
|
|
12
|
+
//# sourceMappingURL=exports.js.map
|
package/esm/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","
|
|
1
|
+
{"version":3,"file":"exports.js","sources":["../../../src/exports.ts"],"sourcesContent":["export type {\n Breadcrumb,\n BreadcrumbHint,\n Request,\n SdkInfo,\n Event,\n EventHint,\n Exception,\n // eslint-disable-next-line deprecation/deprecation\n Severity,\n SeverityLevel,\n StackFrame,\n Stacktrace,\n Thread,\n User,\n Session,\n} from '@sentry/types';\n\nexport type { BrowserOptions } from './client';\nexport type { ReportDialogOptions } from './helpers';\n\nexport {\n addGlobalEventProcessor,\n addBreadcrumb,\n captureException,\n captureEvent,\n captureMessage,\n configureScope,\n createTransport,\n getHubFromCarrier,\n getCurrentHub,\n Hub,\n makeMain,\n Scope,\n startTransaction,\n SDK_VERSION,\n setContext,\n setExtra,\n setExtras,\n setTag,\n setTags,\n setUser,\n withScope,\n FunctionToString,\n InboundFilters,\n} from '@sentry/core';\n\nexport { BrowserClient } from './client';\nexport { makeFetchTransport, makeXHRTransport } from './transports';\nexport {\n defaultStackParser,\n defaultStackLineParsers,\n chromeStackLineParser,\n geckoStackLineParser,\n opera10StackLineParser,\n opera11StackLineParser,\n winjsStackLineParser,\n} from './stack-parsers';\nexport { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDialog, flush, close, wrap } from './sdk';\nexport { GlobalHandlers, TryCatch, Breadcrumbs, LinkedErrors, HttpContext, Dedupe } from './integrations';\n"],"names":[],"mappings":";;;;;;;AAgBA;AACA;AACA;AACA"}
|
package/esm/flags.js
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* our, or the user's build process. Take care when introducing new flags - they must not throw if they are not
|
|
12
12
|
* replaced.
|
|
13
13
|
*/
|
|
14
|
+
|
|
14
15
|
/** Flag that is true for debug builds, false otherwise. */
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
var IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;
|
|
17
|
+
|
|
18
|
+
export { IS_DEBUG_BUILD };
|
|
19
|
+
//# sourceMappingURL=flags.js.map
|
package/esm/flags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flags.js","
|
|
1
|
+
{"version":3,"file":"flags.js","sources":["../../../src/flags.ts"],"sourcesContent":["/*\n * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking\n * for users.\n *\n * Debug flags need to be declared in each package individually and must not be imported across package boundaries,\n * because some build tools have trouble tree-shaking imported guards.\n *\n * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.\n *\n * Debug flag files will contain \"magic strings\" like `__SENTRY_DEBUG__` that may get replaced with actual values during\n * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not\n * replaced.\n */\n\ndeclare const __SENTRY_DEBUG__: boolean;\n\n/** Flag that is true for debug builds, false otherwise. */\nexport const IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;;;;;"}
|