@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
package/build/bundle.js CHANGED
@@ -1,29 +1,32 @@
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
- Copyright (c) Microsoft Corporation. All rights reserved.
5
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6
- this file except in compliance with the License. You may obtain a copy of the
7
- License at http://www.apache.org/licenses/LICENSE-2.0
5
+ Copyright (c) Microsoft Corporation.
8
6
 
9
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
11
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
12
- MERCHANTABLITY OR NON-INFRINGEMENT.
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted.
13
9
 
14
- See the Apache Version 2.0 License for specific language governing permissions
15
- and limitations under the License.
10
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
+ PERFORMANCE OF THIS SOFTWARE.
16
17
  ***************************************************************************** */
17
18
  /* global Reflect, Promise */
18
19
 
19
20
  var extendStatics = function(d, b) {
20
21
  extendStatics = Object.setPrototypeOf ||
21
22
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
23
24
  return extendStatics(d, b);
24
25
  };
25
26
 
26
27
  function __extends(d, b) {
28
+ if (typeof b !== "function" && b !== null)
29
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
27
30
  extendStatics(d, b);
28
31
  function __() { this.constructor = d; }
29
32
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -41,14 +44,15 @@ var Sentry = (function (exports) {
41
44
  };
42
45
 
43
46
  function __values(o) {
44
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
47
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
45
48
  if (m) return m.call(o);
46
- return {
49
+ if (o && typeof o.length === "number") return {
47
50
  next: function () {
48
51
  if (o && i >= o.length) o = void 0;
49
52
  return { value: o && o[i++], done: !o };
50
53
  }
51
54
  };
55
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
52
56
  }
53
57
 
54
58
  function __read(o, n) {
@@ -68,6 +72,7 @@ var Sentry = (function (exports) {
68
72
  return ar;
69
73
  }
70
74
 
75
+ /** @deprecated */
71
76
  function __spread() {
72
77
  for (var ar = [], i = 0; i < arguments.length; i++)
73
78
  ar = ar.concat(__read(arguments[i]));
@@ -77,6 +82,7 @@ var Sentry = (function (exports) {
77
82
  /**
78
83
  * TODO(v7): Remove this enum and replace with SeverityLevel
79
84
  */
85
+ exports.Severity = void 0;
80
86
  (function (Severity) {
81
87
  /** JSDoc */
82
88
  Severity["Fatal"] = "fatal";
@@ -123,41 +129,7 @@ var Sentry = (function (exports) {
123
129
  * @returns true if this is a debug build
124
130
  */
125
131
  function isDebugBuild() {
126
- return typeof __SENTRY_NO_DEBUG__ !== 'undefined' && !__SENTRY_BROWSER_BUNDLE__;
127
- }
128
- /**
129
- * Figures out if we're building a browser bundle.
130
- *
131
- * @returns true if this is a browser bundle build.
132
- */
133
- function isBrowserBundle() {
134
- return typeof __SENTRY_BROWSER_BUNDLE__ !== 'undefined' && !!__SENTRY_BROWSER_BUNDLE__;
135
- }
136
-
137
- /**
138
- * NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
139
- * you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
140
- */
141
- /**
142
- * Checks whether we're in the Node.js or Browser environment
143
- *
144
- * @returns Answer to given question
145
- */
146
- function isNodeEnv() {
147
- // explicitly check for browser bundles as those can be optimized statically
148
- // by terser/rollup.
149
- return (!isBrowserBundle() &&
150
- Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]');
151
- }
152
- /**
153
- * Requires a module which is protected against bundler minification.
154
- *
155
- * @param request The module path to resolve
156
- */
157
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
158
- function dynamicRequire(mod, request) {
159
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
160
- return mod.require(request);
132
+ return typeof __SENTRY_NO_DEBUG__ !== 'undefined' && !true;
161
133
  }
162
134
 
163
135
  /**
@@ -171,9 +143,7 @@ var Sentry = (function (exports) {
171
143
  * @returns Global scope object
172
144
  */
173
145
  function getGlobalObject() {
174
- return (isNodeEnv()
175
- ? global
176
- : typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
146
+ return (typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
177
147
  ? window // eslint-disable-line no-restricted-globals
178
148
  : typeof self !== 'undefined'
179
149
  ? self
@@ -559,7 +529,7 @@ var Sentry = (function (exports) {
559
529
  var SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
560
530
 
561
531
  // TODO: Implement different loggers for different environments
562
- var global$1 = getGlobalObject();
532
+ var global$6 = getGlobalObject();
563
533
  /** Prefix for logging strings */
564
534
  var PREFIX = 'Sentry Logger ';
565
535
  /**
@@ -618,7 +588,7 @@ var Sentry = (function (exports) {
618
588
  return;
619
589
  }
620
590
  consoleSandbox(function () {
621
- global$1.console.log(PREFIX + "[Log]: " + args.join(' '));
591
+ global$6.console.log(PREFIX + "[Log]: " + args.join(' '));
622
592
  });
623
593
  };
624
594
  /** JSDoc */
@@ -631,7 +601,7 @@ var Sentry = (function (exports) {
631
601
  return;
632
602
  }
633
603
  consoleSandbox(function () {
634
- global$1.console.warn(PREFIX + "[Warn]: " + args.join(' '));
604
+ global$6.console.warn(PREFIX + "[Warn]: " + args.join(' '));
635
605
  });
636
606
  };
637
607
  /** JSDoc */
@@ -644,14 +614,14 @@ var Sentry = (function (exports) {
644
614
  return;
645
615
  }
646
616
  consoleSandbox(function () {
647
- global$1.console.error(PREFIX + "[Error]: " + args.join(' '));
617
+ global$6.console.error(PREFIX + "[Error]: " + args.join(' '));
648
618
  });
649
619
  };
650
620
  return Logger;
651
621
  }());
652
622
  // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
653
- global$1.__SENTRY__ = global$1.__SENTRY__ || {};
654
- 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());
655
625
 
656
626
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
657
627
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -695,6 +665,79 @@ var Sentry = (function (exports) {
695
665
  return [memoize, unmemoize];
696
666
  }
697
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
+ }
698
741
  var defaultFunctionName = '<anonymous>';
699
742
  /**
700
743
  * Safely extract function name from itself
@@ -800,16 +843,18 @@ var Sentry = (function (exports) {
800
843
  source[name] = wrapped;
801
844
  }
802
845
  /**
803
- * Defines a non enumerable property. This creates a non enumerable property on an object.
846
+ * Defines a non-enumerable property on the given object.
804
847
  *
805
- * @param func The function to set a property to
806
- * @param name the name of the special sentry property
807
- * @param value the property to define
848
+ * @param obj The object on which to set the property
849
+ * @param name The name of the property to be set
850
+ * @param value The value to which to set the property
808
851
  */
809
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
810
- function addNonEnumerableProperty(func, name, value) {
811
- Object.defineProperty(func, name, {
852
+ function addNonEnumerableProperty(obj, name, value) {
853
+ Object.defineProperty(obj, name, {
854
+ // enumerable: false, // the default, so we can save on bundle size by not explicitly setting it
812
855
  value: value,
856
+ writable: true,
857
+ configurable: true,
813
858
  });
814
859
  }
815
860
  /**
@@ -1241,7 +1286,7 @@ var Sentry = (function (exports) {
1241
1286
  return !isChromePackagedApp && hasHistoryApi;
1242
1287
  }
1243
1288
 
1244
- var global$2 = getGlobalObject();
1289
+ var global$5 = getGlobalObject();
1245
1290
  /**
1246
1291
  * Instrument native APIs to call handlers that can be used to create breadcrumbs, APM spans etc.
1247
1292
  * - Console API
@@ -1325,14 +1370,14 @@ var Sentry = (function (exports) {
1325
1370
  }
1326
1371
  /** JSDoc */
1327
1372
  function instrumentConsole() {
1328
- if (!('console' in global$2)) {
1373
+ if (!('console' in global$5)) {
1329
1374
  return;
1330
1375
  }
1331
1376
  ['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) {
1332
- if (!(level in global$2.console)) {
1377
+ if (!(level in global$5.console)) {
1333
1378
  return;
1334
1379
  }
1335
- fill(global$2.console, level, function (originalConsoleLevel) {
1380
+ fill(global$5.console, level, function (originalConsoleMethod) {
1336
1381
  return function () {
1337
1382
  var args = [];
1338
1383
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1340,8 +1385,8 @@ var Sentry = (function (exports) {
1340
1385
  }
1341
1386
  triggerHandlers('console', { args: args, level: level });
1342
1387
  // this fails for some browsers. :(
1343
- if (originalConsoleLevel) {
1344
- Function.prototype.apply.call(originalConsoleLevel, global$2.console, args);
1388
+ if (originalConsoleMethod) {
1389
+ originalConsoleMethod.apply(global$5.console, args);
1345
1390
  }
1346
1391
  };
1347
1392
  });
@@ -1352,7 +1397,7 @@ var Sentry = (function (exports) {
1352
1397
  if (!supportsNativeFetch()) {
1353
1398
  return;
1354
1399
  }
1355
- fill(global$2, 'fetch', function (originalFetch) {
1400
+ fill(global$5, 'fetch', function (originalFetch) {
1356
1401
  return function () {
1357
1402
  var args = [];
1358
1403
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1368,7 +1413,7 @@ var Sentry = (function (exports) {
1368
1413
  };
1369
1414
  triggerHandlers('fetch', __assign({}, handlerData));
1370
1415
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1371
- return originalFetch.apply(global$2, args).then(function (response) {
1416
+ return originalFetch.apply(global$5, args).then(function (response) {
1372
1417
  triggerHandlers('fetch', __assign(__assign({}, handlerData), { endTimestamp: Date.now(), response: response }));
1373
1418
  return response;
1374
1419
  }, function (error) {
@@ -1385,7 +1430,7 @@ var Sentry = (function (exports) {
1385
1430
  /** Extract `method` from fetch call arguments */
1386
1431
  function getFetchMethod(fetchArgs) {
1387
1432
  if (fetchArgs === void 0) { fetchArgs = []; }
1388
- 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) {
1389
1434
  return String(fetchArgs[0].method).toUpperCase();
1390
1435
  }
1391
1436
  if (fetchArgs[1] && fetchArgs[1].method) {
@@ -1399,7 +1444,7 @@ var Sentry = (function (exports) {
1399
1444
  if (typeof fetchArgs[0] === 'string') {
1400
1445
  return fetchArgs[0];
1401
1446
  }
1402
- if ('Request' in global$2 && isInstanceOf(fetchArgs[0], Request)) {
1447
+ if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request)) {
1403
1448
  return fetchArgs[0].url;
1404
1449
  }
1405
1450
  return String(fetchArgs[0]);
@@ -1407,7 +1452,7 @@ var Sentry = (function (exports) {
1407
1452
  /* eslint-enable @typescript-eslint/no-unsafe-member-access */
1408
1453
  /** JSDoc */
1409
1454
  function instrumentXHR() {
1410
- if (!('XMLHttpRequest' in global$2)) {
1455
+ if (!('XMLHttpRequest' in global$5)) {
1411
1456
  return;
1412
1457
  }
1413
1458
  var xhrproto = XMLHttpRequest.prototype;
@@ -1490,13 +1535,13 @@ var Sentry = (function (exports) {
1490
1535
  if (!supportsHistory()) {
1491
1536
  return;
1492
1537
  }
1493
- var oldOnPopState = global$2.onpopstate;
1494
- global$2.onpopstate = function () {
1538
+ var oldOnPopState = global$5.onpopstate;
1539
+ global$5.onpopstate = function () {
1495
1540
  var args = [];
1496
1541
  for (var _i = 0; _i < arguments.length; _i++) {
1497
1542
  args[_i] = arguments[_i];
1498
1543
  }
1499
- var to = global$2.location.href;
1544
+ var to = global$5.location.href;
1500
1545
  // keep track of the current URL state, as we always receive only the updated state
1501
1546
  var from = lastHref;
1502
1547
  lastHref = to;
@@ -1538,8 +1583,8 @@ var Sentry = (function (exports) {
1538
1583
  return originalHistoryFunction.apply(this, args);
1539
1584
  };
1540
1585
  }
1541
- fill(global$2.history, 'pushState', historyReplacementFunction);
1542
- fill(global$2.history, 'replaceState', historyReplacementFunction);
1586
+ fill(global$5.history, 'pushState', historyReplacementFunction);
1587
+ fill(global$5.history, 'replaceState', historyReplacementFunction);
1543
1588
  }
1544
1589
  var debounceDuration = 1000;
1545
1590
  var debounceTimerID;
@@ -1642,14 +1687,14 @@ var Sentry = (function (exports) {
1642
1687
  }
1643
1688
  // Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together.
1644
1689
  clearTimeout(debounceTimerID);
1645
- debounceTimerID = global$2.setTimeout(function () {
1690
+ debounceTimerID = global$5.setTimeout(function () {
1646
1691
  debounceTimerID = undefined;
1647
1692
  }, debounceDuration);
1648
1693
  };
1649
1694
  }
1650
1695
  /** JSDoc */
1651
1696
  function instrumentDOM() {
1652
- if (!('document' in global$2)) {
1697
+ if (!('document' in global$5)) {
1653
1698
  return;
1654
1699
  }
1655
1700
  // Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom
@@ -1657,8 +1702,8 @@ var Sentry = (function (exports) {
1657
1702
  // we instrument `addEventListener` so that we don't end up attaching this handler twice.
1658
1703
  var triggerDOMHandler = triggerHandlers.bind(null, 'dom');
1659
1704
  var globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true);
1660
- global$2.document.addEventListener('click', globalDOMEventHandler, false);
1661
- global$2.document.addEventListener('keypress', globalDOMEventHandler, false);
1705
+ global$5.document.addEventListener('click', globalDOMEventHandler, false);
1706
+ global$5.document.addEventListener('keypress', globalDOMEventHandler, false);
1662
1707
  // After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled
1663
1708
  // clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That
1664
1709
  // way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler
@@ -1666,7 +1711,7 @@ var Sentry = (function (exports) {
1666
1711
  // guaranteed to fire at least once.)
1667
1712
  ['EventTarget', 'Node'].forEach(function (target) {
1668
1713
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1669
- var proto = global$2[target] && global$2[target].prototype;
1714
+ var proto = global$5[target] && global$5[target].prototype;
1670
1715
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
1671
1716
  if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
1672
1717
  return;
@@ -1727,8 +1772,8 @@ var Sentry = (function (exports) {
1727
1772
  var _oldOnErrorHandler = null;
1728
1773
  /** JSDoc */
1729
1774
  function instrumentError() {
1730
- _oldOnErrorHandler = global$2.onerror;
1731
- global$2.onerror = function (msg, url, line, column, error) {
1775
+ _oldOnErrorHandler = global$5.onerror;
1776
+ global$5.onerror = function (msg, url, line, column, error) {
1732
1777
  triggerHandlers('error', {
1733
1778
  column: column,
1734
1779
  error: error,
@@ -1746,8 +1791,8 @@ var Sentry = (function (exports) {
1746
1791
  var _oldOnUnhandledRejectionHandler = null;
1747
1792
  /** JSDoc */
1748
1793
  function instrumentUnhandledRejection() {
1749
- _oldOnUnhandledRejectionHandler = global$2.onunhandledrejection;
1750
- global$2.onunhandledrejection = function (e) {
1794
+ _oldOnUnhandledRejectionHandler = global$5.onunhandledrejection;
1795
+ global$5.onunhandledrejection = function (e) {
1751
1796
  triggerHandlers('unhandledrejection', e);
1752
1797
  if (_oldOnUnhandledRejectionHandler) {
1753
1798
  // eslint-disable-next-line prefer-rest-params
@@ -2264,23 +2309,10 @@ var Sentry = (function (exports) {
2264
2309
  timeOrigin: timeOrigin,
2265
2310
  };
2266
2311
  }
2267
- /**
2268
- * Returns the native Performance API implementation from Node.js. Returns undefined in old Node.js versions that don't
2269
- * implement the API.
2270
- */
2271
- function getNodePerformance() {
2272
- try {
2273
- var perfHooks = dynamicRequire(module, 'perf_hooks');
2274
- return perfHooks.performance;
2275
- }
2276
- catch (_) {
2277
- return undefined;
2278
- }
2279
- }
2280
2312
  /**
2281
2313
  * The Performance API implementation for the current platform, if available.
2282
2314
  */
2283
- var platformPerformance = isNodeEnv() ? getNodePerformance() : getBrowserPerformance();
2315
+ var platformPerformance = getBrowserPerformance();
2284
2316
  var timestampSource = platformPerformance === undefined
2285
2317
  ? dateTimestampSource
2286
2318
  : {
@@ -2306,7 +2338,7 @@ var Sentry = (function (exports) {
2306
2338
  * The number of milliseconds since the UNIX epoch. This value is only usable in a browser, and only when the
2307
2339
  * performance API is available.
2308
2340
  */
2309
- var browserPerformanceTimeOrigin = (function () {
2341
+ ((function () {
2310
2342
  // Unfortunately browsers may report an inaccurate time origin data, through either performance.timeOrigin or
2311
2343
  // performance.timing.navigationStart, which results in poor results in performance data. We only treat time origin
2312
2344
  // data as reliable if they are within a reasonable threshold of the current time.
@@ -2343,7 +2375,7 @@ var Sentry = (function (exports) {
2343
2375
  }
2344
2376
  }
2345
2377
  return dateNow;
2346
- })();
2378
+ }))();
2347
2379
 
2348
2380
  /**
2349
2381
  * Absolute maximum number of breadcrumbs added to an event.
@@ -3339,38 +3371,9 @@ var Sentry = (function (exports) {
3339
3371
  if (!hasHubOnCarrier(registry) || getHubFromCarrier(registry).isOlderThan(API_VERSION)) {
3340
3372
  setHubOnCarrier(registry, new Hub());
3341
3373
  }
3342
- // Prefer domains over global if they are there (applicable only to Node environment)
3343
- if (isNodeEnv()) {
3344
- return getHubFromActiveDomain(registry);
3345
- }
3346
3374
  // Return hub that lives on a global object
3347
3375
  return getHubFromCarrier(registry);
3348
3376
  }
3349
- /**
3350
- * Try to read the hub from an active domain, and fallback to the registry if one doesn't exist
3351
- * @returns discovered hub
3352
- */
3353
- function getHubFromActiveDomain(registry) {
3354
- try {
3355
- var sentry = getMainCarrier().__SENTRY__;
3356
- var activeDomain = sentry && sentry.extensions && sentry.extensions.domain && sentry.extensions.domain.active;
3357
- // If there's no active domain, just return global hub
3358
- if (!activeDomain) {
3359
- return getHubFromCarrier(registry);
3360
- }
3361
- // If there's no hub on current domain, or it's an old API, assign a new one
3362
- if (!hasHubOnCarrier(activeDomain) || getHubFromCarrier(activeDomain).isOlderThan(API_VERSION)) {
3363
- var registryHubTopStack = getHubFromCarrier(registry).getStackTop();
3364
- setHubOnCarrier(activeDomain, new Hub(registryHubTopStack.client, Scope.clone(registryHubTopStack.scope)));
3365
- }
3366
- // Return hub that lives on a domain
3367
- return getHubFromCarrier(activeDomain);
3368
- }
3369
- catch (_Oo) {
3370
- // Return hub that lives on a global object
3371
- return getHubFromCarrier(registry);
3372
- }
3373
- }
3374
3377
  /**
3375
3378
  * This will tell whether a carrier has a hub on it or not
3376
3379
  * @param carrier object
@@ -4017,6 +4020,11 @@ var Sentry = (function (exports) {
4017
4020
  result = finalScope.applyToEvent(prepared, hint);
4018
4021
  }
4019
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
+ }
4020
4028
  if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
4021
4029
  return _this._normalizeEvent(evt, normalizeDepth);
4022
4030
  }
@@ -4368,22 +4376,27 @@ var Sentry = (function (exports) {
4368
4376
  var transactionSampling = (event.sdkProcessingMetadata || {}).transactionSampling;
4369
4377
  var _a = transactionSampling || {}, samplingMethod = _a.method, sampleRate = _a.rate;
4370
4378
  // TODO: Below is a temporary hack in order to debug a serialization error - see
4371
- // https://github.com/getsentry/sentry-javascript/issues/2809 and
4372
- // https://github.com/getsentry/sentry-javascript/pull/4425. TL;DR: even though we normalize all events (which should
4373
- // 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.
4374
4385
  //
4375
4386
  // When it's time to remove it:
4376
4387
  // 1. Delete everything between here and where the request object `req` is created, EXCEPT the line deleting
4377
4388
  // `sdkProcessingMetadata`
4378
4389
  // 2. Restore the original version of the request body, which is commented out
4379
- // 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
4380
4392
  enhanceEventWithSdkInfo(event, api.metadata.sdk);
4381
4393
  event.tags = event.tags || {};
4382
4394
  event.extra = event.extra || {};
4383
4395
  // In theory, all events should be marked as having gone through normalization and so
4384
- // we should never set this tag
4396
+ // we should never set this tag/extra data
4385
4397
  if (!(event.sdkProcessingMetadata && event.sdkProcessingMetadata.baseClientNormalized)) {
4386
4398
  event.tags.skippedNormalization = true;
4399
+ event.extra.normalizeDepth = event.sdkProcessingMetadata ? event.sdkProcessingMetadata.normalizeDepth : 'unset';
4387
4400
  }
4388
4401
  // prevent this data from being sent to sentry
4389
4402
  // TODO: This is NOT part of the hack - DO NOT DELETE
@@ -4465,7 +4478,7 @@ var Sentry = (function (exports) {
4465
4478
  hub.bindClient(client);
4466
4479
  }
4467
4480
 
4468
- var SDK_VERSION = '6.17.6';
4481
+ var SDK_VERSION = '6.17.9';
4469
4482
 
4470
4483
  var originalFunctionToString;
4471
4484
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4680,214 +4693,96 @@ var Sentry = (function (exports) {
4680
4693
  return InboundFilters;
4681
4694
  }());
4682
4695
 
4683
-
4684
-
4685
4696
  var CoreIntegrations = /*#__PURE__*/Object.freeze({
4686
4697
  __proto__: null,
4687
4698
  FunctionToString: FunctionToString,
4688
4699
  InboundFilters: InboundFilters
4689
4700
  });
4690
4701
 
4691
- /**
4692
- * This was originally forked from https://github.com/occ/TraceKit, but has since been
4693
- * largely modified and is now maintained as part of Sentry JS SDK.
4694
- */
4695
4702
  // global reference to slice
4696
4703
  var UNKNOWN_FUNCTION = '?';
4697
- // Chromium based browsers: Chrome, Brave, new Opera, new Edge
4698
- var chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
4699
- // gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
4700
- // generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
4701
- // We need this specific case for now because we want no other regex to match.
4702
- var gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
4703
- var winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
4704
- var geckoEval = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
4705
- var chromeEval = /\((\S*)(?::(\d+))(?::(\d+))\)/;
4706
- // Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
4707
- var reactMinifiedRegexp = /Minified React error #\d+;/i;
4708
- /** JSDoc */
4709
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
4710
- function computeStackTrace(ex) {
4711
- var stack = null;
4712
- var popSize = 0;
4713
- if (ex) {
4714
- if (typeof ex.framesToPop === 'number') {
4715
- popSize = ex.framesToPop;
4716
- }
4717
- else if (reactMinifiedRegexp.test(ex.message)) {
4718
- popSize = 1;
4719
- }
4720
- }
4721
- try {
4722
- // This must be tried first because Opera 10 *destroys*
4723
- // its stacktrace property if you try to access the stack
4724
- // property first!!
4725
- stack = computeStackTraceFromStacktraceProp(ex);
4726
- if (stack) {
4727
- return popFrames(stack, popSize);
4728
- }
4729
- }
4730
- catch (e) {
4731
- // no-empty
4732
- }
4733
- try {
4734
- stack = computeStackTraceFromStackProp(ex);
4735
- if (stack) {
4736
- return popFrames(stack, popSize);
4737
- }
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;
4738
4713
  }
4739
- catch (e) {
4740
- // no-empty
4714
+ if (colno !== undefined) {
4715
+ frame.colno = colno;
4741
4716
  }
4742
- return {
4743
- message: extractMessage(ex),
4744
- name: ex && ex.name,
4745
- stack: [],
4746
- failed: true,
4747
- };
4717
+ return frame;
4748
4718
  }
4749
- /** JSDoc */
4750
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, complexity
4751
- function computeStackTraceFromStackProp(ex) {
4752
- var _a, _b;
4753
- if (!ex || !ex.stack) {
4754
- return null;
4755
- }
4756
- var stack = [];
4757
- var lines = ex.stack.split('\n');
4758
- var isEval;
4759
- var submatch;
4760
- var parts;
4761
- var element;
4762
- for (var i = 0; i < lines.length; ++i) {
4763
- if ((parts = chrome.exec(lines[i]))) {
4764
- var isNative = parts[2] && parts[2].indexOf('native') === 0; // start of line
4765
- isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line
4766
- if (isEval && (submatch = chromeEval.exec(parts[2]))) {
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) {
4767
4729
  // throw out eval line/column and use top-most line/column number
4768
- parts[2] = submatch[1]; // url
4769
- parts[3] = submatch[2]; // line
4770
- parts[4] = submatch[3]; // column
4730
+ parts[2] = subMatch[1]; // url
4731
+ parts[3] = subMatch[2]; // line
4732
+ parts[4] = subMatch[3]; // column
4771
4733
  }
4772
- // Arpad: Working with the regexp above is super painful. it is quite a hack, but just stripping the `address at `
4773
- // prefix here seems like the quickest solution for now.
4774
- var url = parts[2] && parts[2].indexOf('address at ') === 0 ? parts[2].substr('address at '.length) : parts[2];
4775
- // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now
4776
- // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)
4777
- var func = parts[1] || UNKNOWN_FUNCTION;
4778
- _a = __read(extractSafariExtensionDetails(func, url), 2), func = _a[0], url = _a[1];
4779
- element = {
4780
- url: url,
4781
- func: func,
4782
- args: isNative ? [parts[2]] : [],
4783
- line: parts[3] ? +parts[3] : null,
4784
- column: parts[4] ? +parts[4] : null,
4785
- };
4786
4734
  }
4787
- else if ((parts = winjs.exec(lines[i]))) {
4788
- element = {
4789
- url: parts[2],
4790
- func: parts[1] || UNKNOWN_FUNCTION,
4791
- args: [],
4792
- line: +parts[3],
4793
- column: parts[4] ? +parts[4] : null,
4794
- };
4795
- }
4796
- else if ((parts = gecko.exec(lines[i]))) {
4797
- isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
4798
- if (isEval && (submatch = geckoEval.exec(parts[3]))) {
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);
4739
+ }
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) {
4799
4755
  // throw out eval line/column and use top-most line number
4800
4756
  parts[1] = parts[1] || "eval";
4801
- parts[3] = submatch[1];
4802
- parts[4] = submatch[2];
4757
+ parts[3] = subMatch[1];
4758
+ parts[4] = subMatch[2];
4803
4759
  parts[5] = ''; // no column when eval
4804
4760
  }
4805
- else if (i === 0 && !parts[5] && ex.columnNumber !== void 0) {
4806
- // FireFox uses this awesome columnNumber property for its top frame
4807
- // Also note, Firefox's column number is 0-based and everything else expects 1-based,
4808
- // so adding 1
4809
- // NOTE: this hack doesn't work if top-most frame is eval
4810
- stack[0].column = ex.columnNumber + 1;
4811
- }
4812
- var url = parts[3];
4813
- var func = parts[1] || UNKNOWN_FUNCTION;
4814
- _b = __read(extractSafariExtensionDetails(func, url), 2), func = _b[0], url = _b[1];
4815
- element = {
4816
- url: url,
4817
- func: func,
4818
- args: parts[2] ? parts[2].split(',') : [],
4819
- line: parts[4] ? +parts[4] : null,
4820
- column: parts[5] ? +parts[5] : null,
4821
- };
4822
- }
4823
- else {
4824
- continue;
4825
- }
4826
- if (!element.func && element.line) {
4827
- element.func = UNKNOWN_FUNCTION;
4828
- }
4829
- stack.push(element);
4830
- }
4831
- if (!stack.length) {
4832
- return null;
4833
- }
4834
- return {
4835
- message: extractMessage(ex),
4836
- name: ex.name,
4837
- stack: stack,
4838
- };
4839
- }
4840
- /** JSDoc */
4841
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4842
- function computeStackTraceFromStacktraceProp(ex) {
4843
- if (!ex || !ex.stacktrace) {
4844
- return null;
4845
- }
4846
- // Access and store the stacktrace property before doing ANYTHING
4847
- // else to it because Opera is not very good at providing it
4848
- // reliably in other circumstances.
4849
- var stacktrace = ex.stacktrace;
4850
- var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
4851
- var opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\((.*)\))? in (.*):\s*$/i;
4852
- var lines = stacktrace.split('\n');
4853
- var stack = [];
4854
- var parts;
4855
- for (var line = 0; line < lines.length; line += 2) {
4856
- var element = null;
4857
- if ((parts = opera10Regex.exec(lines[line]))) {
4858
- element = {
4859
- url: parts[2],
4860
- func: parts[3],
4861
- args: [],
4862
- line: +parts[1],
4863
- column: null,
4864
- };
4865
- }
4866
- else if ((parts = opera11Regex.exec(lines[line]))) {
4867
- element = {
4868
- url: parts[6],
4869
- func: parts[3] || parts[4],
4870
- args: parts[5] ? parts[5].split(',') : [],
4871
- line: +parts[1],
4872
- column: +parts[2],
4873
- };
4874
- }
4875
- if (element) {
4876
- if (!element.func && element.line) {
4877
- element.func = UNKNOWN_FUNCTION;
4878
- }
4879
- stack.push(element);
4880
4761
  }
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);
4881
4766
  }
4882
- if (!stack.length) {
4883
- return null;
4884
- }
4885
- return {
4886
- message: extractMessage(ex),
4887
- name: ex.name,
4888
- stack: stack,
4889
- };
4890
- }
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
+ };
4891
4786
  /**
4892
4787
  * Safari web extensions, starting version unknown, can produce "frames-only" stacktraces.
4893
4788
  * What it means, is that instead of format like:
@@ -4905,56 +4800,31 @@ var Sentry = (function (exports) {
4905
4800
  *
4906
4801
  * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.
4907
4802
  * This function is extracted so that we can use it in both places without duplicating the logic.
4908
- * 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
4909
4804
  * and fix this case seems like an impossible, or at least way too time-consuming task.
4910
4805
  */
4911
- var extractSafariExtensionDetails = function (func, url) {
4806
+ var extractSafariExtensionDetails = function (func, filename) {
4912
4807
  var isSafariExtension = func.indexOf('safari-extension') !== -1;
4913
4808
  var isSafariWebExtension = func.indexOf('safari-web-extension') !== -1;
4914
4809
  return isSafariExtension || isSafariWebExtension
4915
4810
  ? [
4916
4811
  func.indexOf('@') !== -1 ? func.split('@')[0] : UNKNOWN_FUNCTION,
4917
- isSafariExtension ? "safari-extension:" + url : "safari-web-extension:" + url,
4812
+ isSafariExtension ? "safari-extension:" + filename : "safari-web-extension:" + filename,
4918
4813
  ]
4919
- : [func, url];
4920
- };
4921
- /** Remove N number of frames from the stack */
4922
- function popFrames(stacktrace, popSize) {
4923
- try {
4924
- return __assign(__assign({}, stacktrace), { stack: stacktrace.stack.slice(popSize) });
4925
- }
4926
- catch (e) {
4927
- return stacktrace;
4928
- }
4929
- }
4930
- /**
4931
- * There are cases where stacktrace.message is an Event object
4932
- * https://github.com/getsentry/sentry-javascript/issues/1949
4933
- * In this specific case we try to extract stacktrace.message.error.message
4934
- */
4935
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4936
- function extractMessage(ex) {
4937
- var message = ex && ex.message;
4938
- if (!message) {
4939
- return 'No error message';
4940
- }
4941
- if (message.error && typeof message.error.message === 'string') {
4942
- return message.error.message;
4943
- }
4944
- return message;
4945
- }
4814
+ : [func, filename];
4815
+ };
4946
4816
 
4947
- var STACKTRACE_LIMIT = 50;
4948
4817
  /**
4949
4818
  * This function creates an exception from an TraceKitStackTrace
4950
4819
  * @param stacktrace TraceKitStackTrace that will be converted to an exception
4951
4820
  * @hidden
4952
4821
  */
4953
- function exceptionFromStacktrace(stacktrace) {
4954
- 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);
4955
4825
  var exception = {
4956
- type: stacktrace.name,
4957
- value: stacktrace.message,
4826
+ type: ex && ex.name,
4827
+ value: extractMessage(ex),
4958
4828
  };
4959
4829
  if (frames && frames.length) {
4960
4830
  exception.stacktrace = { frames: frames };
@@ -4982,10 +4852,8 @@ var Sentry = (function (exports) {
4982
4852
  },
4983
4853
  };
4984
4854
  if (syntheticException) {
4985
- var stacktrace = computeStackTrace(syntheticException);
4986
- var frames_1 = prepareFramesForEvent(stacktrace.stack);
4987
4855
  event.stacktrace = {
4988
- frames: frames_1,
4856
+ frames: parseStackFrames(syntheticException),
4989
4857
  };
4990
4858
  }
4991
4859
  return event;
@@ -4993,43 +4861,57 @@ var Sentry = (function (exports) {
4993
4861
  /**
4994
4862
  * @hidden
4995
4863
  */
4996
- function eventFromStacktrace(stacktrace) {
4997
- var exception = exceptionFromStacktrace(stacktrace);
4864
+ function eventFromError(ex) {
4998
4865
  return {
4999
4866
  exception: {
5000
- values: [exception],
4867
+ values: [exceptionFromError(ex)],
5001
4868
  },
5002
4869
  };
5003
4870
  }
4871
+ /** Parses stack frames from an error */
4872
+ function parseStackFrames(ex) {
4873
+ // Access and store the stacktrace property before doing ANYTHING
4874
+ // else to it because Opera is not very good at providing it
4875
+ // reliably in other circumstances.
4876
+ var stacktrace = ex.stacktrace || ex.stack || '';
4877
+ var popSize = getPopSize(ex);
4878
+ try {
4879
+ // The order of the parsers in important
4880
+ return createStackParser(opera10, opera11, chrome, winjs, gecko)(stacktrace, popSize);
4881
+ }
4882
+ catch (e) {
4883
+ // no-empty
4884
+ }
4885
+ return [];
4886
+ }
4887
+ // Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
4888
+ var reactMinifiedRegexp = /Minified React error #\d+;/i;
4889
+ function getPopSize(ex) {
4890
+ if (ex) {
4891
+ if (typeof ex.framesToPop === 'number') {
4892
+ return ex.framesToPop;
4893
+ }
4894
+ if (reactMinifiedRegexp.test(ex.message)) {
4895
+ return 1;
4896
+ }
4897
+ }
4898
+ return 0;
4899
+ }
5004
4900
  /**
5005
- * @hidden
4901
+ * There are cases where stacktrace.message is an Event object
4902
+ * https://github.com/getsentry/sentry-javascript/issues/1949
4903
+ * In this specific case we try to extract stacktrace.message.error.message
5006
4904
  */
5007
- function prepareFramesForEvent(stack) {
5008
- if (!stack || !stack.length) {
5009
- return [];
5010
- }
5011
- var localStack = stack;
5012
- var firstFrameFunction = localStack[0].func || '';
5013
- var lastFrameFunction = localStack[localStack.length - 1].func || '';
5014
- // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
5015
- if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
5016
- localStack = localStack.slice(1);
4905
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4906
+ function extractMessage(ex) {
4907
+ var message = ex && ex.message;
4908
+ if (!message) {
4909
+ return 'No error message';
5017
4910
  }
5018
- // 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)
5019
- if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
5020
- localStack = localStack.slice(0, -1);
4911
+ if (message.error && typeof message.error.message === 'string') {
4912
+ return message.error.message;
5021
4913
  }
5022
- // The frame where the crash happened, should be the last entry in the array
5023
- return localStack
5024
- .slice(0, STACKTRACE_LIMIT)
5025
- .map(function (frame) { return ({
5026
- colno: frame.column === null ? undefined : frame.column,
5027
- filename: frame.url || localStack[0].url,
5028
- function: frame.func || '?',
5029
- in_app: true,
5030
- lineno: frame.line === null ? undefined : frame.line,
5031
- }); })
5032
- .reverse();
4914
+ return message;
5033
4915
  }
5034
4916
 
5035
4917
  /**
@@ -5073,10 +4955,7 @@ var Sentry = (function (exports) {
5073
4955
  if (isErrorEvent(exception) && exception.error) {
5074
4956
  // If it is an ErrorEvent with `error` property, extract it to get actual Error
5075
4957
  var errorEvent = exception;
5076
- // eslint-disable-next-line no-param-reassign
5077
- exception = errorEvent.error;
5078
- event = eventFromStacktrace(computeStackTrace(exception));
5079
- return event;
4958
+ return eventFromError(errorEvent.error);
5080
4959
  }
5081
4960
  // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name
5082
4961
  // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be
@@ -5088,7 +4967,7 @@ var Sentry = (function (exports) {
5088
4967
  if (isDOMError(exception) || isDOMException(exception)) {
5089
4968
  var domException = exception;
5090
4969
  if ('stack' in exception) {
5091
- event = eventFromStacktrace(computeStackTrace(exception));
4970
+ event = eventFromError(exception);
5092
4971
  }
5093
4972
  else {
5094
4973
  var name_1 = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');
@@ -5103,8 +4982,7 @@ var Sentry = (function (exports) {
5103
4982
  }
5104
4983
  if (isError(exception)) {
5105
4984
  // we have a real Error object, do nothing
5106
- event = eventFromStacktrace(computeStackTrace(exception));
5107
- return event;
4985
+ return eventFromError(exception);
5108
4986
  }
5109
4987
  if (isPlainObject(exception) || isEvent(exception)) {
5110
4988
  // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize
@@ -5142,16 +5020,14 @@ var Sentry = (function (exports) {
5142
5020
  message: input,
5143
5021
  };
5144
5022
  if (options.attachStacktrace && syntheticException) {
5145
- var stacktrace = computeStackTrace(syntheticException);
5146
- var frames_1 = prepareFramesForEvent(stacktrace.stack);
5147
5023
  event.stacktrace = {
5148
- frames: frames_1,
5024
+ frames: parseStackFrames(syntheticException),
5149
5025
  };
5150
5026
  }
5151
5027
  return event;
5152
5028
  }
5153
5029
 
5154
- var global$3 = getGlobalObject();
5030
+ var global$4 = getGlobalObject();
5155
5031
  var cachedFetchImpl;
5156
5032
  /**
5157
5033
  * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
@@ -5197,11 +5073,11 @@ var Sentry = (function (exports) {
5197
5073
  }
5198
5074
  /* eslint-disable @typescript-eslint/unbound-method */
5199
5075
  // Fast path to avoid DOM I/O
5200
- if (isNativeFetch(global$3.fetch)) {
5201
- return (cachedFetchImpl = global$3.fetch.bind(global$3));
5076
+ if (isNativeFetch(global$4.fetch)) {
5077
+ return (cachedFetchImpl = global$4.fetch.bind(global$4));
5202
5078
  }
5203
- var document = global$3.document;
5204
- var fetchImpl = global$3.fetch;
5079
+ var document = global$4.document;
5080
+ var fetchImpl = global$4.fetch;
5205
5081
  // eslint-disable-next-line deprecation/deprecation
5206
5082
  if (document && typeof document.createElement === "function") {
5207
5083
  try {
@@ -5220,7 +5096,7 @@ var Sentry = (function (exports) {
5220
5096
  }
5221
5097
  }
5222
5098
  }
5223
- return (cachedFetchImpl = fetchImpl.bind(global$3));
5099
+ return (cachedFetchImpl = fetchImpl.bind(global$4));
5224
5100
  /* eslint-enable @typescript-eslint/unbound-method */
5225
5101
  }
5226
5102
  /**
@@ -5230,11 +5106,11 @@ var Sentry = (function (exports) {
5230
5106
  * @param body report payload
5231
5107
  */
5232
5108
  function sendReport(url, body) {
5233
- var isRealNavigator = Object.prototype.toString.call(global$3 && global$3.navigator) === '[object Navigator]';
5234
- var hasSendBeacon = isRealNavigator && typeof global$3.navigator.sendBeacon === 'function';
5109
+ var isRealNavigator = Object.prototype.toString.call(global$4 && global$4.navigator) === '[object Navigator]';
5110
+ var hasSendBeacon = isRealNavigator && typeof global$4.navigator.sendBeacon === 'function';
5235
5111
  if (hasSendBeacon) {
5236
5112
  // Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
5237
- var sendBeacon = global$3.navigator.sendBeacon.bind(global$3.navigator);
5113
+ var sendBeacon = global$4.navigator.sendBeacon.bind(global$4.navigator);
5238
5114
  return sendBeacon(url, body);
5239
5115
  }
5240
5116
  if (supportsFetch()) {
@@ -5252,7 +5128,7 @@ var Sentry = (function (exports) {
5252
5128
  var tyStr = ty;
5253
5129
  return tyStr === 'event' ? 'error' : tyStr;
5254
5130
  }
5255
- var global$4 = getGlobalObject();
5131
+ var global$3 = getGlobalObject();
5256
5132
  /** Base Transport class implementation */
5257
5133
  var BaseTransport = /** @class */ (function () {
5258
5134
  function BaseTransport(options) {
@@ -5266,9 +5142,9 @@ var Sentry = (function (exports) {
5266
5142
  this._api = initAPIDetails(options.dsn, options._metadata, options.tunnel);
5267
5143
  // eslint-disable-next-line deprecation/deprecation
5268
5144
  this.url = getStoreEndpointWithUrlEncodedAuth(this._api.dsn);
5269
- if (this.options.sendClientReports && global$4.document) {
5270
- global$4.document.addEventListener('visibilitychange', function () {
5271
- if (global$4.document.visibilityState === 'hidden') {
5145
+ if (this.options.sendClientReports && global$3.document) {
5146
+ global$3.document.addEventListener('visibilitychange', function () {
5147
+ if (global$3.document.visibilityState === 'hidden') {
5272
5148
  _this._flushOutcomes();
5273
5149
  }
5274
5150
  });
@@ -5570,8 +5446,6 @@ var Sentry = (function (exports) {
5570
5446
  return XHRTransport;
5571
5447
  }(BaseTransport));
5572
5448
 
5573
-
5574
-
5575
5449
  var index = /*#__PURE__*/Object.freeze({
5576
5450
  __proto__: null,
5577
5451
  BaseTransport: BaseTransport,
@@ -5621,7 +5495,7 @@ var Sentry = (function (exports) {
5621
5495
  return BrowserBackend;
5622
5496
  }(BaseBackend));
5623
5497
 
5624
- var global$5 = getGlobalObject();
5498
+ var global$2 = getGlobalObject();
5625
5499
  var ignoreOnError = 0;
5626
5500
  /**
5627
5501
  * @hidden
@@ -5647,7 +5521,7 @@ var Sentry = (function (exports) {
5647
5521
  * @returns The wrapped function.
5648
5522
  * @hidden
5649
5523
  */
5650
- function wrap(fn, options, before) {
5524
+ function wrap$1(fn, options, before) {
5651
5525
  // for future readers what this does is wrap a function and then create
5652
5526
  // a bi-directional wrapping between them.
5653
5527
  //
@@ -5685,7 +5559,7 @@ var Sentry = (function (exports) {
5685
5559
  before.apply(this, arguments);
5686
5560
  }
5687
5561
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
5688
- var wrappedArguments = args.map(function (arg) { return wrap(arg, options); });
5562
+ var wrappedArguments = args.map(function (arg) { return wrap$1(arg, options); });
5689
5563
  // Attempt to invoke user-land function
5690
5564
  // NOTE: If you are a Sentry user, and you are seeing this stack frame, it
5691
5565
  // means the sentry.javascript SDK caught an error invoking your application code. This
@@ -5744,7 +5618,7 @@ var Sentry = (function (exports) {
5744
5618
  */
5745
5619
  function injectReportDialog(options) {
5746
5620
  if (options === void 0) { options = {}; }
5747
- if (!global$5.document) {
5621
+ if (!global$2.document) {
5748
5622
  return;
5749
5623
  }
5750
5624
  if (!options.eventId) {
@@ -5759,14 +5633,14 @@ var Sentry = (function (exports) {
5759
5633
  }
5760
5634
  return;
5761
5635
  }
5762
- var script = global$5.document.createElement('script');
5636
+ var script = global$2.document.createElement('script');
5763
5637
  script.async = true;
5764
5638
  script.src = getReportDialogEndpoint(options.dsn, options);
5765
5639
  if (options.onLoad) {
5766
5640
  // eslint-disable-next-line @typescript-eslint/unbound-method
5767
5641
  script.onload = options.onLoad;
5768
5642
  }
5769
- var injectionPoint = global$5.document.head || global$5.document.body;
5643
+ var injectionPoint = global$2.document.head || global$2.document.body;
5770
5644
  if (injectionPoint) {
5771
5645
  injectionPoint.appendChild(script);
5772
5646
  }
@@ -6056,7 +5930,7 @@ var Sentry = (function (exports) {
6056
5930
  args[_i] = arguments[_i];
6057
5931
  }
6058
5932
  var originalCallback = args[0];
6059
- args[0] = wrap(originalCallback, {
5933
+ args[0] = wrap$1(originalCallback, {
6060
5934
  mechanism: {
6061
5935
  data: { function: getFunctionName(original) },
6062
5936
  handled: true,
@@ -6072,7 +5946,7 @@ var Sentry = (function (exports) {
6072
5946
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6073
5947
  return function (callback) {
6074
5948
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6075
- return original.call(this, wrap(callback, {
5949
+ return original.call(this, wrap$1(callback, {
6076
5950
  mechanism: {
6077
5951
  data: {
6078
5952
  function: 'requestAnimationFrame',
@@ -6115,7 +5989,7 @@ var Sentry = (function (exports) {
6115
5989
  wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);
6116
5990
  }
6117
5991
  // Otherwise wrap directly
6118
- return wrap(original, wrapOptions);
5992
+ return wrap$1(original, wrapOptions);
6119
5993
  });
6120
5994
  }
6121
5995
  });
@@ -6136,7 +6010,7 @@ var Sentry = (function (exports) {
6136
6010
  return function (eventName, fn, options) {
6137
6011
  try {
6138
6012
  if (typeof fn.handleEvent === 'function') {
6139
- fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
6013
+ fn.handleEvent = wrap$1(fn.handleEvent.bind(fn), {
6140
6014
  mechanism: {
6141
6015
  data: {
6142
6016
  function: 'handleEvent',
@@ -6154,7 +6028,7 @@ var Sentry = (function (exports) {
6154
6028
  }
6155
6029
  return original.call(this, eventName,
6156
6030
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6157
- wrap(fn, {
6031
+ wrap$1(fn, {
6158
6032
  mechanism: {
6159
6033
  data: {
6160
6034
  function: 'addEventListener',
@@ -6471,12 +6345,11 @@ var Sentry = (function (exports) {
6471
6345
  if (!isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {
6472
6346
  return stack;
6473
6347
  }
6474
- var stacktrace = computeStackTrace(error[key]);
6475
- var exception = exceptionFromStacktrace(stacktrace);
6348
+ var exception = exceptionFromError(error[key]);
6476
6349
  return _walkErrorTree(limit, error[key], key, __spread([exception], stack));
6477
6350
  }
6478
6351
 
6479
- var global$6 = getGlobalObject();
6352
+ var global$1 = getGlobalObject();
6480
6353
  /** UserAgent */
6481
6354
  var UserAgent = /** @class */ (function () {
6482
6355
  function UserAgent() {
@@ -6492,13 +6365,13 @@ var Sentry = (function (exports) {
6492
6365
  addGlobalEventProcessor(function (event) {
6493
6366
  if (getCurrentHub().getIntegration(UserAgent)) {
6494
6367
  // if none of the information we want exists, don't bother
6495
- if (!global$6.navigator && !global$6.location && !global$6.document) {
6368
+ if (!global$1.navigator && !global$1.location && !global$1.document) {
6496
6369
  return event;
6497
6370
  }
6498
6371
  // grab as much info as exists and add it to the event
6499
- var url = (event.request && event.request.url) || (global$6.location && global$6.location.href);
6500
- var referrer = (global$6.document || {}).referrer;
6501
- var userAgent = (global$6.navigator || {}).userAgent;
6372
+ var url = (event.request && event.request.url) || (global$1.location && global$1.location.href);
6373
+ var referrer = (global$1.document || {}).referrer;
6374
+ var userAgent = (global$1.navigator || {}).userAgent;
6502
6375
  var headers = __assign(__assign(__assign({}, (event.request && event.request.headers)), (referrer && { Referer: referrer })), (userAgent && { 'User-Agent': userAgent }));
6503
6376
  var request = __assign(__assign({}, (url && { url: url })), { headers: headers });
6504
6377
  return __assign(__assign({}, event), { request: request });
@@ -6678,8 +6551,6 @@ var Sentry = (function (exports) {
6678
6551
  return undefined;
6679
6552
  }
6680
6553
 
6681
-
6682
-
6683
6554
  var BrowserIntegrations = /*#__PURE__*/Object.freeze({
6684
6555
  __proto__: null,
6685
6556
  GlobalHandlers: GlobalHandlers,
@@ -6934,8 +6805,8 @@ var Sentry = (function (exports) {
6934
6805
  * @returns The result of wrapped function call.
6935
6806
  */
6936
6807
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6937
- function wrap$1(fn) {
6938
- return wrap(fn)();
6808
+ function wrap(fn) {
6809
+ return wrap$1(fn)();
6939
6810
  }
6940
6811
  function startSessionOnHub(hub) {
6941
6812
  hub.startSession({ ignoreDuration: true });
@@ -7025,9 +6896,9 @@ var Sentry = (function (exports) {
7025
6896
  exports.showReportDialog = showReportDialog;
7026
6897
  exports.startTransaction = startTransaction;
7027
6898
  exports.withScope = withScope;
7028
- exports.wrap = wrap$1;
6899
+ exports.wrap = wrap;
7029
6900
 
7030
6901
  return exports;
7031
6902
 
7032
- }({}));
6903
+ })({});
7033
6904
  //# sourceMappingURL=bundle.js.map