@sentry/browser 6.18.0 → 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 (63) hide show
  1. package/build/bundle.es6.js +158 -123
  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 +168 -130
  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.d.ts.map +1 -1
  28. package/dist/transports/base.js +11 -18
  29. package/dist/transports/base.js.map +1 -1
  30. package/dist/transports/utils.js +1 -1
  31. package/dist/transports/utils.js.map +1 -1
  32. package/esm/backend.js +2 -2
  33. package/esm/backend.js.map +1 -1
  34. package/esm/eventbuilder.d.ts +24 -10
  35. package/esm/eventbuilder.d.ts.map +1 -1
  36. package/esm/eventbuilder.js +113 -21
  37. package/esm/eventbuilder.js.map +1 -1
  38. package/esm/helpers.js +2 -2
  39. package/esm/helpers.js.map +1 -1
  40. package/esm/integrations/dedupe.js +1 -1
  41. package/esm/integrations/dedupe.js.map +1 -1
  42. package/esm/integrations/globalhandlers.js +2 -8
  43. package/esm/integrations/globalhandlers.js.map +1 -1
  44. package/esm/integrations/linkederrors.js +1 -1
  45. package/esm/integrations/linkederrors.js.map +1 -1
  46. package/esm/stack-parsers.d.ts +5 -5
  47. package/esm/stack-parsers.d.ts.map +1 -1
  48. package/esm/stack-parsers.js +16 -6
  49. package/esm/stack-parsers.js.map +1 -1
  50. package/esm/transports/base.d.ts.map +1 -1
  51. package/esm/transports/base.js +13 -20
  52. package/esm/transports/base.js.map +1 -1
  53. package/esm/transports/utils.js +1 -1
  54. package/esm/transports/utils.js.map +1 -1
  55. package/package.json +5 -5
  56. package/dist/parsers.d.ts +0 -21
  57. package/dist/parsers.d.ts.map +0 -1
  58. package/dist/parsers.js +0 -108
  59. package/dist/parsers.js.map +0 -1
  60. package/esm/parsers.d.ts +0 -21
  61. package/esm/parsers.d.ts.map +0 -1
  62. package/esm/parsers.js +0 -103
  63. package/esm/parsers.js.map +0 -1
