@sentry/browser 6.18.2 → 6.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/bundles/bundle.debug.min.js +3 -0
  2. package/bundles/bundle.debug.min.js.map +1 -0
  3. package/bundles/bundle.es6.debug.min.js +3 -0
  4. package/bundles/bundle.es6.debug.min.js.map +1 -0
  5. package/{build → bundles}/bundle.es6.js +723 -702
  6. package/bundles/bundle.es6.js.map +1 -0
  7. package/bundles/bundle.es6.min.js +3 -0
  8. package/bundles/bundle.es6.min.js.map +1 -0
  9. package/{build → bundles}/bundle.js +777 -749
  10. package/bundles/bundle.js.map +1 -0
  11. package/bundles/bundle.min.js +3 -0
  12. package/bundles/bundle.min.js.map +1 -0
  13. package/dist/backend.d.ts.map +1 -1
  14. package/dist/backend.js.map +1 -1
  15. package/dist/client.d.ts.map +1 -1
  16. package/dist/client.js +1 -1
  17. package/dist/client.js.map +1 -1
  18. package/dist/eventbuilder.d.ts.map +1 -1
  19. package/dist/eventbuilder.js.map +1 -1
  20. package/dist/exports.d.ts.map +1 -1
  21. package/dist/exports.js.map +1 -1
  22. package/dist/helpers.d.ts.map +1 -1
  23. package/dist/helpers.js +2 -6
  24. package/dist/helpers.js.map +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/integrations/breadcrumbs.d.ts.map +1 -1
  28. package/dist/integrations/breadcrumbs.js.map +1 -1
  29. package/dist/integrations/dedupe.d.ts.map +1 -1
  30. package/dist/integrations/dedupe.js +1 -1
  31. package/dist/integrations/dedupe.js.map +1 -1
  32. package/dist/integrations/globalhandlers.d.ts.map +1 -1
  33. package/dist/integrations/globalhandlers.js +1 -3
  34. package/dist/integrations/globalhandlers.js.map +1 -1
  35. package/dist/integrations/index.d.ts.map +1 -1
  36. package/dist/integrations/index.js.map +1 -1
  37. package/dist/integrations/linkederrors.d.ts.map +1 -1
  38. package/dist/integrations/linkederrors.js.map +1 -1
  39. package/dist/integrations/trycatch.d.ts.map +1 -1
  40. package/dist/integrations/trycatch.js +26 -21
  41. package/dist/integrations/trycatch.js.map +1 -1
  42. package/dist/integrations/useragent.d.ts.map +1 -1
  43. package/dist/integrations/useragent.js.map +1 -1
  44. package/dist/sdk.d.ts.map +1 -1
  45. package/dist/sdk.js +3 -9
  46. package/dist/sdk.js.map +1 -1
  47. package/dist/stack-parsers.d.ts.map +1 -1
  48. package/dist/stack-parsers.js.map +1 -1
  49. package/dist/transports/base.d.ts +6 -6
  50. package/dist/transports/base.d.ts.map +1 -1
  51. package/dist/transports/base.js +17 -68
  52. package/dist/transports/base.js.map +1 -1
  53. package/dist/transports/fetch.d.ts.map +1 -1
  54. package/dist/transports/fetch.js +2 -0
  55. package/dist/transports/fetch.js.map +1 -1
  56. package/dist/transports/index.d.ts.map +1 -1
  57. package/dist/transports/index.js.map +1 -1
  58. package/dist/transports/utils.d.ts.map +1 -1
  59. package/dist/transports/utils.js +1 -2
  60. package/dist/transports/utils.js.map +1 -1
  61. package/dist/transports/xhr.d.ts.map +1 -1
  62. package/dist/transports/xhr.js +2 -0
  63. package/dist/transports/xhr.js.map +1 -1
  64. package/dist/version.d.ts.map +1 -1
  65. package/dist/version.js.map +1 -1
  66. package/esm/backend.d.ts.map +1 -1
  67. package/esm/backend.js.map +1 -1
  68. package/esm/client.d.ts.map +1 -1
  69. package/esm/client.js +2 -2
  70. package/esm/client.js.map +1 -1
  71. package/esm/eventbuilder.d.ts.map +1 -1
  72. package/esm/eventbuilder.js.map +1 -1
  73. package/esm/exports.d.ts.map +1 -1
  74. package/esm/exports.js.map +1 -1
  75. package/esm/helpers.d.ts.map +1 -1
  76. package/esm/helpers.js +2 -6
  77. package/esm/helpers.js.map +1 -1
  78. package/esm/index.d.ts.map +1 -1
  79. package/esm/index.js.map +1 -1
  80. package/esm/integrations/breadcrumbs.d.ts.map +1 -1
  81. package/esm/integrations/breadcrumbs.js.map +1 -1
  82. package/esm/integrations/dedupe.d.ts.map +1 -1
  83. package/esm/integrations/dedupe.js +2 -2
  84. package/esm/integrations/dedupe.js.map +1 -1
  85. package/esm/integrations/globalhandlers.d.ts.map +1 -1
  86. package/esm/integrations/globalhandlers.js +1 -3
  87. package/esm/integrations/globalhandlers.js.map +1 -1
  88. package/esm/integrations/index.d.ts.map +1 -1
  89. package/esm/integrations/index.js.map +1 -1
  90. package/esm/integrations/linkederrors.d.ts.map +1 -1
  91. package/esm/integrations/linkederrors.js.map +1 -1
  92. package/esm/integrations/trycatch.d.ts.map +1 -1
  93. package/esm/integrations/trycatch.js +26 -21
  94. package/esm/integrations/trycatch.js.map +1 -1
  95. package/esm/integrations/useragent.d.ts.map +1 -1
  96. package/esm/integrations/useragent.js.map +1 -1
  97. package/esm/sdk.d.ts.map +1 -1
  98. package/esm/sdk.js +3 -9
  99. package/esm/sdk.js.map +1 -1
  100. package/esm/stack-parsers.d.ts.map +1 -1
  101. package/esm/stack-parsers.js.map +1 -1
  102. package/esm/transports/base.d.ts +6 -6
  103. package/esm/transports/base.d.ts.map +1 -1
  104. package/esm/transports/base.js +19 -70
  105. package/esm/transports/base.js.map +1 -1
  106. package/esm/transports/fetch.d.ts.map +1 -1
  107. package/esm/transports/fetch.js +2 -0
  108. package/esm/transports/fetch.js.map +1 -1
  109. package/esm/transports/index.d.ts.map +1 -1
  110. package/esm/transports/index.js.map +1 -1
  111. package/esm/transports/utils.d.ts.map +1 -1
  112. package/esm/transports/utils.js +1 -2
  113. package/esm/transports/utils.js.map +1 -1
  114. package/esm/transports/xhr.d.ts.map +1 -1
  115. package/esm/transports/xhr.js +2 -0
  116. package/esm/transports/xhr.js.map +1 -1
  117. package/esm/version.d.ts.map +1 -1
  118. package/esm/version.js.map +1 -1
  119. package/package.json +14 -12
  120. package/types/backend.d.ts +43 -0
  121. package/types/backend.d.ts.map +1 -0
  122. package/types/client.d.ts +33 -0
  123. package/types/client.d.ts.map +1 -0
  124. package/types/eventbuilder.d.ts +39 -0
  125. package/types/eventbuilder.d.ts.map +1 -0
  126. package/types/exports.d.ts +10 -0
  127. package/types/exports.d.ts.map +1 -0
  128. package/types/helpers.d.ts +52 -0
  129. package/types/helpers.d.ts.map +1 -0
  130. package/types/index.d.ts +16 -0
  131. package/types/index.d.ts.map +1 -0
  132. package/types/integrations/breadcrumbs.d.ts +47 -0
  133. package/types/integrations/breadcrumbs.d.ts.map +1 -0
  134. package/types/integrations/dedupe.d.ts +21 -0
  135. package/types/integrations/dedupe.d.ts.map +1 -0
  136. package/types/integrations/globalhandlers.d.ts +30 -0
  137. package/types/integrations/globalhandlers.d.ts.map +1 -0
  138. package/types/integrations/index.d.ts +7 -0
  139. package/types/integrations/index.d.ts.map +1 -0
  140. package/types/integrations/linkederrors.d.ts +42 -0
  141. package/types/integrations/linkederrors.d.ts.map +1 -0
  142. package/types/integrations/trycatch.d.ts +33 -0
  143. package/types/integrations/trycatch.d.ts.map +1 -0
  144. package/types/integrations/useragent.d.ts +17 -0
  145. package/types/integrations/useragent.d.ts.map +1 -0
  146. package/types/sdk.d.ts +112 -0
  147. package/types/sdk.d.ts.map +1 -0
  148. package/types/stack-parsers.d.ts +7 -0
  149. package/types/stack-parsers.d.ts.map +1 -0
  150. package/types/transports/base.d.ts +65 -0
  151. package/types/transports/base.d.ts.map +1 -0
  152. package/types/transports/fetch.d.ts +17 -0
  153. package/types/transports/fetch.d.ts.map +1 -0
  154. package/types/transports/index.d.ts +4 -0
  155. package/types/transports/index.d.ts.map +1 -0
  156. package/types/transports/utils.d.ts +48 -0
  157. package/types/transports/utils.d.ts.map +1 -0
  158. package/types/transports/xhr.d.ts +11 -0
  159. package/types/transports/xhr.d.ts.map +1 -0
  160. package/types/version.d.ts +2 -0
  161. package/types/version.d.ts.map +1 -0
  162. package/build/bundle.es6.js.map +0 -1
  163. package/build/bundle.es6.min.js +0 -3
  164. package/build/bundle.es6.min.js.map +0 -1
  165. package/build/bundle.js.map +0 -1
  166. package/build/bundle.min.js +0 -3
  167. package/build/bundle.min.js.map +0 -1
