@sentry/browser 6.17.6 → 6.17.9

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 (45) hide show
  1. package/build/bundle.es6.js +270 -429
  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 +315 -444
  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/eventbuilder.d.ts.map +1 -1
  10. package/dist/eventbuilder.js +4 -11
  11. package/dist/eventbuilder.js.map +1 -1
  12. package/dist/integrations/linkederrors.d.ts.map +1 -1
  13. package/dist/integrations/linkederrors.js +1 -3
  14. package/dist/integrations/linkederrors.js.map +1 -1
  15. package/dist/parsers.d.ts +7 -7
  16. package/dist/parsers.d.ts.map +1 -1
  17. package/dist/parsers.js +52 -40
  18. package/dist/parsers.js.map +1 -1
  19. package/dist/stack-parsers.d.ts +7 -0
  20. package/dist/stack-parsers.d.ts.map +1 -0
  21. package/dist/stack-parsers.js +117 -0
  22. package/dist/stack-parsers.js.map +1 -0
  23. package/esm/eventbuilder.d.ts.map +1 -1
  24. package/esm/eventbuilder.js +5 -12
  25. package/esm/eventbuilder.js.map +1 -1
  26. package/esm/integrations/linkederrors.d.ts.map +1 -1
  27. package/esm/integrations/linkederrors.js +2 -4
  28. package/esm/integrations/linkederrors.js.map +1 -1
  29. package/esm/parsers.d.ts +7 -7
  30. package/esm/parsers.d.ts.map +1 -1
  31. package/esm/parsers.js +50 -38
  32. package/esm/parsers.js.map +1 -1
  33. package/esm/stack-parsers.d.ts +7 -0
  34. package/esm/stack-parsers.d.ts.map +1 -0
  35. package/esm/stack-parsers.js +116 -0
  36. package/esm/stack-parsers.js.map +1 -0
  37. package/package.json +4 -10
  38. package/dist/tracekit.d.ts +0 -38
  39. package/dist/tracekit.d.ts.map +0 -1
  40. package/dist/tracekit.js +0 -259
  41. package/dist/tracekit.js.map +0 -1
  42. package/esm/tracekit.d.ts +0 -38
  43. package/esm/tracekit.d.ts.map +0 -1
  44. package/esm/tracekit.js +0 -257
  45. package/esm/tracekit.js.map +0 -1
