@sentry/browser 6.18.1 → 6.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/build/bundle.es6.js +108 -107
  2. package/build/bundle.es6.js.map +1 -1
  3. package/build/bundle.es6.min.js +2 -2
  4. package/build/bundle.es6.min.js.map +1 -1
  5. package/build/bundle.js +117 -114
  6. package/build/bundle.js.map +1 -1
  7. package/build/bundle.min.js +2 -2
  8. package/build/bundle.min.js.map +1 -1
  9. package/dist/backend.js +2 -2
  10. package/dist/backend.js.map +1 -1
  11. package/dist/eventbuilder.d.ts +24 -10
  12. package/dist/eventbuilder.d.ts.map +1 -1
  13. package/dist/eventbuilder.js +119 -23
  14. package/dist/eventbuilder.js.map +1 -1
  15. package/dist/helpers.js +2 -2
  16. package/dist/helpers.js.map +1 -1
  17. package/dist/integrations/dedupe.js +1 -1
  18. package/dist/integrations/dedupe.js.map +1 -1
  19. package/dist/integrations/globalhandlers.js +2 -8
  20. package/dist/integrations/globalhandlers.js.map +1 -1
  21. package/dist/integrations/linkederrors.js +2 -2
  22. package/dist/integrations/linkederrors.js.map +1 -1
  23. package/dist/stack-parsers.d.ts +5 -5
  24. package/dist/stack-parsers.d.ts.map +1 -1
  25. package/dist/stack-parsers.js +16 -6
  26. package/dist/stack-parsers.js.map +1 -1
  27. package/dist/transports/base.js +1 -1
  28. package/dist/transports/base.js.map +1 -1
  29. package/dist/transports/utils.js +1 -1
  30. package/dist/transports/utils.js.map +1 -1
  31. package/esm/backend.js +2 -2
  32. package/esm/backend.js.map +1 -1
  33. package/esm/eventbuilder.d.ts +24 -10
  34. package/esm/eventbuilder.d.ts.map +1 -1
  35. package/esm/eventbuilder.js +113 -21
  36. package/esm/eventbuilder.js.map +1 -1
  37. package/esm/helpers.js +2 -2
  38. package/esm/helpers.js.map +1 -1
  39. package/esm/integrations/dedupe.js +1 -1
  40. package/esm/integrations/dedupe.js.map +1 -1
  41. package/esm/integrations/globalhandlers.js +2 -8
  42. package/esm/integrations/globalhandlers.js.map +1 -1
  43. package/esm/integrations/linkederrors.js +1 -1
  44. package/esm/integrations/linkederrors.js.map +1 -1
  45. package/esm/stack-parsers.d.ts +5 -5
  46. package/esm/stack-parsers.d.ts.map +1 -1
  47. package/esm/stack-parsers.js +16 -6
  48. package/esm/stack-parsers.js.map +1 -1
  49. package/esm/transports/base.js +1 -1
  50. package/esm/transports/base.js.map +1 -1
  51. package/esm/transports/utils.js +1 -1
  52. package/esm/transports/utils.js.map +1 -1
  53. package/package.json +5 -5
  54. package/dist/parsers.d.ts +0 -21
  55. package/dist/parsers.d.ts.map +0 -1
  56. package/dist/parsers.js +0 -108
  57. package/dist/parsers.js.map +0 -1
  58. package/esm/parsers.d.ts +0 -21
  59. package/esm/parsers.d.ts.map +0 -1
  60. package/esm/parsers.js +0 -103
  61. package/esm/parsers.js.map +0 -1