@@ -1,4 +1,4 @@
1
- /*! @sentry/browser 6.18.2 (22f518e) | https://github.com/getsentry/sentry-javascript */
1
+ /*! @sentry/browser 6.19.2 (f49c509) | https://github.com/getsentry/sentry-javascript */
2
2
  var Sentry = (function (exports) {
3
3
 
4
4
  /*! *****************************************************************************
@@ -114,14 +114,11 @@ var Sentry = (function (exports) {
114
114
  }
115
115
 
116
116
  /**
117
- * This module mostly exists for optimizations in the build process
118
- * through rollup and terser. We define some global constants which
119
- * are normally undefined. However terser overrides these with global
120
- * definitions which can be evaluated by the static analyzer when
121
- * creating a bundle.
122
- *
123
- * In turn the `isDebugBuild` and `isBrowserBundle` functions are pure
124
- * and can help us remove unused code from the bundles.
117
+ * This module exists for optimizations in the build process through rollup and terser. We define some global
118
+ * constants, which can be overridden during build. By guarding certain pieces of code with functions that return these
119
+ * constants, we can control whether or not they appear in the final bundle. (Any code guarded by a false condition will
120
+ * never run, and will hence be dropped during treeshaking.) The two primary uses for this are stripping out calls to
121
+ * `logger` and preventing node-related code from appearing in browser bundles.
125
122
  */
126
123
  /**
127
124
  * Figures out if we're building with debug functionality.
@@ -129,7 +126,7 @@ var Sentry = (function (exports) {
129
126
  * @returns true if this is a debug build
130
127
  */
131
128
  function isDebugBuild() {
132
- return typeof __SENTRY_NO_DEBUG__ !== 'undefined' && !true;
129
+ return true;
133
130
  }
134
131
 
135
132
  /**
@@ -498,9 +495,6 @@ var Sentry = (function (exports) {
498
495
  };
499
496
  }
500
497
  function validateDsn(dsn) {
501
- if (!isDebugBuild()) {
502
- return;
503
- }
504
498
  var port = dsn.port, projectId = dsn.projectId, protocol = dsn.protocol;
505
499
  var requiredComponents = ['protocol', 'publicKey', 'host', 'projectId'];
506
500
  requiredComponents.forEach(function (component) {
@@ -532,6 +526,7 @@ var Sentry = (function (exports) {
532
526
  var global$6 = getGlobalObject();
533
527
  /** Prefix for logging strings */
534
528
  var PREFIX = 'Sentry Logger ';
529
+ var CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert'];
535
530
  /**
536
531
  * Temporarily unwrap `console.log` and friends in order to perform the given callback using the original methods.
537
532
  * Restores wrapping after the callback completes.
@@ -541,7 +536,6 @@ var Sentry = (function (exports) {
541
536
  */
542
537
  function consoleSandbox(callback) {
543
538
  var global = getGlobalObject();
544
- var levels = ['debug', 'info', 'warn', 'error', 'log', 'assert'];
545
539
  if (!('console' in global)) {
546
540
  return callback();
547
541
  }
@@ -549,7 +543,7 @@ var Sentry = (function (exports) {
549
543
  var originalConsole = global.console;
550
544
  var wrappedLevels = {};
551
545
  // Restore all wrapped console methods
552
- levels.forEach(function (level) {
546
+ CONSOLE_LEVELS.forEach(function (level) {
553
547
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
554
548
  if (level in global.console && originalConsole[level].__sentry_original__) {
555
549
  wrappedLevels[level] = originalConsole[level];
@@ -622,142 +616,12 @@ var Sentry = (function (exports) {
622
616
  };
623
617
  return Logger;
624
618
  }());
625
- // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
626
- global$6.__SENTRY__ = global$6.__SENTRY__ || {};
627
- var logger = global$6.__SENTRY__.logger || (global$6.__SENTRY__.logger = new Logger());
628
-
629
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
630
- /* eslint-disable @typescript-eslint/no-explicit-any */
631
- /**
632
- * Helper to decycle json objects
633
- */
634
- function memoBuilder() {
635
- var hasWeakSet = typeof WeakSet === 'function';
636
- var inner = hasWeakSet ? new WeakSet() : [];
637
- function memoize(obj) {
638
- if (hasWeakSet) {
639
- if (inner.has(obj)) {
640
- return true;
641
- }
642
- inner.add(obj);
643
- return false;
644
- }
645
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
646
- for (var i = 0; i < inner.length; i++) {
647
- var value = inner[i];
648
- if (value === obj) {
649
- return true;
650
- }
651
- }
652
- inner.push(obj);
653
- return false;
654
- }
655
- function unmemoize(obj) {
656
- if (hasWeakSet) {
657
- inner.delete(obj);
658
- }
659
- else {
660
- for (var i = 0; i < inner.length; i++) {
661
- if (inner[i] === obj) {
662
- inner.splice(i, 1);
663
- break;
664
- }
665
- }
666
- }
667
- }
668
- return [memoize, unmemoize];
669
- }
670
-
671
- var STACKTRACE_LIMIT = 50;
672
- /**
673
- * Creates a stack parser with the supplied line parsers
674
- *
675
- * StackFrames are returned in the correct order for Sentry Exception
676
- * frames and with Sentry SDK internal frames removed from the top and bottom
677
- *
678
- */
679
- function createStackParser() {
680
- var parsers = [];
681
- for (var _i = 0; _i < arguments.length; _i++) {
682
- parsers[_i] = arguments[_i];
683
- }
684
- var sortedParsers = parsers.sort(function (a, b) { return a[0] - b[0]; }).map(function (p) { return p[1]; });
685
- return function (stack, skipFirst) {
686
- var e_1, _a, e_2, _b;
687
- if (skipFirst === void 0) { skipFirst = 0; }
688
- var frames = [];
689
- try {
690
- for (var _c = __values(stack.split('\n').slice(skipFirst)), _d = _c.next(); !_d.done; _d = _c.next()) {
691
- var line = _d.value;
692
- try {
693
- for (var sortedParsers_1 = (e_2 = void 0, __values(sortedParsers)), sortedParsers_1_1 = sortedParsers_1.next(); !sortedParsers_1_1.done; sortedParsers_1_1 = sortedParsers_1.next()) {
694
- var parser = sortedParsers_1_1.value;
695
- var frame = parser(line);
696
- if (frame) {
697
- frames.push(frame);
698
- break;
699
- }
700
- }
701
- }
702
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
703
- finally {
704
- try {
705
- if (sortedParsers_1_1 && !sortedParsers_1_1.done && (_b = sortedParsers_1.return)) _b.call(sortedParsers_1);
706
- }
707
- finally { if (e_2) throw e_2.error; }
708
- }
709
- }
710
- }
711
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
712
- finally {
713
- try {
714
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
715
- }
716
- finally { if (e_1) throw e_1.error; }
717
- }
718
- return stripSentryFramesAndReverse(frames);
719
- };
720
- }
721
- /**
722
- * @hidden
723
- */
724
- function stripSentryFramesAndReverse(stack) {
725
- if (!stack.length) {
726
- return [];
727
- }
728
- var localStack = stack;
729
- var firstFrameFunction = localStack[0].function || '';
730
- var lastFrameFunction = localStack[localStack.length - 1].function || '';
731
- // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
732
- if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
733
- localStack = localStack.slice(1);
734
- }
735
- // 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)
736
- if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
737
- localStack = localStack.slice(0, -1);
738
- }
739
- // The frame where the crash happened, should be the last entry in the array
740
- return localStack
741
- .slice(0, STACKTRACE_LIMIT)
742
- .map(function (frame) { return (__assign(__assign({}, frame), { filename: frame.filename || localStack[0].filename, function: frame.function || '?' })); })
743
- .reverse();
744
- }
745
- var defaultFunctionName = '<anonymous>';
746
- /**
747
- * Safely extract function name from itself
748
- */
749
- function getFunctionName(fn) {
750
- try {
751
- if (!fn || typeof fn !== 'function') {
752
- return defaultFunctionName;
753
- }
754
- return fn.name || defaultFunctionName;
755
- }
756
- catch (e) {
757
- // Just accessing custom props in some Selenium environments
758
- // can cause a "Permission denied" exception (see raven-js#495).
759
- return defaultFunctionName;
760
- }
619
+ var sentryGlobal = global$6.__SENTRY__ || {};
620
+ var logger = sentryGlobal.logger || new Logger();
621
+ {
622
+ // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
623
+ sentryGlobal.logger = logger;
624
+ global$6.__SENTRY__ = sentryGlobal;
761
625
  }
762
626
 
763
627
  /**
@@ -950,180 +814,6 @@ var Sentry = (function (exports) {
950
814
  }
951
815
  return value;
952
816
  }
953
- /** Calculates bytes size of input string */
954
- function utf8Length(value) {
955
- // eslint-disable-next-line no-bitwise
956
- return ~-encodeURI(value).split(/%..|./).length;
957
- }
958
- /** Calculates bytes size of input object */
959
- function jsonSize(value) {
960
- return utf8Length(JSON.stringify(value));
961
- }
962
- /** JSDoc */
963
- function normalizeToSize(object,
964
- // Default Node.js REPL depth
965
- depth,
966
- // 100kB, as 200kB is max payload size, so half sounds reasonable
967
- maxSize) {
968
- if (depth === void 0) { depth = 3; }
969
- if (maxSize === void 0) { maxSize = 100 * 1024; }
970
- var serialized = normalize(object, depth);
971
- if (jsonSize(serialized) > maxSize) {
972
- return normalizeToSize(object, depth - 1, maxSize);
973
- }
974
- return serialized;
975
- }
976
- /**
977
- * Transform any non-primitive, BigInt, or Symbol-type value into a string. Acts as a no-op on strings, numbers,
978
- * booleans, null, and undefined.
979
- *
980
- * @param value The value to stringify
981
- * @returns For non-primitive, BigInt, and Symbol-type values, a string denoting the value's type, type and value, or
982
- * type and `description` property, respectively. For non-BigInt, non-Symbol primitives, returns the original value,
983
- * unchanged.
984
- */
985
- function serializeValue(value) {
986
- // Node.js REPL notation
987
- if (typeof value === 'string') {
988
- return value;
989
- }
990
- var type = Object.prototype.toString.call(value);
991
- if (type === '[object Object]') {
992
- return '[Object]';
993
- }
994
- if (type === '[object Array]') {
995
- return '[Array]';
996
- }
997
- // `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
998
- // pass-through.
999
- var serializable = makeSerializable(value);
1000
- return isPrimitive(serializable) ? serializable : type;
1001
- }
1002
- /**
1003
- * makeSerializable()
1004
- *
1005
- * Takes unserializable input and make it serializer-friendly.
1006
- *
1007
- * Handles globals, functions, `undefined`, `NaN`, and other non-serializable values.
1008
- */
1009
- function makeSerializable(value, key) {
1010
- if (key === 'domain' && value && typeof value === 'object' && value._events) {
1011
- return '[Domain]';
1012
- }
1013
- if (key === 'domainEmitter') {
1014
- return '[DomainEmitter]';
1015
- }
1016
- if (typeof global !== 'undefined' && value === global) {
1017
- return '[Global]';
1018
- }
1019
- // It's safe to use `window` and `document` here in this manner, as we are asserting using `typeof` first
1020
- // which won't throw if they are not present.
1021
- // eslint-disable-next-line no-restricted-globals
1022
- if (typeof window !== 'undefined' && value === window) {
1023
- return '[Window]';
1024
- }
1025
- // eslint-disable-next-line no-restricted-globals
1026
- if (typeof document !== 'undefined' && value === document) {
1027
- return '[Document]';
1028
- }
1029
- // React's SyntheticEvent thingy
1030
- if (isSyntheticEvent(value)) {
1031
- return '[SyntheticEvent]';
1032
- }
1033
- if (typeof value === 'number' && value !== value) {
1034
- return '[NaN]';
1035
- }
1036
- if (value === void 0) {
1037
- return '[undefined]';
1038
- }
1039
- if (typeof value === 'function') {
1040
- return "[Function: " + getFunctionName(value) + "]";
1041
- }
1042
- // symbols and bigints are considered primitives by TS, but aren't natively JSON-serilaizable
1043
- if (typeof value === 'symbol') {
1044
- return "[" + String(value) + "]";
1045
- }
1046
- if (typeof value === 'bigint') {
1047
- return "[BigInt: " + String(value) + "]";
1048
- }
1049
- return value;
1050
- }
1051
- /**
1052
- * Walks an object to perform a normalization on it
1053
- *
1054
- * @param key of object that's walked in current iteration
1055
- * @param value object to be walked
1056
- * @param depth Optional number indicating how deep should walking be performed
1057
- * @param memo Optional Memo class handling decycling
1058
- */
1059
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1060
- function walk(key, value, depth, memo) {
1061
- if (depth === void 0) { depth = +Infinity; }
1062
- if (memo === void 0) { memo = memoBuilder(); }
1063
- var _a = __read(memo, 2), memoize = _a[0], unmemoize = _a[1];
1064
- // If we reach the maximum depth, serialize whatever is left
1065
- if (depth === 0) {
1066
- return serializeValue(value);
1067
- }
1068
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
1069
- // If value implements `toJSON` method, call it and return early
1070
- if (value !== null && value !== undefined && typeof value.toJSON === 'function') {
1071
- return value.toJSON();
1072
- }
1073
- /* eslint-enable @typescript-eslint/no-unsafe-member-access */
1074
- // `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
1075
- // pass-through. If what comes back is a primitive (either because it's been stringified or because it was primitive
1076
- // all along), we're done.
1077
- var serializable = makeSerializable(value, key);
1078
- if (isPrimitive(serializable)) {
1079
- return serializable;
1080
- }
1081
- // Create source that we will use for the next iteration. It will either be an objectified error object (`Error` type
1082
- // with extracted key:value pairs) or the input itself.
1083
- var source = getWalkSource(value);
1084
- // Create an accumulator that will act as a parent for all future itterations of that branch
1085
- var acc = Array.isArray(value) ? [] : {};
1086
- // If we already walked that branch, bail out, as it's circular reference
1087
- if (memoize(value)) {
1088
- return '[Circular ~]';
1089
- }
1090
- // Walk all keys of the source
1091
- for (var innerKey in source) {
1092
- // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
1093
- if (!Object.prototype.hasOwnProperty.call(source, innerKey)) {
1094
- continue;
1095
- }
1096
- // Recursively walk through all the child nodes
1097
- var innerValue = source[innerKey];
1098
- acc[innerKey] = walk(innerKey, innerValue, depth - 1, memo);
1099
- }
1100
- // Once walked through all the branches, remove the parent from memo storage
1101
- unmemoize(value);
1102
- // Return accumulated values
1103
- return acc;
1104
- }
1105
- /**
1106
- * normalize()
1107
- *
1108
- * - Creates a copy to prevent original input mutation
1109
- * - Skip non-enumerablers
1110
- * - Calls `toJSON` if implemented
1111
- * - Removes circular references
1112
- * - Translates non-serializeable values (undefined/NaN/Functions) to serializable format
1113
- * - Translates known global objects/Classes to a string representations
1114
- * - Takes care of Error objects serialization
1115
- * - Optionally limit depth of final output
1116
- */
1117
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1118
- function normalize(input, depth) {
1119
- try {
1120
- // since we're at the outermost level, there is no key
1121
- return walk('', input, depth);
1122
- }
1123
- catch (_oO) {
1124
- return '**non-serializable**';
1125
- }
1126
- }
1127
817
  /**
1128
818
  * Given any captured exception, extract its keys and create a sorted
1129
819
  * and truncated list that will be used inside the event message.
@@ -1172,16 +862,108 @@ var Sentry = (function (exports) {
1172
862
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
1173
863
  finally {
1174
864
  try {
1175
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
865
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
866
+ }
867
+ finally { if (e_1) throw e_1.error; }
868
+ }
869
+ return rv;
870
+ }
871
+ if (Array.isArray(val)) {
872
+ return val.map(dropUndefinedKeys);
873
+ }
874
+ return val;
875
+ }
876
+
877
+ var STACKTRACE_LIMIT = 50;
878
+ /**
879
+ * Creates a stack parser with the supplied line parsers
880
+ *
881
+ * StackFrames are returned in the correct order for Sentry Exception
882
+ * frames and with Sentry SDK internal frames removed from the top and bottom
883
+ *
884
+ */
885
+ function createStackParser() {
886
+ var parsers = [];
887
+ for (var _i = 0; _i < arguments.length; _i++) {
888
+ parsers[_i] = arguments[_i];
889
+ }
890
+ var sortedParsers = parsers.sort(function (a, b) { return a[0] - b[0]; }).map(function (p) { return p[1]; });
891
+ return function (stack, skipFirst) {
892
+ var e_1, _a, e_2, _b;
893
+ if (skipFirst === void 0) { skipFirst = 0; }
894
+ var frames = [];
895
+ try {
896
+ for (var _c = __values(stack.split('\n').slice(skipFirst)), _d = _c.next(); !_d.done; _d = _c.next()) {
897
+ var line = _d.value;
898
+ try {
899
+ for (var sortedParsers_1 = (e_2 = void 0, __values(sortedParsers)), sortedParsers_1_1 = sortedParsers_1.next(); !sortedParsers_1_1.done; sortedParsers_1_1 = sortedParsers_1.next()) {
900
+ var parser = sortedParsers_1_1.value;
901
+ var frame = parser(line);
902
+ if (frame) {
903
+ frames.push(frame);
904
+ break;
905
+ }
906
+ }
907
+ }
908
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
909
+ finally {
910
+ try {
911
+ if (sortedParsers_1_1 && !sortedParsers_1_1.done && (_b = sortedParsers_1.return)) _b.call(sortedParsers_1);
912
+ }
913
+ finally { if (e_2) throw e_2.error; }
914
+ }
915
+ }
916
+ }
917
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
918
+ finally {
919
+ try {
920
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1176
921
  }
1177
922
  finally { if (e_1) throw e_1.error; }
1178
923
  }
1179
- return rv;
924
+ return stripSentryFramesAndReverse(frames);
925
+ };
926
+ }
927
+ /**
928
+ * @hidden
929
+ */
930
+ function stripSentryFramesAndReverse(stack) {
931
+ if (!stack.length) {
932
+ return [];
1180
933
  }
1181
- if (Array.isArray(val)) {
1182
- return val.map(dropUndefinedKeys);
934
+ var localStack = stack;
935
+ var firstFrameFunction = localStack[0].function || '';
936
+ var lastFrameFunction = localStack[localStack.length - 1].function || '';
937
+ // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
938
+ if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
939
+ localStack = localStack.slice(1);
940
+ }
941
+ // 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)
942
+ if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
943
+ localStack = localStack.slice(0, -1);
944
+ }
945
+ // The frame where the crash happened, should be the last entry in the array
946
+ return localStack
947
+ .slice(0, STACKTRACE_LIMIT)
948
+ .map(function (frame) { return (__assign(__assign({}, frame), { filename: frame.filename || localStack[0].filename, function: frame.function || '?' })); })
949
+ .reverse();
950
+ }
951
+ var defaultFunctionName = '<anonymous>';
952
+ /**
953
+ * Safely extract function name from itself
954
+ */
955
+ function getFunctionName(fn) {
956
+ try {
957
+ if (!fn || typeof fn !== 'function') {
958
+ return defaultFunctionName;
959
+ }
960
+ return fn.name || defaultFunctionName;
961
+ }
962
+ catch (e) {
963
+ // Just accessing custom props in some Selenium environments
964
+ // can cause a "Permission denied" exception (see raven-js#495).
965
+ return defaultFunctionName;
1183
966
  }
1184
- return val;
1185
967
  }
1186
968
 
1187
969
  /**
@@ -1244,9 +1026,7 @@ var Sentry = (function (exports) {
1244
1026
  doc.head.removeChild(sandbox);
1245
1027
  }
1246
1028
  catch (err) {
1247
- if (isDebugBuild()) {
1248
- logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);
1249
- }
1029
+ logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);
1250
1030
  }
1251
1031
  }
1252
1032
  return result;
@@ -1338,6 +1118,7 @@ var Sentry = (function (exports) {
1338
1118
  break;
1339
1119
  default:
1340
1120
  logger.warn('unknown instrumentation type:', type);
1121
+ return;
1341
1122
  }
1342
1123
  }
1343
1124
  /**
@@ -1363,9 +1144,7 @@ var Sentry = (function (exports) {
1363
1144
  handler(data);
1364
1145
  }
1365
1146
  catch (e) {
1366
- if (isDebugBuild()) {
1367
- logger.error("Error while triggering instrumentation handler.\nType: " + type + "\nName: " + getFunctionName(handler) + "\nError:", e);
1368
- }
1147
+ logger.error("Error while triggering instrumentation handler.\nType: " + type + "\nName: " + getFunctionName(handler) + "\nError:", e);
1369
1148
  }
1370
1149
  }
1371
1150
  }
@@ -1382,7 +1161,7 @@ var Sentry = (function (exports) {
1382
1161
  if (!('console' in global$5)) {
1383
1162
  return;
1384
1163
  }
1385
- ['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) {
1164
+ CONSOLE_LEVELS.forEach(function (level) {
1386
1165
  if (!(level in global$5.console)) {
1387
1166
  return;
1388
1167
  }
@@ -1811,6 +1590,48 @@ var Sentry = (function (exports) {
1811
1590
  };
1812
1591
  }
1813
1592
 
1593
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
1594
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1595
+ /**
1596
+ * Helper to decycle json objects
1597
+ */
1598
+ function memoBuilder() {
1599
+ var hasWeakSet = typeof WeakSet === 'function';
1600
+ var inner = hasWeakSet ? new WeakSet() : [];
1601
+ function memoize(obj) {
1602
+ if (hasWeakSet) {
1603
+ if (inner.has(obj)) {
1604
+ return true;
1605
+ }
1606
+ inner.add(obj);
1607
+ return false;
1608
+ }
1609
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
1610
+ for (var i = 0; i < inner.length; i++) {
1611
+ var value = inner[i];
1612
+ if (value === obj) {
1613
+ return true;
1614
+ }
1615
+ }
1616
+ inner.push(obj);
1617
+ return false;
1618
+ }
1619
+ function unmemoize(obj) {
1620
+ if (hasWeakSet) {
1621
+ inner.delete(obj);
1622
+ }
1623
+ else {
1624
+ for (var i = 0; i < inner.length; i++) {
1625
+ if (inner[i] === obj) {
1626
+ inner.splice(i, 1);
1627
+ break;
1628
+ }
1629
+ }
1630
+ }
1631
+ }
1632
+ return [memoize, unmemoize];
1633
+ }
1634
+
1814
1635
  /**
1815
1636
  * UUID4 generator
1816
1637
  *
@@ -1965,7 +1786,195 @@ var Sentry = (function (exports) {
1965
1786
  catch (err) {
1966
1787
  // `exception` is a primitive, so we can't mark it seen
1967
1788
  }
1968
- return false;
1789
+ return false;
1790
+ }
1791
+
1792
+ /**
1793
+ * Recursively normalizes the given object.
1794
+ *
1795
+ * - Creates a copy to prevent original input mutation
1796
+ * - Skips non-enumerable properties
1797
+ * - When stringifying, calls `toJSON` if implemented
1798
+ * - Removes circular references
1799
+ * - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format
1800
+ * - Translates known global objects/classes to a string representations
1801
+ * - Takes care of `Error` object serialization
1802
+ * - Optionally limits depth of final output
1803
+ * - Optionally limits number of properties/elements included in any single object/array
1804
+ *
1805
+ * @param input The object to be normalized.
1806
+ * @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)
1807
+ * @param maxProperties The max number of elements or properties to be included in any single array or
1808
+ * object in the normallized output..
1809
+ * @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
1810
+ */
1811
+ function normalize(input, depth, maxProperties) {
1812
+ if (depth === void 0) { depth = +Infinity; }
1813
+ if (maxProperties === void 0) { maxProperties = +Infinity; }
1814
+ try {
1815
+ // since we're at the outermost level, there is no key
1816
+ return walk('', input, depth, maxProperties);
1817
+ }
1818
+ catch (_oO) {
1819
+ return '**non-serializable**';
1820
+ }
1821
+ }
1822
+ /** JSDoc */
1823
+ function normalizeToSize(object,
1824
+ // Default Node.js REPL depth
1825
+ depth,
1826
+ // 100kB, as 200kB is max payload size, so half sounds reasonable
1827
+ maxSize) {
1828
+ if (depth === void 0) { depth = 3; }
1829
+ if (maxSize === void 0) { maxSize = 100 * 1024; }
1830
+ var serialized = normalize(object, depth);
1831
+ if (jsonSize(serialized) > maxSize) {
1832
+ return normalizeToSize(object, depth - 1, maxSize);
1833
+ }
1834
+ return serialized;
1835
+ }
1836
+ /**
1837
+ * Walks an object to perform a normalization on it
1838
+ *
1839
+ * @param key of object that's walked in current iteration
1840
+ * @param value object to be walked
1841
+ * @param depth Optional number indicating how deep should walking be performed
1842
+ * @param maxProperties Optional maximum number of properties/elements included in any single object/array
1843
+ * @param memo Optional Memo class handling decycling
1844
+ */
1845
+ function walk(key, value, depth, maxProperties, memo) {
1846
+ if (depth === void 0) { depth = +Infinity; }
1847
+ if (maxProperties === void 0) { maxProperties = +Infinity; }
1848
+ if (memo === void 0) { memo = memoBuilder(); }
1849
+ var _a = __read(memo, 2), memoize = _a[0], unmemoize = _a[1];
1850
+ // If we reach the maximum depth, serialize whatever is left
1851
+ if (depth === 0) {
1852
+ return serializeValue(value);
1853
+ }
1854
+ // If value implements `toJSON` method, call it and return early
1855
+ if (value !== null && value !== undefined && typeof value.toJSON === 'function') {
1856
+ return value.toJSON();
1857
+ }
1858
+ // `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
1859
+ // pass-through. If what comes back is a primitive (either because it's been stringified or because it was primitive
1860
+ // all along), we're done.
1861
+ var serializable = makeSerializable(value, key);
1862
+ if (isPrimitive(serializable)) {
1863
+ return serializable;
1864
+ }
1865
+ // Create source that we will use for the next iteration. It will either be an objectified error object (`Error` type
1866
+ // with extracted key:value pairs) or the input itself.
1867
+ var source = getWalkSource(value);
1868
+ // Create an accumulator that will act as a parent for all future itterations of that branch
1869
+ var acc = Array.isArray(value) ? [] : {};
1870
+ // If we already walked that branch, bail out, as it's circular reference
1871
+ if (memoize(value)) {
1872
+ return '[Circular ~]';
1873
+ }
1874
+ var propertyCount = 0;
1875
+ // Walk all keys of the source
1876
+ for (var innerKey in source) {
1877
+ // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
1878
+ if (!Object.prototype.hasOwnProperty.call(source, innerKey)) {
1879
+ continue;
1880
+ }
1881
+ if (propertyCount >= maxProperties) {
1882
+ acc[innerKey] = '[MaxProperties ~]';
1883
+ break;
1884
+ }
1885
+ propertyCount += 1;
1886
+ // Recursively walk through all the child nodes
1887
+ var innerValue = source[innerKey];
1888
+ acc[innerKey] = walk(innerKey, innerValue, depth - 1, maxProperties, memo);
1889
+ }
1890
+ // Once walked through all the branches, remove the parent from memo storage
1891
+ unmemoize(value);
1892
+ // Return accumulated values
1893
+ return acc;
1894
+ }
1895
+ /**
1896
+ * Transform any non-primitive, BigInt, or Symbol-type value into a string. Acts as a no-op on strings, numbers,
1897
+ * booleans, null, and undefined.
1898
+ *
1899
+ * @param value The value to stringify
1900
+ * @returns For non-primitive, BigInt, and Symbol-type values, a string denoting the value's type, type and value, or
1901
+ * type and `description` property, respectively. For non-BigInt, non-Symbol primitives, returns the original value,
1902
+ * unchanged.
1903
+ */
1904
+ function serializeValue(value) {
1905
+ // Node.js REPL notation
1906
+ if (typeof value === 'string') {
1907
+ return value;
1908
+ }
1909
+ var type = Object.prototype.toString.call(value);
1910
+ if (type === '[object Object]') {
1911
+ return '[Object]';
1912
+ }
1913
+ if (type === '[object Array]') {
1914
+ return '[Array]';
1915
+ }
1916
+ // `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
1917
+ // pass-through.
1918
+ var serializable = makeSerializable(value);
1919
+ return isPrimitive(serializable) ? serializable : type;
1920
+ }
1921
+ /**
1922
+ * makeSerializable()
1923
+ *
1924
+ * Takes unserializable input and make it serializer-friendly.
1925
+ *
1926
+ * Handles globals, functions, `undefined`, `NaN`, and other non-serializable values.
1927
+ */
1928
+ function makeSerializable(value, key) {
1929
+ if (key === 'domain' && value && typeof value === 'object' && value._events) {
1930
+ return '[Domain]';
1931
+ }
1932
+ if (key === 'domainEmitter') {
1933
+ return '[DomainEmitter]';
1934
+ }
1935
+ if (typeof global !== 'undefined' && value === global) {
1936
+ return '[Global]';
1937
+ }
1938
+ // It's safe to use `window` and `document` here in this manner, as we are asserting using `typeof` first
1939
+ // which won't throw if they are not present.
1940
+ // eslint-disable-next-line no-restricted-globals
1941
+ if (typeof window !== 'undefined' && value === window) {
1942
+ return '[Window]';
1943
+ }
1944
+ // eslint-disable-next-line no-restricted-globals
1945
+ if (typeof document !== 'undefined' && value === document) {
1946
+ return '[Document]';
1947
+ }
1948
+ // React's SyntheticEvent thingy
1949
+ if (isSyntheticEvent(value)) {
1950
+ return '[SyntheticEvent]';
1951
+ }
1952
+ if (typeof value === 'number' && value !== value) {
1953
+ return '[NaN]';
1954
+ }
1955
+ if (value === void 0) {
1956
+ return '[undefined]';
1957
+ }
1958
+ if (typeof value === 'function') {
1959
+ return "[Function: " + getFunctionName(value) + "]";
1960
+ }
1961
+ // symbols and bigints are considered primitives by TS, but aren't natively JSON-serilaizable
1962
+ if (typeof value === 'symbol') {
1963
+ return "[" + String(value) + "]";
1964
+ }
1965
+ if (typeof value === 'bigint') {
1966
+ return "[BigInt: " + String(value) + "]";
1967
+ }
1968
+ return value;
1969
+ }
1970
+ /** Calculates bytes size of input string */
1971
+ function utf8Length(value) {
1972
+ // eslint-disable-next-line no-bitwise
1973
+ return ~-encodeURI(value).split(/%..|./).length;
1974
+ }
1975
+ /** Calculates bytes size of input object */
1976
+ function jsonSize(value) {
1977
+ return utf8Length(JSON.stringify(value));
1969
1978
  }
1970
1979
 
1971
1980
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
@@ -2428,6 +2437,83 @@ var Sentry = (function (exports) {
2428
2437
  return headerDate - now;
2429
2438
  }
2430
2439
  return DEFAULT_RETRY_AFTER;
2440
+ }
2441
+ /**
2442
+ * Gets the time that given category is disabled until for rate limiting
2443
+ */
2444
+ function disabledUntil(limits, category) {
2445
+ return limits[category] || limits.all || 0;
2446
+ }
2447
+ /**
2448
+ * Checks if a category is rate limited
2449
+ */
2450
+ function isRateLimited(limits, category, now) {
2451
+ if (now === void 0) { now = Date.now(); }
2452
+ return disabledUntil(limits, category) > now;
2453
+ }
2454
+ /**
2455
+ * Update ratelimits from incoming headers.
2456
+ * Returns true if headers contains a non-empty rate limiting header.
2457
+ */
2458
+ function updateRateLimits(limits, headers, now) {
2459
+ var e_1, _a, e_2, _b;
2460
+ if (now === void 0) { now = Date.now(); }
2461
+ var updatedRateLimits = __assign({}, limits);
2462
+ // "The name is case-insensitive."
2463
+ // https://developer.mozilla.org/en-US/docs/Web/API/Headers/get
2464
+ var rateLimitHeader = headers['x-sentry-rate-limits'];
2465
+ var retryAfterHeader = headers['retry-after'];
2466
+ if (rateLimitHeader) {
2467
+ try {
2468
+ /**
2469
+ * rate limit headers are of the form
2470
+ * <header>,<header>,..
2471
+ * where each <header> is of the form
2472
+ * <retry_after>: <categories>: <scope>: <reason_code>
2473
+ * where
2474
+ * <retry_after> is a delay in seconds
2475
+ * <categories> is the event type(s) (error, transaction, etc) being rate limited and is of the form
2476
+ * <category>;<category>;...
2477
+ * <scope> is what's being limited (org, project, or key) - ignored by SDK
2478
+ * <reason_code> is an arbitrary string like "org_quota" - ignored by SDK
2479
+ */
2480
+ for (var _c = __values(rateLimitHeader.trim().split(',')), _d = _c.next(); !_d.done; _d = _c.next()) {
2481
+ var limit = _d.value;
2482
+ var parameters = limit.split(':', 2);
2483
+ var headerDelay = parseInt(parameters[0], 10);
2484
+ var delay = (!isNaN(headerDelay) ? headerDelay : 60) * 1000; // 60sec default
2485
+ if (!parameters[1]) {
2486
+ updatedRateLimits.all = now + delay;
2487
+ }
2488
+ else {
2489
+ try {
2490
+ for (var _e = (e_2 = void 0, __values(parameters[1].split(';'))), _f = _e.next(); !_f.done; _f = _e.next()) {
2491
+ var category = _f.value;
2492
+ updatedRateLimits[category] = now + delay;
2493
+ }
2494
+ }
2495
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2496
+ finally {
2497
+ try {
2498
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
2499
+ }
2500
+ finally { if (e_2) throw e_2.error; }
2501
+ }
2502
+ }
2503
+ }
2504
+ }
2505
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2506
+ finally {
2507
+ try {
2508
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2509
+ }
2510
+ finally { if (e_1) throw e_1.error; }
2511
+ }
2512
+ }
2513
+ else if (retryAfterHeader) {
2514
+ updatedRateLimits.all = now + parseRetryAfterHeader(retryAfterHeader, now);
2515
+ }
2516
+ return updatedRateLimits;
2431
2517
  }
2432
2518
 
2433
2519
  /**
@@ -3487,13 +3573,7 @@ var Sentry = (function (exports) {
3487
3573
  */
3488
3574
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3489
3575
  function captureException(exception, captureContext) {
3490
- var syntheticException;
3491
- try {
3492
- throw new Error('Sentry syntheticException');
3493
- }
3494
- catch (exception) {
3495
- syntheticException = exception;
3496
- }
3576
+ var syntheticException = new Error('Sentry syntheticException');
3497
3577
  return callOnHub('captureException', exception, {
3498
3578
  captureContext: captureContext,
3499
3579
  originalException: exception,
@@ -3508,13 +3588,7 @@ var Sentry = (function (exports) {
3508
3588
  * @returns The generated eventId.
3509
3589
  */
3510
3590
  function captureMessage(message, captureContext) {
3511
- var syntheticException;
3512
- try {
3513
- throw new Error(message);
3514
- }
3515
- catch (exception) {
3516
- syntheticException = exception;
3517
- }
3591
+ var syntheticException = new Error(message);
3518
3592
  // This is necessary to provide explicit scopes upgrade, without changing the original
3519
3593
  // arity of the `captureMessage(message, level)` method.
3520
3594
  var level = typeof captureContext === 'string' ? captureContext : undefined;
@@ -3885,15 +3959,11 @@ var Sentry = (function (exports) {
3885
3959
  */
3886
3960
  BaseClient.prototype.captureSession = function (session) {
3887
3961
  if (!this._isEnabled()) {
3888
- if (isDebugBuild()) {
3889
- logger.warn('SDK not enabled, will not capture session.');
3890
- }
3962
+ logger.warn('SDK not enabled, will not capture session.');
3891
3963
  return;
3892
3964
  }
3893
3965
  if (!(typeof session.release === 'string')) {
3894
- if (isDebugBuild()) {
3895
- logger.warn('Discarded session because of missing or non-string release');
3896
- }
3966
+ logger.warn('Discarded session because of missing or non-string release');
3897
3967
  }
3898
3968
  else {
3899
3969
  this._sendSession(session);
@@ -4054,7 +4124,7 @@ var Sentry = (function (exports) {
4054
4124
  */
4055
4125
  BaseClient.prototype._prepareEvent = function (event, scope, hint) {
4056
4126
  var _this = this;
4057
- var _a = this.getOptions().normalizeDepth, normalizeDepth = _a === void 0 ? 3 : _a;
4127
+ var _a = this.getOptions(), _b = _a.normalizeDepth, normalizeDepth = _b === void 0 ? 3 : _b, _c = _a.normalizeMaxBreadth, normalizeMaxBreadth = _c === void 0 ? 1000 : _c;
4058
4128
  var prepared = __assign(__assign({}, event), { event_id: event.event_id || (hint && hint.event_id ? hint.event_id : uuid4()), timestamp: event.timestamp || dateTimestampInSeconds() });
4059
4129
  this._applyClientOptions(prepared);
4060
4130
  this._applyIntegrationsMetadata(prepared);
@@ -4079,7 +4149,7 @@ var Sentry = (function (exports) {
4079
4149
  evt.sdkProcessingMetadata = __assign(__assign({}, evt.sdkProcessingMetadata), { normalizeDepth: normalize(normalizeDepth) });
4080
4150
  }
4081
4151
  if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
4082
- return _this._normalizeEvent(evt, normalizeDepth);
4152
+ return _this._normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
4083
4153
  }
4084
4154
  return evt;
4085
4155
  });
@@ -4094,20 +4164,20 @@ var Sentry = (function (exports) {
4094
4164
  * @param event Event
4095
4165
  * @returns Normalized event
4096
4166
  */
4097
- BaseClient.prototype._normalizeEvent = function (event, depth) {
4167
+ BaseClient.prototype._normalizeEvent = function (event, depth, maxBreadth) {
4098
4168
  if (!event) {
4099
4169
  return null;
4100
4170
  }
4101
4171
  var normalized = __assign(__assign(__assign(__assign(__assign({}, event), (event.breadcrumbs && {
4102
4172
  breadcrumbs: event.breadcrumbs.map(function (b) { return (__assign(__assign({}, b), (b.data && {
4103
- data: normalize(b.data, depth),
4173
+ data: normalize(b.data, depth, maxBreadth),
4104
4174
  }))); }),
4105
4175
  })), (event.user && {
4106
- user: normalize(event.user, depth),
4176
+ user: normalize(event.user, depth, maxBreadth),
4107
4177
  })), (event.contexts && {
4108
- contexts: normalize(event.contexts, depth),
4178
+ contexts: normalize(event.contexts, depth, maxBreadth),
4109
4179
  })), (event.extra && {
4110
- extra: normalize(event.extra, depth),
4180
+ extra: normalize(event.extra, depth, maxBreadth),
4111
4181
  }));
4112
4182
  // event.contexts.trace stores information about a Transaction. Similarly,
4113
4183
  // event.spans[] stores information about child Spans. Given that a
@@ -4294,95 +4364,6 @@ var Sentry = (function (exports) {
4294
4364
  return rv;
4295
4365
  }
4296
4366
 
4297
- /** Noop transport */
4298
- var NoopTransport = /** @class */ (function () {
4299
- function NoopTransport() {
4300
- }
4301
- /**
4302
- * @inheritDoc
4303
- */
4304
- NoopTransport.prototype.sendEvent = function (_) {
4305
- return resolvedSyncPromise({
4306
- reason: 'NoopTransport: Event has been skipped because no Dsn is configured.',
4307
- status: 'skipped',
4308
- });
4309
- };
4310
- /**
4311
- * @inheritDoc
4312
- */
4313
- NoopTransport.prototype.close = function (_) {
4314
- return resolvedSyncPromise(true);
4315
- };
4316
- return NoopTransport;
4317
- }());
4318
-
4319
- /**
4320
- * This is the base implemention of a Backend.
4321
- * @hidden
4322
- */
4323
- var BaseBackend = /** @class */ (function () {
4324
- /** Creates a new backend instance. */
4325
- function BaseBackend(options) {
4326
- this._options = options;
4327
- if (!this._options.dsn) {
4328
- logger.warn('No DSN provided, backend will not do anything.');
4329
- }
4330
- this._transport = this._setupTransport();
4331
- }
4332
- /**
4333
- * @inheritDoc
4334
- */
4335
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
4336
- BaseBackend.prototype.eventFromException = function (_exception, _hint) {
4337
- throw new SentryError('Backend has to implement `eventFromException` method');
4338
- };
4339
- /**
4340
- * @inheritDoc
4341
- */
4342
- BaseBackend.prototype.eventFromMessage = function (_message, _level, _hint) {
4343
- throw new SentryError('Backend has to implement `eventFromMessage` method');
4344
- };
4345
- /**
4346
- * @inheritDoc
4347
- */
4348
- BaseBackend.prototype.sendEvent = function (event) {
4349
- void this._transport.sendEvent(event).then(null, function (reason) {
4350
- if (isDebugBuild()) {
4351
- logger.error('Error while sending event:', reason);
4352
- }
4353
- });
4354
- };
4355
- /**
4356
- * @inheritDoc
4357
- */
4358
- BaseBackend.prototype.sendSession = function (session) {
4359
- if (!this._transport.sendSession) {
4360
- if (isDebugBuild()) {
4361
- logger.warn("Dropping session because custom transport doesn't implement sendSession");
4362
- }
4363
- return;
4364
- }
4365
- void this._transport.sendSession(session).then(null, function (reason) {
4366
- if (isDebugBuild()) {
4367
- logger.error('Error while sending session:', reason);
4368
- }
4369
- });
4370
- };
4371
- /**
4372
- * @inheritDoc
4373
- */
4374
- BaseBackend.prototype.getTransport = function () {
4375
- return this._transport;
4376
- };
4377
- /**
4378
- * Sets up the transport so it can be used later to send requests.
4379
- */
4380
- BaseBackend.prototype._setupTransport = function () {
4381
- return new NoopTransport();
4382
- };
4383
- return BaseBackend;
4384
- }());
4385
-
4386
4367
  /** Extract sdk info from from the API metadata */
4387
4368
  function getSdkMetadataForEnvelopeHeader(api) {
4388
4369
  if (!api.metadata || !api.metadata.sdk) {
@@ -4406,8 +4387,8 @@ var Sentry = (function (exports) {
4406
4387
  event.sdk.packages = __spread((event.sdk.packages || []), (sdkInfo.packages || []));
4407
4388
  return event;
4408
4389
  }
4409
- /** Creates a SentryRequest from a Session. */
4410
- function sessionToSentryRequest(session, api) {
4390
+ /** Creates an envelope from a Session */
4391
+ function createSessionEnvelope(session, api) {
4411
4392
  var sdkInfo = getSdkMetadataForEnvelopeHeader(api);
4412
4393
  var envelopeHeaders = __assign(__assign({ sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
4413
4394
  // I know this is hacky but we don't want to add `sessions` to request type since it's never rate limited
@@ -4415,12 +4396,36 @@ var Sentry = (function (exports) {
4415
4396
  // TODO (v7) Have to cast type because envelope items do not accept a `SentryRequestType`
4416
4397
  var envelopeItem = [{ type: type }, session];
4417
4398
  var envelope = createEnvelope(envelopeHeaders, [envelopeItem]);
4399
+ return [envelope, type];
4400
+ }
4401
+ /** Creates a SentryRequest from a Session. */
4402
+ function sessionToSentryRequest(session, api) {
4403
+ var _a = __read(createSessionEnvelope(session, api), 2), envelope = _a[0], type = _a[1];
4418
4404
  return {
4419
4405
  body: serializeEnvelope(envelope),
4420
4406
  type: type,
4421
4407
  url: getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel),
4422
4408
  };
4423
4409
  }
4410
+ /**
4411
+ * Create an Envelope from an event. Note that this is duplicated from below,
4412
+ * but on purpose as this will be refactored in v7.
4413
+ */
4414
+ function createEventEnvelope(event, api) {
4415
+ var sdkInfo = getSdkMetadataForEnvelopeHeader(api);
4416
+ var eventType = event.type || 'event';
4417
+ var transactionSampling = (event.sdkProcessingMetadata || {}).transactionSampling;
4418
+ var _a = transactionSampling || {}, samplingMethod = _a.method, sampleRate = _a.rate;
4419
+ var envelopeHeaders = __assign(__assign({ event_id: event.event_id, sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
4420
+ var eventItem = [
4421
+ {
4422
+ type: eventType,
4423
+ sample_rates: [{ id: samplingMethod, rate: sampleRate }],
4424
+ },
4425
+ event,
4426
+ ];
4427
+ return createEnvelope(envelopeHeaders, [eventItem]);
4428
+ }
4424
4429
  /** Creates a SentryRequest from an event. */
4425
4430
  function eventToSentryRequest(event, api) {
4426
4431
  var sdkInfo = getSdkMetadataForEnvelopeHeader(api);
@@ -4466,47 +4471,156 @@ var Sentry = (function (exports) {
4466
4471
  try {
4467
4472
  body = JSON.stringify(normalize(event));
4468
4473
  }
4469
- catch (newErr) {
4470
- // At this point even renormalization hasn't worked, meaning something about the event data has gone very wrong.
4471
- // Time to cut our losses and record only the new error. With luck, even in the problematic cases we're trying to
4472
- // debug with this hack, we won't ever land here.
4473
- var innerErr = newErr;
4474
- body = JSON.stringify({
4475
- message: 'JSON.stringify error after renormalization',
4476
- // setting `extra: { innerErr }` here for some reason results in an empty object, so unpack manually
4477
- extra: { message: innerErr.message, stack: innerErr.stack },
4474
+ catch (newErr) {
4475
+ // At this point even renormalization hasn't worked, meaning something about the event data has gone very wrong.
4476
+ // Time to cut our losses and record only the new error. With luck, even in the problematic cases we're trying to
4477
+ // debug with this hack, we won't ever land here.
4478
+ var innerErr = newErr;
4479
+ body = JSON.stringify({
4480
+ message: 'JSON.stringify error after renormalization',
4481
+ // setting `extra: { innerErr }` here for some reason results in an empty object, so unpack manually
4482
+ extra: { message: innerErr.message, stack: innerErr.stack },
4483
+ });
4484
+ }
4485
+ }
4486
+ var req = {
4487
+ // this is the relevant line of code before the hack was added, to make it easy to undo said hack once we've solved
4488
+ // the mystery
4489
+ // body: JSON.stringify(sdkInfo ? enhanceEventWithSdkInfo(event, api.metadata.sdk) : event),
4490
+ body: body,
4491
+ type: eventType,
4492
+ url: useEnvelope
4493
+ ? getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel)
4494
+ : getStoreEndpointWithUrlEncodedAuth(api.dsn),
4495
+ };
4496
+ // https://develop.sentry.dev/sdk/envelopes/
4497
+ // Since we don't need to manipulate envelopes nor store them, there is no
4498
+ // exported concept of an Envelope with operations including serialization and
4499
+ // deserialization. Instead, we only implement a minimal subset of the spec to
4500
+ // serialize events inline here.
4501
+ if (useEnvelope) {
4502
+ var envelopeHeaders = __assign(__assign({ event_id: event.event_id, sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
4503
+ var eventItem = [
4504
+ {
4505
+ type: eventType,
4506
+ sample_rates: [{ id: samplingMethod, rate: sampleRate }],
4507
+ },
4508
+ req.body,
4509
+ ];
4510
+ var envelope = createEnvelope(envelopeHeaders, [eventItem]);
4511
+ req.body = serializeEnvelope(envelope);
4512
+ }
4513
+ return req;
4514
+ }
4515
+
4516
+ /** Noop transport */
4517
+ var NoopTransport = /** @class */ (function () {
4518
+ function NoopTransport() {
4519
+ }
4520
+ /**
4521
+ * @inheritDoc
4522
+ */
4523
+ NoopTransport.prototype.sendEvent = function (_) {
4524
+ return resolvedSyncPromise({
4525
+ reason: 'NoopTransport: Event has been skipped because no Dsn is configured.',
4526
+ status: 'skipped',
4527
+ });
4528
+ };
4529
+ /**
4530
+ * @inheritDoc
4531
+ */
4532
+ NoopTransport.prototype.close = function (_) {
4533
+ return resolvedSyncPromise(true);
4534
+ };
4535
+ return NoopTransport;
4536
+ }());
4537
+
4538
+ /**
4539
+ * This is the base implemention of a Backend.
4540
+ * @hidden
4541
+ */
4542
+ var BaseBackend = /** @class */ (function () {
4543
+ /** Creates a new backend instance. */
4544
+ function BaseBackend(options) {
4545
+ this._options = options;
4546
+ if (!this._options.dsn) {
4547
+ logger.warn('No DSN provided, backend will not do anything.');
4548
+ }
4549
+ this._transport = this._setupTransport();
4550
+ }
4551
+ /**
4552
+ * @inheritDoc
4553
+ */
4554
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
4555
+ BaseBackend.prototype.eventFromException = function (_exception, _hint) {
4556
+ throw new SentryError('Backend has to implement `eventFromException` method');
4557
+ };
4558
+ /**
4559
+ * @inheritDoc
4560
+ */
4561
+ BaseBackend.prototype.eventFromMessage = function (_message, _level, _hint) {
4562
+ throw new SentryError('Backend has to implement `eventFromMessage` method');
4563
+ };
4564
+ /**
4565
+ * @inheritDoc
4566
+ */
4567
+ BaseBackend.prototype.sendEvent = function (event) {
4568
+ // TODO(v7): Remove the if-else
4569
+ if (this._newTransport &&
4570
+ this._options.dsn &&
4571
+ this._options._experiments &&
4572
+ this._options._experiments.newTransport) {
4573
+ var api = initAPIDetails(this._options.dsn, this._options._metadata, this._options.tunnel);
4574
+ var env = createEventEnvelope(event, api);
4575
+ void this._newTransport.send(env).then(null, function (reason) {
4576
+ logger.error('Error while sending event:', reason);
4577
+ });
4578
+ }
4579
+ else {
4580
+ void this._transport.sendEvent(event).then(null, function (reason) {
4581
+ logger.error('Error while sending event:', reason);
4478
4582
  });
4479
4583
  }
4480
- }
4481
- var req = {
4482
- // this is the relevant line of code before the hack was added, to make it easy to undo said hack once we've solved
4483
- // the mystery
4484
- // body: JSON.stringify(sdkInfo ? enhanceEventWithSdkInfo(event, api.metadata.sdk) : event),
4485
- body: body,
4486
- type: eventType,
4487
- url: useEnvelope
4488
- ? getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel)
4489
- : getStoreEndpointWithUrlEncodedAuth(api.dsn),
4490
4584
  };
4491
- // https://develop.sentry.dev/sdk/envelopes/
4492
- // Since we don't need to manipulate envelopes nor store them, there is no
4493
- // exported concept of an Envelope with operations including serialization and
4494
- // deserialization. Instead, we only implement a minimal subset of the spec to
4495
- // serialize events inline here.
4496
- if (useEnvelope) {
4497
- var envelopeHeaders = __assign(__assign({ event_id: event.event_id, sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
4498
- var eventItem = [
4499
- {
4500
- type: eventType,
4501
- sample_rates: [{ id: samplingMethod, rate: sampleRate }],
4502
- },
4503
- req.body,
4504
- ];
4505
- var envelope = createEnvelope(envelopeHeaders, [eventItem]);
4506
- req.body = serializeEnvelope(envelope);
4507
- }
4508
- return req;
4509
- }
4585
+ /**
4586
+ * @inheritDoc
4587
+ */
4588
+ BaseBackend.prototype.sendSession = function (session) {
4589
+ if (!this._transport.sendSession) {
4590
+ logger.warn("Dropping session because custom transport doesn't implement sendSession");
4591
+ return;
4592
+ }
4593
+ // TODO(v7): Remove the if-else
4594
+ if (this._newTransport &&
4595
+ this._options.dsn &&
4596
+ this._options._experiments &&
4597
+ this._options._experiments.newTransport) {
4598
+ var api = initAPIDetails(this._options.dsn, this._options._metadata, this._options.tunnel);
4599
+ var _a = __read(createSessionEnvelope(session, api), 1), env = _a[0];
4600
+ void this._newTransport.send(env).then(null, function (reason) {
4601
+ logger.error('Error while sending session:', reason);
4602
+ });
4603
+ }
4604
+ else {
4605
+ void this._transport.sendSession(session).then(null, function (reason) {
4606
+ logger.error('Error while sending session:', reason);
4607
+ });
4608
+ }
4609
+ };
4610
+ /**
4611
+ * @inheritDoc
4612
+ */
4613
+ BaseBackend.prototype.getTransport = function () {
4614
+ return this._transport;
4615
+ };
4616
+ /**
4617
+ * Sets up the transport so it can be used later to send requests.
4618
+ */
4619
+ BaseBackend.prototype._setupTransport = function () {
4620
+ return new NoopTransport();
4621
+ };
4622
+ return BaseBackend;
4623
+ }());
4510
4624
 
4511
4625
  /**
4512
4626
  * Internal function to create a new SDK client instance. The client is
@@ -4517,7 +4631,9 @@ var Sentry = (function (exports) {
4517
4631
  */
4518
4632
  function initAndBind(clientClass, options) {
4519
4633
  if (options.debug === true) {
4520
- logger.enable();
4634
+ {
4635
+ logger.enable();
4636
+ }
4521
4637
  }
4522
4638
  var hub = getCurrentHub();
4523
4639
  var scope = hub.getScope();
@@ -4528,7 +4644,7 @@ var Sentry = (function (exports) {
4528
4644
  hub.bindClient(client);
4529
4645
  }
4530
4646
 
4531
- var SDK_VERSION = '6.18.2';
4647
+ var SDK_VERSION = '6.19.2';
4532
4648
 
4533
4649
  var originalFunctionToString;
4534
4650
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4578,170 +4694,139 @@ var Sentry = (function (exports) {
4578
4694
  /**
4579
4695
  * @inheritDoc
4580
4696
  */
4581
- InboundFilters.prototype.setupOnce = function () {
4697
+ InboundFilters.prototype.setupOnce = function (addGlobalEventProcessor, getCurrentHub) {
4582
4698
  addGlobalEventProcessor(function (event) {
4583
4699
  var hub = getCurrentHub();
4584
- if (!hub) {
4585
- return event;
4586
- }
4587
- var self = hub.getIntegration(InboundFilters);
4588
- if (self) {
4589
- var client = hub.getClient();
4590
- var clientOptions = client ? client.getOptions() : {};
4591
- // This checks prevents most of the occurrences of the bug linked below:
4592
- // https://github.com/getsentry/sentry-javascript/issues/2622
4593
- // The bug is caused by multiple SDK instances, where one is minified and one is using non-mangled code.
4594
- // Unfortunatelly we cannot fix it reliably (thus reserved property in rollup's terser config),
4595
- // as we cannot force people using multiple instances in their apps to sync SDK versions.
4596
- var options = typeof self._mergeOptions === 'function' ? self._mergeOptions(clientOptions) : {};
4597
- if (typeof self._shouldDropEvent !== 'function') {
4598
- return event;
4700
+ if (hub) {
4701
+ var self_1 = hub.getIntegration(InboundFilters);
4702
+ if (self_1) {
4703
+ var client = hub.getClient();
4704
+ var clientOptions = client ? client.getOptions() : {};
4705
+ var options = _mergeOptions(self_1._options, clientOptions);
4706
+ return _shouldDropEvent$1(event, options) ? null : event;
4599
4707
  }
4600
- return self._shouldDropEvent(event, options) ? null : event;
4601
4708
  }
4602
4709
  return event;
4603
4710
  });
4604
4711
  };
4605
- /** JSDoc */
4606
- InboundFilters.prototype._shouldDropEvent = function (event, options) {
4607
- if (this._isSentryError(event, options)) {
4608
- if (isDebugBuild()) {
4609
- logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + getEventDescription(event));
4610
- }
4611
- return true;
4612
- }
4613
- if (this._isIgnoredError(event, options)) {
4614
- if (isDebugBuild()) {
4615
- logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + getEventDescription(event));
4616
- }
4617
- return true;
4712
+ /**
4713
+ * @inheritDoc
4714
+ */
4715
+ InboundFilters.id = 'InboundFilters';
4716
+ return InboundFilters;
4717
+ }());
4718
+ /** JSDoc */
4719
+ function _mergeOptions(internalOptions, clientOptions) {
4720
+ if (internalOptions === void 0) { internalOptions = {}; }
4721
+ if (clientOptions === void 0) { clientOptions = {}; }
4722
+ return {
4723
+ allowUrls: __spread((internalOptions.whitelistUrls || []), (internalOptions.allowUrls || []), (clientOptions.whitelistUrls || []), (clientOptions.allowUrls || [])),
4724
+ denyUrls: __spread((internalOptions.blacklistUrls || []), (internalOptions.denyUrls || []), (clientOptions.blacklistUrls || []), (clientOptions.denyUrls || [])),
4725
+ ignoreErrors: __spread((internalOptions.ignoreErrors || []), (clientOptions.ignoreErrors || []), DEFAULT_IGNORE_ERRORS),
4726
+ ignoreInternal: internalOptions.ignoreInternal !== undefined ? internalOptions.ignoreInternal : true,
4727
+ };
4728
+ }
4729
+ /** JSDoc */
4730
+ function _shouldDropEvent$1(event, options) {
4731
+ if (options.ignoreInternal && _isSentryError(event)) {
4732
+ logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + getEventDescription(event));
4733
+ return true;
4734
+ }
4735
+ if (_isIgnoredError(event, options.ignoreErrors)) {
4736
+ logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + getEventDescription(event));
4737
+ return true;
4738
+ }
4739
+ if (_isDeniedUrl(event, options.denyUrls)) {
4740
+ logger.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + _getEventFilterUrl(event));
4741
+ return true;
4742
+ }
4743
+ if (!_isAllowedUrl(event, options.allowUrls)) {
4744
+ logger.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + _getEventFilterUrl(event));
4745
+ return true;
4746
+ }
4747
+ return false;
4748
+ }
4749
+ function _isIgnoredError(event, ignoreErrors) {
4750
+ if (!ignoreErrors || !ignoreErrors.length) {
4751
+ return false;
4752
+ }
4753
+ return _getPossibleEventMessages(event).some(function (message) {
4754
+ return ignoreErrors.some(function (pattern) { return isMatchingPattern(message, pattern); });
4755
+ });
4756
+ }
4757
+ function _isDeniedUrl(event, denyUrls) {
4758
+ // TODO: Use Glob instead?
4759
+ if (!denyUrls || !denyUrls.length) {
4760
+ return false;
4761
+ }
4762
+ var url = _getEventFilterUrl(event);
4763
+ return !url ? false : denyUrls.some(function (pattern) { return isMatchingPattern(url, pattern); });
4764
+ }
4765
+ function _isAllowedUrl(event, allowUrls) {
4766
+ // TODO: Use Glob instead?
4767
+ if (!allowUrls || !allowUrls.length) {
4768
+ return true;
4769
+ }
4770
+ var url = _getEventFilterUrl(event);
4771
+ return !url ? true : allowUrls.some(function (pattern) { return isMatchingPattern(url, pattern); });
4772
+ }
4773
+ function _getPossibleEventMessages(event) {
4774
+ if (event.message) {
4775
+ return [event.message];
4776
+ }
4777
+ if (event.exception) {
4778
+ try {
4779
+ var _a = (event.exception.values && event.exception.values[0]) || {}, _b = _a.type, type = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c;
4780
+ return ["" + value, type + ": " + value];
4618
4781
  }
4619
- if (this._isDeniedUrl(event, options)) {
4620
- if (isDebugBuild()) {
4621
- logger.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + this._getEventFilterUrl(event));
4622
- }
4623
- return true;
4782
+ catch (oO) {
4783
+ logger.error("Cannot extract message for event " + getEventDescription(event));
4784
+ return [];
4624
4785
  }
4625
- if (!this._isAllowedUrl(event, options)) {
4626
- if (isDebugBuild()) {
4627
- logger.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + this._getEventFilterUrl(event));
4628
- }
4629
- return true;
4786
+ }
4787
+ return [];
4788
+ }
4789
+ function _isSentryError(event) {
4790
+ try {
4791
+ // @ts-ignore can't be a sentry error if undefined
4792
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
4793
+ return event.exception.values[0].type === 'SentryError';
4794
+ }
4795
+ catch (e) {
4796
+ // ignore
4797
+ }
4798
+ return false;
4799
+ }
4800
+ function _getLastValidUrl(frames) {
4801
+ if (frames === void 0) { frames = []; }
4802
+ for (var i = frames.length - 1; i >= 0; i--) {
4803
+ var frame = frames[i];
4804
+ if (frame && frame.filename !== '<anonymous>' && frame.filename !== '[native code]') {
4805
+ return frame.filename || null;
4630
4806
  }
4631
- return false;
4632
- };
4633
- /** JSDoc */
4634
- InboundFilters.prototype._isSentryError = function (event, options) {
4635
- if (!options.ignoreInternal) {
4636
- return false;
4807
+ }
4808
+ return null;
4809
+ }
4810
+ function _getEventFilterUrl(event) {
4811
+ try {
4812
+ if (event.stacktrace) {
4813
+ return _getLastValidUrl(event.stacktrace.frames);
4637
4814
  }
4815
+ var frames_1;
4638
4816
  try {
4639
- // @ts-ignore can't be a sentry error if undefined
4640
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
4641
- return event.exception.values[0].type === 'SentryError';
4817
+ // @ts-ignore we only care about frames if the whole thing here is defined
4818
+ frames_1 = event.exception.values[0].stacktrace.frames;
4642
4819
  }
4643
4820
  catch (e) {
4644
4821
  // ignore
4645
4822
  }
4646
- return false;
4647
- };
4648
- /** JSDoc */
4649
- InboundFilters.prototype._isIgnoredError = function (event, options) {
4650
- if (!options.ignoreErrors || !options.ignoreErrors.length) {
4651
- return false;
4652
- }
4653
- return this._getPossibleEventMessages(event).some(function (message) {
4654
- // Not sure why TypeScript complains here...
4655
- return options.ignoreErrors.some(function (pattern) { return isMatchingPattern(message, pattern); });
4656
- });
4657
- };
4658
- /** JSDoc */
4659
- InboundFilters.prototype._isDeniedUrl = function (event, options) {
4660
- // TODO: Use Glob instead?
4661
- if (!options.denyUrls || !options.denyUrls.length) {
4662
- return false;
4663
- }
4664
- var url = this._getEventFilterUrl(event);
4665
- return !url ? false : options.denyUrls.some(function (pattern) { return isMatchingPattern(url, pattern); });
4666
- };
4667
- /** JSDoc */
4668
- InboundFilters.prototype._isAllowedUrl = function (event, options) {
4669
- // TODO: Use Glob instead?
4670
- if (!options.allowUrls || !options.allowUrls.length) {
4671
- return true;
4672
- }
4673
- var url = this._getEventFilterUrl(event);
4674
- return !url ? true : options.allowUrls.some(function (pattern) { return isMatchingPattern(url, pattern); });
4675
- };
4676
- /** JSDoc */
4677
- InboundFilters.prototype._mergeOptions = function (clientOptions) {
4678
- if (clientOptions === void 0) { clientOptions = {}; }
4679
- return {
4680
- allowUrls: __spread((this._options.whitelistUrls || []), (this._options.allowUrls || []), (clientOptions.whitelistUrls || []), (clientOptions.allowUrls || [])),
4681
- denyUrls: __spread((this._options.blacklistUrls || []), (this._options.denyUrls || []), (clientOptions.blacklistUrls || []), (clientOptions.denyUrls || [])),
4682
- ignoreErrors: __spread((this._options.ignoreErrors || []), (clientOptions.ignoreErrors || []), DEFAULT_IGNORE_ERRORS),
4683
- ignoreInternal: typeof this._options.ignoreInternal !== 'undefined' ? this._options.ignoreInternal : true,
4684
- };
4685
- };
4686
- /** JSDoc */
4687
- InboundFilters.prototype._getPossibleEventMessages = function (event) {
4688
- if (event.message) {
4689
- return [event.message];
4690
- }
4691
- if (event.exception) {
4692
- try {
4693
- var _a = (event.exception.values && event.exception.values[0]) || {}, _b = _a.type, type = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c;
4694
- return ["" + value, type + ": " + value];
4695
- }
4696
- catch (oO) {
4697
- if (isDebugBuild()) {
4698
- logger.error("Cannot extract message for event " + getEventDescription(event));
4699
- }
4700
- return [];
4701
- }
4702
- }
4703
- return [];
4704
- };
4705
- /** JSDoc */
4706
- InboundFilters.prototype._getLastValidUrl = function (frames) {
4707
- if (frames === void 0) { frames = []; }
4708
- for (var i = frames.length - 1; i >= 0; i--) {
4709
- var frame = frames[i];
4710
- if (frame && frame.filename !== '<anonymous>' && frame.filename !== '[native code]') {
4711
- return frame.filename || null;
4712
- }
4713
- }
4823
+ return frames_1 ? _getLastValidUrl(frames_1) : null;
4824
+ }
4825
+ catch (oO) {
4826
+ logger.error("Cannot extract url for event " + getEventDescription(event));
4714
4827
  return null;
4715
- };
4716
- /** JSDoc */
4717
- InboundFilters.prototype._getEventFilterUrl = function (event) {
4718
- try {
4719
- if (event.stacktrace) {
4720
- return this._getLastValidUrl(event.stacktrace.frames);
4721
- }
4722
- var frames_1;
4723
- try {
4724
- // @ts-ignore we only care about frames if the whole thing here is defined
4725
- frames_1 = event.exception.values[0].stacktrace.frames;
4726
- }
4727
- catch (e) {
4728
- // ignore
4729
- }
4730
- return frames_1 ? this._getLastValidUrl(frames_1) : null;
4731
- }
4732
- catch (oO) {
4733
- if (isDebugBuild()) {
4734
- logger.error("Cannot extract url for event " + getEventDescription(event));
4735
- }
4736
- return null;
4737
- }
4738
- };
4739
- /**
4740
- * @inheritDoc
4741
- */
4742
- InboundFilters.id = 'InboundFilters';
4743
- return InboundFilters;
4744
- }());
4828
+ }
4829
+ }
4745
4830
 
4746
4831
  var CoreIntegrations = /*#__PURE__*/Object.freeze({
4747
4832
  __proto__: null,
@@ -5144,9 +5229,7 @@ var Sentry = (function (exports) {
5144
5229
  document.head.removeChild(sandbox);
5145
5230
  }
5146
5231
  catch (e) {
5147
- if (isDebugBuild()) {
5148
- logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
5149
- }
5232
+ logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
5150
5233
  }
5151
5234
  }
5152
5235
  return (cachedFetchImpl = fetchImpl.bind(global$4));
@@ -5277,13 +5360,11 @@ var Sentry = (function (exports) {
5277
5360
  BaseTransport.prototype._handleResponse = function (_a) {
5278
5361
  var requestType = _a.requestType, response = _a.response, headers = _a.headers, resolve = _a.resolve, reject = _a.reject;
5279
5362
  var status = eventStatusFromHttpCode(response.status);
5280
- /**
5281
- * "The name is case-insensitive."
5282
- * https://developer.mozilla.org/en-US/docs/Web/API/Headers/get
5283
- */
5284
- var limited = this._handleRateLimit(headers);
5285
- if (limited && isDebugBuild()) {
5286
- logger.warn("Too many " + requestType + " requests, backing off until: " + this._disabledUntil(requestType));
5363
+ this._rateLimits = updateRateLimits(this._rateLimits, headers);
5364
+ // eslint-disable-next-line deprecation/deprecation
5365
+ if (this._isRateLimited(requestType) && isDebugBuild()) {
5366
+ // eslint-disable-next-line deprecation/deprecation
5367
+ logger.warn("Too many " + requestType + " requests, backing off until: " + this._disabledUntil(requestType));
5287
5368
  }
5288
5369
  if (status === 'success') {
5289
5370
  resolve({ status: status });
@@ -5293,71 +5374,21 @@ var Sentry = (function (exports) {
5293
5374
  };
5294
5375
  /**
5295
5376
  * Gets the time that given category is disabled until for rate limiting
5377
+ *
5378
+ * @deprecated Please use `disabledUntil` from @sentry/utils
5296
5379
  */
5297
5380
  BaseTransport.prototype._disabledUntil = function (requestType) {
5298
5381
  var category = requestTypeToCategory(requestType);
5299
- return this._rateLimits[category] || this._rateLimits.all;
5382
+ return new Date(disabledUntil(this._rateLimits, category));
5300
5383
  };
5301
5384
  /**
5302
5385
  * Checks if a category is rate limited
5386
+ *
5387
+ * @deprecated Please use `isRateLimited` from @sentry/utils
5303
5388
  */
5304
5389
  BaseTransport.prototype._isRateLimited = function (requestType) {
5305
- return this._disabledUntil(requestType) > new Date(Date.now());
5306
- };
5307
- /**
5308
- * Sets internal _rateLimits from incoming headers. Returns true if headers contains a non-empty rate limiting header.
5309
- */
5310
- BaseTransport.prototype._handleRateLimit = function (headers) {
5311
- var e_1, _a, e_2, _b;
5312
- var now = Date.now();
5313
- var rlHeader = headers['x-sentry-rate-limits'];
5314
- var raHeader = headers['retry-after'];
5315
- if (rlHeader) {
5316
- try {
5317
- // rate limit headers are of the form
5318
- // <header>,<header>,..
5319
- // where each <header> is of the form
5320
- // <retry_after>: <categories>: <scope>: <reason_code>
5321
- // where
5322
- // <retry_after> is a delay in ms
5323
- // <categories> is the event type(s) (error, transaction, etc) being rate limited and is of the form
5324
- // <category>;<category>;...
5325
- // <scope> is what's being limited (org, project, or key) - ignored by SDK
5326
- // <reason_code> is an arbitrary string like "org_quota" - ignored by SDK
5327
- for (var _c = __values(rlHeader.trim().split(',')), _d = _c.next(); !_d.done; _d = _c.next()) {
5328
- var limit = _d.value;
5329
- var parameters = limit.split(':', 2);
5330
- var headerDelay = parseInt(parameters[0], 10);
5331
- var delay = (!isNaN(headerDelay) ? headerDelay : 60) * 1000; // 60sec default
5332
- try {
5333
- for (var _e = (e_2 = void 0, __values(parameters[1].split(';'))), _f = _e.next(); !_f.done; _f = _e.next()) {
5334
- var category = _f.value;
5335
- this._rateLimits[category || 'all'] = new Date(now + delay);
5336
- }
5337
- }
5338
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
5339
- finally {
5340
- try {
5341
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
5342
- }
5343
- finally { if (e_2) throw e_2.error; }
5344
- }
5345
- }
5346
- }
5347
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
5348
- finally {
5349
- try {
5350
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
5351
- }
5352
- finally { if (e_1) throw e_1.error; }
5353
- }
5354
- return true;
5355
- }
5356
- else if (raHeader) {
5357
- this._rateLimits.all = new Date(now + parseRetryAfterHeader(raHeader, now));
5358
- return true;
5359
- }
5360
- return false;
5390
+ var category = requestTypeToCategory(requestType);
5391
+ return isRateLimited(this._rateLimits, category);
5361
5392
  };
5362
5393
  return BaseTransport;
5363
5394
  }());
@@ -5377,11 +5408,13 @@ var Sentry = (function (exports) {
5377
5408
  */
5378
5409
  FetchTransport.prototype._sendRequest = function (sentryRequest, originalPayload) {
5379
5410
  var _this = this;
5411
+ // eslint-disable-next-line deprecation/deprecation
5380
5412
  if (this._isRateLimited(sentryRequest.type)) {
5381
5413
  this.recordLostEvent('ratelimit_backoff', sentryRequest.type);
5382
5414
  return Promise.reject({
5383
5415
  event: originalPayload,
5384
5416
  type: sentryRequest.type,
5417
+ // eslint-disable-next-line deprecation/deprecation
5385
5418
  reason: "Transport for " + sentryRequest.type + " requests locked till " + this._disabledUntil(sentryRequest.type) + " due to too many requests.",
5386
5419
  status: 429,
5387
5420
  });
@@ -5447,11 +5480,13 @@ var Sentry = (function (exports) {
5447
5480
  */
5448
5481
  XHRTransport.prototype._sendRequest = function (sentryRequest, originalPayload) {
5449
5482
  var _this = this;
5483
+ // eslint-disable-next-line deprecation/deprecation
5450
5484
  if (this._isRateLimited(sentryRequest.type)) {
5451
5485
  this.recordLostEvent('ratelimit_backoff', sentryRequest.type);
5452
5486
  return Promise.reject({
5453
5487
  event: originalPayload,
5454
5488
  type: sentryRequest.type,
5489
+ // eslint-disable-next-line deprecation/deprecation
5455
5490
  reason: "Transport for " + sentryRequest.type + " requests locked till " + this._disabledUntil(sentryRequest.type) + " due to too many requests.",
5456
5491
  status: 429,
5457
5492
  });
@@ -5668,15 +5703,11 @@ var Sentry = (function (exports) {
5668
5703
  return;
5669
5704
  }
5670
5705
  if (!options.eventId) {
5671
- if (isDebugBuild()) {
5672
- logger.error('Missing eventId option in showReportDialog call');
5673
- }
5706
+ logger.error('Missing eventId option in showReportDialog call');
5674
5707
  return;
5675
5708
  }
5676
5709
  if (!options.dsn) {
5677
- if (isDebugBuild()) {
5678
- logger.error('Missing dsn option in showReportDialog call');
5679
- }
5710
+ logger.error('Missing dsn option in showReportDialog call');
5680
5711
  return;
5681
5712
  }
5682
5713
  var script = global$2.document.createElement('script');
@@ -5868,9 +5899,7 @@ var Sentry = (function (exports) {
5868
5899
  return event;
5869
5900
  }
5870
5901
  function globalHandlerLog(type) {
5871
- if (isDebugBuild()) {
5872
- logger.log("Global Handler attached: " + type);
5873
- }
5902
+ logger.log("Global Handler attached: " + type);
5874
5903
  }
5875
5904
  function addMechanismAndCapture(hub, error, event, type) {
5876
5905
  addExceptionMechanism(event, {
@@ -5986,16 +6015,18 @@ var Sentry = (function (exports) {
5986
6015
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5987
6016
  return function (callback) {
5988
6017
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5989
- return original.call(this, wrap$1(callback, {
5990
- mechanism: {
5991
- data: {
5992
- function: 'requestAnimationFrame',
5993
- handler: getFunctionName(original),
6018
+ return original.apply(this, [
6019
+ wrap$1(callback, {
6020
+ mechanism: {
6021
+ data: {
6022
+ function: 'requestAnimationFrame',
6023
+ handler: getFunctionName(original),
6024
+ },
6025
+ handled: true,
6026
+ type: 'instrument',
5994
6027
  },
5995
- handled: true,
5996
- type: 'instrument',
5997
- },
5998
- }));
6028
+ }),
6029
+ ]);
5999
6030
  };
6000
6031
  }
6001
6032
  /** JSDoc */
@@ -6066,19 +6097,22 @@ var Sentry = (function (exports) {
6066
6097
  catch (err) {
6067
6098
  // can sometimes get 'Permission denied to access property "handle Event'
6068
6099
  }
6069
- return original.call(this, eventName,
6070
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6071
- wrap$1(fn, {
6072
- mechanism: {
6073
- data: {
6074
- function: 'addEventListener',
6075
- handler: getFunctionName(fn),
6076
- target: target,
6100
+ return original.apply(this, [
6101
+ eventName,
6102
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6103
+ wrap$1(fn, {
6104
+ mechanism: {
6105
+ data: {
6106
+ function: 'addEventListener',
6107
+ handler: getFunctionName(fn),
6108
+ target: target,
6109
+ },
6110
+ handled: true,
6111
+ type: 'instrument',
6077
6112
  },
6078
- handled: true,
6079
- type: 'instrument',
6080
- },
6081
- }), options);
6113
+ }),
6114
+ options,
6115
+ ]);
6082
6116
  };
6083
6117
  });
6084
6118
  fill(proto, 'removeEventListener', function (originalRemoveEventListener) {
@@ -6814,9 +6848,7 @@ var Sentry = (function (exports) {
6814
6848
  if (client) {
6815
6849
  return client.flush(timeout);
6816
6850
  }
6817
- if (isDebugBuild()) {
6818
- logger.warn('Cannot flush events. No client defined.');
6819
- }
6851
+ logger.warn('Cannot flush events. No client defined.');
6820
6852
  return resolvedSyncPromise(false);
6821
6853
  }
6822
6854
  /**
@@ -6832,9 +6864,7 @@ var Sentry = (function (exports) {
6832
6864
  if (client) {
6833
6865
  return client.close(timeout);
6834
6866
  }
6835
- if (isDebugBuild()) {
6836
- logger.warn('Cannot flush events and disable SDK. No client defined.');
6837
- }
6867
+ logger.warn('Cannot flush events and disable SDK. No client defined.');
6838
6868
  return resolvedSyncPromise(false);
6839
6869
  }
6840
6870
  /**
@@ -6859,9 +6889,7 @@ var Sentry = (function (exports) {
6859
6889
  var window = getGlobalObject();
6860
6890
  var document = window.document;
6861
6891
  if (typeof document === 'undefined') {
6862
- if (isDebugBuild()) {
6863
- logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
6864
- }
6892
+ logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
6865
6893
  return;
6866
6894
  }
6867
6895
  var hub = getCurrentHub();