@@ -1,8 +1,10 @@
1
- /*! @sentry/browser 6.17.6 (4b4faec) | https://github.com/getsentry/sentry-javascript */
1
+ /*! @sentry/browser 6.17.9 (4ef06bf) | https://github.com/getsentry/sentry-javascript */
2
2
  var Sentry = (function (exports) {
3
+
3
4
  /**
4
5
  * TODO(v7): Remove this enum and replace with SeverityLevel
5
6
  */
7
+ exports.Severity = void 0;
6
8
  (function (Severity) {
7
9
  /** JSDoc */
8
10
  Severity["Fatal"] = "fatal";
@@ -49,41 +51,7 @@ var Sentry = (function (exports) {
49
51
  * @returns true if this is a debug build
50
52
  */
51
53
  function isDebugBuild() {
52
- return typeof __SENTRY_NO_DEBUG__ !== 'undefined' && !__SENTRY_BROWSER_BUNDLE__;
53
- }
54
- /**
55
- * Figures out if we're building a browser bundle.
56
- *
57
- * @returns true if this is a browser bundle build.
58
- */
59
- function isBrowserBundle() {
60
- return typeof __SENTRY_BROWSER_BUNDLE__ !== 'undefined' && !!__SENTRY_BROWSER_BUNDLE__;
61
- }
62
-
63
- /**
64
- * NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
65
- * you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
66
- */
67
- /**
68
- * Checks whether we're in the Node.js or Browser environment
69
- *
70
- * @returns Answer to given question
71
- */
72
- function isNodeEnv() {
73
- // explicitly check for browser bundles as those can be optimized statically
74
- // by terser/rollup.
75
- return (!isBrowserBundle() &&
76
- Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]');
77
- }
78
- /**
79
- * Requires a module which is protected against bundler minification.
80
- *
81
- * @param request The module path to resolve
82
- */
83
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
84
- function dynamicRequire(mod, request) {
85
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
86
- return mod.require(request);
54
+ return typeof __SENTRY_NO_DEBUG__ !== 'undefined' && !true;
87
55
  }
88
56
 
89
57
  /**
@@ -97,9 +65,7 @@ var Sentry = (function (exports) {
97
65
  * @returns Global scope object
98
66
  */
99
67
  function getGlobalObject() {
100
- return (isNodeEnv()
101
- ? global
102
- : typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
68
+ return (typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
103
69
  ? window // eslint-disable-line no-restricted-globals
104
70
  : typeof self !== 'undefined'
105
71
  ? self
@@ -480,7 +446,7 @@ var Sentry = (function (exports) {
480
446
  const SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
481
447
 
482
448
  // TODO: Implement different loggers for different environments
483
- const global$1 = getGlobalObject();
449
+ const global$6 = getGlobalObject();
484
450
  /** Prefix for logging strings */
485
451
  const PREFIX = 'Sentry Logger ';
486
452
  /**
@@ -535,7 +501,7 @@ var Sentry = (function (exports) {
535
501
  return;
536
502
  }
537
503
  consoleSandbox(() => {
538
- global$1.console.log(`${PREFIX}[Log]: ${args.join(' ')}`);
504
+ global$6.console.log(`${PREFIX}[Log]: ${args.join(' ')}`);
539
505
  });
540
506
  }
541
507
  /** JSDoc */
@@ -544,7 +510,7 @@ var Sentry = (function (exports) {
544
510
  return;
545
511
  }
546
512
  consoleSandbox(() => {
547
- global$1.console.warn(`${PREFIX}[Warn]: ${args.join(' ')}`);
513
+ global$6.console.warn(`${PREFIX}[Warn]: ${args.join(' ')}`);
548
514
  });
549
515
  }
550
516
  /** JSDoc */
@@ -553,13 +519,13 @@ var Sentry = (function (exports) {
553
519
  return;
554
520
  }
555
521
  consoleSandbox(() => {
556
- global$1.console.error(`${PREFIX}[Error]: ${args.join(' ')}`);
522
+ global$6.console.error(`${PREFIX}[Error]: ${args.join(' ')}`);
557
523
  });
558
524
  }
559
525
  }
560
526
  // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
561
- global$1.__SENTRY__ = global$1.__SENTRY__ || {};
562
- const logger = global$1.__SENTRY__.logger || (global$1.__SENTRY__.logger = new Logger());
527
+ global$6.__SENTRY__ = global$6.__SENTRY__ || {};
528
+ const logger = global$6.__SENTRY__.logger || (global$6.__SENTRY__.logger = new Logger());
563
529
 
564
530
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
565
531
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -603,6 +569,53 @@ var Sentry = (function (exports) {
603
569
  return [memoize, unmemoize];
604
570
  }
605
571
 
572
+ const STACKTRACE_LIMIT = 50;
573
+ /**
574
+ * Creates a stack parser with the supplied line parsers
575
+ *
576
+ * StackFrames are returned in the correct order for Sentry Exception
577
+ * frames and with Sentry SDK internal frames removed from the top and bottom
578
+ *
579
+ * */
580
+ function createStackParser(...parsers) {
581
+ return (stack, skipFirst = 0) => {
582
+ const frames = [];
583
+ for (const line of stack.split('\n').slice(skipFirst)) {
584
+ for (const parser of parsers) {
585
+ const frame = parser(line);
586
+ if (frame) {
587
+ frames.push(frame);
588
+ break;
589
+ }
590
+ }
591
+ }
592
+ return stripSentryFramesAndReverse(frames);
593
+ };
594
+ }
595
+ /**
596
+ * @hidden
597
+ */
598
+ function stripSentryFramesAndReverse(stack) {
599
+ if (!stack.length) {
600
+ return [];
601
+ }
602
+ let localStack = stack;
603
+ const firstFrameFunction = localStack[0].function || '';
604
+ const lastFrameFunction = localStack[localStack.length - 1].function || '';
605
+ // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
606
+ if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
607
+ localStack = localStack.slice(1);
608
+ }
609
+ // If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
610
+ if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
611
+ localStack = localStack.slice(0, -1);
612
+ }
613
+ // The frame where the crash happened, should be the last entry in the array
614
+ return localStack
615
+ .slice(0, STACKTRACE_LIMIT)
616
+ .map(frame => (Object.assign(Object.assign({}, frame), { filename: frame.filename || localStack[0].filename, function: frame.function || '?' })))
617
+ .reverse();
618
+ }
606
619
  const defaultFunctionName = '<anonymous>';
607
620
  /**
608
621
  * Safely extract function name from itself
@@ -707,16 +720,18 @@ var Sentry = (function (exports) {
707
720
  source[name] = wrapped;
708
721
  }
709
722
  /**
710
- * Defines a non enumerable property. This creates a non enumerable property on an object.
723
+ * Defines a non-enumerable property on the given object.
711
724
  *
712
- * @param func The function to set a property to
713
- * @param name the name of the special sentry property
714
- * @param value the property to define
725
+ * @param obj The object on which to set the property
726
+ * @param name The name of the property to be set
727
+ * @param value The value to which to set the property
715
728
  */
716
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
717
- function addNonEnumerableProperty(func, name, value) {
718
- Object.defineProperty(func, name, {
729
+ function addNonEnumerableProperty(obj, name, value) {
730
+ Object.defineProperty(obj, name, {
731
+ // enumerable: false, // the default, so we can save on bundle size by not explicitly setting it
719
732
  value: value,
733
+ writable: true,
734
+ configurable: true,
720
735
  });
721
736
  }
722
737
  /**
@@ -1132,7 +1147,7 @@ var Sentry = (function (exports) {
1132
1147
  return !isChromePackagedApp && hasHistoryApi;
1133
1148
  }
1134
1149
 
1135
- const global$2 = getGlobalObject();
1150
+ const global$5 = getGlobalObject();
1136
1151
  /**
1137
1152
  * Instrument native APIs to call handlers that can be used to create breadcrumbs, APM spans etc.
1138
1153
  * - Console API
@@ -1205,19 +1220,19 @@ var Sentry = (function (exports) {
1205
1220
  }
1206
1221
  /** JSDoc */
1207
1222
  function instrumentConsole() {
1208
- if (!('console' in global$2)) {
1223
+ if (!('console' in global$5)) {
1209
1224
  return;
1210
1225
  }
1211
1226
  ['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) {
1212
- if (!(level in global$2.console)) {
1227
+ if (!(level in global$5.console)) {
1213
1228
  return;
1214
1229
  }
1215
- fill(global$2.console, level, function (originalConsoleLevel) {
1230
+ fill(global$5.console, level, function (originalConsoleMethod) {
1216
1231
  return function (...args) {
1217
1232
  triggerHandlers('console', { args, level });
1218
1233
  // this fails for some browsers. :(
1219
- if (originalConsoleLevel) {
1220
- Function.prototype.apply.call(originalConsoleLevel, global$2.console, args);
1234
+ if (originalConsoleMethod) {
1235
+ originalConsoleMethod.apply(global$5.console, args);
1221
1236
  }
1222
1237
  };
1223
1238
  });
@@ -1228,7 +1243,7 @@ var Sentry = (function (exports) {
1228
1243
  if (!supportsNativeFetch()) {
1229
1244
  return;
1230
1245
  }
1231
- fill(global$2, 'fetch', function (originalFetch) {
1246
+ fill(global$5, 'fetch', function (originalFetch) {
1232
1247
  return function (...args) {
1233
1248
  const handlerData = {
1234
1249
  args,
@@ -1240,7 +1255,7 @@ var Sentry = (function (exports) {
1240
1255
  };
1241
1256
  triggerHandlers('fetch', Object.assign({}, handlerData));
1242
1257
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1243
- return originalFetch.apply(global$2, args).then((response) => {
1258
+ return originalFetch.apply(global$5, args).then((response) => {
1244
1259
  triggerHandlers('fetch', Object.assign(Object.assign({}, handlerData), { endTimestamp: Date.now(), response }));
1245
1260
  return response;
1246
1261
  }, (error) => {
@@ -1256,7 +1271,7 @@ var Sentry = (function (exports) {
1256
1271
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
1257
1272
  /** Extract `method` from fetch call arguments */
1258
1273
  function getFetchMethod(fetchArgs = []) {
1259
- if ('Request' in global$2 && isInstanceOf(fetchArgs[0], Request) && fetchArgs[0].method) {
1274
+ if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request) && fetchArgs[0].method) {
1260
1275
  return String(fetchArgs[0].method).toUpperCase();
1261
1276
  }
1262
1277
  if (fetchArgs[1] && fetchArgs[1].method) {
@@ -1269,7 +1284,7 @@ var Sentry = (function (exports) {
1269
1284
  if (typeof fetchArgs[0] === 'string') {
1270
1285
  return fetchArgs[0];
1271
1286
  }
1272
- if ('Request' in global$2 && isInstanceOf(fetchArgs[0], Request)) {
1287
+ if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request)) {
1273
1288
  return fetchArgs[0].url;
1274
1289
  }
1275
1290
  return String(fetchArgs[0]);
@@ -1277,7 +1292,7 @@ var Sentry = (function (exports) {
1277
1292
  /* eslint-enable @typescript-eslint/no-unsafe-member-access */
1278
1293
  /** JSDoc */
1279
1294
  function instrumentXHR() {
1280
- if (!('XMLHttpRequest' in global$2)) {
1295
+ if (!('XMLHttpRequest' in global$5)) {
1281
1296
  return;
1282
1297
  }
1283
1298
  const xhrproto = XMLHttpRequest.prototype;
@@ -1348,9 +1363,9 @@ var Sentry = (function (exports) {
1348
1363
  if (!supportsHistory()) {
1349
1364
  return;
1350
1365
  }
1351
- const oldOnPopState = global$2.onpopstate;
1352
- global$2.onpopstate = function (...args) {
1353
- const to = global$2.location.href;
1366
+ const oldOnPopState = global$5.onpopstate;
1367
+ global$5.onpopstate = function (...args) {
1368
+ const to = global$5.location.href;
1354
1369
  // keep track of the current URL state, as we always receive only the updated state
1355
1370
  const from = lastHref;
1356
1371
  lastHref = to;
@@ -1388,8 +1403,8 @@ var Sentry = (function (exports) {
1388
1403
  return originalHistoryFunction.apply(this, args);
1389
1404
  };
1390
1405
  }
1391
- fill(global$2.history, 'pushState', historyReplacementFunction);
1392
- fill(global$2.history, 'replaceState', historyReplacementFunction);
1406
+ fill(global$5.history, 'pushState', historyReplacementFunction);
1407
+ fill(global$5.history, 'replaceState', historyReplacementFunction);
1393
1408
  }
1394
1409
  const debounceDuration = 1000;
1395
1410
  let debounceTimerID;
@@ -1491,14 +1506,14 @@ var Sentry = (function (exports) {
1491
1506
  }
1492
1507
  // Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together.
1493
1508
  clearTimeout(debounceTimerID);
1494
- debounceTimerID = global$2.setTimeout(() => {
1509
+ debounceTimerID = global$5.setTimeout(() => {
1495
1510
  debounceTimerID = undefined;
1496
1511
  }, debounceDuration);
1497
1512
  };
1498
1513
  }
1499
1514
  /** JSDoc */
1500
1515
  function instrumentDOM() {
1501
- if (!('document' in global$2)) {
1516
+ if (!('document' in global$5)) {
1502
1517
  return;
1503
1518
  }
1504
1519
  // Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom
@@ -1506,8 +1521,8 @@ var Sentry = (function (exports) {
1506
1521
  // we instrument `addEventListener` so that we don't end up attaching this handler twice.
1507
1522
  const triggerDOMHandler = triggerHandlers.bind(null, 'dom');
1508
1523
  const globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true);
1509
- global$2.document.addEventListener('click', globalDOMEventHandler, false);
1510
- global$2.document.addEventListener('keypress', globalDOMEventHandler, false);
1524
+ global$5.document.addEventListener('click', globalDOMEventHandler, false);
1525
+ global$5.document.addEventListener('keypress', globalDOMEventHandler, false);
1511
1526
  // After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled
1512
1527
  // clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That
1513
1528
  // way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler
@@ -1515,7 +1530,7 @@ var Sentry = (function (exports) {
1515
1530
  // guaranteed to fire at least once.)
1516
1531
  ['EventTarget', 'Node'].forEach((target) => {
1517
1532
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1518
- const proto = global$2[target] && global$2[target].prototype;
1533
+ const proto = global$5[target] && global$5[target].prototype;
1519
1534
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
1520
1535
  if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
1521
1536
  return;
@@ -1576,8 +1591,8 @@ var Sentry = (function (exports) {
1576
1591
  let _oldOnErrorHandler = null;
1577
1592
  /** JSDoc */
1578
1593
  function instrumentError() {
1579
- _oldOnErrorHandler = global$2.onerror;
1580
- global$2.onerror = function (msg, url, line, column, error) {
1594
+ _oldOnErrorHandler = global$5.onerror;
1595
+ global$5.onerror = function (msg, url, line, column, error) {
1581
1596
  triggerHandlers('error', {
1582
1597
  column,
1583
1598
  error,
@@ -1595,8 +1610,8 @@ var Sentry = (function (exports) {
1595
1610
  let _oldOnUnhandledRejectionHandler = null;
1596
1611
  /** JSDoc */
1597
1612
  function instrumentUnhandledRejection() {
1598
- _oldOnUnhandledRejectionHandler = global$2.onunhandledrejection;
1599
- global$2.onunhandledrejection = function (e) {
1613
+ _oldOnUnhandledRejectionHandler = global$5.onunhandledrejection;
1614
+ global$5.onunhandledrejection = function (e) {
1600
1615
  triggerHandlers('unhandledrejection', e);
1601
1616
  if (_oldOnUnhandledRejectionHandler) {
1602
1617
  // eslint-disable-next-line prefer-rest-params
@@ -2107,23 +2122,10 @@ var Sentry = (function (exports) {
2107
2122
  timeOrigin,
2108
2123
  };
2109
2124
  }
2110
- /**
2111
- * Returns the native Performance API implementation from Node.js. Returns undefined in old Node.js versions that don't
2112
- * implement the API.
2113
- */
2114
- function getNodePerformance() {
2115
- try {
2116
- const perfHooks = dynamicRequire(module, 'perf_hooks');
2117
- return perfHooks.performance;
2118
- }
2119
- catch (_) {
2120
- return undefined;
2121
- }
2122
- }
2123
2125
  /**
2124
2126
  * The Performance API implementation for the current platform, if available.
2125
2127
  */
2126
- const platformPerformance = isNodeEnv() ? getNodePerformance() : getBrowserPerformance();
2128
+ const platformPerformance = getBrowserPerformance();
2127
2129
  const timestampSource = platformPerformance === undefined
2128
2130
  ? dateTimestampSource
2129
2131
  : {
@@ -2149,7 +2151,7 @@ var Sentry = (function (exports) {
2149
2151
  * The number of milliseconds since the UNIX epoch. This value is only usable in a browser, and only when the
2150
2152
  * performance API is available.
2151
2153
  */
2152
- const browserPerformanceTimeOrigin = (() => {
2154
+ (() => {
2153
2155
  // Unfortunately browsers may report an inaccurate time origin data, through either performance.timeOrigin or
2154
2156
  // performance.timing.navigationStart, which results in poor results in performance data. We only treat time origin
2155
2157
  // data as reliable if they are within a reasonable threshold of the current time.
@@ -3160,38 +3162,9 @@ var Sentry = (function (exports) {
3160
3162
  if (!hasHubOnCarrier(registry) || getHubFromCarrier(registry).isOlderThan(API_VERSION)) {
3161
3163
  setHubOnCarrier(registry, new Hub());
3162
3164
  }
3163
- // Prefer domains over global if they are there (applicable only to Node environment)
3164
- if (isNodeEnv()) {
3165
- return getHubFromActiveDomain(registry);
3166
- }
3167
3165
  // Return hub that lives on a global object
3168
3166
  return getHubFromCarrier(registry);
3169
3167
  }
3170
- /**
3171
- * Try to read the hub from an active domain, and fallback to the registry if one doesn't exist
3172
- * @returns discovered hub
3173
- */
3174
- function getHubFromActiveDomain(registry) {
3175
- try {
3176
- const sentry = getMainCarrier().__SENTRY__;
3177
- const activeDomain = sentry && sentry.extensions && sentry.extensions.domain && sentry.extensions.domain.active;
3178
- // If there's no active domain, just return global hub
3179
- if (!activeDomain) {
3180
- return getHubFromCarrier(registry);
3181
- }
3182
- // If there's no hub on current domain, or it's an old API, assign a new one
3183
- if (!hasHubOnCarrier(activeDomain) || getHubFromCarrier(activeDomain).isOlderThan(API_VERSION)) {
3184
- const registryHubTopStack = getHubFromCarrier(registry).getStackTop();
3185
- setHubOnCarrier(activeDomain, new Hub(registryHubTopStack.client, Scope.clone(registryHubTopStack.scope)));
3186
- }
3187
- // Return hub that lives on a domain
3188
- return getHubFromCarrier(activeDomain);
3189
- }
3190
- catch (_Oo) {
3191
- // Return hub that lives on a global object
3192
- return getHubFromCarrier(registry);
3193
- }
3194
- }
3195
3168
  /**
3196
3169
  * This will tell whether a carrier has a hub on it or not
3197
3170
  * @param carrier object
@@ -3820,6 +3793,11 @@ var Sentry = (function (exports) {
3820
3793
  result = finalScope.applyToEvent(prepared, hint);
3821
3794
  }
3822
3795
  return result.then(evt => {
3796
+ if (evt) {
3797
+ // TODO this is more of the hack trying to solve https://github.com/getsentry/sentry-javascript/issues/2809
3798
+ // it is only attached as extra data to the event if the event somehow skips being normalized
3799
+ evt.sdkProcessingMetadata = Object.assign(Object.assign({}, evt.sdkProcessingMetadata), { normalizeDepth: normalize(normalizeDepth) });
3800
+ }
3823
3801
  if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
3824
3802
  return this._normalizeEvent(evt, normalizeDepth);
3825
3803
  }
@@ -4164,22 +4142,27 @@ var Sentry = (function (exports) {
4164
4142
  const { transactionSampling } = event.sdkProcessingMetadata || {};
4165
4143
  const { method: samplingMethod, rate: sampleRate } = transactionSampling || {};
4166
4144
  // TODO: Below is a temporary hack in order to debug a serialization error - see
4167
- // https://github.com/getsentry/sentry-javascript/issues/2809 and
4168
- // https://github.com/getsentry/sentry-javascript/pull/4425. TL;DR: even though we normalize all events (which should
4169
- // prevent this), something is causing `JSON.stringify` to throw a circular reference error.
4145
+ // https://github.com/getsentry/sentry-javascript/issues/2809,
4146
+ // https://github.com/getsentry/sentry-javascript/pull/4425, and
4147
+ // https://github.com/getsentry/sentry-javascript/pull/4574.
4148
+ //
4149
+ // TL; DR: even though we normalize all events (which should prevent this), something is causing `JSON.stringify` to
4150
+ // throw a circular reference error.
4170
4151
  //
4171
4152
  // When it's time to remove it:
4172
4153
  // 1. Delete everything between here and where the request object `req` is created, EXCEPT the line deleting
4173
4154
  // `sdkProcessingMetadata`
4174
4155
  // 2. Restore the original version of the request body, which is commented out
4175
- // 3. Search for `skippedNormalization` and pull out the companion hack in the browser playwright tests
4156
+ // 3. Search for either of the PR URLs above and pull out the companion hacks in the browser playwright tests and the
4157
+ // baseClient tests in this package
4176
4158
  enhanceEventWithSdkInfo(event, api.metadata.sdk);
4177
4159
  event.tags = event.tags || {};
4178
4160
  event.extra = event.extra || {};
4179
4161
  // In theory, all events should be marked as having gone through normalization and so
4180
- // we should never set this tag
4162
+ // we should never set this tag/extra data
4181
4163
  if (!(event.sdkProcessingMetadata && event.sdkProcessingMetadata.baseClientNormalized)) {
4182
4164
  event.tags.skippedNormalization = true;
4165
+ event.extra.normalizeDepth = event.sdkProcessingMetadata ? event.sdkProcessingMetadata.normalizeDepth : 'unset';
4183
4166
  }
4184
4167
  // prevent this data from being sent to sentry
4185
4168
  // TODO: This is NOT part of the hack - DO NOT DELETE
@@ -4261,7 +4244,7 @@ var Sentry = (function (exports) {
4261
4244
  hub.bindClient(client);
4262
4245
  }
4263
4246
 
4264
- const SDK_VERSION = '6.17.6';
4247
+ const SDK_VERSION = '6.17.9';
4265
4248
 
4266
4249
  let originalFunctionToString;
4267
4250
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4484,213 +4467,95 @@ var Sentry = (function (exports) {
4484
4467
  */
4485
4468
  InboundFilters.id = 'InboundFilters';
4486
4469
 
4487
-
4488
-
4489
4470
  var CoreIntegrations = /*#__PURE__*/Object.freeze({
4490
4471
  __proto__: null,
4491
4472
  FunctionToString: FunctionToString,
4492
4473
  InboundFilters: InboundFilters
4493
4474
  });
4494
4475
 
4495
- /**
4496
- * This was originally forked from https://github.com/occ/TraceKit, but has since been
4497
- * largely modified and is now maintained as part of Sentry JS SDK.
4498
- */
4499
4476
  // global reference to slice
4500
4477
  const UNKNOWN_FUNCTION = '?';
4501
- // Chromium based browsers: Chrome, Brave, new Opera, new Edge
4502
- const chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
4503
- // gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
4504
- // generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
4505
- // We need this specific case for now because we want no other regex to match.
4506
- const gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
4507
- const winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
4508
- const geckoEval = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
4509
- const chromeEval = /\((\S*)(?::(\d+))(?::(\d+))\)/;
4510
- // Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
4511
- const reactMinifiedRegexp = /Minified React error #\d+;/i;
4512
- /** JSDoc */
4513
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
4514
- function computeStackTrace(ex) {
4515
- let stack = null;
4516
- let popSize = 0;
4517
- if (ex) {
4518
- if (typeof ex.framesToPop === 'number') {
4519
- popSize = ex.framesToPop;
4520
- }
4521
- else if (reactMinifiedRegexp.test(ex.message)) {
4522
- popSize = 1;
4523
- }
4524
- }
4525
- try {
4526
- // This must be tried first because Opera 10 *destroys*
4527
- // its stacktrace property if you try to access the stack
4528
- // property first!!
4529
- stack = computeStackTraceFromStacktraceProp(ex);
4530
- if (stack) {
4531
- return popFrames(stack, popSize);
4532
- }
4533
- }
4534
- catch (e) {
4535
- // no-empty
4536
- }
4537
- try {
4538
- stack = computeStackTraceFromStackProp(ex);
4539
- if (stack) {
4540
- return popFrames(stack, popSize);
4541
- }
4478
+ function createFrame(filename, func, lineno, colno) {
4479
+ const frame = {
4480
+ filename,
4481
+ function: func,
4482
+ // All browser frames are considered in_app
4483
+ in_app: true,
4484
+ };
4485
+ if (lineno !== undefined) {
4486
+ frame.lineno = lineno;
4542
4487
  }
4543
- catch (e) {
4544
- // no-empty
4488
+ if (colno !== undefined) {
4489
+ frame.colno = colno;
4545
4490
  }
4546
- return {
4547
- message: extractMessage(ex),
4548
- name: ex && ex.name,
4549
- stack: [],
4550
- failed: true,
4551
- };
4491
+ return frame;
4552
4492
  }
4553
- /** JSDoc */
4554
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, complexity
4555
- function computeStackTraceFromStackProp(ex) {
4556
- if (!ex || !ex.stack) {
4557
- return null;
4558
- }
4559
- const stack = [];
4560
- const lines = ex.stack.split('\n');
4561
- let isEval;
4562
- let submatch;
4563
- let parts;
4564
- let element;
4565
- for (let i = 0; i < lines.length; ++i) {
4566
- if ((parts = chrome.exec(lines[i]))) {
4567
- const isNative = parts[2] && parts[2].indexOf('native') === 0; // start of line
4568
- isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line
4569
- if (isEval && (submatch = chromeEval.exec(parts[2]))) {
4493
+ // Chromium based browsers: Chrome, Brave, new Opera, new Edge
4494
+ const chromeRegex = /^\s*at (?:(.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
4495
+ const chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
4496
+ const chrome = line => {
4497
+ const parts = chromeRegex.exec(line);
4498
+ if (parts) {
4499
+ const isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line
4500
+ if (isEval) {
4501
+ const subMatch = chromeEvalRegex.exec(parts[2]);
4502
+ if (subMatch) {
4570
4503
  // throw out eval line/column and use top-most line/column number
4571
- parts[2] = submatch[1]; // url
4572
- parts[3] = submatch[2]; // line
4573
- parts[4] = submatch[3]; // column
4504
+ parts[2] = subMatch[1]; // url
4505
+ parts[3] = subMatch[2]; // line
4506
+ parts[4] = subMatch[3]; // column
4574
4507
  }
4575
- // Arpad: Working with the regexp above is super painful. it is quite a hack, but just stripping the `address at `
4576
- // prefix here seems like the quickest solution for now.
4577
- let url = parts[2] && parts[2].indexOf('address at ') === 0 ? parts[2].substr('address at '.length) : parts[2];
4578
- // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now
4579
- // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)
4580
- let func = parts[1] || UNKNOWN_FUNCTION;
4581
- [func, url] = extractSafariExtensionDetails(func, url);
4582
- element = {
4583
- url,
4584
- func,
4585
- args: isNative ? [parts[2]] : [],
4586
- line: parts[3] ? +parts[3] : null,
4587
- column: parts[4] ? +parts[4] : null,
4588
- };
4589
- }
4590
- else if ((parts = winjs.exec(lines[i]))) {
4591
- element = {
4592
- url: parts[2],
4593
- func: parts[1] || UNKNOWN_FUNCTION,
4594
- args: [],
4595
- line: +parts[3],
4596
- column: parts[4] ? +parts[4] : null,
4597
- };
4598
4508
  }
4599
- else if ((parts = gecko.exec(lines[i]))) {
4600
- isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
4601
- if (isEval && (submatch = geckoEval.exec(parts[3]))) {
4509
+ // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now
4510
+ // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)
4511
+ const [func, filename] = extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2]);
4512
+ return createFrame(filename, func, parts[3] ? +parts[3] : undefined, parts[4] ? +parts[4] : undefined);
4513
+ }
4514
+ return;
4515
+ };
4516
+ // gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
4517
+ // generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
4518
+ // We need this specific case for now because we want no other regex to match.
4519
+ const geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
4520
+ const geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
4521
+ const gecko = line => {
4522
+ const parts = geckoREgex.exec(line);
4523
+ if (parts) {
4524
+ const isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
4525
+ if (isEval) {
4526
+ const subMatch = geckoEvalRegex.exec(parts[3]);
4527
+ if (subMatch) {
4602
4528
  // throw out eval line/column and use top-most line number
4603
4529
  parts[1] = parts[1] || `eval`;
4604
- parts[3] = submatch[1];
4605
- parts[4] = submatch[2];
4530
+ parts[3] = subMatch[1];
4531
+ parts[4] = subMatch[2];
4606
4532
  parts[5] = ''; // no column when eval
4607
4533
  }
4608
- else if (i === 0 && !parts[5] && ex.columnNumber !== void 0) {
4609
- // FireFox uses this awesome columnNumber property for its top frame
4610
- // Also note, Firefox's column number is 0-based and everything else expects 1-based,
4611
- // so adding 1
4612
- // NOTE: this hack doesn't work if top-most frame is eval
4613
- stack[0].column = ex.columnNumber + 1;
4614
- }
4615
- let url = parts[3];
4616
- let func = parts[1] || UNKNOWN_FUNCTION;
4617
- [func, url] = extractSafariExtensionDetails(func, url);
4618
- element = {
4619
- url,
4620
- func,
4621
- args: parts[2] ? parts[2].split(',') : [],
4622
- line: parts[4] ? +parts[4] : null,
4623
- column: parts[5] ? +parts[5] : null,
4624
- };
4625
- }
4626
- else {
4627
- continue;
4628
- }
4629
- if (!element.func && element.line) {
4630
- element.func = UNKNOWN_FUNCTION;
4631
4534
  }
4632
- stack.push(element);
4633
- }
4634
- if (!stack.length) {
4635
- return null;
4636
- }
4637
- return {
4638
- message: extractMessage(ex),
4639
- name: ex.name,
4640
- stack,
4641
- };
4642
- }
4643
- /** JSDoc */
4644
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4645
- function computeStackTraceFromStacktraceProp(ex) {
4646
- if (!ex || !ex.stacktrace) {
4647
- return null;
4648
- }
4649
- // Access and store the stacktrace property before doing ANYTHING
4650
- // else to it because Opera is not very good at providing it
4651
- // reliably in other circumstances.
4652
- const stacktrace = ex.stacktrace;
4653
- const opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
4654
- const opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\((.*)\))? in (.*):\s*$/i;
4655
- const lines = stacktrace.split('\n');
4656
- const stack = [];
4657
- let parts;
4658
- for (let line = 0; line < lines.length; line += 2) {
4659
- let element = null;
4660
- if ((parts = opera10Regex.exec(lines[line]))) {
4661
- element = {
4662
- url: parts[2],
4663
- func: parts[3],
4664
- args: [],
4665
- line: +parts[1],
4666
- column: null,
4667
- };
4668
- }
4669
- else if ((parts = opera11Regex.exec(lines[line]))) {
4670
- element = {
4671
- url: parts[6],
4672
- func: parts[3] || parts[4],
4673
- args: parts[5] ? parts[5].split(',') : [],
4674
- line: +parts[1],
4675
- column: +parts[2],
4676
- };
4677
- }
4678
- if (element) {
4679
- if (!element.func && element.line) {
4680
- element.func = UNKNOWN_FUNCTION;
4681
- }
4682
- stack.push(element);
4683
- }
4684
- }
4685
- if (!stack.length) {
4686
- return null;
4535
+ let filename = parts[3];
4536
+ let func = parts[1] || UNKNOWN_FUNCTION;
4537
+ [func, filename] = extractSafariExtensionDetails(func, filename);
4538
+ return createFrame(filename, func, parts[4] ? +parts[4] : undefined, parts[5] ? +parts[5] : undefined);
4687
4539
  }
4688
- return {
4689
- message: extractMessage(ex),
4690
- name: ex.name,
4691
- stack,
4692
- };
4693
- }
4540
+ return;
4541
+ };
4542
+ const winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
4543
+ const winjs = line => {
4544
+ const parts = winjsRegex.exec(line);
4545
+ return parts
4546
+ ? createFrame(parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined)
4547
+ : undefined;
4548
+ };
4549
+ const opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
4550
+ const opera10 = line => {
4551
+ const parts = opera10Regex.exec(line);
4552
+ return parts ? createFrame(parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined;
4553
+ };
4554
+ const opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
4555
+ const opera11 = line => {
4556
+ const parts = opera11Regex.exec(line);
4557
+ return parts ? createFrame(parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;
4558
+ };
4694
4559
  /**
4695
4560
  * Safari web extensions, starting version unknown, can produce "frames-only" stacktraces.
4696
4561
  * What it means, is that instead of format like:
@@ -4708,56 +4573,31 @@ var Sentry = (function (exports) {
4708
4573
  *
4709
4574
  * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.
4710
4575
  * This function is extracted so that we can use it in both places without duplicating the logic.
4711
- * Unfortunatelly "just" changing RegExp is too complicated now and making it pass all tests
4576
+ * Unfortunately "just" changing RegExp is too complicated now and making it pass all tests
4712
4577
  * and fix this case seems like an impossible, or at least way too time-consuming task.
4713
4578
  */
4714
- const extractSafariExtensionDetails = (func, url) => {
4579
+ const extractSafariExtensionDetails = (func, filename) => {
4715
4580
  const isSafariExtension = func.indexOf('safari-extension') !== -1;
4716
4581
  const isSafariWebExtension = func.indexOf('safari-web-extension') !== -1;
4717
4582
  return isSafariExtension || isSafariWebExtension
4718
4583
  ? [
4719
4584
  func.indexOf('@') !== -1 ? func.split('@')[0] : UNKNOWN_FUNCTION,
4720
- isSafariExtension ? `safari-extension:${url}` : `safari-web-extension:${url}`,
4585
+ isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`,
4721
4586
  ]
4722
- : [func, url];
4723
- };
4724
- /** Remove N number of frames from the stack */
4725
- function popFrames(stacktrace, popSize) {
4726
- try {
4727
- return Object.assign(Object.assign({}, stacktrace), { stack: stacktrace.stack.slice(popSize) });
4728
- }
4729
- catch (e) {
4730
- return stacktrace;
4731
- }
4732
- }
4733
- /**
4734
- * There are cases where stacktrace.message is an Event object
4735
- * https://github.com/getsentry/sentry-javascript/issues/1949
4736
- * In this specific case we try to extract stacktrace.message.error.message
4737
- */
4738
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4739
- function extractMessage(ex) {
4740
- const message = ex && ex.message;
4741
- if (!message) {
4742
- return 'No error message';
4743
- }
4744
- if (message.error && typeof message.error.message === 'string') {
4745
- return message.error.message;
4746
- }
4747
- return message;
4748
- }
4587
+ : [func, filename];
4588
+ };
4749
4589
 
4750
- const STACKTRACE_LIMIT = 50;
4751
4590
  /**
4752
4591
  * This function creates an exception from an TraceKitStackTrace
4753
4592
  * @param stacktrace TraceKitStackTrace that will be converted to an exception
4754
4593
  * @hidden
4755
4594
  */
4756
- function exceptionFromStacktrace(stacktrace) {
4757
- const frames = prepareFramesForEvent(stacktrace.stack);
4595
+ function exceptionFromError(ex) {
4596
+ // Get the frames first since Opera can lose the stack if we touch anything else first
4597
+ const frames = parseStackFrames(ex);
4758
4598
  const exception = {
4759
- type: stacktrace.name,
4760
- value: stacktrace.message,
4599
+ type: ex && ex.name,
4600
+ value: extractMessage(ex),
4761
4601
  };
4762
4602
  if (frames && frames.length) {
4763
4603
  exception.stacktrace = { frames };
@@ -4785,10 +4625,8 @@ var Sentry = (function (exports) {
4785
4625
  },
4786
4626
  };
4787
4627
  if (syntheticException) {
4788
- const stacktrace = computeStackTrace(syntheticException);
4789
- const frames = prepareFramesForEvent(stacktrace.stack);
4790
4628
  event.stacktrace = {
4791
- frames,
4629
+ frames: parseStackFrames(syntheticException),
4792
4630
  };
4793
4631
  }
4794
4632
  return event;
@@ -4796,43 +4634,57 @@ var Sentry = (function (exports) {
4796
4634
  /**
4797
4635
  * @hidden
4798
4636
  */
4799
- function eventFromStacktrace(stacktrace) {
4800
- const exception = exceptionFromStacktrace(stacktrace);
4637
+ function eventFromError(ex) {
4801
4638
  return {
4802
4639
  exception: {
4803
- values: [exception],
4640
+ values: [exceptionFromError(ex)],
4804
4641
  },
4805
4642
  };
4806
4643
  }
4644
+ /** Parses stack frames from an error */
4645
+ function parseStackFrames(ex) {
4646
+ // Access and store the stacktrace property before doing ANYTHING
4647
+ // else to it because Opera is not very good at providing it
4648
+ // reliably in other circumstances.
4649
+ const stacktrace = ex.stacktrace || ex.stack || '';
4650
+ const popSize = getPopSize(ex);
4651
+ try {
4652
+ // The order of the parsers in important
4653
+ return createStackParser(opera10, opera11, chrome, winjs, gecko)(stacktrace, popSize);
4654
+ }
4655
+ catch (e) {
4656
+ // no-empty
4657
+ }
4658
+ return [];
4659
+ }
4660
+ // Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
4661
+ const reactMinifiedRegexp = /Minified React error #\d+;/i;
4662
+ function getPopSize(ex) {
4663
+ if (ex) {
4664
+ if (typeof ex.framesToPop === 'number') {
4665
+ return ex.framesToPop;
4666
+ }
4667
+ if (reactMinifiedRegexp.test(ex.message)) {
4668
+ return 1;
4669
+ }
4670
+ }
4671
+ return 0;
4672
+ }
4807
4673
  /**
4808
- * @hidden
4674
+ * There are cases where stacktrace.message is an Event object
4675
+ * https://github.com/getsentry/sentry-javascript/issues/1949
4676
+ * In this specific case we try to extract stacktrace.message.error.message
4809
4677
  */
4810
- function prepareFramesForEvent(stack) {
4811
- if (!stack || !stack.length) {
4812
- return [];
4813
- }
4814
- let localStack = stack;
4815
- const firstFrameFunction = localStack[0].func || '';
4816
- const lastFrameFunction = localStack[localStack.length - 1].func || '';
4817
- // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
4818
- if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
4819
- localStack = localStack.slice(1);
4678
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4679
+ function extractMessage(ex) {
4680
+ const message = ex && ex.message;
4681
+ if (!message) {
4682
+ return 'No error message';
4820
4683
  }
4821
- // If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
4822
- if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
4823
- localStack = localStack.slice(0, -1);
4684
+ if (message.error && typeof message.error.message === 'string') {
4685
+ return message.error.message;
4824
4686
  }
4825
- // The frame where the crash happened, should be the last entry in the array
4826
- return localStack
4827
- .slice(0, STACKTRACE_LIMIT)
4828
- .map((frame) => ({
4829
- colno: frame.column === null ? undefined : frame.column,
4830
- filename: frame.url || localStack[0].url,
4831
- function: frame.func || '?',
4832
- in_app: true,
4833
- lineno: frame.line === null ? undefined : frame.line,
4834
- }))
4835
- .reverse();
4687
+ return message;
4836
4688
  }
4837
4689
 
4838
4690
  /**
@@ -4874,10 +4726,7 @@ var Sentry = (function (exports) {
4874
4726
  if (isErrorEvent(exception) && exception.error) {
4875
4727
  // If it is an ErrorEvent with `error` property, extract it to get actual Error
4876
4728
  const errorEvent = exception;
4877
- // eslint-disable-next-line no-param-reassign
4878
- exception = errorEvent.error;
4879
- event = eventFromStacktrace(computeStackTrace(exception));
4880
- return event;
4729
+ return eventFromError(errorEvent.error);
4881
4730
  }
4882
4731
  // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name
4883
4732
  // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be
@@ -4889,7 +4738,7 @@ var Sentry = (function (exports) {
4889
4738
  if (isDOMError(exception) || isDOMException(exception)) {
4890
4739
  const domException = exception;
4891
4740
  if ('stack' in exception) {
4892
- event = eventFromStacktrace(computeStackTrace(exception));
4741
+ event = eventFromError(exception);
4893
4742
  }
4894
4743
  else {
4895
4744
  const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');
@@ -4904,8 +4753,7 @@ var Sentry = (function (exports) {
4904
4753
  }
4905
4754
  if (isError(exception)) {
4906
4755
  // we have a real Error object, do nothing
4907
- event = eventFromStacktrace(computeStackTrace(exception));
4908
- return event;
4756
+ return eventFromError(exception);
4909
4757
  }
4910
4758
  if (isPlainObject(exception) || isEvent(exception)) {
4911
4759
  // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize
@@ -4942,16 +4790,14 @@ var Sentry = (function (exports) {
4942
4790
  message: input,
4943
4791
  };
4944
4792
  if (options.attachStacktrace && syntheticException) {
4945
- const stacktrace = computeStackTrace(syntheticException);
4946
- const frames = prepareFramesForEvent(stacktrace.stack);
4947
4793
  event.stacktrace = {
4948
- frames,
4794
+ frames: parseStackFrames(syntheticException),
4949
4795
  };
4950
4796
  }
4951
4797
  return event;
4952
4798
  }
4953
4799
 
4954
- const global$3 = getGlobalObject();
4800
+ const global$4 = getGlobalObject();
4955
4801
  let cachedFetchImpl;
4956
4802
  /**
4957
4803
  * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
@@ -4997,11 +4843,11 @@ var Sentry = (function (exports) {
4997
4843
  }
4998
4844
  /* eslint-disable @typescript-eslint/unbound-method */
4999
4845
  // Fast path to avoid DOM I/O
5000
- if (isNativeFetch(global$3.fetch)) {
5001
- return (cachedFetchImpl = global$3.fetch.bind(global$3));
4846
+ if (isNativeFetch(global$4.fetch)) {
4847
+ return (cachedFetchImpl = global$4.fetch.bind(global$4));
5002
4848
  }
5003
- const document = global$3.document;
5004
- let fetchImpl = global$3.fetch;
4849
+ const document = global$4.document;
4850
+ let fetchImpl = global$4.fetch;
5005
4851
  // eslint-disable-next-line deprecation/deprecation
5006
4852
  if (document && typeof document.createElement === `function`) {
5007
4853
  try {
@@ -5020,7 +4866,7 @@ var Sentry = (function (exports) {
5020
4866
  }
5021
4867
  }
5022
4868
  }
5023
- return (cachedFetchImpl = fetchImpl.bind(global$3));
4869
+ return (cachedFetchImpl = fetchImpl.bind(global$4));
5024
4870
  /* eslint-enable @typescript-eslint/unbound-method */
5025
4871
  }
5026
4872
  /**
@@ -5030,11 +4876,11 @@ var Sentry = (function (exports) {
5030
4876
  * @param body report payload
5031
4877
  */
5032
4878
  function sendReport(url, body) {
5033
- const isRealNavigator = Object.prototype.toString.call(global$3 && global$3.navigator) === '[object Navigator]';
5034
- const hasSendBeacon = isRealNavigator && typeof global$3.navigator.sendBeacon === 'function';
4879
+ const isRealNavigator = Object.prototype.toString.call(global$4 && global$4.navigator) === '[object Navigator]';
4880
+ const hasSendBeacon = isRealNavigator && typeof global$4.navigator.sendBeacon === 'function';
5035
4881
  if (hasSendBeacon) {
5036
4882
  // Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
5037
- const sendBeacon = global$3.navigator.sendBeacon.bind(global$3.navigator);
4883
+ const sendBeacon = global$4.navigator.sendBeacon.bind(global$4.navigator);
5038
4884
  return sendBeacon(url, body);
5039
4885
  }
5040
4886
  if (supportsFetch()) {
@@ -5052,7 +4898,7 @@ var Sentry = (function (exports) {
5052
4898
  const tyStr = ty;
5053
4899
  return tyStr === 'event' ? 'error' : tyStr;
5054
4900
  }
5055
- const global$4 = getGlobalObject();
4901
+ const global$3 = getGlobalObject();
5056
4902
  /** Base Transport class implementation */
5057
4903
  class BaseTransport {
5058
4904
  constructor(options) {
@@ -5065,9 +4911,9 @@ var Sentry = (function (exports) {
5065
4911
  this._api = initAPIDetails(options.dsn, options._metadata, options.tunnel);
5066
4912
  // eslint-disable-next-line deprecation/deprecation
5067
4913
  this.url = getStoreEndpointWithUrlEncodedAuth(this._api.dsn);
5068
- if (this.options.sendClientReports && global$4.document) {
5069
- global$4.document.addEventListener('visibilitychange', () => {
5070
- if (global$4.document.visibilityState === 'hidden') {
4914
+ if (this.options.sendClientReports && global$3.document) {
4915
+ global$3.document.addEventListener('visibilitychange', () => {
4916
+ if (global$3.document.visibilityState === 'hidden') {
5071
4917
  this._flushOutcomes();
5072
4918
  }
5073
4919
  });
@@ -5331,8 +5177,6 @@ var Sentry = (function (exports) {
5331
5177
  }
5332
5178
  }
5333
5179
 
5334
-
5335
-
5336
5180
  var index = /*#__PURE__*/Object.freeze({
5337
5181
  __proto__: null,
5338
5182
  BaseTransport: BaseTransport,
@@ -5376,7 +5220,7 @@ var Sentry = (function (exports) {
5376
5220
  }
5377
5221
  }
5378
5222
 
5379
- const global$5 = getGlobalObject();
5223
+ const global$2 = getGlobalObject();
5380
5224
  let ignoreOnError = 0;
5381
5225
  /**
5382
5226
  * @hidden
@@ -5402,7 +5246,7 @@ var Sentry = (function (exports) {
5402
5246
  * @returns The wrapped function.
5403
5247
  * @hidden
5404
5248
  */
5405
- function wrap(fn, options = {}, before) {
5249
+ function wrap$1(fn, options = {}, before) {
5406
5250
  // for future readers what this does is wrap a function and then create
5407
5251
  // a bi-directional wrapping between them.
5408
5252
  //
@@ -5439,7 +5283,7 @@ var Sentry = (function (exports) {
5439
5283
  before.apply(this, arguments);
5440
5284
  }
5441
5285
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
5442
- const wrappedArguments = args.map((arg) => wrap(arg, options));
5286
+ const wrappedArguments = args.map((arg) => wrap$1(arg, options));
5443
5287
  // Attempt to invoke user-land function
5444
5288
  // NOTE: If you are a Sentry user, and you are seeing this stack frame, it
5445
5289
  // means the sentry.javascript SDK caught an error invoking your application code. This
@@ -5497,7 +5341,7 @@ var Sentry = (function (exports) {
5497
5341
  * @hidden
5498
5342
  */
5499
5343
  function injectReportDialog(options = {}) {
5500
- if (!global$5.document) {
5344
+ if (!global$2.document) {
5501
5345
  return;
5502
5346
  }
5503
5347
  if (!options.eventId) {
@@ -5512,14 +5356,14 @@ var Sentry = (function (exports) {
5512
5356
  }
5513
5357
  return;
5514
5358
  }
5515
- const script = global$5.document.createElement('script');
5359
+ const script = global$2.document.createElement('script');
5516
5360
  script.async = true;
5517
5361
  script.src = getReportDialogEndpoint(options.dsn, options);
5518
5362
  if (options.onLoad) {
5519
5363
  // eslint-disable-next-line @typescript-eslint/unbound-method
5520
5364
  script.onload = options.onLoad;
5521
5365
  }
5522
- const injectionPoint = global$5.document.head || global$5.document.body;
5366
+ const injectionPoint = global$2.document.head || global$2.document.body;
5523
5367
  if (injectionPoint) {
5524
5368
  injectionPoint.appendChild(script);
5525
5369
  }
@@ -5804,7 +5648,7 @@ var Sentry = (function (exports) {
5804
5648
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5805
5649
  return function (...args) {
5806
5650
  const originalCallback = args[0];
5807
- args[0] = wrap(originalCallback, {
5651
+ args[0] = wrap$1(originalCallback, {
5808
5652
  mechanism: {
5809
5653
  data: { function: getFunctionName(original) },
5810
5654
  handled: true,
@@ -5820,7 +5664,7 @@ var Sentry = (function (exports) {
5820
5664
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5821
5665
  return function (callback) {
5822
5666
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5823
- return original.call(this, wrap(callback, {
5667
+ return original.call(this, wrap$1(callback, {
5824
5668
  mechanism: {
5825
5669
  data: {
5826
5670
  function: 'requestAnimationFrame',
@@ -5859,7 +5703,7 @@ var Sentry = (function (exports) {
5859
5703
  wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);
5860
5704
  }
5861
5705
  // Otherwise wrap directly
5862
- return wrap(original, wrapOptions);
5706
+ return wrap$1(original, wrapOptions);
5863
5707
  });
5864
5708
  }
5865
5709
  });
@@ -5880,7 +5724,7 @@ var Sentry = (function (exports) {
5880
5724
  return function (eventName, fn, options) {
5881
5725
  try {
5882
5726
  if (typeof fn.handleEvent === 'function') {
5883
- fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
5727
+ fn.handleEvent = wrap$1(fn.handleEvent.bind(fn), {
5884
5728
  mechanism: {
5885
5729
  data: {
5886
5730
  function: 'handleEvent',
@@ -5898,7 +5742,7 @@ var Sentry = (function (exports) {
5898
5742
  }
5899
5743
  return original.call(this, eventName,
5900
5744
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5901
- wrap(fn, {
5745
+ wrap$1(fn, {
5902
5746
  mechanism: {
5903
5747
  data: {
5904
5748
  function: 'addEventListener',
@@ -6212,12 +6056,11 @@ var Sentry = (function (exports) {
6212
6056
  if (!isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {
6213
6057
  return stack;
6214
6058
  }
6215
- const stacktrace = computeStackTrace(error[key]);
6216
- const exception = exceptionFromStacktrace(stacktrace);
6059
+ const exception = exceptionFromError(error[key]);
6217
6060
  return _walkErrorTree(limit, error[key], key, [exception, ...stack]);
6218
6061
  }
6219
6062
 
6220
- const global$6 = getGlobalObject();
6063
+ const global$1 = getGlobalObject();
6221
6064
  /** UserAgent */
6222
6065
  class UserAgent {
6223
6066
  constructor() {
@@ -6233,13 +6076,13 @@ var Sentry = (function (exports) {
6233
6076
  addGlobalEventProcessor((event) => {
6234
6077
  if (getCurrentHub().getIntegration(UserAgent)) {
6235
6078
  // if none of the information we want exists, don't bother
6236
- if (!global$6.navigator && !global$6.location && !global$6.document) {
6079
+ if (!global$1.navigator && !global$1.location && !global$1.document) {
6237
6080
  return event;
6238
6081
  }
6239
6082
  // grab as much info as exists and add it to the event
6240
- const url = (event.request && event.request.url) || (global$6.location && global$6.location.href);
6241
- const { referrer } = global$6.document || {};
6242
- const { userAgent } = global$6.navigator || {};
6083
+ const url = (event.request && event.request.url) || (global$1.location && global$1.location.href);
6084
+ const { referrer } = global$1.document || {};
6085
+ const { userAgent } = global$1.navigator || {};
6243
6086
  const headers = Object.assign(Object.assign(Object.assign({}, (event.request && event.request.headers)), (referrer && { Referer: referrer })), (userAgent && { 'User-Agent': userAgent }));
6244
6087
  const request = Object.assign(Object.assign({}, (url && { url })), { headers });
6245
6088
  return Object.assign(Object.assign({}, event), { request });
@@ -6417,8 +6260,6 @@ var Sentry = (function (exports) {
6417
6260
  return undefined;
6418
6261
  }
6419
6262
 
6420
-
6421
-
6422
6263
  var BrowserIntegrations = /*#__PURE__*/Object.freeze({
6423
6264
  __proto__: null,
6424
6265
  GlobalHandlers: GlobalHandlers,
@@ -6665,8 +6506,8 @@ var Sentry = (function (exports) {
6665
6506
  * @returns The result of wrapped function call.
6666
6507
  */
6667
6508
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6668
- function wrap$1(fn) {
6669
- return wrap(fn)();
6509
+ function wrap(fn) {
6510
+ return wrap$1(fn)();
6670
6511
  }
6671
6512
  function startSessionOnHub(hub) {
6672
6513
  hub.startSession({ ignoreDuration: true });
@@ -6755,9 +6596,9 @@ var Sentry = (function (exports) {
6755
6596
  exports.showReportDialog = showReportDialog;
6756
6597
  exports.startTransaction = startTransaction;
6757
6598
  exports.withScope = withScope;
6758
- exports.wrap = wrap$1;
6599
+ exports.wrap = wrap;
6759
6600
 
6760
6601
  return exports;
6761
6602
 
6762
- }({}));
6603
+ })({});
6763
6604
  //# sourceMappingURL=bundle.es6.js.map