@sentry/browser 6.17.8-beta.0 → 6.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/build/bundle.es6.js +266 -340
  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 +298 -356
  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 +7 -13
  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 +55 -42
  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 +8 -14
  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 +53 -40
  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 -7
  38. package/dist/tracekit.d.ts +0 -23
  39. package/dist/tracekit.d.ts.map +0 -1
  40. package/dist/tracekit.js +0 -184
  41. package/dist/tracekit.js.map +0 -1
  42. package/esm/tracekit.d.ts +0 -23
  43. package/esm/tracekit.d.ts.map +0 -1
  44. package/esm/tracekit.js +0 -182
  45. package/esm/tracekit.js.map +0 -1
package/build/bundle.js CHANGED
@@ -1,5 +1,6 @@
1
- /*! @sentry/browser 6.17.8-beta.0 (07f9257) | https://github.com/getsentry/sentry-javascript */
1
+ /*! @sentry/browser 6.18.0 (70c1d77) | https://github.com/getsentry/sentry-javascript */
2
2
  var Sentry = (function (exports) {
3
+
3
4
  /*! *****************************************************************************
4
5
  Copyright (c) Microsoft Corporation.
5
6
 
@@ -81,6 +82,7 @@ var Sentry = (function (exports) {
81
82
  /**
82
83
  * TODO(v7): Remove this enum and replace with SeverityLevel
83
84
  */
85
+ exports.Severity = void 0;
84
86
  (function (Severity) {
85
87
  /** JSDoc */
86
88
  Severity["Fatal"] = "fatal";
@@ -127,41 +129,7 @@ var Sentry = (function (exports) {
127
129
  * @returns true if this is a debug build
128
130
  */
129
131
  function isDebugBuild() {
130
- return typeof __SENTRY_NO_DEBUG__ !== 'undefined' && !__SENTRY_BROWSER_BUNDLE__;
131
- }
132
- /**
133
- * Figures out if we're building a browser bundle.
134
- *
135
- * @returns true if this is a browser bundle build.
136
- */
137
- function isBrowserBundle() {
138
- return typeof __SENTRY_BROWSER_BUNDLE__ !== 'undefined' && !!__SENTRY_BROWSER_BUNDLE__;
139
- }
140
-
141
- /**
142
- * NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
143
- * you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
144
- */
145
- /**
146
- * Checks whether we're in the Node.js or Browser environment
147
- *
148
- * @returns Answer to given question
149
- */
150
- function isNodeEnv() {
151
- // explicitly check for browser bundles as those can be optimized statically
152
- // by terser/rollup.
153
- return (!isBrowserBundle() &&
154
- Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]');
155
- }
156
- /**
157
- * Requires a module which is protected against bundler minification.
158
- *
159
- * @param request The module path to resolve
160
- */
161
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
162
- function dynamicRequire(mod, request) {
163
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
164
- return mod.require(request);
132
+ return typeof __SENTRY_NO_DEBUG__ !== 'undefined' && !true;
165
133
  }
166
134
 
167
135
  /**
@@ -175,9 +143,7 @@ var Sentry = (function (exports) {
175
143
  * @returns Global scope object
176
144
  */
177
145
  function getGlobalObject() {
178
- return (isNodeEnv()
179
- ? global
180
- : typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
146
+ return (typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
181
147
  ? window // eslint-disable-line no-restricted-globals
182
148
  : typeof self !== 'undefined'
183
149
  ? self
@@ -563,7 +529,7 @@ var Sentry = (function (exports) {
563
529
  var SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
564
530
 
565
531
  // TODO: Implement different loggers for different environments
566
- var global$1 = getGlobalObject();
532
+ var global$6 = getGlobalObject();
567
533
  /** Prefix for logging strings */
568
534
  var PREFIX = 'Sentry Logger ';
569
535
  /**
@@ -622,7 +588,7 @@ var Sentry = (function (exports) {
622
588
  return;
623
589
  }
624
590
  consoleSandbox(function () {
625
- global$1.console.log(PREFIX + "[Log]: " + args.join(' '));
591
+ global$6.console.log(PREFIX + "[Log]: " + args.join(' '));
626
592
  });
627
593
  };
628
594
  /** JSDoc */
@@ -635,7 +601,7 @@ var Sentry = (function (exports) {
635
601
  return;
636
602
  }
637
603
  consoleSandbox(function () {
638
- global$1.console.warn(PREFIX + "[Warn]: " + args.join(' '));
604
+ global$6.console.warn(PREFIX + "[Warn]: " + args.join(' '));
639
605
  });
640
606
  };
641
607
  /** JSDoc */
@@ -648,14 +614,14 @@ var Sentry = (function (exports) {
648
614
  return;
649
615
  }
650
616
  consoleSandbox(function () {
651
- global$1.console.error(PREFIX + "[Error]: " + args.join(' '));
617
+ global$6.console.error(PREFIX + "[Error]: " + args.join(' '));
652
618
  });
653
619
  };
654
620
  return Logger;
655
621
  }());
656
622
  // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
657
- global$1.__SENTRY__ = global$1.__SENTRY__ || {};
658
- var logger = global$1.__SENTRY__.logger || (global$1.__SENTRY__.logger = new Logger());
623
+ global$6.__SENTRY__ = global$6.__SENTRY__ || {};
624
+ var logger = global$6.__SENTRY__.logger || (global$6.__SENTRY__.logger = new Logger());
659
625
 
660
626
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
661
627
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -699,6 +665,79 @@ var Sentry = (function (exports) {
699
665
  return [memoize, unmemoize];
700
666
  }
701
667
 
668
+ var STACKTRACE_LIMIT = 50;
669
+ /**
670
+ * Creates a stack parser with the supplied line parsers
671
+ *
672
+ * StackFrames are returned in the correct order for Sentry Exception
673
+ * frames and with Sentry SDK internal frames removed from the top and bottom
674
+ *
675
+ * */
676
+ function createStackParser() {
677
+ var parsers = [];
678
+ for (var _i = 0; _i < arguments.length; _i++) {
679
+ parsers[_i] = arguments[_i];
680
+ }
681
+ return function (stack, skipFirst) {
682
+ var e_1, _a, e_2, _b;
683
+ if (skipFirst === void 0) { skipFirst = 0; }
684
+ var frames = [];
685
+ try {
686
+ for (var _c = __values(stack.split('\n').slice(skipFirst)), _d = _c.next(); !_d.done; _d = _c.next()) {
687
+ var line = _d.value;
688
+ try {
689
+ for (var parsers_1 = (e_2 = void 0, __values(parsers)), parsers_1_1 = parsers_1.next(); !parsers_1_1.done; parsers_1_1 = parsers_1.next()) {
690
+ var parser = parsers_1_1.value;
691
+ var frame = parser(line);
692
+ if (frame) {
693
+ frames.push(frame);
694
+ break;
695
+ }
696
+ }
697
+ }
698
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
699
+ finally {
700
+ try {
701
+ if (parsers_1_1 && !parsers_1_1.done && (_b = parsers_1.return)) _b.call(parsers_1);
702
+ }
703
+ finally { if (e_2) throw e_2.error; }
704
+ }
705
+ }
706
+ }
707
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
708
+ finally {
709
+ try {
710
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
711
+ }
712
+ finally { if (e_1) throw e_1.error; }
713
+ }
714
+ return stripSentryFramesAndReverse(frames);
715
+ };
716
+ }
717
+ /**
718
+ * @hidden
719
+ */
720
+ function stripSentryFramesAndReverse(stack) {
721
+ if (!stack.length) {
722
+ return [];
723
+ }
724
+ var localStack = stack;
725
+ var firstFrameFunction = localStack[0].function || '';
726
+ var lastFrameFunction = localStack[localStack.length - 1].function || '';
727
+ // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
728
+ if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
729
+ localStack = localStack.slice(1);
730
+ }
731
+ // 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)
732
+ if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
733
+ localStack = localStack.slice(0, -1);
734
+ }
735
+ // The frame where the crash happened, should be the last entry in the array
736
+ return localStack
737
+ .slice(0, STACKTRACE_LIMIT)
738
+ .map(function (frame) { return (__assign(__assign({}, frame), { filename: frame.filename || localStack[0].filename, function: frame.function || '?' })); })
739
+ .reverse();
740
+ }
702
741
  var defaultFunctionName = '<anonymous>';
703
742
  /**
704
743
  * Safely extract function name from itself
@@ -1247,7 +1286,7 @@ var Sentry = (function (exports) {
1247
1286
  return !isChromePackagedApp && hasHistoryApi;
1248
1287
  }
1249
1288
 
1250
- var global$2 = getGlobalObject();
1289
+ var global$5 = getGlobalObject();
1251
1290
  /**
1252
1291
  * Instrument native APIs to call handlers that can be used to create breadcrumbs, APM spans etc.
1253
1292
  * - Console API
@@ -1331,14 +1370,14 @@ var Sentry = (function (exports) {
1331
1370
  }
1332
1371
  /** JSDoc */
1333
1372
  function instrumentConsole() {
1334
- if (!('console' in global$2)) {
1373
+ if (!('console' in global$5)) {
1335
1374
  return;
1336
1375
  }
1337
1376
  ['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) {
1338
- if (!(level in global$2.console)) {
1377
+ if (!(level in global$5.console)) {
1339
1378
  return;
1340
1379
  }
1341
- fill(global$2.console, level, function (originalConsoleMethod) {
1380
+ fill(global$5.console, level, function (originalConsoleMethod) {
1342
1381
  return function () {
1343
1382
  var args = [];
1344
1383
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1347,7 +1386,7 @@ var Sentry = (function (exports) {
1347
1386
  triggerHandlers('console', { args: args, level: level });
1348
1387
  // this fails for some browsers. :(
1349
1388
  if (originalConsoleMethod) {
1350
- originalConsoleMethod.call(global$2.console, args);
1389
+ originalConsoleMethod.apply(global$5.console, args);
1351
1390
  }
1352
1391
  };
1353
1392
  });
@@ -1358,7 +1397,7 @@ var Sentry = (function (exports) {
1358
1397
  if (!supportsNativeFetch()) {
1359
1398
  return;
1360
1399
  }
1361
- fill(global$2, 'fetch', function (originalFetch) {
1400
+ fill(global$5, 'fetch', function (originalFetch) {
1362
1401
  return function () {
1363
1402
  var args = [];
1364
1403
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1374,7 +1413,7 @@ var Sentry = (function (exports) {
1374
1413
  };
1375
1414
  triggerHandlers('fetch', __assign({}, handlerData));
1376
1415
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1377
- return originalFetch.apply(global$2, args).then(function (response) {
1416
+ return originalFetch.apply(global$5, args).then(function (response) {
1378
1417
  triggerHandlers('fetch', __assign(__assign({}, handlerData), { endTimestamp: Date.now(), response: response }));
1379
1418
  return response;
1380
1419
  }, function (error) {
@@ -1391,7 +1430,7 @@ var Sentry = (function (exports) {
1391
1430
  /** Extract `method` from fetch call arguments */
1392
1431
  function getFetchMethod(fetchArgs) {
1393
1432
  if (fetchArgs === void 0) { fetchArgs = []; }
1394
- if ('Request' in global$2 && isInstanceOf(fetchArgs[0], Request) && fetchArgs[0].method) {
1433
+ if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request) && fetchArgs[0].method) {
1395
1434
  return String(fetchArgs[0].method).toUpperCase();
1396
1435
  }
1397
1436
  if (fetchArgs[1] && fetchArgs[1].method) {
@@ -1405,7 +1444,7 @@ var Sentry = (function (exports) {
1405
1444
  if (typeof fetchArgs[0] === 'string') {
1406
1445
  return fetchArgs[0];
1407
1446
  }
1408
- if ('Request' in global$2 && isInstanceOf(fetchArgs[0], Request)) {
1447
+ if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request)) {
1409
1448
  return fetchArgs[0].url;
1410
1449
  }
1411
1450
  return String(fetchArgs[0]);
@@ -1413,7 +1452,7 @@ var Sentry = (function (exports) {
1413
1452
  /* eslint-enable @typescript-eslint/no-unsafe-member-access */
1414
1453
  /** JSDoc */
1415
1454
  function instrumentXHR() {
1416
- if (!('XMLHttpRequest' in global$2)) {
1455
+ if (!('XMLHttpRequest' in global$5)) {
1417
1456
  return;
1418
1457
  }
1419
1458
  var xhrproto = XMLHttpRequest.prototype;
@@ -1496,13 +1535,13 @@ var Sentry = (function (exports) {
1496
1535
  if (!supportsHistory()) {
1497
1536
  return;
1498
1537
  }
1499
- var oldOnPopState = global$2.onpopstate;
1500
- global$2.onpopstate = function () {
1538
+ var oldOnPopState = global$5.onpopstate;
1539
+ global$5.onpopstate = function () {
1501
1540
  var args = [];
1502
1541
  for (var _i = 0; _i < arguments.length; _i++) {
1503
1542
  args[_i] = arguments[_i];
1504
1543
  }
1505
- var to = global$2.location.href;
1544
+ var to = global$5.location.href;
1506
1545
  // keep track of the current URL state, as we always receive only the updated state
1507
1546
  var from = lastHref;
1508
1547
  lastHref = to;
@@ -1544,8 +1583,8 @@ var Sentry = (function (exports) {
1544
1583
  return originalHistoryFunction.apply(this, args);
1545
1584
  };
1546
1585
  }
1547
- fill(global$2.history, 'pushState', historyReplacementFunction);
1548
- fill(global$2.history, 'replaceState', historyReplacementFunction);
1586
+ fill(global$5.history, 'pushState', historyReplacementFunction);
1587
+ fill(global$5.history, 'replaceState', historyReplacementFunction);
1549
1588
  }
1550
1589
  var debounceDuration = 1000;
1551
1590
  var debounceTimerID;
@@ -1648,14 +1687,14 @@ var Sentry = (function (exports) {
1648
1687
  }
1649
1688
  // Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together.
1650
1689
  clearTimeout(debounceTimerID);
1651
- debounceTimerID = global$2.setTimeout(function () {
1690
+ debounceTimerID = global$5.setTimeout(function () {
1652
1691
  debounceTimerID = undefined;
1653
1692
  }, debounceDuration);
1654
1693
  };
1655
1694
  }
1656
1695
  /** JSDoc */
1657
1696
  function instrumentDOM() {
1658
- if (!('document' in global$2)) {
1697
+ if (!('document' in global$5)) {
1659
1698
  return;
1660
1699
  }
1661
1700
  // Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom
@@ -1663,8 +1702,8 @@ var Sentry = (function (exports) {
1663
1702
  // we instrument `addEventListener` so that we don't end up attaching this handler twice.
1664
1703
  var triggerDOMHandler = triggerHandlers.bind(null, 'dom');
1665
1704
  var globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true);
1666
- global$2.document.addEventListener('click', globalDOMEventHandler, false);
1667
- global$2.document.addEventListener('keypress', globalDOMEventHandler, false);
1705
+ global$5.document.addEventListener('click', globalDOMEventHandler, false);
1706
+ global$5.document.addEventListener('keypress', globalDOMEventHandler, false);
1668
1707
  // After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled
1669
1708
  // clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That
1670
1709
  // way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler
@@ -1672,7 +1711,7 @@ var Sentry = (function (exports) {
1672
1711
  // guaranteed to fire at least once.)
1673
1712
  ['EventTarget', 'Node'].forEach(function (target) {
1674
1713
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1675
- var proto = global$2[target] && global$2[target].prototype;
1714
+ var proto = global$5[target] && global$5[target].prototype;
1676
1715
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
1677
1716
  if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
1678
1717
  return;
@@ -1733,8 +1772,8 @@ var Sentry = (function (exports) {
1733
1772
  var _oldOnErrorHandler = null;
1734
1773
  /** JSDoc */
1735
1774
  function instrumentError() {
1736
- _oldOnErrorHandler = global$2.onerror;
1737
- global$2.onerror = function (msg, url, line, column, error) {
1775
+ _oldOnErrorHandler = global$5.onerror;
1776
+ global$5.onerror = function (msg, url, line, column, error) {
1738
1777
  triggerHandlers('error', {
1739
1778
  column: column,
1740
1779
  error: error,
@@ -1752,8 +1791,8 @@ var Sentry = (function (exports) {
1752
1791
  var _oldOnUnhandledRejectionHandler = null;
1753
1792
  /** JSDoc */
1754
1793
  function instrumentUnhandledRejection() {
1755
- _oldOnUnhandledRejectionHandler = global$2.onunhandledrejection;
1756
- global$2.onunhandledrejection = function (e) {
1794
+ _oldOnUnhandledRejectionHandler = global$5.onunhandledrejection;
1795
+ global$5.onunhandledrejection = function (e) {
1757
1796
  triggerHandlers('unhandledrejection', e);
1758
1797
  if (_oldOnUnhandledRejectionHandler) {
1759
1798
  // eslint-disable-next-line prefer-rest-params
@@ -2270,23 +2309,10 @@ var Sentry = (function (exports) {
2270
2309
  timeOrigin: timeOrigin,
2271
2310
  };
2272
2311
  }
2273
- /**
2274
- * Returns the native Performance API implementation from Node.js. Returns undefined in old Node.js versions that don't
2275
- * implement the API.
2276
- */
2277
- function getNodePerformance() {
2278
- try {
2279
- var perfHooks = dynamicRequire(module, 'perf_hooks');
2280
- return perfHooks.performance;
2281
- }
2282
- catch (_) {
2283
- return undefined;
2284
- }
2285
- }
2286
2312
  /**
2287
2313
  * The Performance API implementation for the current platform, if available.
2288
2314
  */
2289
- var platformPerformance = isNodeEnv() ? getNodePerformance() : getBrowserPerformance();
2315
+ var platformPerformance = getBrowserPerformance();
2290
2316
  var timestampSource = platformPerformance === undefined
2291
2317
  ? dateTimestampSource
2292
2318
  : {
@@ -2312,7 +2338,7 @@ var Sentry = (function (exports) {
2312
2338
  * The number of milliseconds since the UNIX epoch. This value is only usable in a browser, and only when the
2313
2339
  * performance API is available.
2314
2340
  */
2315
- var browserPerformanceTimeOrigin = (function () {
2341
+ ((function () {
2316
2342
  // Unfortunately browsers may report an inaccurate time origin data, through either performance.timeOrigin or
2317
2343
  // performance.timing.navigationStart, which results in poor results in performance data. We only treat time origin
2318
2344
  // data as reliable if they are within a reasonable threshold of the current time.
@@ -2349,7 +2375,7 @@ var Sentry = (function (exports) {
2349
2375
  }
2350
2376
  }
2351
2377
  return dateNow;
2352
- })();
2378
+ }))();
2353
2379
 
2354
2380
  /**
2355
2381
  * Absolute maximum number of breadcrumbs added to an event.
@@ -3014,7 +3040,7 @@ var Sentry = (function (exports) {
3014
3040
  */
3015
3041
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3016
3042
  Hub.prototype.captureException = function (exception, hint) {
3017
- var eventId = (this._lastEventId = uuid4());
3043
+ var eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
3018
3044
  var finalHint = hint;
3019
3045
  // If there's no explicit hint provided, mimic the same thing that would happen
3020
3046
  // in the minimal itself to create a consistent behavior.
@@ -3040,7 +3066,7 @@ var Sentry = (function (exports) {
3040
3066
  * @inheritDoc
3041
3067
  */
3042
3068
  Hub.prototype.captureMessage = function (message, level, hint) {
3043
- var eventId = (this._lastEventId = uuid4());
3069
+ var eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
3044
3070
  var finalHint = hint;
3045
3071
  // If there's no explicit hint provided, mimic the same thing that would happen
3046
3072
  // in the minimal itself to create a consistent behavior.
@@ -3066,7 +3092,7 @@ var Sentry = (function (exports) {
3066
3092
  * @inheritDoc
3067
3093
  */
3068
3094
  Hub.prototype.captureEvent = function (event, hint) {
3069
- var eventId = uuid4();
3095
+ var eventId = hint && hint.event_id ? hint.event_id : uuid4();
3070
3096
  if (event.type !== 'transaction') {
3071
3097
  this._lastEventId = eventId;
3072
3098
  }
@@ -3345,38 +3371,9 @@ var Sentry = (function (exports) {
3345
3371
  if (!hasHubOnCarrier(registry) || getHubFromCarrier(registry).isOlderThan(API_VERSION)) {
3346
3372
  setHubOnCarrier(registry, new Hub());
3347
3373
  }
3348
- // Prefer domains over global if they are there (applicable only to Node environment)
3349
- if (isNodeEnv()) {
3350
- return getHubFromActiveDomain(registry);
3351
- }
3352
3374
  // Return hub that lives on a global object
3353
3375
  return getHubFromCarrier(registry);
3354
3376
  }
3355
- /**
3356
- * Try to read the hub from an active domain, and fallback to the registry if one doesn't exist
3357
- * @returns discovered hub
3358
- */
3359
- function getHubFromActiveDomain(registry) {
3360
- try {
3361
- var sentry = getMainCarrier().__SENTRY__;
3362
- var activeDomain = sentry && sentry.extensions && sentry.extensions.domain && sentry.extensions.domain.active;
3363
- // If there's no active domain, just return global hub
3364
- if (!activeDomain) {
3365
- return getHubFromCarrier(registry);
3366
- }
3367
- // If there's no hub on current domain, or it's an old API, assign a new one
3368
- if (!hasHubOnCarrier(activeDomain) || getHubFromCarrier(activeDomain).isOlderThan(API_VERSION)) {
3369
- var registryHubTopStack = getHubFromCarrier(registry).getStackTop();
3370
- setHubOnCarrier(activeDomain, new Hub(registryHubTopStack.client, Scope.clone(registryHubTopStack.scope)));
3371
- }
3372
- // Return hub that lives on a domain
3373
- return getHubFromCarrier(activeDomain);
3374
- }
3375
- catch (_Oo) {
3376
- // Return hub that lives on a global object
3377
- return getHubFromCarrier(registry);
3378
- }
3379
- }
3380
3377
  /**
3381
3378
  * This will tell whether a carrier has a hub on it or not
3382
3379
  * @param carrier object
@@ -4023,6 +4020,11 @@ var Sentry = (function (exports) {
4023
4020
  result = finalScope.applyToEvent(prepared, hint);
4024
4021
  }
4025
4022
  return result.then(function (evt) {
4023
+ if (evt) {
4024
+ // TODO this is more of the hack trying to solve https://github.com/getsentry/sentry-javascript/issues/2809
4025
+ // it is only attached as extra data to the event if the event somehow skips being normalized
4026
+ evt.sdkProcessingMetadata = __assign(__assign({}, evt.sdkProcessingMetadata), { normalizeDepth: normalize(normalizeDepth) });
4027
+ }
4026
4028
  if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
4027
4029
  return _this._normalizeEvent(evt, normalizeDepth);
4028
4030
  }
@@ -4374,22 +4376,27 @@ var Sentry = (function (exports) {
4374
4376
  var transactionSampling = (event.sdkProcessingMetadata || {}).transactionSampling;
4375
4377
  var _a = transactionSampling || {}, samplingMethod = _a.method, sampleRate = _a.rate;
4376
4378
  // TODO: Below is a temporary hack in order to debug a serialization error - see
4377
- // https://github.com/getsentry/sentry-javascript/issues/2809 and
4378
- // https://github.com/getsentry/sentry-javascript/pull/4425. TL;DR: even though we normalize all events (which should
4379
- // prevent this), something is causing `JSON.stringify` to throw a circular reference error.
4379
+ // https://github.com/getsentry/sentry-javascript/issues/2809,
4380
+ // https://github.com/getsentry/sentry-javascript/pull/4425, and
4381
+ // https://github.com/getsentry/sentry-javascript/pull/4574.
4382
+ //
4383
+ // TL; DR: even though we normalize all events (which should prevent this), something is causing `JSON.stringify` to
4384
+ // throw a circular reference error.
4380
4385
  //
4381
4386
  // When it's time to remove it:
4382
4387
  // 1. Delete everything between here and where the request object `req` is created, EXCEPT the line deleting
4383
4388
  // `sdkProcessingMetadata`
4384
4389
  // 2. Restore the original version of the request body, which is commented out
4385
- // 3. Search for `skippedNormalization` and pull out the companion hack in the browser playwright tests
4390
+ // 3. Search for either of the PR URLs above and pull out the companion hacks in the browser playwright tests and the
4391
+ // baseClient tests in this package
4386
4392
  enhanceEventWithSdkInfo(event, api.metadata.sdk);
4387
4393
  event.tags = event.tags || {};
4388
4394
  event.extra = event.extra || {};
4389
4395
  // In theory, all events should be marked as having gone through normalization and so
4390
- // we should never set this tag
4396
+ // we should never set this tag/extra data
4391
4397
  if (!(event.sdkProcessingMetadata && event.sdkProcessingMetadata.baseClientNormalized)) {
4392
4398
  event.tags.skippedNormalization = true;
4399
+ event.extra.normalizeDepth = event.sdkProcessingMetadata ? event.sdkProcessingMetadata.normalizeDepth : 'unset';
4393
4400
  }
4394
4401
  // prevent this data from being sent to sentry
4395
4402
  // TODO: This is NOT part of the hack - DO NOT DELETE
@@ -4471,7 +4478,7 @@ var Sentry = (function (exports) {
4471
4478
  hub.bindClient(client);
4472
4479
  }
4473
4480
 
4474
- var SDK_VERSION = '6.17.8-beta.0';
4481
+ var SDK_VERSION = '6.18.0';
4475
4482
 
4476
4483
  var originalFunctionToString;
4477
4484
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4686,8 +4693,6 @@ var Sentry = (function (exports) {
4686
4693
  return InboundFilters;
4687
4694
  }());
4688
4695
 
4689
-
4690
-
4691
4696
  var CoreIntegrations = /*#__PURE__*/Object.freeze({
4692
4697
  __proto__: null,
4693
4698
  FunctionToString: FunctionToString,
@@ -4696,138 +4701,88 @@ var Sentry = (function (exports) {
4696
4701
 
4697
4702
  // global reference to slice
4698
4703
  var UNKNOWN_FUNCTION = '?';
4699
- // Chromium based browsers: Chrome, Brave, new Opera, new Edge
4700
- var chrome = /^\s*at (?:(.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
4701
- // gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
4702
- // generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
4703
- // We need this specific case for now because we want no other regex to match.
4704
- var gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
4705
- var winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
4706
- var geckoEval = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
4707
- var chromeEval = /\((\S*)(?::(\d+))(?::(\d+))\)/;
4708
- // Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
4709
- var reactMinifiedRegexp = /Minified React error #\d+;/i;
4710
- var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
4711
- var opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
4712
- /** JSDoc */
4713
- function computeStackTrace(ex) {
4714
- var frames = [];
4715
- var popSize = 0;
4716
- if (ex) {
4717
- if (typeof ex.framesToPop === 'number') {
4718
- popSize = ex.framesToPop;
4719
- }
4720
- else if (reactMinifiedRegexp.test(ex.message)) {
4721
- popSize = 1;
4722
- }
4723
- }
4724
- try {
4725
- // Access and store the stacktrace property before doing ANYTHING
4726
- // else to it because Opera is not very good at providing it
4727
- // reliably in other circumstances.
4728
- var stacktrace = ex.stacktrace || ex.stack || '';
4729
- frames = parseFrames(stacktrace);
4730
- }
4731
- catch (e) {
4732
- // no-empty
4704
+ function createFrame(filename, func, lineno, colno) {
4705
+ var frame = {
4706
+ filename: filename,
4707
+ function: func,
4708
+ // All browser frames are considered in_app
4709
+ in_app: true,
4710
+ };
4711
+ if (lineno !== undefined) {
4712
+ frame.lineno = lineno;
4733
4713
  }
4734
- if (frames.length && popSize > 0) {
4735
- frames = frames.slice(popSize);
4714
+ if (colno !== undefined) {
4715
+ frame.colno = colno;
4736
4716
  }
4737
- return {
4738
- message: extractMessage(ex),
4739
- name: ex && ex.name,
4740
- stack: frames,
4741
- };
4717
+ return frame;
4742
4718
  }
4743
- /** JSDoc */
4744
- // eslint-disable-next-line complexity
4745
- function parseFrames(stackString) {
4746
- var e_1, _a, _b;
4747
- var frames = [];
4748
- var lines = stackString.split('\n');
4749
- var isEval;
4750
- var submatch;
4751
- var parts;
4752
- var element;
4753
- try {
4754
- for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
4755
- var line = lines_1_1.value;
4756
- if ((parts = opera10Regex.exec(line))) {
4757
- element = {
4758
- filename: parts[2],
4759
- function: parts[3] || UNKNOWN_FUNCTION,
4760
- lineno: +parts[1],
4761
- };
4762
- }
4763
- else if ((parts = opera11Regex.exec(line))) {
4764
- element = {
4765
- filename: parts[5],
4766
- function: parts[3] || parts[4] || UNKNOWN_FUNCTION,
4767
- lineno: +parts[1],
4768
- colno: +parts[2],
4769
- };
4770
- }
4771
- else if ((parts = chrome.exec(line))) {
4772
- isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line
4773
- if (isEval && (submatch = chromeEval.exec(parts[2]))) {
4774
- // throw out eval line/column and use top-most line/column number
4775
- parts[2] = submatch[1]; // url
4776
- parts[3] = submatch[2]; // line
4777
- parts[4] = submatch[3]; // column
4778
- }
4779
- // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now
4780
- // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)
4781
- var _c = __read(extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2]), 2), func = _c[0], filename = _c[1];
4782
- element = {
4783
- filename: filename,
4784
- function: func,
4785
- lineno: parts[3] ? +parts[3] : undefined,
4786
- colno: parts[4] ? +parts[4] : undefined,
4787
- };
4788
- }
4789
- else if ((parts = winjs.exec(line))) {
4790
- element = {
4791
- filename: parts[2],
4792
- function: parts[1] || UNKNOWN_FUNCTION,
4793
- lineno: +parts[3],
4794
- colno: parts[4] ? +parts[4] : undefined,
4795
- };
4796
- }
4797
- else if ((parts = gecko.exec(line))) {
4798
- isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
4799
- if (isEval && (submatch = geckoEval.exec(parts[3]))) {
4800
- // throw out eval line/column and use top-most line number
4801
- parts[1] = parts[1] || "eval";
4802
- parts[3] = submatch[1];
4803
- parts[4] = submatch[2];
4804
- parts[5] = ''; // no column when eval
4805
- }
4806
- var filename = parts[3];
4807
- var func = parts[1] || UNKNOWN_FUNCTION;
4808
- _b = __read(extractSafariExtensionDetails(func, filename), 2), func = _b[0], filename = _b[1];
4809
- element = {
4810
- filename: filename,
4811
- function: func,
4812
- lineno: parts[4] ? +parts[4] : undefined,
4813
- colno: parts[5] ? +parts[5] : undefined,
4814
- };
4815
- }
4816
- else {
4817
- continue;
4719
+ // Chromium based browsers: Chrome, Brave, new Opera, new Edge
4720
+ var chromeRegex = /^\s*at (?:(.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
4721
+ var chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
4722
+ var chrome = function (line) {
4723
+ var parts = chromeRegex.exec(line);
4724
+ if (parts) {
4725
+ var isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line
4726
+ if (isEval) {
4727
+ var subMatch = chromeEvalRegex.exec(parts[2]);
4728
+ if (subMatch) {
4729
+ // throw out eval line/column and use top-most line/column number
4730
+ parts[2] = subMatch[1]; // url
4731
+ parts[3] = subMatch[2]; // line
4732
+ parts[4] = subMatch[3]; // column
4818
4733
  }
4819
- frames.push(element);
4820
4734
  }
4735
+ // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now
4736
+ // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)
4737
+ var _a = __read(extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2]), 2), func = _a[0], filename = _a[1];
4738
+ return createFrame(filename, func, parts[3] ? +parts[3] : undefined, parts[4] ? +parts[4] : undefined);
4821
4739
  }
4822
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
4823
- finally {
4824
- try {
4825
- if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
4740
+ return;
4741
+ };
4742
+ // gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
4743
+ // generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
4744
+ // We need this specific case for now because we want no other regex to match.
4745
+ var geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
4746
+ var geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
4747
+ var gecko = function (line) {
4748
+ var _a;
4749
+ var parts = geckoREgex.exec(line);
4750
+ if (parts) {
4751
+ var isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
4752
+ if (isEval) {
4753
+ var subMatch = geckoEvalRegex.exec(parts[3]);
4754
+ if (subMatch) {
4755
+ // throw out eval line/column and use top-most line number
4756
+ parts[1] = parts[1] || "eval";
4757
+ parts[3] = subMatch[1];
4758
+ parts[4] = subMatch[2];
4759
+ parts[5] = ''; // no column when eval
4760
+ }
4826
4761
  }
4827
- finally { if (e_1) throw e_1.error; }
4762
+ var filename = parts[3];
4763
+ var func = parts[1] || UNKNOWN_FUNCTION;
4764
+ _a = __read(extractSafariExtensionDetails(func, filename), 2), func = _a[0], filename = _a[1];
4765
+ return createFrame(filename, func, parts[4] ? +parts[4] : undefined, parts[5] ? +parts[5] : undefined);
4828
4766
  }
4829
- return frames;
4830
- }
4767
+ return;
4768
+ };
4769
+ var winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
4770
+ var winjs = function (line) {
4771
+ var parts = winjsRegex.exec(line);
4772
+ return parts
4773
+ ? createFrame(parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined)
4774
+ : undefined;
4775
+ };
4776
+ var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
4777
+ var opera10 = function (line) {
4778
+ var parts = opera10Regex.exec(line);
4779
+ return parts ? createFrame(parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined;
4780
+ };
4781
+ var opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
4782
+ var opera11 = function (line) {
4783
+ var parts = opera11Regex.exec(line);
4784
+ return parts ? createFrame(parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;
4785
+ };
4831
4786
  /**
4832
4787
  * Safari web extensions, starting version unknown, can produce "frames-only" stacktraces.
4833
4788
  * What it means, is that instead of format like:
@@ -4845,7 +4800,7 @@ var Sentry = (function (exports) {
4845
4800
  *
4846
4801
  * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.
4847
4802
  * This function is extracted so that we can use it in both places without duplicating the logic.
4848
- * Unfortunatelly "just" changing RegExp is too complicated now and making it pass all tests
4803
+ * Unfortunately "just" changing RegExp is too complicated now and making it pass all tests
4849
4804
  * and fix this case seems like an impossible, or at least way too time-consuming task.
4850
4805
  */
4851
4806
  var extractSafariExtensionDetails = function (func, filename) {
@@ -4857,35 +4812,19 @@ var Sentry = (function (exports) {
4857
4812
  isSafariExtension ? "safari-extension:" + filename : "safari-web-extension:" + filename,
4858
4813
  ]
4859
4814
  : [func, filename];
4860
- };
4861
- /**
4862
- * There are cases where stacktrace.message is an Event object
4863
- * https://github.com/getsentry/sentry-javascript/issues/1949
4864
- * In this specific case we try to extract stacktrace.message.error.message
4865
- */
4866
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4867
- function extractMessage(ex) {
4868
- var message = ex && ex.message;
4869
- if (!message) {
4870
- return 'No error message';
4871
- }
4872
- if (message.error && typeof message.error.message === 'string') {
4873
- return message.error.message;
4874
- }
4875
- return message;
4876
- }
4815
+ };
4877
4816
 
4878
- var STACKTRACE_LIMIT = 50;
4879
4817
  /**
4880
4818
  * This function creates an exception from an TraceKitStackTrace
4881
4819
  * @param stacktrace TraceKitStackTrace that will be converted to an exception
4882
4820
  * @hidden
4883
4821
  */
4884
- function exceptionFromStacktrace(stacktrace) {
4885
- var frames = prepareFramesForEvent(stacktrace.stack);
4822
+ function exceptionFromError(ex) {
4823
+ // Get the frames first since Opera can lose the stack if we touch anything else first
4824
+ var frames = parseStackFrames(ex);
4886
4825
  var exception = {
4887
- type: stacktrace.name,
4888
- value: stacktrace.message,
4826
+ type: ex && ex.name,
4827
+ value: extractMessage(ex),
4889
4828
  };
4890
4829
  if (frames && frames.length) {
4891
4830
  exception.stacktrace = { frames: frames };
@@ -4913,54 +4852,67 @@ var Sentry = (function (exports) {
4913
4852
  },
4914
4853
  };
4915
4854
  if (syntheticException) {
4916
- var stacktrace = computeStackTrace(syntheticException);
4917
- var frames_1 = prepareFramesForEvent(stacktrace.stack);
4918
- event.stacktrace = {
4919
- frames: frames_1,
4920
- };
4855
+ var frames_1 = parseStackFrames(syntheticException);
4856
+ if (frames_1.length) {
4857
+ event.stacktrace = { frames: frames_1 };
4858
+ }
4921
4859
  }
4922
4860
  return event;
4923
4861
  }
4924
4862
  /**
4925
4863
  * @hidden
4926
4864
  */
4927
- function eventFromStacktrace(stacktrace) {
4928
- var exception = exceptionFromStacktrace(stacktrace);
4865
+ function eventFromError(ex) {
4929
4866
  return {
4930
4867
  exception: {
4931
- values: [exception],
4868
+ values: [exceptionFromError(ex)],
4932
4869
  },
4933
4870
  };
4934
4871
  }
4872
+ /** Parses stack frames from an error */
4873
+ function parseStackFrames(ex) {
4874
+ // Access and store the stacktrace property before doing ANYTHING
4875
+ // else to it because Opera is not very good at providing it
4876
+ // reliably in other circumstances.
4877
+ var stacktrace = ex.stacktrace || ex.stack || '';
4878
+ var popSize = getPopSize(ex);
4879
+ try {
4880
+ // The order of the parsers in important
4881
+ return createStackParser(opera10, opera11, chrome, winjs, gecko)(stacktrace, popSize);
4882
+ }
4883
+ catch (e) {
4884
+ // no-empty
4885
+ }
4886
+ return [];
4887
+ }
4888
+ // Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
4889
+ var reactMinifiedRegexp = /Minified React error #\d+;/i;
4890
+ function getPopSize(ex) {
4891
+ if (ex) {
4892
+ if (typeof ex.framesToPop === 'number') {
4893
+ return ex.framesToPop;
4894
+ }
4895
+ if (reactMinifiedRegexp.test(ex.message)) {
4896
+ return 1;
4897
+ }
4898
+ }
4899
+ return 0;
4900
+ }
4935
4901
  /**
4936
- * @hidden
4902
+ * There are cases where stacktrace.message is an Event object
4903
+ * https://github.com/getsentry/sentry-javascript/issues/1949
4904
+ * In this specific case we try to extract stacktrace.message.error.message
4937
4905
  */
4938
- function prepareFramesForEvent(stack) {
4939
- if (!stack.length) {
4940
- return [];
4941
- }
4942
- var localStack = stack;
4943
- var firstFrameFunction = localStack[0].function || '';
4944
- var lastFrameFunction = localStack[localStack.length - 1].function || '';
4945
- // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
4946
- if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
4947
- localStack = localStack.slice(1);
4906
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4907
+ function extractMessage(ex) {
4908
+ var message = ex && ex.message;
4909
+ if (!message) {
4910
+ return 'No error message';
4948
4911
  }
4949
- // 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)
4950
- if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
4951
- localStack = localStack.slice(0, -1);
4912
+ if (message.error && typeof message.error.message === 'string') {
4913
+ return message.error.message;
4952
4914
  }
4953
- // The frame where the crash happened, should be the last entry in the array
4954
- return localStack
4955
- .slice(0, STACKTRACE_LIMIT)
4956
- .map(function (frame) { return ({
4957
- filename: frame.filename || localStack[0].filename,
4958
- function: frame.function || '?',
4959
- lineno: frame.lineno,
4960
- colno: frame.colno,
4961
- in_app: true,
4962
- }); })
4963
- .reverse();
4915
+ return message;
4964
4916
  }
4965
4917
 
4966
4918
  /**
@@ -5004,10 +4956,7 @@ var Sentry = (function (exports) {
5004
4956
  if (isErrorEvent(exception) && exception.error) {
5005
4957
  // If it is an ErrorEvent with `error` property, extract it to get actual Error
5006
4958
  var errorEvent = exception;
5007
- // eslint-disable-next-line no-param-reassign
5008
- exception = errorEvent.error;
5009
- event = eventFromStacktrace(computeStackTrace(exception));
5010
- return event;
4959
+ return eventFromError(errorEvent.error);
5011
4960
  }
5012
4961
  // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name
5013
4962
  // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be
@@ -5019,7 +4968,7 @@ var Sentry = (function (exports) {
5019
4968
  if (isDOMError(exception) || isDOMException(exception)) {
5020
4969
  var domException = exception;
5021
4970
  if ('stack' in exception) {
5022
- event = eventFromStacktrace(computeStackTrace(exception));
4971
+ event = eventFromError(exception);
5023
4972
  }
5024
4973
  else {
5025
4974
  var name_1 = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');
@@ -5034,8 +4983,7 @@ var Sentry = (function (exports) {
5034
4983
  }
5035
4984
  if (isError(exception)) {
5036
4985
  // we have a real Error object, do nothing
5037
- event = eventFromStacktrace(computeStackTrace(exception));
5038
- return event;
4986
+ return eventFromError(exception);
5039
4987
  }
5040
4988
  if (isPlainObject(exception) || isEvent(exception)) {
5041
4989
  // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize
@@ -5073,16 +5021,15 @@ var Sentry = (function (exports) {
5073
5021
  message: input,
5074
5022
  };
5075
5023
  if (options.attachStacktrace && syntheticException) {
5076
- var stacktrace = computeStackTrace(syntheticException);
5077
- var frames_1 = prepareFramesForEvent(stacktrace.stack);
5078
- event.stacktrace = {
5079
- frames: frames_1,
5080
- };
5024
+ var frames_1 = parseStackFrames(syntheticException);
5025
+ if (frames_1.length) {
5026
+ event.stacktrace = { frames: frames_1 };
5027
+ }
5081
5028
  }
5082
5029
  return event;
5083
5030
  }
5084
5031
 
5085
- var global$3 = getGlobalObject();
5032
+ var global$4 = getGlobalObject();
5086
5033
  var cachedFetchImpl;
5087
5034
  /**
5088
5035
  * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
@@ -5128,11 +5075,11 @@ var Sentry = (function (exports) {
5128
5075
  }
5129
5076
  /* eslint-disable @typescript-eslint/unbound-method */
5130
5077
  // Fast path to avoid DOM I/O
5131
- if (isNativeFetch(global$3.fetch)) {
5132
- return (cachedFetchImpl = global$3.fetch.bind(global$3));
5078
+ if (isNativeFetch(global$4.fetch)) {
5079
+ return (cachedFetchImpl = global$4.fetch.bind(global$4));
5133
5080
  }
5134
- var document = global$3.document;
5135
- var fetchImpl = global$3.fetch;
5081
+ var document = global$4.document;
5082
+ var fetchImpl = global$4.fetch;
5136
5083
  // eslint-disable-next-line deprecation/deprecation
5137
5084
  if (document && typeof document.createElement === "function") {
5138
5085
  try {
@@ -5151,7 +5098,7 @@ var Sentry = (function (exports) {
5151
5098
  }
5152
5099
  }
5153
5100
  }
5154
- return (cachedFetchImpl = fetchImpl.bind(global$3));
5101
+ return (cachedFetchImpl = fetchImpl.bind(global$4));
5155
5102
  /* eslint-enable @typescript-eslint/unbound-method */
5156
5103
  }
5157
5104
  /**
@@ -5161,11 +5108,11 @@ var Sentry = (function (exports) {
5161
5108
  * @param body report payload
5162
5109
  */
5163
5110
  function sendReport(url, body) {
5164
- var isRealNavigator = Object.prototype.toString.call(global$3 && global$3.navigator) === '[object Navigator]';
5165
- var hasSendBeacon = isRealNavigator && typeof global$3.navigator.sendBeacon === 'function';
5111
+ var isRealNavigator = Object.prototype.toString.call(global$4 && global$4.navigator) === '[object Navigator]';
5112
+ var hasSendBeacon = isRealNavigator && typeof global$4.navigator.sendBeacon === 'function';
5166
5113
  if (hasSendBeacon) {
5167
5114
  // Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
5168
- var sendBeacon = global$3.navigator.sendBeacon.bind(global$3.navigator);
5115
+ var sendBeacon = global$4.navigator.sendBeacon.bind(global$4.navigator);
5169
5116
  return sendBeacon(url, body);
5170
5117
  }
5171
5118
  if (supportsFetch()) {
@@ -5183,7 +5130,7 @@ var Sentry = (function (exports) {
5183
5130
  var tyStr = ty;
5184
5131
  return tyStr === 'event' ? 'error' : tyStr;
5185
5132
  }
5186
- var global$4 = getGlobalObject();
5133
+ var global$3 = getGlobalObject();
5187
5134
  /** Base Transport class implementation */
5188
5135
  var BaseTransport = /** @class */ (function () {
5189
5136
  function BaseTransport(options) {
@@ -5197,9 +5144,9 @@ var Sentry = (function (exports) {
5197
5144
  this._api = initAPIDetails(options.dsn, options._metadata, options.tunnel);
5198
5145
  // eslint-disable-next-line deprecation/deprecation
5199
5146
  this.url = getStoreEndpointWithUrlEncodedAuth(this._api.dsn);
5200
- if (this.options.sendClientReports && global$4.document) {
5201
- global$4.document.addEventListener('visibilitychange', function () {
5202
- if (global$4.document.visibilityState === 'hidden') {
5147
+ if (this.options.sendClientReports && global$3.document) {
5148
+ global$3.document.addEventListener('visibilitychange', function () {
5149
+ if (global$3.document.visibilityState === 'hidden') {
5203
5150
  _this._flushOutcomes();
5204
5151
  }
5205
5152
  });
@@ -5501,8 +5448,6 @@ var Sentry = (function (exports) {
5501
5448
  return XHRTransport;
5502
5449
  }(BaseTransport));
5503
5450
 
5504
-
5505
-
5506
5451
  var index = /*#__PURE__*/Object.freeze({
5507
5452
  __proto__: null,
5508
5453
  BaseTransport: BaseTransport,
@@ -5552,7 +5497,7 @@ var Sentry = (function (exports) {
5552
5497
  return BrowserBackend;
5553
5498
  }(BaseBackend));
5554
5499
 
5555
- var global$5 = getGlobalObject();
5500
+ var global$2 = getGlobalObject();
5556
5501
  var ignoreOnError = 0;
5557
5502
  /**
5558
5503
  * @hidden
@@ -5578,7 +5523,7 @@ var Sentry = (function (exports) {
5578
5523
  * @returns The wrapped function.
5579
5524
  * @hidden
5580
5525
  */
5581
- function wrap(fn, options, before) {
5526
+ function wrap$1(fn, options, before) {
5582
5527
  // for future readers what this does is wrap a function and then create
5583
5528
  // a bi-directional wrapping between them.
5584
5529
  //
@@ -5616,7 +5561,7 @@ var Sentry = (function (exports) {
5616
5561
  before.apply(this, arguments);
5617
5562
  }
5618
5563
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
5619
- var wrappedArguments = args.map(function (arg) { return wrap(arg, options); });
5564
+ var wrappedArguments = args.map(function (arg) { return wrap$1(arg, options); });
5620
5565
  // Attempt to invoke user-land function
5621
5566
  // NOTE: If you are a Sentry user, and you are seeing this stack frame, it
5622
5567
  // means the sentry.javascript SDK caught an error invoking your application code. This
@@ -5675,7 +5620,7 @@ var Sentry = (function (exports) {
5675
5620
  */
5676
5621
  function injectReportDialog(options) {
5677
5622
  if (options === void 0) { options = {}; }
5678
- if (!global$5.document) {
5623
+ if (!global$2.document) {
5679
5624
  return;
5680
5625
  }
5681
5626
  if (!options.eventId) {
@@ -5690,14 +5635,14 @@ var Sentry = (function (exports) {
5690
5635
  }
5691
5636
  return;
5692
5637
  }
5693
- var script = global$5.document.createElement('script');
5638
+ var script = global$2.document.createElement('script');
5694
5639
  script.async = true;
5695
5640
  script.src = getReportDialogEndpoint(options.dsn, options);
5696
5641
  if (options.onLoad) {
5697
5642
  // eslint-disable-next-line @typescript-eslint/unbound-method
5698
5643
  script.onload = options.onLoad;
5699
5644
  }
5700
- var injectionPoint = global$5.document.head || global$5.document.body;
5645
+ var injectionPoint = global$2.document.head || global$2.document.body;
5701
5646
  if (injectionPoint) {
5702
5647
  injectionPoint.appendChild(script);
5703
5648
  }
@@ -5987,7 +5932,7 @@ var Sentry = (function (exports) {
5987
5932
  args[_i] = arguments[_i];
5988
5933
  }
5989
5934
  var originalCallback = args[0];
5990
- args[0] = wrap(originalCallback, {
5935
+ args[0] = wrap$1(originalCallback, {
5991
5936
  mechanism: {
5992
5937
  data: { function: getFunctionName(original) },
5993
5938
  handled: true,
@@ -6003,7 +5948,7 @@ var Sentry = (function (exports) {
6003
5948
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6004
5949
  return function (callback) {
6005
5950
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6006
- return original.call(this, wrap(callback, {
5951
+ return original.call(this, wrap$1(callback, {
6007
5952
  mechanism: {
6008
5953
  data: {
6009
5954
  function: 'requestAnimationFrame',
@@ -6046,7 +5991,7 @@ var Sentry = (function (exports) {
6046
5991
  wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);
6047
5992
  }
6048
5993
  // Otherwise wrap directly
6049
- return wrap(original, wrapOptions);
5994
+ return wrap$1(original, wrapOptions);
6050
5995
  });
6051
5996
  }
6052
5997
  });
@@ -6067,7 +6012,7 @@ var Sentry = (function (exports) {
6067
6012
  return function (eventName, fn, options) {
6068
6013
  try {
6069
6014
  if (typeof fn.handleEvent === 'function') {
6070
- fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
6015
+ fn.handleEvent = wrap$1(fn.handleEvent.bind(fn), {
6071
6016
  mechanism: {
6072
6017
  data: {
6073
6018
  function: 'handleEvent',
@@ -6085,7 +6030,7 @@ var Sentry = (function (exports) {
6085
6030
  }
6086
6031
  return original.call(this, eventName,
6087
6032
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6088
- wrap(fn, {
6033
+ wrap$1(fn, {
6089
6034
  mechanism: {
6090
6035
  data: {
6091
6036
  function: 'addEventListener',
@@ -6402,12 +6347,11 @@ var Sentry = (function (exports) {
6402
6347
  if (!isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {
6403
6348
  return stack;
6404
6349
  }
6405
- var stacktrace = computeStackTrace(error[key]);
6406
- var exception = exceptionFromStacktrace(stacktrace);
6350
+ var exception = exceptionFromError(error[key]);
6407
6351
  return _walkErrorTree(limit, error[key], key, __spread([exception], stack));
6408
6352
  }
6409
6353
 
6410
- var global$6 = getGlobalObject();
6354
+ var global$1 = getGlobalObject();
6411
6355
  /** UserAgent */
6412
6356
  var UserAgent = /** @class */ (function () {
6413
6357
  function UserAgent() {
@@ -6423,13 +6367,13 @@ var Sentry = (function (exports) {
6423
6367
  addGlobalEventProcessor(function (event) {
6424
6368
  if (getCurrentHub().getIntegration(UserAgent)) {
6425
6369
  // if none of the information we want exists, don't bother
6426
- if (!global$6.navigator && !global$6.location && !global$6.document) {
6370
+ if (!global$1.navigator && !global$1.location && !global$1.document) {
6427
6371
  return event;
6428
6372
  }
6429
6373
  // grab as much info as exists and add it to the event
6430
- var url = (event.request && event.request.url) || (global$6.location && global$6.location.href);
6431
- var referrer = (global$6.document || {}).referrer;
6432
- var userAgent = (global$6.navigator || {}).userAgent;
6374
+ var url = (event.request && event.request.url) || (global$1.location && global$1.location.href);
6375
+ var referrer = (global$1.document || {}).referrer;
6376
+ var userAgent = (global$1.navigator || {}).userAgent;
6433
6377
  var headers = __assign(__assign(__assign({}, (event.request && event.request.headers)), (referrer && { Referer: referrer })), (userAgent && { 'User-Agent': userAgent }));
6434
6378
  var request = __assign(__assign({}, (url && { url: url })), { headers: headers });
6435
6379
  return __assign(__assign({}, event), { request: request });
@@ -6609,8 +6553,6 @@ var Sentry = (function (exports) {
6609
6553
  return undefined;
6610
6554
  }
6611
6555
 
6612
-
6613
-
6614
6556
  var BrowserIntegrations = /*#__PURE__*/Object.freeze({
6615
6557
  __proto__: null,
6616
6558
  GlobalHandlers: GlobalHandlers,
@@ -6865,8 +6807,8 @@ var Sentry = (function (exports) {
6865
6807
  * @returns The result of wrapped function call.
6866
6808
  */
6867
6809
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6868
- function wrap$1(fn) {
6869
- return wrap(fn)();
6810
+ function wrap(fn) {
6811
+ return wrap$1(fn)();
6870
6812
  }
6871
6813
  function startSessionOnHub(hub) {
6872
6814
  hub.startSession({ ignoreDuration: true });
@@ -6956,9 +6898,9 @@ var Sentry = (function (exports) {
6956
6898
  exports.showReportDialog = showReportDialog;
6957
6899
  exports.startTransaction = startTransaction;
6958
6900
  exports.withScope = withScope;
6959
- exports.wrap = wrap$1;
6901
+ exports.wrap = wrap;
6960
6902
 
6961
6903
  return exports;
6962
6904
 
6963
- }({}));
6905
+ })({});
6964
6906
  //# sourceMappingURL=bundle.js.map