package/dist/backend.js CHANGED
@@ -18,14 +18,14 @@ var BrowserBackend = /** @class */ (function (_super) {
18
18
  * @inheritDoc
19
19
  */
20
20
  BrowserBackend.prototype.eventFromException = function (exception, hint) {
21
- return eventbuilder_1.eventFromException(this._options, exception, hint);
21
+ return eventbuilder_1.eventFromException(exception, hint, this._options.attachStacktrace);
22
22
  };
23
23
  /**
24
24
  * @inheritDoc
25
25
  */
26
26
  BrowserBackend.prototype.eventFromMessage = function (message, level, hint) {
27
27
  if (level === void 0) { level = types_1.Severity.Info; }
28
- return eventbuilder_1.eventFromMessage(this._options, message, level, hint);
28
+ return eventbuilder_1.eventFromMessage(message, level, hint, this._options.attachStacktrace);
29
29
  };
30
30
  /**
31
31
  * @inheritDoc
@@ -1 +1 @@
1
- {"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAC3C,uCAA+E;AAC/E,uCAA8C;AAE9C,+CAAsE;AACtE,2CAA4D;AA4B5D;;;GAGG;AACH;IAAoC,0CAA2B;IAA/D;;IAuCA,CA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types';\nimport { supportsFetch } from '@sentry/utils';\n\nimport { eventFromException, eventFromMessage } from './eventbuilder';\nimport { FetchTransport, XHRTransport } from './transports';\n\n/**\n * Configuration options for the Sentry Browser SDK.\n * @see BrowserClient for more information.\n */\nexport interface BrowserOptions extends Options {\n /**\n * A pattern for error URLs which should exclusively be sent to Sentry.\n * This is the opposite of {@link Options.denyUrls}.\n * By default, all errors will be sent.\n */\n allowUrls?: Array<string | RegExp>;\n\n /**\n * A pattern for error URLs which should not be sent to Sentry.\n * To allow certain errors instead, use {@link Options.allowUrls}.\n * By default, all errors will be sent.\n */\n denyUrls?: Array<string | RegExp>;\n\n /** @deprecated use {@link Options.allowUrls} instead. */\n whitelistUrls?: Array<string | RegExp>;\n\n /** @deprecated use {@link Options.denyUrls} instead. */\n blacklistUrls?: Array<string | RegExp>;\n}\n\n/**\n * The Sentry Browser SDK Backend.\n * @hidden\n */\nexport class BrowserBackend extends BaseBackend<BrowserOptions> {\n /**\n * @inheritDoc\n */\n public eventFromException(exception: unknown, hint?: EventHint): PromiseLike<Event> {\n return eventFromException(this._options, exception, hint);\n }\n /**\n * @inheritDoc\n */\n public eventFromMessage(message: string, level: Severity = Severity.Info, hint?: EventHint): PromiseLike<Event> {\n return eventFromMessage(this._options, message, level, hint);\n }\n\n /**\n * @inheritDoc\n */\n protected _setupTransport(): Transport {\n if (!this._options.dsn) {\n // We return the noop transport here in case there is no Dsn.\n return super._setupTransport();\n }\n\n const transportOptions = {\n ...this._options.transportOptions,\n dsn: this._options.dsn,\n tunnel: this._options.tunnel,\n sendClientReports: this._options.sendClientReports,\n _metadata: this._options._metadata,\n };\n\n if (this._options.transport) {\n return new this._options.transport(transportOptions);\n }\n if (supportsFetch()) {\n return new FetchTransport(transportOptions);\n }\n return new XHRTransport(transportOptions);\n }\n}\n"]}
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAC3C,uCAA+E;AAC/E,uCAA8C;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AAvCD,CAAoC,kBAAW,GAuC9C;AAvCY,wCAAc","sourcesContent":["import { BaseBackend } from '@sentry/core';\nimport { Event, EventHint, Options, Severity, Transport } from '@sentry/types';\nimport { supportsFetch } from '@sentry/utils';\n\nimport { eventFromException, eventFromMessage } from './eventbuilder';\nimport { FetchTransport, XHRTransport } from './transports';\n\n/**\n * Configuration options for the Sentry Browser SDK.\n * @see BrowserClient for more information.\n */\nexport interface BrowserOptions extends Options {\n /**\n * A pattern for error URLs which should exclusively be sent to Sentry.\n * This is the opposite of {@link Options.denyUrls}.\n * By default, all errors will be sent.\n */\n allowUrls?: Array<string | RegExp>;\n\n /**\n * A pattern for error URLs which should not be sent to Sentry.\n * To allow certain errors instead, use {@link Options.allowUrls}.\n * By default, all errors will be sent.\n */\n denyUrls?: Array<string | RegExp>;\n\n /** @deprecated use {@link Options.allowUrls} instead. */\n whitelistUrls?: Array<string | RegExp>;\n\n /** @deprecated use {@link Options.denyUrls} instead. */\n blacklistUrls?: Array<string | RegExp>;\n}\n\n/**\n * The Sentry Browser SDK Backend.\n * @hidden\n */\nexport class BrowserBackend extends BaseBackend<BrowserOptions> {\n /**\n * @inheritDoc\n */\n public eventFromException(exception: unknown, hint?: EventHint): PromiseLike<Event> {\n return eventFromException(exception, hint, this._options.attachStacktrace);\n }\n /**\n * @inheritDoc\n */\n public eventFromMessage(message: string, level: Severity = Severity.Info, hint?: EventHint): PromiseLike<Event> {\n return eventFromMessage(message, level, hint, this._options.attachStacktrace);\n }\n\n /**\n * @inheritDoc\n */\n protected _setupTransport(): Transport {\n if (!this._options.dsn) {\n // We return the noop transport here in case there is no Dsn.\n return super._setupTransport();\n }\n\n const transportOptions = {\n ...this._options.transportOptions,\n dsn: this._options.dsn,\n tunnel: this._options.tunnel,\n sendClientReports: this._options.sendClientReports,\n _metadata: this._options._metadata,\n };\n\n if (this._options.transport) {\n return new this._options.transport(transportOptions);\n }\n if (supportsFetch()) {\n return new FetchTransport(transportOptions);\n }\n return new XHRTransport(transportOptions);\n }\n}\n"]}
@@ -1,25 +1,39 @@
1
- import { Event, EventHint, Options, Severity } from '@sentry/types';
1
+ import { Event, EventHint, Exception, Severity, StackFrame } from '@sentry/types';
2
+ /**
3
+ * This function creates an exception from an TraceKitStackTrace
4
+ * @param stacktrace TraceKitStackTrace that will be converted to an exception
5
+ * @hidden
6
+ */
7
+ export declare function exceptionFromError(ex: Error): Exception;
8
+ /**
9
+ * @hidden
10
+ */
11
+ export declare function eventFromPlainObject(exception: Record<string, unknown>, syntheticException?: Error, isUnhandledRejection?: boolean): Event;
12
+ /**
13
+ * @hidden
14
+ */
15
+ export declare function eventFromError(ex: Error): Event;
16
+ /** Parses stack frames from an error */
17
+ export declare function parseStackFrames(ex: Error & {
18
+ framesToPop?: number;
19
+ stacktrace?: string;
20
+ }): StackFrame[];
2
21
  /**
3
22
  * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.
4
23
  * @hidden
5
24
  */
6
- export declare function eventFromException(options: Options, exception: unknown, hint?: EventHint): PromiseLike<Event>;
25
+ export declare function eventFromException(exception: unknown, hint?: EventHint, attachStacktrace?: boolean): PromiseLike<Event>;
7
26
  /**
8
27
  * Builds and Event from a Message
9
28
  * @hidden
10
29
  */
11
- export declare function eventFromMessage(options: Options, message: string, level?: Severity, hint?: EventHint): PromiseLike<Event>;
30
+ export declare function eventFromMessage(message: string, level?: Severity, hint?: EventHint, attachStacktrace?: boolean): PromiseLike<Event>;
12
31
  /**
13
32
  * @hidden
14
33
  */
15
- export declare function eventFromUnknownInput(exception: unknown, syntheticException?: Error, options?: {
16
- isRejection?: boolean;
17
- attachStacktrace?: boolean;
18
- }): Event;
34
+ export declare function eventFromUnknownInput(exception: unknown, syntheticException?: Error, attachStacktrace?: boolean, isUnhandledRejection?: boolean): Event;
19
35
  /**
20
36
  * @hidden
21
37
  */
22
- export declare function eventFromString(input: string, syntheticException?: Error, options?: {
23
- attachStacktrace?: boolean;
24
- }): Event;
38
+ export declare function eventFromString(input: string, syntheticException?: Error, attachStacktrace?: boolean): Event;
25
39
  //# sourceMappingURL=eventbuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"eventbuilder.d.ts","sourceRoot":"","sources":["../src/eventbuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAepE;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,CAW7G;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,GAAE,QAAwB,EAC/B,IAAI,CAAC,EAAE,SAAS,GACf,WAAW,CAAC,KAAK,CAAC,CAUpB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,OAAO,EAClB,kBAAkB,CAAC,EAAE,KAAK,EAC1B,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACvB,GACL,KAAK,CAiEP;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,kBAAkB,CAAC,EAAE,KAAK,EAC1B,OAAO,GAAE;IACP,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACvB,GACL,KAAK,CAaP"}
1
+ {"version":3,"file":"eventbuilder.d.ts","sourceRoot":"","sources":["../src/eventbuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAwBlF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,KAAK,GAAG,SAAS,CAkBvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,kBAAkB,CAAC,EAAE,KAAK,EAC1B,oBAAoB,CAAC,EAAE,OAAO,GAC7B,KAAK,CAyBP;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,KAAK,GAAG,KAAK,CAM/C;AAED,wCAAwC;AACxC,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,KAAK,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,EAAE,CAqBxG;AAmCD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,OAAO,EAClB,IAAI,CAAC,EAAE,SAAS,EAChB,gBAAgB,CAAC,EAAE,OAAO,GACzB,WAAW,CAAC,KAAK,CAAC,CASpB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,KAAK,GAAE,QAAwB,EAC/B,IAAI,CAAC,EAAE,SAAS,EAChB,gBAAgB,CAAC,EAAE,OAAO,GACzB,WAAW,CAAC,KAAK,CAAC,CAQpB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,OAAO,EAClB,kBAAkB,CAAC,EAAE,KAAK,EAC1B,gBAAgB,CAAC,EAAE,OAAO,EAC1B,oBAAoB,CAAC,EAAE,OAAO,GAC7B,KAAK,CAiEP;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,EAAE,OAAO,GAAG,KAAK,CAa5G"}
@@ -2,16 +2,116 @@ Object.defineProperty(exports, "__esModule", { value: true });
2
2
  var tslib_1 = require("tslib");
3
3
  var types_1 = require("@sentry/types");
4
4
  var utils_1 = require("@sentry/utils");
5
- var parsers_1 = require("./parsers");
5
+ var stack_parsers_1 = require("./stack-parsers");
6
+ /**
7
+ * This function creates an exception from an TraceKitStackTrace
8
+ * @param stacktrace TraceKitStackTrace that will be converted to an exception
9
+ * @hidden
10
+ */
11
+ function exceptionFromError(ex) {
12
+ // Get the frames first since Opera can lose the stack if we touch anything else first
13
+ var frames = parseStackFrames(ex);
14
+ var exception = {
15
+ type: ex && ex.name,
16
+ value: extractMessage(ex),
17
+ };
18
+ if (frames.length) {
19
+ exception.stacktrace = { frames: frames };
20
+ }
21
+ if (exception.type === undefined && exception.value === '') {
22
+ exception.value = 'Unrecoverable error caught';
23
+ }
24
+ return exception;
25
+ }
26
+ exports.exceptionFromError = exceptionFromError;
27
+ /**
28
+ * @hidden
29
+ */
30
+ function eventFromPlainObject(exception, syntheticException, isUnhandledRejection) {
31
+ var event = {
32
+ exception: {
33
+ values: [
34
+ {
35
+ type: utils_1.isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error',
36
+ value: "Non-Error " + (isUnhandledRejection ? 'promise rejection' : 'exception') + " captured with keys: " + utils_1.extractExceptionKeysForMessage(exception),
37
+ },
38
+ ],
39
+ },
40
+ extra: {
41
+ __serialized__: utils_1.normalizeToSize(exception),
42
+ },
43
+ };
44
+ if (syntheticException) {
45
+ var frames_1 = parseStackFrames(syntheticException);
46
+ if (frames_1.length) {
47
+ event.stacktrace = { frames: frames_1 };
48
+ }
49
+ }
50
+ return event;
51
+ }
52
+ exports.eventFromPlainObject = eventFromPlainObject;
53
+ /**
54
+ * @hidden
55
+ */
56
+ function eventFromError(ex) {
57
+ return {
58
+ exception: {
59
+ values: [exceptionFromError(ex)],
60
+ },
61
+ };
62
+ }
63
+ exports.eventFromError = eventFromError;
64
+ /** Parses stack frames from an error */
65
+ function parseStackFrames(ex) {
66
+ // Access and store the stacktrace property before doing ANYTHING
67
+ // else to it because Opera is not very good at providing it
68
+ // reliably in other circumstances.
69
+ var stacktrace = ex.stacktrace || ex.stack || '';
70
+ var popSize = getPopSize(ex);
71
+ try {
72
+ return utils_1.createStackParser(stack_parsers_1.opera10StackParser, stack_parsers_1.opera11StackParser, stack_parsers_1.chromeStackParser, stack_parsers_1.winjsStackParser, stack_parsers_1.geckoStackParser)(stacktrace, popSize);
73
+ }
74
+ catch (e) {
75
+ // no-empty
76
+ }
77
+ return [];
78
+ }
79
+ exports.parseStackFrames = parseStackFrames;
80
+ // Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
81
+ var reactMinifiedRegexp = /Minified React error #\d+;/i;
82
+ function getPopSize(ex) {
83
+ if (ex) {
84
+ if (typeof ex.framesToPop === 'number') {
85
+ return ex.framesToPop;
86
+ }
87
+ if (reactMinifiedRegexp.test(ex.message)) {
88
+ return 1;
89
+ }
90
+ }
91
+ return 0;
92
+ }
93
+ /**
94
+ * There are cases where stacktrace.message is an Event object
95
+ * https://github.com/getsentry/sentry-javascript/issues/1949
96
+ * In this specific case we try to extract stacktrace.message.error.message
97
+ */
98
+ function extractMessage(ex) {
99
+ var message = ex && ex.message;
100
+ if (!message) {
101
+ return 'No error message';
102
+ }
103
+ if (message.error && typeof message.error.message === 'string') {
104
+ return message.error.message;
105
+ }
106
+ return message;
107
+ }
6
108
  /**
7
109
  * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.
8
110
  * @hidden
9
111
  */
10
- function eventFromException(options, exception, hint) {
112
+ function eventFromException(exception, hint, attachStacktrace) {
11
113
  var syntheticException = (hint && hint.syntheticException) || undefined;
12
- var event = eventFromUnknownInput(exception, syntheticException, {
13
- attachStacktrace: options.attachStacktrace,
14
- });
114
+ var event = eventFromUnknownInput(exception, syntheticException, attachStacktrace);
15
115
  utils_1.addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
16
116
  event.level = types_1.Severity.Error;
17
117
  if (hint && hint.event_id) {
@@ -24,12 +124,10 @@ exports.eventFromException = eventFromException;
24
124
  * Builds and Event from a Message
25
125
  * @hidden
26
126
  */
27
- function eventFromMessage(options, message, level, hint) {
127
+ function eventFromMessage(message, level, hint, attachStacktrace) {
28
128
  if (level === void 0) { level = types_1.Severity.Info; }
29
129
  var syntheticException = (hint && hint.syntheticException) || undefined;
30
- var event = eventFromString(message, syntheticException, {
31
- attachStacktrace: options.attachStacktrace,
32
- });
130
+ var event = eventFromString(message, syntheticException, attachStacktrace);
33
131
  event.level = level;
34
132
  if (hint && hint.event_id) {
35
133
  event.event_id = hint.event_id;
@@ -40,13 +138,12 @@ exports.eventFromMessage = eventFromMessage;
40
138
  /**
41
139
  * @hidden
42
140
  */
43
- function eventFromUnknownInput(exception, syntheticException, options) {
44
- if (options === void 0) { options = {}; }
141
+ function eventFromUnknownInput(exception, syntheticException, attachStacktrace, isUnhandledRejection) {
45
142
  var event;
46
143
  if (utils_1.isErrorEvent(exception) && exception.error) {
47
144
  // If it is an ErrorEvent with `error` property, extract it to get actual Error
48
145
  var errorEvent = exception;
49
- return parsers_1.eventFromError(errorEvent.error);
146
+ return eventFromError(errorEvent.error);
50
147
  }
51
148
  // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name
52
149
  // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be
@@ -58,12 +155,12 @@ function eventFromUnknownInput(exception, syntheticException, options) {
58
155
  if (utils_1.isDOMError(exception) || utils_1.isDOMException(exception)) {
59
156
  var domException = exception;
60
157
  if ('stack' in exception) {
61
- event = parsers_1.eventFromError(exception);
158
+ event = eventFromError(exception);
62
159
  }
63
160
  else {
64
161
  var name_1 = domException.name || (utils_1.isDOMError(domException) ? 'DOMError' : 'DOMException');
65
162
  var message = domException.message ? name_1 + ": " + domException.message : name_1;
66
- event = eventFromString(message, syntheticException, options);
163
+ event = eventFromString(message, syntheticException, attachStacktrace);
67
164
  utils_1.addExceptionTypeValue(event, message);
68
165
  }
69
166
  if ('code' in domException) {
@@ -73,14 +170,14 @@ function eventFromUnknownInput(exception, syntheticException, options) {
73
170
  }
74
171
  if (utils_1.isError(exception)) {
75
172
  // we have a real Error object, do nothing
76
- return parsers_1.eventFromError(exception);
173
+ return eventFromError(exception);
77
174
  }
78
175
  if (utils_1.isPlainObject(exception) || utils_1.isEvent(exception)) {
79
176
  // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize
80
177
  // it manually. This will allow us to group events based on top-level keys which is much better than creating a new
81
178
  // group on any key/value change.
82
179
  var objectException = exception;
83
- event = parsers_1.eventFromPlainObject(objectException, syntheticException, options.isRejection);
180
+ event = eventFromPlainObject(objectException, syntheticException, isUnhandledRejection);
84
181
  utils_1.addExceptionMechanism(event, {
85
182
  synthetic: true,
86
183
  });
@@ -95,7 +192,7 @@ function eventFromUnknownInput(exception, syntheticException, options) {
95
192
  // - a plain Object
96
193
  //
97
194
  // So bail out and capture it as a simple message:
98
- event = eventFromString(exception, syntheticException, options);
195
+ event = eventFromString(exception, syntheticException, attachStacktrace);
99
196
  utils_1.addExceptionTypeValue(event, "" + exception, undefined);
100
197
  utils_1.addExceptionMechanism(event, {
101
198
  synthetic: true,
@@ -106,15 +203,14 @@ exports.eventFromUnknownInput = eventFromUnknownInput;
106
203
  /**
107
204
  * @hidden
108
205
  */
109
- function eventFromString(input, syntheticException, options) {
110
- if (options === void 0) { options = {}; }
206
+ function eventFromString(input, syntheticException, attachStacktrace) {
111
207
  var event = {
112
208
  message: input,
113
209
  };
114
- if (options.attachStacktrace && syntheticException) {
115
- var frames_1 = parsers_1.parseStackFrames(syntheticException);
116
- if (frames_1.length) {
117
- event.stacktrace = { frames: frames_1 };
210
+ if (attachStacktrace && syntheticException) {
211
+ var frames_2 = parseStackFrames(syntheticException);
212
+ if (frames_2.length) {
213
+ event.stacktrace = { frames: frames_2 };
118
214
  }
119
215
  }
120
216
  return event;
@@ -1 +1 @@
1
- {"version":3,"file":"eventbuilder.js","sourceRoot":"","sources":["../src/eventbuilder.ts"],"names":[],"mappings":";;AAAA,uCAAoE;AACpE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port {\n addExceptionMechanism,\n addExceptionTypeValue,\n isDOMError,\n isDOMException,\n isError,\n isErrorEvent,\n isEvent,\n isPlainObject,\n resolvedSyncPromise,\n} from '@sentry/utils';\n\nimport { eventFromError, eventFromPlainObject, parseStackFrames } from './parsers';\n\n/**\n * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.\n * @hidden\n */\nexport function eventFromException(options: Options, exception: unknown, hint?: EventHint): PromiseLike<Event> {\n const syntheticException = (hint && hint.syntheticException) || undefined;\n const event = eventFromUnknownInput(exception, syntheticException, {\n attachStacktrace: options.attachStacktrace,\n });\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 options: Options,\n message: string,\n level: Severity = Severity.Info,\n hint?: EventHint,\n): PromiseLike<Event> {\n const syntheticException = (hint && hint.syntheticException) || undefined;\n const event = eventFromString(message, syntheticException, {\n attachStacktrace: options.attachStacktrace,\n });\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 options: {\n isRejection?: boolean;\n attachStacktrace?: boolean;\n } = {},\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, options);\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 as Error)) {\n // we have a real Error object, do nothing\n return eventFromError(exception as Error);\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, options.isRejection);\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, options);\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 input: string,\n syntheticException?: Error,\n options: {\n attachStacktrace?: boolean;\n } = {},\n): Event {\n const event: Event = {\n message: input,\n };\n\n if (options.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","sourceRoot":"","sources":["../src/eventbuilder.ts"],"names":[],"mappings":";;AAAA,uCAAkF;AAClF,uCAauB;AAEvB,iDAM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Hint, 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 as Error)) {\n // we have a real Error object, do nothing\n return eventFromError(exception as Error);\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"]}
package/dist/helpers.js CHANGED
@@ -133,13 +133,13 @@ function injectReportDialog(options) {
133
133
  }
134
134
  if (!options.eventId) {
135
135
  if (utils_1.isDebugBuild()) {
136
- utils_1.logger.error("Missing eventId option in showReportDialog call");
136
+ utils_1.logger.error('Missing eventId option in showReportDialog call');
137
137
  }
138
138
  return;
139
139
  }
140
140
  if (!options.dsn) {
141
141
  if (utils_1.isDebugBuild()) {
142
- utils_1.logger.error("Missing dsn option in showReportDialog call");
142
+ utils_1.logger.error('Missing dsn option in showReportDialog call');
143
143
  }
144
144
  return;
145
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;AAAA,qCAAoF;AAEpF,uCASuB;AAEvB,IAAM,MAAM,GAAG,uBAAe,EAAU,CAAC;AACzC,IAAI,aAAa,GAAW,CAAC,CAAC;AAE9B;;GAEG;AACH,SAAgB,mBAAmB;IACjC,OAAO,aAAa,GAAG,CAAC,CAAC;AAC3B,CAAC;AAFD,kDAEC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,2CAA2C;IAC3C,aAAa,IAAI,CAAC,CAAC;IACnB,UAAU,CAAC;QACT,aAAa,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAND,8CAMC;AAED;;;;;;;G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ACrC;IAAC,OAAO,GAAG,EAAE,GAAE;IAEhB,OAAO,aAAa,CAAC;AACvB,CAAC;AAhHD,oBAgHC;AA8BD;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,OAAiC;IAAjC,wBAAA,EAAA,YAAiC;IAClE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACpB,OAAO;KACR;IAED,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;QACpB,IAAI,oBAAY,EAAE,EAAE;YAClB,cAAM,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACjE;QACD,OAAO;KACR;IAED,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QAChB,IAAI,oBAAY,EAAE,EAAE;YAClB,cAAM,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAC7D;QACD,OAAO;KACR;IAED,IAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,GAAG,GAAG,8BAAuB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAE3D,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,6DAA6D;QAC7D,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;KAChC;IAED,IAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAEpE,IAAI,cAAc,EAAE;QAClB,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;KACpC;AACH,CAAC;AAjCD,gDAiCC","sourcesContent":["import { captureException, getReportDialogEndpoint, withScope } from '@sentry/core';\nimport { DsnLike, Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types';\nimport {\n addExceptionMechanism,\n addExceptionTypeValue,\n addNonEnumerableProperty,\n getGlobalObject,\n getOriginalFunction,\n isDebugBuild,\n logger,\n markFunctionWrapped,\n} from '@sentry/utils';\n\nconst global = getGlobalObject<Window>();\nlet ignoreOnError: number = 0;\n\n/**\n * @hidden\n */\nexport function shouldIgnoreOnError(): boolean {\n return ignoreOnError > 0;\n}\n\n/**\n * @hidden\n */\nexport function ignoreNextOnError(): void {\n // onerror should trigger before setTimeout\n ignoreOnError += 1;\n setTimeout(() => {\n ignoreOnError -= 1;\n });\n}\n\n/**\n * Instruments the given function and sends an event to Sentry every time the\n * function throws an exception.\n *\n * @param fn A function to wrap.\n * @returns The wrapped function.\n * @hidden\n */\nexport function wrap(\n fn: WrappedFunction,\n options: {\n mechanism?: Mechanism;\n } = {},\n before?: WrappedFunction,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // for future readers what this does is wrap a function and then create\n // a bi-directional wrapping between them.\n //\n // example: wrapped = wrap(original);\n // original.__sentry_wrapped__ -> wrapped\n // wrapped.__sentry_original__ -> original\n\n if (typeof fn !== 'function') {\n return fn;\n }\n\n try {\n // if we're dealing with a function that was previously wrapped, return\n // the original wrapper.\n const wrapper = fn.__sentry_wrapped__;\n if (wrapper) {\n return wrapper;\n }\n\n // We don't wanna wrap it twice\n if (getOriginalFunction(fn)) {\n return fn;\n }\n } catch (e) {\n // Just accessing custom props in some Selenium environments\n // can cause a \"Permission denied\" exception (see raven-js#495).\n // Bail on wrapping and return the function as-is (defers to window.onerror).\n return fn;\n }\n\n /* eslint-disable prefer-rest-params */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sentryWrapped: WrappedFunction = function (this: any): void {\n const args = Array.prototype.slice.call(arguments);\n\n try {\n if (before && typeof before === 'function') {\n before.apply(this, arguments);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n const wrappedArguments = args.map((arg: any) => wrap(arg, options));\n\n // Attempt to invoke user-land function\n // NOTE: If you are a Sentry user, and you are seeing this stack frame, it\n // means the sentry.javascript SDK caught an error invoking your application code. This\n // is expected behavior and NOT indicative of a bug with sentry.javascript.\n return fn.apply(this, wrappedArguments);\n } catch (ex) {\n ignoreNextOnError();\n\n withScope((scope: Scope) => {\n scope.addEventProcessor((event: SentryEvent) => {\n if (options.mechanism) {\n addExceptionTypeValue(event, undefined, undefined);\n addExceptionMechanism(event, options.mechanism);\n }\n\n event.extra = {\n ...event.extra,\n arguments: args,\n };\n\n return event;\n });\n\n captureException(ex);\n });\n\n throw ex;\n }\n };\n /* eslint-enable prefer-rest-params */\n\n // Accessing some objects may throw\n // ref: https://github.com/getsentry/sentry-javascript/issues/1168\n try {\n for (const property in fn) {\n if (Object.prototype.hasOwnProperty.call(fn, property)) {\n sentryWrapped[property] = fn[property];\n }\n }\n } catch (_oO) {} // eslint-disable-line no-empty\n\n // Signal that this function has been wrapped/filled already\n // for both debugging and to prevent it to being wrapped/filled twice\n markFunctionWrapped(sentryWrapped, fn);\n\n addNonEnumerableProperty(fn, '__sentry_wrapped__', sentryWrapped);\n\n // Restore original function name (not all browsers allow that)\n try {\n const descriptor = Object.getOwnPropertyDescriptor(sentryWrapped, 'name') as PropertyDescriptor;\n if (descriptor.configurable) {\n Object.defineProperty(sentryWrapped, 'name', {\n get(): string {\n return fn.name;\n },\n });\n }\n // eslint-disable-next-line no-empty\n } catch (_oO) {}\n\n return sentryWrapped;\n}\n\n/**\n * All properties the report dialog supports\n */\nexport interface ReportDialogOptions {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n eventId?: string;\n dsn?: DsnLike;\n user?: {\n email?: string;\n name?: string;\n };\n lang?: string;\n title?: string;\n subtitle?: string;\n subtitle2?: string;\n labelName?: string;\n labelEmail?: string;\n labelComments?: string;\n labelClose?: string;\n labelSubmit?: string;\n errorGeneric?: string;\n errorFormEntry?: string;\n successMessage?: string;\n /** Callback after reportDialog showed up */\n onLoad?(): void;\n}\n\n/**\n * Injects the Report Dialog script\n * @hidden\n */\nexport function injectReportDialog(options: ReportDialogOptions = {}): void {\n if (!global.document) {\n return;\n }\n\n if (!options.eventId) {\n if (isDebugBuild()) {\n logger.error(`Missing eventId option in showReportDialog call`);\n }\n return;\n }\n\n if (!options.dsn) {\n if (isDebugBuild()) {\n logger.error(`Missing dsn option in showReportDialog call`);\n }\n return;\n }\n\n const script = global.document.createElement('script');\n script.async = true;\n script.src = getReportDialogEndpoint(options.dsn, options);\n\n if (options.onLoad) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n script.onload = options.onLoad;\n }\n\n const injectionPoint = global.document.head || global.document.body;\n\n if (injectionPoint) {\n injectionPoint.appendChild(script);\n }\n}\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;AAAA,qCAAoF;AAEpF,uCASuB;AAEvB,IAAM,MAAM,GAAG,uBAAe,EAAU,CAAC;AACzC,IAAI,aAAa,GAAW,CAAC,CAAC;AAE9B;;GAEG;AACH,SAAgB,mBAAmB;IACjC,OAAO,aAAa,GAAG,CAAC,CAAC;AAC3B,CAAC;AAFD,kDAEC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,2CAA2C;IAC3C,aAAa,IAAI,CAAC,CAAC;IACnB,UAAU,CAAC;QACT,aAAa,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAND,8CAMC;AAED;;;;;;;GAOG;AACH,SAAgB,IAAI,CAClB,EAAmB,EACnB,OAEM,EACN,MAAwB;IAGxB,uEAAuE;IACvE,0CAA0C;IAC1C,EAAE;IACF,qCAAqC;IACrC,0CAA0C;IAC1C,2CAA2C;IAX3C,wBAAA,EAAA,YAEM;IAWN,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;QAC5B,OAAO,EAAE,CAAC;KACX;IAED,IAAI;QACF,uEAAuE;QACvE,wBAAwB;QACxB,IAAM,OAAO,GAAG,EAAE,CAAC,kBAAkB,CAAC;QACtC,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC;SAChB;QAED,+BA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C,GAAG,EAAE;QAChB,IAAI,oBAAY,EAAE,EAAE;YAClB,cAAM,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAC7D;QACD,OAAO;KACR;IAED,IAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,GAAG,GAAG,8BAAuB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAE3D,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,6DAA6D;QAC7D,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;KAChC;IAED,IAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAEpE,IAAI,cAAc,EAAE;QAClB,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;KACpC;AACH,CAAC;AAjCD,gDAiCC","sourcesContent":["import { captureException, getReportDialogEndpoint, withScope } from '@sentry/core';\nimport { DsnLike, Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types';\nimport {\n addExceptionMechanism,\n addExceptionTypeValue,\n addNonEnumerableProperty,\n getGlobalObject,\n getOriginalFunction,\n isDebugBuild,\n logger,\n markFunctionWrapped,\n} from '@sentry/utils';\n\nconst global = getGlobalObject<Window>();\nlet ignoreOnError: number = 0;\n\n/**\n * @hidden\n */\nexport function shouldIgnoreOnError(): boolean {\n return ignoreOnError > 0;\n}\n\n/**\n * @hidden\n */\nexport function ignoreNextOnError(): void {\n // onerror should trigger before setTimeout\n ignoreOnError += 1;\n setTimeout(() => {\n ignoreOnError -= 1;\n });\n}\n\n/**\n * Instruments the given function and sends an event to Sentry every time the\n * function throws an exception.\n *\n * @param fn A function to wrap.\n * @returns The wrapped function.\n * @hidden\n */\nexport function wrap(\n fn: WrappedFunction,\n options: {\n mechanism?: Mechanism;\n } = {},\n before?: WrappedFunction,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // for future readers what this does is wrap a function and then create\n // a bi-directional wrapping between them.\n //\n // example: wrapped = wrap(original);\n // original.__sentry_wrapped__ -> wrapped\n // wrapped.__sentry_original__ -> original\n\n if (typeof fn !== 'function') {\n return fn;\n }\n\n try {\n // if we're dealing with a function that was previously wrapped, return\n // the original wrapper.\n const wrapper = fn.__sentry_wrapped__;\n if (wrapper) {\n return wrapper;\n }\n\n // We don't wanna wrap it twice\n if (getOriginalFunction(fn)) {\n return fn;\n }\n } catch (e) {\n // Just accessing custom props in some Selenium environments\n // can cause a \"Permission denied\" exception (see raven-js#495).\n // Bail on wrapping and return the function as-is (defers to window.onerror).\n return fn;\n }\n\n /* eslint-disable prefer-rest-params */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sentryWrapped: WrappedFunction = function (this: any): void {\n const args = Array.prototype.slice.call(arguments);\n\n try {\n if (before && typeof before === 'function') {\n before.apply(this, arguments);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n const wrappedArguments = args.map((arg: any) => wrap(arg, options));\n\n // Attempt to invoke user-land function\n // NOTE: If you are a Sentry user, and you are seeing this stack frame, it\n // means the sentry.javascript SDK caught an error invoking your application code. This\n // is expected behavior and NOT indicative of a bug with sentry.javascript.\n return fn.apply(this, wrappedArguments);\n } catch (ex) {\n ignoreNextOnError();\n\n withScope((scope: Scope) => {\n scope.addEventProcessor((event: SentryEvent) => {\n if (options.mechanism) {\n addExceptionTypeValue(event, undefined, undefined);\n addExceptionMechanism(event, options.mechanism);\n }\n\n event.extra = {\n ...event.extra,\n arguments: args,\n };\n\n return event;\n });\n\n captureException(ex);\n });\n\n throw ex;\n }\n };\n /* eslint-enable prefer-rest-params */\n\n // Accessing some objects may throw\n // ref: https://github.com/getsentry/sentry-javascript/issues/1168\n try {\n for (const property in fn) {\n if (Object.prototype.hasOwnProperty.call(fn, property)) {\n sentryWrapped[property] = fn[property];\n }\n }\n } catch (_oO) {} // eslint-disable-line no-empty\n\n // Signal that this function has been wrapped/filled already\n // for both debugging and to prevent it to being wrapped/filled twice\n markFunctionWrapped(sentryWrapped, fn);\n\n addNonEnumerableProperty(fn, '__sentry_wrapped__', sentryWrapped);\n\n // Restore original function name (not all browsers allow that)\n try {\n const descriptor = Object.getOwnPropertyDescriptor(sentryWrapped, 'name') as PropertyDescriptor;\n if (descriptor.configurable) {\n Object.defineProperty(sentryWrapped, 'name', {\n get(): string {\n return fn.name;\n },\n });\n }\n // eslint-disable-next-line no-empty\n } catch (_oO) {}\n\n return sentryWrapped;\n}\n\n/**\n * All properties the report dialog supports\n */\nexport interface ReportDialogOptions {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n eventId?: string;\n dsn?: DsnLike;\n user?: {\n email?: string;\n name?: string;\n };\n lang?: string;\n title?: string;\n subtitle?: string;\n subtitle2?: string;\n labelName?: string;\n labelEmail?: string;\n labelComments?: string;\n labelClose?: string;\n labelSubmit?: string;\n errorGeneric?: string;\n errorFormEntry?: string;\n successMessage?: string;\n /** Callback after reportDialog showed up */\n onLoad?(): void;\n}\n\n/**\n * Injects the Report Dialog script\n * @hidden\n */\nexport function injectReportDialog(options: ReportDialogOptions = {}): void {\n if (!global.document) {\n return;\n }\n\n if (!options.eventId) {\n if (isDebugBuild()) {\n logger.error('Missing eventId option in showReportDialog call');\n }\n return;\n }\n\n if (!options.dsn) {\n if (isDebugBuild()) {\n logger.error('Missing dsn option in showReportDialog call');\n }\n return;\n }\n\n const script = global.document.createElement('script');\n script.async = true;\n script.src = getReportDialogEndpoint(options.dsn, options);\n\n if (options.onLoad) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n script.onload = options.onLoad;\n }\n\n const injectionPoint = global.document.head || global.document.body;\n\n if (injectionPoint) {\n injectionPoint.appendChild(script);\n }\n}\n"]}
@@ -18,7 +18,7 @@ var Dedupe = /** @class */ (function () {
18
18
  // Juuust in case something goes wrong
19
19
  try {
20
20
  if (_shouldDropEvent(currentEvent, self._previousEvent)) {
21
- utils_1.logger.warn("Event dropped due to being a duplicate of previously captured event.");
21
+ utils_1.logger.warn('Event dropped due to being a duplicate of previously captured event.');
22
22
  return null;
23
23
  }
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dedupe.js","sourceRoot":"","sources":["../../src/integrations/dedupe.ts"],"names":[],"mappings":";AACA,uCAAuC;AAEvC,2BAA2B;AAC3B;IAAA;QAME;;WAEG;QACI,SAAI,GAAW,MAAM,CAAC,EAAE,CAAC;IA6BlC,CAAC;IAtBC;;OAEG;IACI,0BAAS,GAAhB,UAAiB,uBAA2D,EAAE,aAAwB;QACpG,uBAAuB,CAAC,UAAC,YAAmB;YAC1C,IAAM,IAAI,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACpD,IAAI,IAAI,EAAE;gBACR,sCAAsC;gBACtC,IAAI;oBACF,IAAI,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE;wBACvD,cAAM,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;wBACpF,OAAO,IAAI,CAAC;qBACb;iBACF;gBAAC,OAAO,GAAG,EAAE;oBACZ,OAAO,CAAC,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,CAAC;iBAC7C;gBAED,OAAO,CAAC,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,CAAC;aAC7C;YACD,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IApCD;;OAEG;IACW,SAAE,GAAW,QAAQ,CAAC;IAkCtC,aAAC;CAAA,AAtCD,IAsCC;AAtCY,wBAAM;AAwCnB,YAAY;AACZ,SAAS,gBAAgB,CAAC,YAAmB,EAAE,aAAqB;IAClE,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,KAAK,CAAC;KACd;IAED,IAAI,mBAAmB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ACF;SAAM,IAAI,KAAK,CAAC,UAAU,EAAE;QAC3B,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;KAChC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { Event, EventProcessor, Exception, Hub, Integration, StackFrame } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\n/** Deduplication filter */\nexport class Dedupe implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Dedupe';\n\n /**\n * @inheritDoc\n */\n public name: string = Dedupe.id;\n\n /**\n * @inheritDoc\n */\n private _previousEvent?: Event;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {\n addGlobalEventProcessor((currentEvent: Event) => {\n const self = getCurrentHub().getIntegration(Dedupe);\n if (self) {\n // Juuust in case something goes wrong\n try {\n if (_shouldDropEvent(currentEvent, self._previousEvent)) {\n logger.warn(`Event dropped due to being a duplicate of previously captured event.`);\n return null;\n }\n } catch (_oO) {\n return (self._previousEvent = currentEvent);\n }\n\n return (self._previousEvent = currentEvent);\n }\n return currentEvent;\n });\n }\n}\n\n/** JSDoc */\nfunction _shouldDropEvent(currentEvent: Event, previousEvent?: Event): boolean {\n if (!previousEvent) {\n return false;\n }\n\n if (_isSameMessageEvent(currentEvent, previousEvent)) {\n return true;\n }\n\n if (_isSameExceptionEvent(currentEvent, previousEvent)) {\n return true;\n }\n\n return false;\n}\n\n/** JSDoc */\nfunction _isSameMessageEvent(currentEvent: Event, previousEvent: Event): boolean {\n const currentMessage = currentEvent.message;\n const previousMessage = previousEvent.message;\n\n // If neither event has a message property, they were both exceptions, so bail out\n if (!currentMessage && !previousMessage) {\n return false;\n }\n\n // If only one event has a stacktrace, but not the other one, they are not the same\n if ((currentMessage && !previousMessage) || (!currentMessage && previousMessage)) {\n return false;\n }\n\n if (currentMessage !== previousMessage) {\n return false;\n }\n\n if (!_isSameFingerprint(currentEvent, previousEvent)) {\n return false;\n }\n\n if (!_isSameStacktrace(currentEvent, previousEvent)) {\n return false;\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameExceptionEvent(currentEvent: Event, previousEvent: Event): boolean {\n const previousException = _getExceptionFromEvent(previousEvent);\n const currentException = _getExceptionFromEvent(currentEvent);\n\n if (!previousException || !currentException) {\n return false;\n }\n\n if (previousException.type !== currentException.type || previousException.value !== currentException.value) {\n return false;\n }\n\n if (!_isSameFingerprint(currentEvent, previousEvent)) {\n return false;\n }\n\n if (!_isSameStacktrace(currentEvent, previousEvent)) {\n return false;\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameStacktrace(currentEvent: Event, previousEvent: Event): boolean {\n let currentFrames = _getFramesFromEvent(currentEvent);\n let previousFrames = _getFramesFromEvent(previousEvent);\n\n // If neither event has a stacktrace, they are assumed to be the same\n if (!currentFrames && !previousFrames) {\n return true;\n }\n\n // If only one event has a stacktrace, but not the other one, they are not the same\n if ((currentFrames && !previousFrames) || (!currentFrames && previousFrames)) {\n return false;\n }\n\n currentFrames = currentFrames as StackFrame[];\n previousFrames = previousFrames as StackFrame[];\n\n // If number of frames differ, they are not the same\n if (previousFrames.length !== currentFrames.length) {\n return false;\n }\n\n // Otherwise, compare the two\n for (let i = 0; i < previousFrames.length; i++) {\n const frameA = previousFrames[i];\n const frameB = currentFrames[i];\n\n if (\n frameA.filename !== frameB.filename ||\n frameA.lineno !== frameB.lineno ||\n frameA.colno !== frameB.colno ||\n frameA.function !== frameB.function\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameFingerprint(currentEvent: Event, previousEvent: Event): boolean {\n let currentFingerprint = currentEvent.fingerprint;\n let previousFingerprint = previousEvent.fingerprint;\n\n // If neither event has a fingerprint, they are assumed to be the same\n if (!currentFingerprint && !previousFingerprint) {\n return true;\n }\n\n // If only one event has a fingerprint, but not the other one, they are not the same\n if ((currentFingerprint && !previousFingerprint) || (!currentFingerprint && previousFingerprint)) {\n return false;\n }\n\n currentFingerprint = currentFingerprint as string[];\n previousFingerprint = previousFingerprint as string[];\n\n // Otherwise, compare the two\n try {\n return !!(currentFingerprint.join('') === previousFingerprint.join(''));\n } catch (_oO) {\n return false;\n }\n}\n\n/** JSDoc */\nfunction _getExceptionFromEvent(event: Event): Exception | undefined {\n return event.exception && event.exception.values && event.exception.values[0];\n}\n\n/** JSDoc */\nfunction _getFramesFromEvent(event: Event): StackFrame[] | undefined {\n const exception = event.exception;\n\n if (exception) {\n try {\n // @ts-ignore Object could be undefined\n return exception.values[0].stacktrace.frames;\n } catch (_oO) {\n return undefined;\n }\n } else if (event.stacktrace) {\n return event.stacktrace.frames;\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"dedupe.js","sourceRoot":"","sources":["../../src/integrations/dedupe.ts"],"names":[],"mappings":";AACA,uCAAuC;AAEvC,2BAA2B;AAC3B;IAAA;QAME;;WAEG;QACI,SAAI,GAAW,MAAM,CAAC,EAAE,CAAC;IA6BlC,CAAC;IAtBC;;OAEG;IACI,0BAAS,GAAhB,UAAiB,uBAA2D,EAAE,aAAwB;QACpG,uBAAuB,CAAC,UAAC,YAAmB;YAC1C,IAAM,IAAI,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACpD,IAAI,IAAI,EAAE;gBACR,sCAAsC;gBACtC,IAAI;oBACF,IAAI,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE;wBACvD,cAAM,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;wBACpF,OAAO,IAAI,CAAC;qBACb;iBACF;gBAAC,OAAO,GAAG,EAAE;oBACZ,OAAO,CAAC,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,CAAC;iBAC7C;gBAED,OAAO,CAAC,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,CAAC;aAC7C;YACD,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IApCD;;OAEG;IACW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,KAAK,CAAC,SAAS,CAAC;IAElC,IAAI,SAAS,EAAE;QACb,IAAI;YACF,uCAAuC;YACvC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;SAC9C;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,SAAS,CAAC;SAClB;KACF;SAAM,IAAI,KAAK,CAAC,UAAU,EAAE;QAC3B,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;KAChC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { Event, EventProcessor, Exception, Hub, Integration, StackFrame } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\n/** Deduplication filter */\nexport class Dedupe implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Dedupe';\n\n /**\n * @inheritDoc\n */\n public name: string = Dedupe.id;\n\n /**\n * @inheritDoc\n */\n private _previousEvent?: Event;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {\n addGlobalEventProcessor((currentEvent: Event) => {\n const self = getCurrentHub().getIntegration(Dedupe);\n if (self) {\n // Juuust in case something goes wrong\n try {\n if (_shouldDropEvent(currentEvent, self._previousEvent)) {\n logger.warn('Event dropped due to being a duplicate of previously captured event.');\n return null;\n }\n } catch (_oO) {\n return (self._previousEvent = currentEvent);\n }\n\n return (self._previousEvent = currentEvent);\n }\n return currentEvent;\n });\n }\n}\n\n/** JSDoc */\nfunction _shouldDropEvent(currentEvent: Event, previousEvent?: Event): boolean {\n if (!previousEvent) {\n return false;\n }\n\n if (_isSameMessageEvent(currentEvent, previousEvent)) {\n return true;\n }\n\n if (_isSameExceptionEvent(currentEvent, previousEvent)) {\n return true;\n }\n\n return false;\n}\n\n/** JSDoc */\nfunction _isSameMessageEvent(currentEvent: Event, previousEvent: Event): boolean {\n const currentMessage = currentEvent.message;\n const previousMessage = previousEvent.message;\n\n // If neither event has a message property, they were both exceptions, so bail out\n if (!currentMessage && !previousMessage) {\n return false;\n }\n\n // If only one event has a stacktrace, but not the other one, they are not the same\n if ((currentMessage && !previousMessage) || (!currentMessage && previousMessage)) {\n return false;\n }\n\n if (currentMessage !== previousMessage) {\n return false;\n }\n\n if (!_isSameFingerprint(currentEvent, previousEvent)) {\n return false;\n }\n\n if (!_isSameStacktrace(currentEvent, previousEvent)) {\n return false;\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameExceptionEvent(currentEvent: Event, previousEvent: Event): boolean {\n const previousException = _getExceptionFromEvent(previousEvent);\n const currentException = _getExceptionFromEvent(currentEvent);\n\n if (!previousException || !currentException) {\n return false;\n }\n\n if (previousException.type !== currentException.type || previousException.value !== currentException.value) {\n return false;\n }\n\n if (!_isSameFingerprint(currentEvent, previousEvent)) {\n return false;\n }\n\n if (!_isSameStacktrace(currentEvent, previousEvent)) {\n return false;\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameStacktrace(currentEvent: Event, previousEvent: Event): boolean {\n let currentFrames = _getFramesFromEvent(currentEvent);\n let previousFrames = _getFramesFromEvent(previousEvent);\n\n // If neither event has a stacktrace, they are assumed to be the same\n if (!currentFrames && !previousFrames) {\n return true;\n }\n\n // If only one event has a stacktrace, but not the other one, they are not the same\n if ((currentFrames && !previousFrames) || (!currentFrames && previousFrames)) {\n return false;\n }\n\n currentFrames = currentFrames as StackFrame[];\n previousFrames = previousFrames as StackFrame[];\n\n // If number of frames differ, they are not the same\n if (previousFrames.length !== currentFrames.length) {\n return false;\n }\n\n // Otherwise, compare the two\n for (let i = 0; i < previousFrames.length; i++) {\n const frameA = previousFrames[i];\n const frameB = currentFrames[i];\n\n if (\n frameA.filename !== frameB.filename ||\n frameA.lineno !== frameB.lineno ||\n frameA.colno !== frameB.colno ||\n frameA.function !== frameB.function\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/** JSDoc */\nfunction _isSameFingerprint(currentEvent: Event, previousEvent: Event): boolean {\n let currentFingerprint = currentEvent.fingerprint;\n let previousFingerprint = previousEvent.fingerprint;\n\n // If neither event has a fingerprint, they are assumed to be the same\n if (!currentFingerprint && !previousFingerprint) {\n return true;\n }\n\n // If only one event has a fingerprint, but not the other one, they are not the same\n if ((currentFingerprint && !previousFingerprint) || (!currentFingerprint && previousFingerprint)) {\n return false;\n }\n\n currentFingerprint = currentFingerprint as string[];\n previousFingerprint = previousFingerprint as string[];\n\n // Otherwise, compare the two\n try {\n return !!(currentFingerprint.join('') === previousFingerprint.join(''));\n } catch (_oO) {\n return false;\n }\n}\n\n/** JSDoc */\nfunction _getExceptionFromEvent(event: Event): Exception | undefined {\n return event.exception && event.exception.values && event.exception.values[0];\n}\n\n/** JSDoc */\nfunction _getFramesFromEvent(event: Event): StackFrame[] | undefined {\n const exception = event.exception;\n\n if (exception) {\n try {\n // @ts-ignore Object could be undefined\n return exception.values[0].stacktrace.frames;\n } catch (_oO) {\n return undefined;\n }\n } else if (event.stacktrace) {\n return event.stacktrace.frames;\n }\n return undefined;\n}\n"]}
@@ -64,10 +64,7 @@ function _installGlobalOnErrorHandler() {
64
64
  }
65
65
  var event = error === undefined && utils_1.isString(msg)
66
66
  ? _eventFromIncompleteOnError(msg, url, line, column)
67
- : _enhanceEventWithInitialFrame(eventbuilder_1.eventFromUnknownInput(error || msg, undefined, {
68
- attachStacktrace: attachStacktrace,
69
- isRejection: false,
70
- }), url, line, column);
67
+ : _enhanceEventWithInitialFrame(eventbuilder_1.eventFromUnknownInput(error || msg, undefined, attachStacktrace, false), url, line, column);
71
68
  event.level = types_1.Severity.Error;
72
69
  addMechanismAndCapture(hub, error, event, 'onerror');
73
70
  });
@@ -106,10 +103,7 @@ function _installGlobalOnUnhandledRejectionHandler() {
106
103
  }
107
104
  var event = utils_1.isPrimitive(error)
108
105
  ? _eventFromRejectionWithPrimitive(error)
109
- : eventbuilder_1.eventFromUnknownInput(error, undefined, {
110
- attachStacktrace: attachStacktrace,
111
- isRejection: true,
112
- });
106
+ : eventbuilder_1.eventFromUnknownInput(error, undefined, attachStacktrace, true);
113
107
  event.level = types_1.Severity.Error;
114
108
  addMechanismAndCapture(hub, error, event, 'onunhandledrejection');
115
109
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"globalhandlers.js","sourceRoot":"","sources":["../../src/integrations/globalhandlers.ts"],"names":[],"mappings":";;AAAA,+DAA+D;AAC/D,qCAA6C;AAC7C,uCAAwF;AACxF,uCASuB;AAEvB,gDAAwD;AACxD,sCAAiD;AAOjD,sBAAsB;AACtB;IAuBE,YAAY;IACZ,wBAAmB,OAAoC;QAlBvD;;WAEG;QACI,SAAI,GAAW,cAAc,CAAC,EAAE,CAAC;QAKxC;;;WAGG;QACK,iBAAY,GAA2E;YAC7F,OAAO,EAAE,4BAA4B;YACrC,oBAAoB,EAAE,yCAAyC;SAChE,CAAC;QAIA,IAAI,CAAC,QAAQ,sBACX,OAAO,EAAE,IAAI,EACb,oBAAoB,EAAE,IAAI,IACvB,OAAO,CACX,CAAC;IACJ,CAAC;IACD;;OAEG;IACI,kCAAS,GAAhB;QACE,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;QAC3B,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE9B,2FAA2F;QAC3F,wCAAwC;QACxC,wCAAwC;QACxC,KAAK,IAAM,GAAG,IAAI,OAAO,EAAE;YACzB,IAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,GAA2C,CAAC,CAAC;YACnF,IAAI,WAAW,IAAI,OAAO,CAAC,GAA2C,CAAC,EAAE;gBACvE,gBAAgB,CAAC,GAAG,CAAC,CAAC;gBACtB,WAAW,EAAE,CAAC;gBACd,IAAI,CAAC,YAAY,CAAC,GAA2C,CAAC,GAAG,SAAS,CAAC;aAC5E;SACF;IACH,CAAC;IAhDD;;OAEG;IACW,iBAAE,GAAW,gBAAgB,CAAC;IA8C9C,qBAAC;CAAA,AAlDD,IAkDC;AAlDY,wCAAc;AAoD3B,YAAY;AACZ,SAA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AAE,CAAC,gBAAgB,CAAC;IACxE,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;AACjC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport { getCurrentHub } from '@sentry/core';\nimport { Event, EventHint, Hub, Integration, Primitive, Severity } from '@sentry/types';\nimport {\n addExceptionMechanism,\n addInstrumentationHandler,\n getLocationHref,\n isDebugBuild,\n isErrorEvent,\n isPrimitive,\n isString,\n logger,\n} from '@sentry/utils';\n\nimport { eventFromUnknownInput } from '../eventbuilder';\nimport { shouldIgnoreOnError } from '../helpers';\n\ntype GlobalHandlersIntegrationsOptionKeys = 'onerror' | 'onunhandledrejection';\n\n/** JSDoc */\ntype GlobalHandlersIntegrations = Record<GlobalHandlersIntegrationsOptionKeys, boolean>;\n\n/** Global handlers */\nexport class GlobalHandlers implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'GlobalHandlers';\n\n /**\n * @inheritDoc\n */\n public name: string = GlobalHandlers.id;\n\n /** JSDoc */\n private readonly _options: GlobalHandlersIntegrations;\n\n /**\n * Stores references functions to installing handlers. Will set to undefined\n * after they have been run so that they are not used twice.\n */\n private _installFunc: Record<GlobalHandlersIntegrationsOptionKeys, (() => void) | undefined> = {\n onerror: _installGlobalOnErrorHandler,\n onunhandledrejection: _installGlobalOnUnhandledRejectionHandler,\n };\n\n /** JSDoc */\n public constructor(options?: GlobalHandlersIntegrations) {\n this._options = {\n onerror: true,\n onunhandledrejection: true,\n ...options,\n };\n }\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n Error.stackTraceLimit = 50;\n const options = this._options;\n\n // We can disable guard-for-in as we construct the options object above + do checks against\n // `this._installFunc` for the property.\n // eslint-disable-next-line guard-for-in\n for (const key in options) {\n const installFunc = this._installFunc[key as GlobalHandlersIntegrationsOptionKeys];\n if (installFunc && options[key as GlobalHandlersIntegrationsOptionKeys]) {\n globalHandlerLog(key);\n installFunc();\n this._installFunc[key as GlobalHandlersIntegrationsOptionKeys] = undefined;\n }\n }\n }\n}\n\n/** JSDoc */\nfunction _installGlobalOnErrorHandler(): void {\n addInstrumentationHandler(\n 'error',\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (data: { msg: any; url: any; line: any; column: any; error: any }) => {\n const [hub, attachStacktrace] = getHubAndAttachStacktrace();\n if (!hub.getIntegration(GlobalHandlers)) {\n return;\n }\n const { msg, url, line, column, error } = data;\n if (shouldIgnoreOnError() || (error && error.__sentry_own_request__)) {\n return;\n }\n\n const event =\n error === undefined && isString(msg)\n ? _eventFromIncompleteOnError(msg, url, line, column)\n : _enhanceEventWithInitialFrame(\n eventFromUnknownInput(error || msg, undefined, {\n attachStacktrace,\n isRejection: false,\n }),\n url,\n line,\n column,\n );\n\n event.level = Severity.Error;\n\n addMechanismAndCapture(hub, error, event, 'onerror');\n },\n );\n}\n\n/** JSDoc */\nfunction _installGlobalOnUnhandledRejectionHandler(): void {\n addInstrumentationHandler(\n 'unhandledrejection',\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (e: any) => {\n const [hub, attachStacktrace] = getHubAndAttachStacktrace();\n if (!hub.getIntegration(GlobalHandlers)) {\n return;\n }\n let error = e;\n\n // dig the object of the rejection out of known event types\n try {\n // PromiseRejectionEvents store the object of the rejection under 'reason'\n // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent\n if ('reason' in e) {\n error = e.reason;\n }\n // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents\n // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into\n // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec\n // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and\n // https://github.com/getsentry/sentry-javascript/issues/2380\n else if ('detail' in e && 'reason' in e.detail) {\n error = e.detail.reason;\n }\n } catch (_oO) {\n // no-empty\n }\n\n if (shouldIgnoreOnError() || (error && error.__sentry_own_request__)) {\n return true;\n }\n\n const event = isPrimitive(error)\n ? _eventFromRejectionWithPrimitive(error)\n : eventFromUnknownInput(error, undefined, {\n attachStacktrace,\n isRejection: true,\n });\n\n event.level = Severity.Error;\n\n addMechanismAndCapture(hub, error, event, 'onunhandledrejection');\n return;\n },\n );\n}\n\n/**\n * Create an event from a promise rejection where the `reason` is a primitive.\n *\n * @param reason: The `reason` property of the promise rejection\n * @returns An Event object with an appropriate `exception` value\n */\nfunction _eventFromRejectionWithPrimitive(reason: Primitive): Event {\n return {\n exception: {\n values: [\n {\n type: 'UnhandledRejection',\n // String() is needed because the Primitive type includes symbols (which can't be automatically stringified)\n value: `Non-Error promise rejection captured with value: ${String(reason)}`,\n },\n ],\n },\n };\n}\n\n/**\n * This function creates a stack from an old, error-less onerror handler.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _eventFromIncompleteOnError(msg: any, url: any, line: any, column: any): Event {\n const ERROR_TYPES_RE =\n /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;\n\n // If 'message' is ErrorEvent, get real message from inside\n let message = isErrorEvent(msg) ? msg.message : msg;\n let name = 'Error';\n\n const groups = message.match(ERROR_TYPES_RE);\n if (groups) {\n name = groups[1];\n message = groups[2];\n }\n\n const event = {\n exception: {\n values: [\n {\n type: name,\n value: message,\n },\n ],\n },\n };\n\n return _enhanceEventWithInitialFrame(event, url, line, column);\n}\n\n/** JSDoc */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column: any): Event {\n // event.exception\n const e = (event.exception = event.exception || {});\n // event.exception.values\n const ev = (e.values = e.values || []);\n // event.exception.values[0]\n const ev0 = (ev[0] = ev[0] || {});\n // event.exception.values[0].stacktrace\n const ev0s = (ev0.stacktrace = ev0.stacktrace || {});\n // event.exception.values[0].stacktrace.frames\n const ev0sf = (ev0s.frames = ev0s.frames || []);\n\n const colno = isNaN(parseInt(column, 10)) ? undefined : column;\n const lineno = isNaN(parseInt(line, 10)) ? undefined : line;\n const filename = isString(url) && url.length > 0 ? url : getLocationHref();\n\n // event.exception.values[0].stacktrace.frames\n if (ev0sf.length === 0) {\n ev0sf.push({\n colno,\n filename,\n function: '?',\n in_app: true,\n lineno,\n });\n }\n\n return event;\n}\n\nfunction globalHandlerLog(type: string): void {\n if (isDebugBuild()) {\n logger.log(`Global Handler attached: ${type}`);\n }\n}\n\nfunction addMechanismAndCapture(hub: Hub, error: EventHint['originalException'], event: Event, type: string): void {\n addExceptionMechanism(event, {\n handled: false,\n type,\n });\n hub.captureEvent(event, {\n originalException: error,\n });\n}\n\nfunction getHubAndAttachStacktrace(): [Hub, boolean | undefined] {\n const hub = getCurrentHub();\n const client = hub.getClient();\n const attachStacktrace = client && client.getOptions().attachStacktrace;\n return [hub, attachStacktrace];\n}\n"]}
1
+ {"version":3,"file":"globalhandlers.js","sourceRoot":"","sources":["../../src/integrations/globalhandlers.ts"],"names":[],"mappings":";;AAAA,+DAA+D;AAC/D,qCAA6C;AAC7C,uCAAwF;AACxF,uCASuB;AAEvB,gDAAwD;AACxD,sCAAiD;AAOjD,sBAAsB;AACtB;IAuBE,YAAY;IACZ,wBAAmB,OAAoC;QAlBvD;;WAEG;QACI,SAAI,GAAW,cAAc,CAAC,EAAE,CAAC;QAKxC;;;WAGG;QACK,iBAAY,GAA2E;YAC7F,OAAO,EAAE,4BAA4B;YACrC,oBAAoB,EAAE,yCAAyC;SAChE,CAAC;QAIA,IAAI,CAAC,QAAQ,sBACX,OAAO,EAAE,IAAI,EACb,oBAAoB,EAAE,IAAI,IACvB,OAAO,CACX,CAAC;IACJ,CAAC;IACD;;OAEG;IACI,kCAAS,GAAhB;QACE,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;QAC3B,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE9B,2FAA2F;QAC3F,wCAAwC;QACxC,wCAAwC;QACxC,KAAK,IAAM,GAAG,IAAI,OAAO,EAAE;YACzB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AO,EAAE,KAAK;QACd,IAAI,MAAA;KACL,CAAC,CAAC;IACH,GAAG,CAAC,YAAY,CAAC,KAAK,EAAE;QACtB,iBAAiB,EAAE,KAAK;KACzB,CAAC,CAAC;AACL,CAAC;AAED,SAAS,yBAAyB;IAChC,IAAM,GAAG,GAAG,oBAAa,EAAE,CAAC;IAC5B,IAAM,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC;IAC/B,IAAM,gBAAgB,GAAG,MAAM,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC,gBAAgB,CAAC;IACxE,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;AACjC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport { getCurrentHub } from '@sentry/core';\nimport { Event, EventHint, Hub, Integration, Primitive, Severity } from '@sentry/types';\nimport {\n addExceptionMechanism,\n addInstrumentationHandler,\n getLocationHref,\n isDebugBuild,\n isErrorEvent,\n isPrimitive,\n isString,\n logger,\n} from '@sentry/utils';\n\nimport { eventFromUnknownInput } from '../eventbuilder';\nimport { shouldIgnoreOnError } from '../helpers';\n\ntype GlobalHandlersIntegrationsOptionKeys = 'onerror' | 'onunhandledrejection';\n\n/** JSDoc */\ntype GlobalHandlersIntegrations = Record<GlobalHandlersIntegrationsOptionKeys, boolean>;\n\n/** Global handlers */\nexport class GlobalHandlers implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'GlobalHandlers';\n\n /**\n * @inheritDoc\n */\n public name: string = GlobalHandlers.id;\n\n /** JSDoc */\n private readonly _options: GlobalHandlersIntegrations;\n\n /**\n * Stores references functions to installing handlers. Will set to undefined\n * after they have been run so that they are not used twice.\n */\n private _installFunc: Record<GlobalHandlersIntegrationsOptionKeys, (() => void) | undefined> = {\n onerror: _installGlobalOnErrorHandler,\n onunhandledrejection: _installGlobalOnUnhandledRejectionHandler,\n };\n\n /** JSDoc */\n public constructor(options?: GlobalHandlersIntegrations) {\n this._options = {\n onerror: true,\n onunhandledrejection: true,\n ...options,\n };\n }\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n Error.stackTraceLimit = 50;\n const options = this._options;\n\n // We can disable guard-for-in as we construct the options object above + do checks against\n // `this._installFunc` for the property.\n // eslint-disable-next-line guard-for-in\n for (const key in options) {\n const installFunc = this._installFunc[key as GlobalHandlersIntegrationsOptionKeys];\n if (installFunc && options[key as GlobalHandlersIntegrationsOptionKeys]) {\n globalHandlerLog(key);\n installFunc();\n this._installFunc[key as GlobalHandlersIntegrationsOptionKeys] = undefined;\n }\n }\n }\n}\n\n/** JSDoc */\nfunction _installGlobalOnErrorHandler(): void {\n addInstrumentationHandler(\n 'error',\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (data: { msg: any; url: any; line: any; column: any; error: any }) => {\n const [hub, attachStacktrace] = getHubAndAttachStacktrace();\n if (!hub.getIntegration(GlobalHandlers)) {\n return;\n }\n const { msg, url, line, column, error } = data;\n if (shouldIgnoreOnError() || (error && error.__sentry_own_request__)) {\n return;\n }\n\n const event =\n error === undefined && isString(msg)\n ? _eventFromIncompleteOnError(msg, url, line, column)\n : _enhanceEventWithInitialFrame(\n eventFromUnknownInput(error || msg, undefined, attachStacktrace, false),\n url,\n line,\n column,\n );\n\n event.level = Severity.Error;\n\n addMechanismAndCapture(hub, error, event, 'onerror');\n },\n );\n}\n\n/** JSDoc */\nfunction _installGlobalOnUnhandledRejectionHandler(): void {\n addInstrumentationHandler(\n 'unhandledrejection',\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (e: any) => {\n const [hub, attachStacktrace] = getHubAndAttachStacktrace();\n if (!hub.getIntegration(GlobalHandlers)) {\n return;\n }\n let error = e;\n\n // dig the object of the rejection out of known event types\n try {\n // PromiseRejectionEvents store the object of the rejection under 'reason'\n // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent\n if ('reason' in e) {\n error = e.reason;\n }\n // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents\n // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into\n // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec\n // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and\n // https://github.com/getsentry/sentry-javascript/issues/2380\n else if ('detail' in e && 'reason' in e.detail) {\n error = e.detail.reason;\n }\n } catch (_oO) {\n // no-empty\n }\n\n if (shouldIgnoreOnError() || (error && error.__sentry_own_request__)) {\n return true;\n }\n\n const event = isPrimitive(error)\n ? _eventFromRejectionWithPrimitive(error)\n : eventFromUnknownInput(error, undefined, attachStacktrace, true);\n\n event.level = Severity.Error;\n\n addMechanismAndCapture(hub, error, event, 'onunhandledrejection');\n return;\n },\n );\n}\n\n/**\n * Create an event from a promise rejection where the `reason` is a primitive.\n *\n * @param reason: The `reason` property of the promise rejection\n * @returns An Event object with an appropriate `exception` value\n */\nfunction _eventFromRejectionWithPrimitive(reason: Primitive): Event {\n return {\n exception: {\n values: [\n {\n type: 'UnhandledRejection',\n // String() is needed because the Primitive type includes symbols (which can't be automatically stringified)\n value: `Non-Error promise rejection captured with value: ${String(reason)}`,\n },\n ],\n },\n };\n}\n\n/**\n * This function creates a stack from an old, error-less onerror handler.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _eventFromIncompleteOnError(msg: any, url: any, line: any, column: any): Event {\n const ERROR_TYPES_RE =\n /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;\n\n // If 'message' is ErrorEvent, get real message from inside\n let message = isErrorEvent(msg) ? msg.message : msg;\n let name = 'Error';\n\n const groups = message.match(ERROR_TYPES_RE);\n if (groups) {\n name = groups[1];\n message = groups[2];\n }\n\n const event = {\n exception: {\n values: [\n {\n type: name,\n value: message,\n },\n ],\n },\n };\n\n return _enhanceEventWithInitialFrame(event, url, line, column);\n}\n\n/** JSDoc */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column: any): Event {\n // event.exception\n const e = (event.exception = event.exception || {});\n // event.exception.values\n const ev = (e.values = e.values || []);\n // event.exception.values[0]\n const ev0 = (ev[0] = ev[0] || {});\n // event.exception.values[0].stacktrace\n const ev0s = (ev0.stacktrace = ev0.stacktrace || {});\n // event.exception.values[0].stacktrace.frames\n const ev0sf = (ev0s.frames = ev0s.frames || []);\n\n const colno = isNaN(parseInt(column, 10)) ? undefined : column;\n const lineno = isNaN(parseInt(line, 10)) ? undefined : line;\n const filename = isString(url) && url.length > 0 ? url : getLocationHref();\n\n // event.exception.values[0].stacktrace.frames\n if (ev0sf.length === 0) {\n ev0sf.push({\n colno,\n filename,\n function: '?',\n in_app: true,\n lineno,\n });\n }\n\n return event;\n}\n\nfunction globalHandlerLog(type: string): void {\n if (isDebugBuild()) {\n logger.log(`Global Handler attached: ${type}`);\n }\n}\n\nfunction addMechanismAndCapture(hub: Hub, error: EventHint['originalException'], event: Event, type: string): void {\n addExceptionMechanism(event, {\n handled: false,\n type,\n });\n hub.captureEvent(event, {\n originalException: error,\n });\n}\n\nfunction getHubAndAttachStacktrace(): [Hub, boolean | undefined] {\n const hub = getCurrentHub();\n const client = hub.getClient();\n const attachStacktrace = client && client.getOptions().attachStacktrace;\n return [hub, attachStacktrace];\n}\n"]}
@@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
2
2
  var tslib_1 = require("tslib");
3
3
  var core_1 = require("@sentry/core");
4
4
  var utils_1 = require("@sentry/utils");
5
- var parsers_1 = require("../parsers");
5
+ var eventbuilder_1 = require("../eventbuilder");
6
6
  var DEFAULT_KEY = 'cause';
7
7
  var DEFAULT_LIMIT = 5;
8
8
  /** Adds SDK info to an event. */
@@ -55,7 +55,7 @@ function _walkErrorTree(limit, error, key, stack) {
55
55
  if (!utils_1.isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {
56
56
  return stack;
57
57
  }
58
- var exception = parsers_1.exceptionFromError(error[key]);
58
+ var exception = eventbuilder_1.exceptionFromError(error[key]);
59
59
  return _walkErrorTree(limit, error[key], key, tslib_1.__spread([exception], stack));
60
60
  }
61
61
  exports._walkErrorTree = _walkErrorTree;