@@ -51,7 +51,7 @@ export function getNativeFetchImplementation() {
51
51
  var document = global.document;
52
52
  var fetchImpl = global.fetch;
53
53
  // eslint-disable-next-line deprecation/deprecation
54
- if (document && typeof document.createElement === "function") {
54
+ if (document && typeof document.createElement === 'function') {
55
55
  try {
56
56
  var sandbox = document.createElement('iframe');
57
57
  sandbox.hidden = true;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/transports/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE5G,IAAM,MAAM,GAAG,eAAe,EAAU,CAAC;AACzC,IAAI,eAA0B,CAAC;AAI/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,4BAA4B;IAC1C,IAAI,eAAe,EAAE;QACnB,OAAO,eAAe,CAAC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,OAAO,MAAM,CAAC,SAAS,CAAC,UAAU,KAAK,UAAU,CAAC;IAE3F,IAAI,aAAa,EAAE;QACjB,wHAAwH;QACxH,IAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtE,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;KAC9B;IAED,IAAI,aAAa,EAAE,EAAE;QACnB,IAAM,OAAK,GAAG,4BAA4B,EAAE,CAAC;QAC7C,OAAO,MAAM,CACX,OAAK,CAAC,GAAG,EAAE;YACT,IAAI,MAAA;YACJ,MAAM,EAAE,MAAM;YACd,WAAW,EAAE,MAAM;YACnB,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;KACH;AACH,CAAC","sourcesContent":["import { forget, getGlobalObject, isDebugBuild, isNativeFetch, logger, supportsFetch } from '@sentry/utils';\n\nconst global = getGlobalObject<Window>();\nlet cachedFetchImpl: FetchImpl;\n\nexport type FetchImpl = typeof fetch;\n\n/**\n * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.\n * Whenever someone wraps the Fetch API and returns the wrong promise chain,\n * this chain becomes orphaned and there is no possible way to capture it's rejections\n * other than allowing it bubble up to this very handler. eg.\n *\n * const f = window.fetch;\n * window.fetch = function () {\n * const p = f.apply(this, arguments);\n *\n * p.then(function() {\n * console.log('hi.');\n * });\n *\n * return p;\n * }\n *\n * `p.then(function () { ... })` is producing a completely separate promise chain,\n * however, what's returned is `p` - the result of original `fetch` call.\n *\n * This mean, that whenever we use the Fetch API to send our own requests, _and_\n * some ad-blocker blocks it, this orphaned chain will _always_ reject,\n * effectively causing another event to be captured.\n * This makes a whole process become an infinite loop, which we need to somehow\n * deal with, and break it in one way or another.\n *\n * To deal with this issue, we are making sure that we _always_ use the real\n * browser Fetch API, instead of relying on what `window.fetch` exposes.\n * The only downside to this would be missing our own requests as breadcrumbs,\n * but because we are already not doing this, it should be just fine.\n *\n * Possible failed fetch error messages per-browser:\n *\n * Chrome: Failed to fetch\n * Edge: Failed to Fetch\n * Firefox: NetworkError when attempting to fetch resource\n * Safari: resource blocked by content blocker\n */\nexport function getNativeFetchImplementation(): FetchImpl {\n if (cachedFetchImpl) {\n return cachedFetchImpl;\n }\n\n /* eslint-disable @typescript-eslint/unbound-method */\n\n // Fast path to avoid DOM I/O\n if (isNativeFetch(global.fetch)) {\n return (cachedFetchImpl = global.fetch.bind(global));\n }\n\n const document = global.document;\n let fetchImpl = global.fetch;\n // eslint-disable-next-line deprecation/deprecation\n if (document && typeof document.createElement === `function`) {\n try {\n const sandbox = document.createElement('iframe');\n sandbox.hidden = true;\n document.head.appendChild(sandbox);\n const contentWindow = sandbox.contentWindow;\n if (contentWindow && contentWindow.fetch) {\n fetchImpl = contentWindow.fetch;\n }\n document.head.removeChild(sandbox);\n } catch (e) {\n if (isDebugBuild()) {\n logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);\n }\n }\n }\n\n return (cachedFetchImpl = fetchImpl.bind(global));\n /* eslint-enable @typescript-eslint/unbound-method */\n}\n\n/**\n * Sends sdk client report using sendBeacon or fetch as a fallback if available\n *\n * @param url report endpoint\n * @param body report payload\n */\nexport function sendReport(url: string, body: string): void {\n const isRealNavigator = Object.prototype.toString.call(global && global.navigator) === '[object Navigator]';\n const hasSendBeacon = isRealNavigator && typeof global.navigator.sendBeacon === 'function';\n\n if (hasSendBeacon) {\n // Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch\n const sendBeacon = global.navigator.sendBeacon.bind(global.navigator);\n return sendBeacon(url, body);\n }\n\n if (supportsFetch()) {\n const fetch = getNativeFetchImplementation();\n return forget(\n fetch(url, {\n body,\n method: 'POST',\n credentials: 'omit',\n keepalive: true,\n }),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/transports/utils.ts"],"names":[],"mappings":"A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AG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,qDAAqD;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,IAAY;IAClD,IAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,oBAAoB,CAAC;IAC5G,IAAM,aAAa,GAAG,eAAe,IAAI,OAAO,MAAM,CAAC,SAAS,CAAC,UAAU,KAAK,UAAU,CAAC;IAE3F,IAAI,aAAa,EAAE;QACjB,wHAAwH;QACxH,IAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtE,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;KAC9B;IAED,IAAI,aAAa,EAAE,EAAE;QACnB,IAAM,OAAK,GAAG,4BAA4B,EAAE,CAAC;QAC7C,OAAO,MAAM,CACX,OAAK,CAAC,GAAG,EAAE;YACT,IAAI,MAAA;YACJ,MAAM,EAAE,MAAM;YACd,WAAW,EAAE,MAAM;YACnB,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;KACH;AACH,CAAC","sourcesContent":["import { forget, getGlobalObject, isDebugBuild, isNativeFetch, logger, supportsFetch } from '@sentry/utils';\n\nconst global = getGlobalObject<Window>();\nlet cachedFetchImpl: FetchImpl;\n\nexport type FetchImpl = typeof fetch;\n\n/**\n * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.\n * Whenever someone wraps the Fetch API and returns the wrong promise chain,\n * this chain becomes orphaned and there is no possible way to capture it's rejections\n * other than allowing it bubble up to this very handler. eg.\n *\n * const f = window.fetch;\n * window.fetch = function () {\n * const p = f.apply(this, arguments);\n *\n * p.then(function() {\n * console.log('hi.');\n * });\n *\n * return p;\n * }\n *\n * `p.then(function () { ... })` is producing a completely separate promise chain,\n * however, what's returned is `p` - the result of original `fetch` call.\n *\n * This mean, that whenever we use the Fetch API to send our own requests, _and_\n * some ad-blocker blocks it, this orphaned chain will _always_ reject,\n * effectively causing another event to be captured.\n * This makes a whole process become an infinite loop, which we need to somehow\n * deal with, and break it in one way or another.\n *\n * To deal with this issue, we are making sure that we _always_ use the real\n * browser Fetch API, instead of relying on what `window.fetch` exposes.\n * The only downside to this would be missing our own requests as breadcrumbs,\n * but because we are already not doing this, it should be just fine.\n *\n * Possible failed fetch error messages per-browser:\n *\n * Chrome: Failed to fetch\n * Edge: Failed to Fetch\n * Firefox: NetworkError when attempting to fetch resource\n * Safari: resource blocked by content blocker\n */\nexport function getNativeFetchImplementation(): FetchImpl {\n if (cachedFetchImpl) {\n return cachedFetchImpl;\n }\n\n /* eslint-disable @typescript-eslint/unbound-method */\n\n // Fast path to avoid DOM I/O\n if (isNativeFetch(global.fetch)) {\n return (cachedFetchImpl = global.fetch.bind(global));\n }\n\n const document = global.document;\n let fetchImpl = global.fetch;\n // eslint-disable-next-line deprecation/deprecation\n if (document && typeof document.createElement === 'function') {\n try {\n const sandbox = document.createElement('iframe');\n sandbox.hidden = true;\n document.head.appendChild(sandbox);\n const contentWindow = sandbox.contentWindow;\n if (contentWindow && contentWindow.fetch) {\n fetchImpl = contentWindow.fetch;\n }\n document.head.removeChild(sandbox);\n } catch (e) {\n if (isDebugBuild()) {\n logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);\n }\n }\n }\n\n return (cachedFetchImpl = fetchImpl.bind(global));\n /* eslint-enable @typescript-eslint/unbound-method */\n}\n\n/**\n * Sends sdk client report using sendBeacon or fetch as a fallback if available\n *\n * @param url report endpoint\n * @param body report payload\n */\nexport function sendReport(url: string, body: string): void {\n const isRealNavigator = Object.prototype.toString.call(global && global.navigator) === '[object Navigator]';\n const hasSendBeacon = isRealNavigator && typeof global.navigator.sendBeacon === 'function';\n\n if (hasSendBeacon) {\n // Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch\n const sendBeacon = global.navigator.sendBeacon.bind(global.navigator);\n return sendBeacon(url, body);\n }\n\n if (supportsFetch()) {\n const fetch = getNativeFetchImplementation();\n return forget(\n fetch(url, {\n body,\n method: 'POST',\n credentials: 'omit',\n keepalive: true,\n }),\n );\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/browser",
3
- "version": "6.18.0",
3
+ "version": "6.18.2",
4
4
  "description": "Official Sentry SDK for browsers",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
@@ -16,9 +16,9 @@
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "@sentry/core": "6.18.0",
20
- "@sentry/types": "6.18.0",
21
- "@sentry/utils": "6.18.0",
19
+ "@sentry/core": "6.18.2",
20
+ "@sentry/types": "6.18.2",
21
+ "@sentry/utils": "6.18.2",
22
22
  "tslib": "^1.9.3"
23
23
  },
24
24
  "devDependencies": {
@@ -27,7 +27,7 @@
27
27
  "chai": "^4.1.2",
28
28
  "chokidar": "^3.0.2",
29
29
  "jsdom": "^15.0.0",
30
- "karma": "^4.1.0",
30
+ "karma": "^6.3.16",
31
31
  "karma-chai": "^0.1.0",
32
32
  "karma-chrome-launcher": "^2.2.0",
33
33
  "karma-firefox-launcher": "^2.1.2",
package/dist/parsers.d.ts DELETED
@@ -1,21 +0,0 @@
1
- import { Event, Exception, 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, rejection?: 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[];
21
- //# sourceMappingURL=parsers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK7D;;;;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,SAAS,CAAC,EAAE,OAAO,GAClB,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,CAgBxG"}
package/dist/parsers.js DELETED
@@ -1,108 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- var utils_1 = require("@sentry/utils");
3
- var stack_parsers_1 = require("./stack-parsers");
4
- /**
5
- * This function creates an exception from an TraceKitStackTrace
6
- * @param stacktrace TraceKitStackTrace that will be converted to an exception
7
- * @hidden
8
- */
9
- function exceptionFromError(ex) {
10
- // Get the frames first since Opera can lose the stack if we touch anything else first
11
- var frames = parseStackFrames(ex);
12
- var exception = {
13
- type: ex && ex.name,
14
- value: extractMessage(ex),
15
- };
16
- if (frames && frames.length) {
17
- exception.stacktrace = { frames: frames };
18
- }
19
- if (exception.type === undefined && exception.value === '') {
20
- exception.value = 'Unrecoverable error caught';
21
- }
22
- return exception;
23
- }
24
- exports.exceptionFromError = exceptionFromError;
25
- /**
26
- * @hidden
27
- */
28
- function eventFromPlainObject(exception, syntheticException, rejection) {
29
- var event = {
30
- exception: {
31
- values: [
32
- {
33
- type: utils_1.isEvent(exception) ? exception.constructor.name : rejection ? 'UnhandledRejection' : 'Error',
34
- value: "Non-Error " + (rejection ? 'promise rejection' : 'exception') + " captured with keys: " + utils_1.extractExceptionKeysForMessage(exception),
35
- },
36
- ],
37
- },
38
- extra: {
39
- __serialized__: utils_1.normalizeToSize(exception),
40
- },
41
- };
42
- if (syntheticException) {
43
- var frames_1 = parseStackFrames(syntheticException);
44
- if (frames_1.length) {
45
- event.stacktrace = { frames: frames_1 };
46
- }
47
- }
48
- return event;
49
- }
50
- exports.eventFromPlainObject = eventFromPlainObject;
51
- /**
52
- * @hidden
53
- */
54
- function eventFromError(ex) {
55
- return {
56
- exception: {
57
- values: [exceptionFromError(ex)],
58
- },
59
- };
60
- }
61
- exports.eventFromError = eventFromError;
62
- /** Parses stack frames from an error */
63
- function parseStackFrames(ex) {
64
- // Access and store the stacktrace property before doing ANYTHING
65
- // else to it because Opera is not very good at providing it
66
- // reliably in other circumstances.
67
- var stacktrace = ex.stacktrace || ex.stack || '';
68
- var popSize = getPopSize(ex);
69
- try {
70
- // The order of the parsers in important
71
- return utils_1.createStackParser(stack_parsers_1.opera10, stack_parsers_1.opera11, stack_parsers_1.chrome, stack_parsers_1.winjs, stack_parsers_1.gecko)(stacktrace, popSize);
72
- }
73
- catch (e) {
74
- // no-empty
75
- }
76
- return [];
77
- }
78
- exports.parseStackFrames = parseStackFrames;
79
- // Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
80
- var reactMinifiedRegexp = /Minified React error #\d+;/i;
81
- function getPopSize(ex) {
82
- if (ex) {
83
- if (typeof ex.framesToPop === 'number') {
84
- return ex.framesToPop;
85
- }
86
- if (reactMinifiedRegexp.test(ex.message)) {
87
- return 1;
88
- }
89
- }
90
- return 0;
91
- }
92
- /**
93
- * There are cases where stacktrace.message is an Event object
94
- * https://github.com/getsentry/sentry-javascript/issues/1949
95
- * In this specific case we try to extract stacktrace.message.error.message
96
- */
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
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
- }
108
- //# sourceMappingURL=parsers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parsers.js","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":";AAEA,uCAA4G;AAE5G,iDAAyE;AAEzE;;;;GAIG;AACH,SAAgB,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,IAAI,MAAM,CAAC,MAAM,EAAE;QAC3B,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;AAlBD,gDAkBC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAClC,SAAkC,EAClC,kBAA0B,EAC1B,SAAmB;IAEnB,IAAM,KAAK,GAAU;QACnB,SAAS,EAAE;YACT,MAAM,EAAE;gBACN;oBACE,IAAI,EAAE,eAAO,CAAC,SAA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BC;AAED,2KAA2K;AAC3K,IAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAE1D,SAAS,UAAU,CAAC,EAAoC;IACtD,IAAI,EAAE,EAAE;QACN,IAAI,OAAO,EAAE,CAAC,WAAW,KAAK,QAAQ,EAAE;YACtC,OAAO,EAAE,CAAC,WAAW,CAAC;SACvB;QAED,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;YACxC,OAAO,CAAC,CAAC;SACV;KACF;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;GAIG;AACH,8DAA8D;AAC9D,SAAS,cAAc,CAAC,EAAO;IAC7B,IAAM,OAAO,GAAG,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC;IACjC,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,kBAAkB,CAAC;KAC3B;IACD,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;QAC9D,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;KAC9B;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport { Event, Exception, StackFrame } from '@sentry/types';\nimport { createStackParser, extractExceptionKeysForMessage, isEvent, normalizeToSize } from '@sentry/utils';\n\nimport { chrome, gecko, opera10, opera11, winjs } 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 && 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 rejection?: boolean,\n): Event {\n const event: Event = {\n exception: {\n values: [\n {\n type: isEvent(exception) ? exception.constructor.name : rejection ? 'UnhandledRejection' : 'Error',\n value: `Non-Error ${\n rejection ? '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 // The order of the parsers in important\n return createStackParser(opera10, opera11, chrome, winjs, gecko)(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 */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction extractMessage(ex: any): 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"]}
package/esm/parsers.d.ts DELETED
@@ -1,21 +0,0 @@
1
- import { Event, Exception, 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, rejection?: 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[];
21
- //# sourceMappingURL=parsers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK7D;;;;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,SAAS,CAAC,EAAE,OAAO,GAClB,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,CAgBxG"}
package/esm/parsers.js DELETED
@@ -1,103 +0,0 @@
1
- import { createStackParser, extractExceptionKeysForMessage, isEvent, normalizeToSize } from '@sentry/utils';
2
- import { chrome, gecko, opera10, opera11, winjs } from './stack-parsers';
3
- /**
4
- * This function creates an exception from an TraceKitStackTrace
5
- * @param stacktrace TraceKitStackTrace that will be converted to an exception
6
- * @hidden
7
- */
8
- export function exceptionFromError(ex) {
9
- // Get the frames first since Opera can lose the stack if we touch anything else first
10
- var frames = parseStackFrames(ex);
11
- var exception = {
12
- type: ex && ex.name,
13
- value: extractMessage(ex),
14
- };
15
- if (frames && frames.length) {
16
- exception.stacktrace = { frames: frames };
17
- }
18
- if (exception.type === undefined && exception.value === '') {
19
- exception.value = 'Unrecoverable error caught';
20
- }
21
- return exception;
22
- }
23
- /**
24
- * @hidden
25
- */
26
- export function eventFromPlainObject(exception, syntheticException, rejection) {
27
- var event = {
28
- exception: {
29
- values: [
30
- {
31
- type: isEvent(exception) ? exception.constructor.name : rejection ? 'UnhandledRejection' : 'Error',
32
- value: "Non-Error " + (rejection ? 'promise rejection' : 'exception') + " captured with keys: " + extractExceptionKeysForMessage(exception),
33
- },
34
- ],
35
- },
36
- extra: {
37
- __serialized__: normalizeToSize(exception),
38
- },
39
- };
40
- if (syntheticException) {
41
- var frames_1 = parseStackFrames(syntheticException);
42
- if (frames_1.length) {
43
- event.stacktrace = { frames: frames_1 };
44
- }
45
- }
46
- return event;
47
- }
48
- /**
49
- * @hidden
50
- */
51
- export function eventFromError(ex) {
52
- return {
53
- exception: {
54
- values: [exceptionFromError(ex)],
55
- },
56
- };
57
- }
58
- /** Parses stack frames from an error */
59
- export function parseStackFrames(ex) {
60
- // Access and store the stacktrace property before doing ANYTHING
61
- // else to it because Opera is not very good at providing it
62
- // reliably in other circumstances.
63
- var stacktrace = ex.stacktrace || ex.stack || '';
64
- var popSize = getPopSize(ex);
65
- try {
66
- // The order of the parsers in important
67
- return createStackParser(opera10, opera11, chrome, winjs, gecko)(stacktrace, popSize);
68
- }
69
- catch (e) {
70
- // no-empty
71
- }
72
- return [];
73
- }
74
- // Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
75
- var reactMinifiedRegexp = /Minified React error #\d+;/i;
76
- function getPopSize(ex) {
77
- if (ex) {
78
- if (typeof ex.framesToPop === 'number') {
79
- return ex.framesToPop;
80
- }
81
- if (reactMinifiedRegexp.test(ex.message)) {
82
- return 1;
83
- }
84
- }
85
- return 0;
86
- }
87
- /**
88
- * There are cases where stacktrace.message is an Event object
89
- * https://github.com/getsentry/sentry-javascript/issues/1949
90
- * In this specific case we try to extract stacktrace.message.error.message
91
- */
92
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
- function extractMessage(ex) {
94
- var message = ex && ex.message;
95
- if (!message) {
96
- return 'No error message';
97
- }
98
- if (message.error && typeof message.error.message === 'string') {
99
- return message.error.message;
100
- }
101
- return message;
102
- }
103
- //# sourceMappingURL=parsers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parsers.js","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5G,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;;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,IAAI,MAAM,CAAC,MAAM,EAAE;QAC3B,SAAS,CAAC,UAAU,GAAG,EAAE,MAAM,QAAA,EAAE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I,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;IAEnD,IAAM,OAAO,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;IAE/B,IAAI;QACF,wCAAwC;QACxC,OAAO,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;KACvF;IAAC,OAAO,CAAC,EAAE;QACV,WAAW;KACZ;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,2KAA2K;AAC3K,IAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAE1D,SAAS,UAAU,CAAC,EAAoC;IACtD,IAAI,EAAE,EAAE;QACN,IAAI,OAAO,EAAE,CAAC,WAAW,KAAK,QAAQ,EAAE;YACtC,OAAO,EAAE,CAAC,WAAW,CAAC;SACvB;QAED,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;YACxC,OAAO,CAAC,CAAC;SACV;KACF;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;GAIG;AACH,8DAA8D;AAC9D,SAAS,cAAc,CAAC,EAAO;IAC7B,IAAM,OAAO,GAAG,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC;IACjC,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,kBAAkB,CAAC;KAC3B;IACD,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;QAC9D,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;KAC9B;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport { Event, Exception, StackFrame } from '@sentry/types';\nimport { createStackParser, extractExceptionKeysForMessage, isEvent, normalizeToSize } from '@sentry/utils';\n\nimport { chrome, gecko, opera10, opera11, winjs } 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 && 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 rejection?: boolean,\n): Event {\n const event: Event = {\n exception: {\n values: [\n {\n type: isEvent(exception) ? exception.constructor.name : rejection ? 'UnhandledRejection' : 'Error',\n value: `Non-Error ${\n rejection ? '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 // The order of the parsers in important\n return createStackParser(opera10, opera11, chrome, winjs, gecko)(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 */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction extractMessage(ex: any): 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"]}