@sentry/browser 6.19.2 → 6.19.5

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 (179) hide show
  1. package/build/bundle.debug.min.js +3 -0
  2. package/build/bundle.debug.min.js.map +1 -0
  3. package/build/bundle.es6.debug.min.js +3 -0
  4. package/build/bundle.es6.debug.min.js.map +1 -0
  5. package/{bundles → build}/bundle.es6.js +476 -270
  6. package/build/bundle.es6.js.map +1 -0
  7. package/build/bundle.es6.min.js +3 -0
  8. package/build/bundle.es6.min.js.map +1 -0
  9. package/{bundles → build}/bundle.js +486 -289
  10. package/build/bundle.js.map +1 -0
  11. package/build/bundle.min.js +3 -0
  12. package/build/bundle.min.js.map +1 -0
  13. package/dist/backend.d.ts.map +1 -1
  14. package/dist/backend.js +8 -0
  15. package/dist/backend.js.map +1 -1
  16. package/dist/client.d.ts.map +1 -1
  17. package/dist/client.js +2 -1
  18. package/dist/client.js.map +1 -1
  19. package/dist/eventbuilder.d.ts.map +1 -1
  20. package/dist/eventbuilder.js.map +1 -1
  21. package/dist/exports.d.ts.map +1 -1
  22. package/dist/exports.js.map +1 -1
  23. package/dist/flags.d.ts +3 -0
  24. package/dist/flags.d.ts.map +1 -0
  25. package/dist/flags.js +17 -0
  26. package/dist/flags.js.map +1 -0
  27. package/dist/helpers.d.ts.map +1 -1
  28. package/dist/helpers.js +3 -2
  29. package/dist/helpers.js.map +1 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/integrations/breadcrumbs.d.ts.map +1 -1
  33. package/dist/integrations/breadcrumbs.js.map +1 -1
  34. package/dist/integrations/dedupe.d.ts.map +1 -1
  35. package/dist/integrations/dedupe.js +2 -1
  36. package/dist/integrations/dedupe.js.map +1 -1
  37. package/dist/integrations/globalhandlers.d.ts.map +1 -1
  38. package/dist/integrations/globalhandlers.js +2 -1
  39. package/dist/integrations/globalhandlers.js.map +1 -1
  40. package/dist/integrations/index.d.ts.map +1 -1
  41. package/dist/integrations/index.js.map +1 -1
  42. package/dist/integrations/linkederrors.d.ts.map +1 -1
  43. package/dist/integrations/linkederrors.js.map +1 -1
  44. package/dist/integrations/trycatch.d.ts.map +1 -1
  45. package/dist/integrations/trycatch.js.map +1 -1
  46. package/dist/integrations/useragent.d.ts.map +1 -1
  47. package/dist/integrations/useragent.js.map +1 -1
  48. package/dist/sdk.d.ts.map +1 -1
  49. package/dist/sdk.js +4 -3
  50. package/dist/sdk.js.map +1 -1
  51. package/dist/stack-parsers.d.ts.map +1 -1
  52. package/dist/stack-parsers.js.map +1 -1
  53. package/dist/transports/base.d.ts.map +1 -1
  54. package/dist/transports/base.js +7 -6
  55. package/dist/transports/base.js.map +1 -1
  56. package/dist/transports/fetch.d.ts.map +1 -1
  57. package/dist/transports/fetch.js.map +1 -1
  58. package/dist/transports/index.d.ts +2 -0
  59. package/dist/transports/index.d.ts.map +1 -1
  60. package/dist/transports/index.js +4 -0
  61. package/dist/transports/index.js.map +1 -1
  62. package/dist/transports/new-fetch.d.ts +10 -0
  63. package/dist/transports/new-fetch.d.ts.map +1 -0
  64. package/dist/transports/new-fetch.js +27 -0
  65. package/dist/transports/new-fetch.js.map +1 -0
  66. package/dist/transports/new-xhr.d.ts +11 -0
  67. package/dist/transports/new-xhr.d.ts.map +1 -0
  68. package/dist/transports/new-xhr.js +46 -0
  69. package/dist/transports/new-xhr.js.map +1 -0
  70. package/dist/transports/utils.d.ts.map +1 -1
  71. package/dist/transports/utils.js +2 -1
  72. package/dist/transports/utils.js.map +1 -1
  73. package/dist/transports/xhr.d.ts.map +1 -1
  74. package/dist/transports/xhr.js.map +1 -1
  75. package/dist/version.d.ts.map +1 -1
  76. package/dist/version.js.map +1 -1
  77. package/esm/backend.d.ts.map +1 -1
  78. package/esm/backend.js +10 -2
  79. package/esm/backend.js.map +1 -1
  80. package/esm/client.d.ts.map +1 -1
  81. package/esm/client.js +3 -2
  82. package/esm/client.js.map +1 -1
  83. package/esm/eventbuilder.d.ts.map +1 -1
  84. package/esm/eventbuilder.js.map +1 -1
  85. package/esm/exports.d.ts.map +1 -1
  86. package/esm/exports.js.map +1 -1
  87. package/esm/flags.d.ts +3 -0
  88. package/esm/flags.d.ts.map +1 -0
  89. package/esm/flags.js +16 -0
  90. package/esm/flags.js.map +1 -0
  91. package/esm/helpers.d.ts.map +1 -1
  92. package/esm/helpers.js +4 -3
  93. package/esm/helpers.js.map +1 -1
  94. package/esm/index.d.ts.map +1 -1
  95. package/esm/index.js.map +1 -1
  96. package/esm/integrations/breadcrumbs.d.ts.map +1 -1
  97. package/esm/integrations/breadcrumbs.js.map +1 -1
  98. package/esm/integrations/dedupe.d.ts.map +1 -1
  99. package/esm/integrations/dedupe.js +3 -2
  100. package/esm/integrations/dedupe.js.map +1 -1
  101. package/esm/integrations/globalhandlers.d.ts.map +1 -1
  102. package/esm/integrations/globalhandlers.js +3 -2
  103. package/esm/integrations/globalhandlers.js.map +1 -1
  104. package/esm/integrations/index.d.ts.map +1 -1
  105. package/esm/integrations/index.js.map +1 -1
  106. package/esm/integrations/linkederrors.d.ts.map +1 -1
  107. package/esm/integrations/linkederrors.js.map +1 -1
  108. package/esm/integrations/trycatch.d.ts.map +1 -1
  109. package/esm/integrations/trycatch.js.map +1 -1
  110. package/esm/integrations/useragent.d.ts.map +1 -1
  111. package/esm/integrations/useragent.js.map +1 -1
  112. package/esm/sdk.d.ts.map +1 -1
  113. package/esm/sdk.js +5 -4
  114. package/esm/sdk.js.map +1 -1
  115. package/esm/stack-parsers.d.ts.map +1 -1
  116. package/esm/stack-parsers.js.map +1 -1
  117. package/esm/transports/base.d.ts.map +1 -1
  118. package/esm/transports/base.js +8 -7
  119. package/esm/transports/base.js.map +1 -1
  120. package/esm/transports/fetch.d.ts.map +1 -1
  121. package/esm/transports/fetch.js.map +1 -1
  122. package/esm/transports/index.d.ts +2 -0
  123. package/esm/transports/index.d.ts.map +1 -1
  124. package/esm/transports/index.js +2 -0
  125. package/esm/transports/index.js.map +1 -1
  126. package/esm/transports/new-fetch.d.ts +10 -0
  127. package/esm/transports/new-fetch.d.ts.map +1 -0
  128. package/esm/transports/new-fetch.js +25 -0
  129. package/esm/transports/new-fetch.js.map +1 -0
  130. package/esm/transports/new-xhr.d.ts +11 -0
  131. package/esm/transports/new-xhr.d.ts.map +1 -0
  132. package/esm/transports/new-xhr.js +44 -0
  133. package/esm/transports/new-xhr.js.map +1 -0
  134. package/esm/transports/utils.d.ts.map +1 -1
  135. package/esm/transports/utils.js +3 -2
  136. package/esm/transports/utils.js.map +1 -1
  137. package/esm/transports/xhr.d.ts.map +1 -1
  138. package/esm/transports/xhr.js.map +1 -1
  139. package/esm/version.d.ts.map +1 -1
  140. package/esm/version.js.map +1 -1
  141. package/package.json +6 -45
  142. package/types/backend.d.ts.map +1 -1
  143. package/types/client.d.ts.map +1 -1
  144. package/types/eventbuilder.d.ts.map +1 -1
  145. package/types/exports.d.ts.map +1 -1
  146. package/types/flags.d.ts +3 -0
  147. package/types/flags.d.ts.map +1 -0
  148. package/types/helpers.d.ts.map +1 -1
  149. package/types/index.d.ts.map +1 -1
  150. package/types/integrations/breadcrumbs.d.ts.map +1 -1
  151. package/types/integrations/dedupe.d.ts.map +1 -1
  152. package/types/integrations/globalhandlers.d.ts.map +1 -1
  153. package/types/integrations/index.d.ts.map +1 -1
  154. package/types/integrations/linkederrors.d.ts.map +1 -1
  155. package/types/integrations/trycatch.d.ts.map +1 -1
  156. package/types/integrations/useragent.d.ts.map +1 -1
  157. package/types/sdk.d.ts.map +1 -1
  158. package/types/stack-parsers.d.ts.map +1 -1
  159. package/types/transports/base.d.ts.map +1 -1
  160. package/types/transports/fetch.d.ts.map +1 -1
  161. package/types/transports/index.d.ts +2 -0
  162. package/types/transports/index.d.ts.map +1 -1
  163. package/types/transports/new-fetch.d.ts +10 -0
  164. package/types/transports/new-fetch.d.ts.map +1 -0
  165. package/types/transports/new-xhr.d.ts +11 -0
  166. package/types/transports/new-xhr.d.ts.map +1 -0
  167. package/types/transports/utils.d.ts.map +1 -1
  168. package/types/transports/xhr.d.ts.map +1 -1
  169. package/types/version.d.ts.map +1 -1
  170. package/bundles/bundle.debug.min.js +0 -3
  171. package/bundles/bundle.debug.min.js.map +0 -1
  172. package/bundles/bundle.es6.debug.min.js +0 -3
  173. package/bundles/bundle.es6.debug.min.js.map +0 -1
  174. package/bundles/bundle.es6.js.map +0 -1
  175. package/bundles/bundle.es6.min.js +0 -3
  176. package/bundles/bundle.es6.min.js.map +0 -1
  177. package/bundles/bundle.js.map +0 -1
  178. package/bundles/bundle.min.js +0 -3
  179. package/bundles/bundle.min.js.map +0 -1
@@ -1,4 +1,4 @@
1
- /*! @sentry/browser 6.19.2 (f49c509) | https://github.com/getsentry/sentry-javascript */
1
+ /*! @sentry/browser 6.19.5 (755d2cd) | https://github.com/getsentry/sentry-javascript */
2
2
  var Sentry = (function (exports) {
3
3
 
4
4
  /*! *****************************************************************************
@@ -113,22 +113,6 @@ var Sentry = (function (exports) {
113
113
  });
114
114
  }
115
115
 
116
- /**
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.
122
- */
123
- /**
124
- * Figures out if we're building with debug functionality.
125
- *
126
- * @returns true if this is a debug build
127
- */
128
- function isDebugBuild() {
129
- return true;
130
- }
131
-
132
116
  /**
133
117
  * NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
134
118
  * you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
@@ -145,6 +129,23 @@ var Sentry = (function (exports) {
145
129
  : typeof self !== 'undefined'
146
130
  ? self
147
131
  : fallbackGlobalObject);
132
+ }
133
+ /**
134
+ * Returns a global singleton contained in the global `__SENTRY__` object.
135
+ *
136
+ * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory
137
+ * function and added to the `__SENTRY__` object.
138
+ *
139
+ * @param name name of the global singleton on __SENTRY__
140
+ * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__`
141
+ * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `getGlobalObject`'s return value
142
+ * @returns the singleton
143
+ */
144
+ function getGlobalSingleton(name, creator, obj) {
145
+ var global = (obj || getGlobalObject());
146
+ var __SENTRY__ = (global.__SENTRY__ = global.__SENTRY__ || {});
147
+ var singleton = __SENTRY__[name] || (__SENTRY__[name] = creator());
148
+ return singleton;
148
149
  }
149
150
 
150
151
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -279,6 +280,16 @@ var Sentry = (function (exports) {
279
280
  function isSyntheticEvent(wat) {
280
281
  return isPlainObject(wat) && 'nativeEvent' in wat && 'preventDefault' in wat && 'stopPropagation' in wat;
281
282
  }
283
+ /**
284
+ * Checks whether given value is NaN
285
+ * {@link isNaN}.
286
+ *
287
+ * @param wat A value to be checked.
288
+ * @returns A boolean representing the result.
289
+ */
290
+ function isNaN$1(wat) {
291
+ return typeof wat === 'number' && wat !== wat;
292
+ }
282
293
  /**
283
294
  * Checks whether given value's type is an instance of provided constructor.
284
295
  * {@link isInstanceOf}.
@@ -437,6 +448,22 @@ var Sentry = (function (exports) {
437
448
  return SentryError;
438
449
  }(Error));
439
450
 
451
+ /*
452
+ * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking
453
+ * for users.
454
+ *
455
+ * Debug flags need to be declared in each package individually and must not be imported across package boundaries,
456
+ * because some build tools have trouble tree-shaking imported guards.
457
+ *
458
+ * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.
459
+ *
460
+ * Debug flag files will contain "magic strings" like `true` that may get replaced with actual values during
461
+ * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not
462
+ * replaced.
463
+ */
464
+ /** Flag that is true for debug builds, false otherwise. */
465
+ var IS_DEBUG_BUILD$3 = true;
466
+
440
467
  /** Regular expression used to parse a Dsn. */
441
468
  var DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/;
442
469
  function isValidProtocol(protocol) {
@@ -528,8 +555,7 @@ var Sentry = (function (exports) {
528
555
  var PREFIX = 'Sentry Logger ';
529
556
  var CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert'];
530
557
  /**
531
- * Temporarily unwrap `console.log` and friends in order to perform the given callback using the original methods.
532
- * Restores wrapping after the callback completes.
558
+ * Temporarily disable sentry console instrumentations.
533
559
  *
534
560
  * @param callback The function to run against the original `console` messages
535
561
  * @returns The results of the callback
@@ -539,89 +565,68 @@ var Sentry = (function (exports) {
539
565
  if (!('console' in global)) {
540
566
  return callback();
541
567
  }
542
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
543
568
  var originalConsole = global.console;
544
569
  var wrappedLevels = {};
545
570
  // Restore all wrapped console methods
546
571
  CONSOLE_LEVELS.forEach(function (level) {
547
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
548
- if (level in global.console && originalConsole[level].__sentry_original__) {
572
+ // TODO(v7): Remove this check as it's only needed for Node 6
573
+ var originalWrappedFunc = originalConsole[level] && originalConsole[level].__sentry_original__;
574
+ if (level in global.console && originalWrappedFunc) {
549
575
  wrappedLevels[level] = originalConsole[level];
550
- originalConsole[level] = originalConsole[level].__sentry_original__;
576
+ originalConsole[level] = originalWrappedFunc;
551
577
  }
552
578
  });
553
- // Perform callback manipulations
554
- var result = callback();
555
- // Revert restoration to wrapped state
556
- Object.keys(wrappedLevels).forEach(function (level) {
557
- originalConsole[level] = wrappedLevels[level];
558
- });
559
- return result;
560
- }
561
- /** JSDoc */
562
- var Logger = /** @class */ (function () {
563
- /** JSDoc */
564
- function Logger() {
565
- this._enabled = false;
579
+ try {
580
+ return callback();
566
581
  }
567
- /** JSDoc */
568
- Logger.prototype.disable = function () {
569
- this._enabled = false;
570
- };
571
- /** JSDoc */
572
- Logger.prototype.enable = function () {
573
- this._enabled = true;
574
- };
575
- /** JSDoc */
576
- Logger.prototype.log = function () {
577
- var args = [];
578
- for (var _i = 0; _i < arguments.length; _i++) {
579
- args[_i] = arguments[_i];
580
- }
581
- if (!this._enabled) {
582
- return;
583
- }
584
- consoleSandbox(function () {
585
- var _a;
586
- (_a = global$6.console).log.apply(_a, __spread([PREFIX + "[Log]:"], args));
582
+ finally {
583
+ // Revert restoration to wrapped state
584
+ Object.keys(wrappedLevels).forEach(function (level) {
585
+ originalConsole[level] = wrappedLevels[level];
587
586
  });
587
+ }
588
+ }
589
+ function makeLogger() {
590
+ var enabled = false;
591
+ var logger = {
592
+ enable: function () {
593
+ enabled = true;
594
+ },
595
+ disable: function () {
596
+ enabled = false;
597
+ },
588
598
  };
589
- /** JSDoc */
590
- Logger.prototype.warn = function () {
591
- var args = [];
592
- for (var _i = 0; _i < arguments.length; _i++) {
593
- args[_i] = arguments[_i];
594
- }
595
- if (!this._enabled) {
596
- return;
597
- }
598
- consoleSandbox(function () {
599
- var _a;
600
- (_a = global$6.console).warn.apply(_a, __spread([PREFIX + "[Warn]:"], args));
599
+ if (IS_DEBUG_BUILD$3) {
600
+ CONSOLE_LEVELS.forEach(function (name) {
601
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
602
+ logger[name] = function () {
603
+ var args = [];
604
+ for (var _i = 0; _i < arguments.length; _i++) {
605
+ args[_i] = arguments[_i];
606
+ }
607
+ if (enabled) {
608
+ consoleSandbox(function () {
609
+ var _a;
610
+ (_a = global$6.console)[name].apply(_a, __spread([PREFIX + "[" + name + "]:"], args));
611
+ });
612
+ }
613
+ };
601
614
  });
602
- };
603
- /** JSDoc */
604
- Logger.prototype.error = function () {
605
- var args = [];
606
- for (var _i = 0; _i < arguments.length; _i++) {
607
- args[_i] = arguments[_i];
608
- }
609
- if (!this._enabled) {
610
- return;
611
- }
612
- consoleSandbox(function () {
613
- var _a;
614
- (_a = global$6.console).error.apply(_a, __spread([PREFIX + "[Error]:"], args));
615
+ }
616
+ else {
617
+ CONSOLE_LEVELS.forEach(function (name) {
618
+ logger[name] = function () { return undefined; };
615
619
  });
616
- };
617
- return Logger;
618
- }());
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;
620
+ }
621
+ return logger;
622
+ }
623
+ // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
624
+ var logger;
625
+ if (IS_DEBUG_BUILD$3) {
626
+ logger = getGlobalSingleton('logger', makeLogger);
627
+ }
628
+ else {
629
+ logger = makeLogger();
625
630
  }
626
631
 
627
632
  /**
@@ -764,55 +769,38 @@ var Sentry = (function (exports) {
764
769
  *
765
770
  * @param value Initial source that we have to transform in order for it to be usable by the serializer
766
771
  */
767
- function getWalkSource(value) {
772
+ function convertToPlainObject(value) {
773
+ var newObj = value;
768
774
  if (isError(value)) {
769
- var error = value;
770
- var err = {
771
- message: error.message,
772
- name: error.name,
773
- stack: error.stack,
774
- };
775
- for (var i in error) {
776
- if (Object.prototype.hasOwnProperty.call(error, i)) {
777
- err[i] = error[i];
778
- }
779
- }
780
- return err;
775
+ newObj = __assign({ message: value.message, name: value.name, stack: value.stack }, getOwnProperties(value));
781
776
  }
782
- if (isEvent(value)) {
777
+ else if (isEvent(value)) {
783
778
  var event_1 = value;
784
- var source = {};
785
- // Accessing event attributes can throw (see https://github.com/getsentry/sentry-javascript/issues/768 and
786
- // https://github.com/getsentry/sentry-javascript/issues/838), but accessing `type` hasn't been wrapped in a
787
- // try-catch in at least two years and no one's complained, so that's likely not an issue anymore
788
- source.type = event_1.type;
789
- try {
790
- source.target = isElement(event_1.target)
791
- ? htmlTreeAsString(event_1.target)
792
- : Object.prototype.toString.call(event_1.target);
793
- }
794
- catch (_oO) {
795
- source.target = '<unknown>';
796
- }
797
- try {
798
- source.currentTarget = isElement(event_1.currentTarget)
799
- ? htmlTreeAsString(event_1.currentTarget)
800
- : Object.prototype.toString.call(event_1.currentTarget);
801
- }
802
- catch (_oO) {
803
- source.currentTarget = '<unknown>';
804
- }
779
+ newObj = __assign({ type: event_1.type, target: serializeEventTarget(event_1.target), currentTarget: serializeEventTarget(event_1.currentTarget) }, getOwnProperties(event_1));
805
780
  if (typeof CustomEvent !== 'undefined' && isInstanceOf(value, CustomEvent)) {
806
- source.detail = event_1.detail;
781
+ newObj.detail = event_1.detail;
807
782
  }
808
- for (var attr in event_1) {
809
- if (Object.prototype.hasOwnProperty.call(event_1, attr)) {
810
- source[attr] = event_1[attr];
811
- }
783
+ }
784
+ return newObj;
785
+ }
786
+ /** Creates a string representation of the target of an `Event` object */
787
+ function serializeEventTarget(target) {
788
+ try {
789
+ return isElement(target) ? htmlTreeAsString(target) : Object.prototype.toString.call(target);
790
+ }
791
+ catch (_oO) {
792
+ return '<unknown>';
793
+ }
794
+ }
795
+ /** Filters out all but an object's own properties */
796
+ function getOwnProperties(obj) {
797
+ var extractedProps = {};
798
+ for (var property in obj) {
799
+ if (Object.prototype.hasOwnProperty.call(obj, property)) {
800
+ extractedProps[property] = obj[property];
812
801
  }
813
- return source;
814
802
  }
815
- return value;
803
+ return extractedProps;
816
804
  }
817
805
  /**
818
806
  * Given any captured exception, extract its keys and create a sorted
@@ -822,7 +810,7 @@ var Sentry = (function (exports) {
822
810
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
823
811
  function extractExceptionKeysForMessage(exception, maxLength) {
824
812
  if (maxLength === void 0) { maxLength = 40; }
825
- var keys = Object.keys(getWalkSource(exception));
813
+ var keys = Object.keys(convertToPlainObject(exception));
826
814
  keys.sort();
827
815
  if (!keys.length) {
828
816
  return '[object has no keys]';
@@ -849,13 +837,12 @@ var Sentry = (function (exports) {
849
837
  function dropUndefinedKeys(val) {
850
838
  var e_1, _a;
851
839
  if (isPlainObject(val)) {
852
- var obj = val;
853
840
  var rv = {};
854
841
  try {
855
- for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
842
+ for (var _b = __values(Object.keys(val)), _c = _b.next(); !_c.done; _c = _b.next()) {
856
843
  var key = _c.value;
857
- if (typeof obj[key] !== 'undefined') {
858
- rv[key] = dropUndefinedKeys(obj[key]);
844
+ if (typeof val[key] !== 'undefined') {
845
+ rv[key] = dropUndefinedKeys(val[key]);
859
846
  }
860
847
  }
861
848
  }
@@ -1813,10 +1800,10 @@ var Sentry = (function (exports) {
1813
1800
  if (maxProperties === void 0) { maxProperties = +Infinity; }
1814
1801
  try {
1815
1802
  // since we're at the outermost level, there is no key
1816
- return walk('', input, depth, maxProperties);
1803
+ return visit('', input, depth, maxProperties);
1817
1804
  }
1818
- catch (_oO) {
1819
- return '**non-serializable**';
1805
+ catch (err) {
1806
+ return { ERROR: "**non-serializable** (" + err + ")" };
1820
1807
  }
1821
1808
  }
1822
1809
  /** JSDoc */
@@ -1827,145 +1814,145 @@ var Sentry = (function (exports) {
1827
1814
  maxSize) {
1828
1815
  if (depth === void 0) { depth = 3; }
1829
1816
  if (maxSize === void 0) { maxSize = 100 * 1024; }
1830
- var serialized = normalize(object, depth);
1831
- if (jsonSize(serialized) > maxSize) {
1817
+ var normalized = normalize(object, depth);
1818
+ if (jsonSize(normalized) > maxSize) {
1832
1819
  return normalizeToSize(object, depth - 1, maxSize);
1833
1820
  }
1834
- return serialized;
1821
+ return normalized;
1835
1822
  }
1836
1823
  /**
1837
- * Walks an object to perform a normalization on it
1824
+ * Visits a node to perform normalization on it
1838
1825
  *
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
1826
+ * @param key The key corresponding to the given node
1827
+ * @param value The node to be visited
1828
+ * @param depth Optional number indicating the maximum recursion depth
1829
+ * @param maxProperties Optional maximum number of properties/elements included in any single object/array
1843
1830
  * @param memo Optional Memo class handling decycling
1844
1831
  */
1845
- function walk(key, value, depth, maxProperties, memo) {
1832
+ function visit(key, value, depth, maxProperties, memo) {
1846
1833
  if (depth === void 0) { depth = +Infinity; }
1847
1834
  if (maxProperties === void 0) { maxProperties = +Infinity; }
1848
1835
  if (memo === void 0) { memo = memoBuilder(); }
1849
1836
  var _a = __read(memo, 2), memoize = _a[0], unmemoize = _a[1];
1850
- // If we reach the maximum depth, serialize whatever is left
1837
+ // If the value has a `toJSON` method, see if we can bail and let it do the work
1838
+ var valueWithToJSON = value;
1839
+ if (valueWithToJSON && typeof valueWithToJSON.toJSON === 'function') {
1840
+ try {
1841
+ return valueWithToJSON.toJSON();
1842
+ }
1843
+ catch (err) {
1844
+ // pass (The built-in `toJSON` failed, but we can still try to do it ourselves)
1845
+ }
1846
+ }
1847
+ // Get the simple cases out of the way first
1848
+ if (value === null || (['number', 'boolean', 'string'].includes(typeof value) && !isNaN$1(value))) {
1849
+ return value;
1850
+ }
1851
+ var stringified = stringifyValue(key, value);
1852
+ // Anything we could potentially dig into more (objects or arrays) will have come back as `"[object XXXX]"`.
1853
+ // Everything else will have already been serialized, so if we don't see that pattern, we're done.
1854
+ if (!stringified.startsWith('[object ')) {
1855
+ return stringified;
1856
+ }
1857
+ // We're also done if we've reached the max depth
1851
1858
  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
1859
+ // At this point we know `serialized` is a string of the form `"[object XXXX]"`. Clean it up so it's just `"[XXXX]"`.
1860
+ return stringified.replace('object ', '');
1861
+ }
1862
+ // If we've already visited this branch, bail out, as it's circular reference. If not, note that we're seeing it now.
1871
1863
  if (memoize(value)) {
1872
1864
  return '[Circular ~]';
1873
1865
  }
1874
- var propertyCount = 0;
1875
- // Walk all keys of the source
1876
- for (var innerKey in source) {
1866
+ // At this point we know we either have an object or an array, we haven't seen it before, and we're going to recurse
1867
+ // because we haven't yet reached the max depth. Create an accumulator to hold the results of visiting each
1868
+ // property/entry, and keep track of the number of items we add to it.
1869
+ var normalized = (Array.isArray(value) ? [] : {});
1870
+ var numAdded = 0;
1871
+ // Before we begin, convert`Error` and`Event` instances into plain objects, since some of each of their relevant
1872
+ // properties are non-enumerable and otherwise would get missed.
1873
+ var visitable = (isError(value) || isEvent(value) ? convertToPlainObject(value) : value);
1874
+ for (var visitKey in visitable) {
1877
1875
  // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
1878
- if (!Object.prototype.hasOwnProperty.call(source, innerKey)) {
1876
+ if (!Object.prototype.hasOwnProperty.call(visitable, visitKey)) {
1879
1877
  continue;
1880
1878
  }
1881
- if (propertyCount >= maxProperties) {
1882
- acc[innerKey] = '[MaxProperties ~]';
1879
+ if (numAdded >= maxProperties) {
1880
+ normalized[visitKey] = '[MaxProperties ~]';
1883
1881
  break;
1884
1882
  }
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);
1883
+ // Recursively visit all the child nodes
1884
+ var visitValue = visitable[visitKey];
1885
+ normalized[visitKey] = visit(visitKey, visitValue, depth - 1, maxProperties, memo);
1886
+ numAdded += 1;
1889
1887
  }
1890
- // Once walked through all the branches, remove the parent from memo storage
1888
+ // Once we've visited all the branches, remove the parent from memo storage
1891
1889
  unmemoize(value);
1892
1890
  // 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;
1891
+ return normalized;
1920
1892
  }
1921
1893
  /**
1922
- * makeSerializable()
1894
+ * Stringify the given value. Handles various known special values and types.
1923
1895
  *
1924
- * Takes unserializable input and make it serializer-friendly.
1896
+ * Not meant to be used on simple primitives which already have a string representation, as it will, for example, turn
1897
+ * the number 1231 into "[Object Number]", nor on `null`, as it will throw.
1925
1898
  *
1926
- * Handles globals, functions, `undefined`, `NaN`, and other non-serializable values.
1899
+ * @param value The value to stringify
1900
+ * @returns A stringified representation of the given value
1927
1901
  */
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) + "]";
1902
+ function stringifyValue(key,
1903
+ // this type is a tiny bit of a cheat, since this function does handle NaN (which is technically a number), but for
1904
+ // our internal use, it'll do
1905
+ value) {
1906
+ try {
1907
+ if (key === 'domain' && value && typeof value === 'object' && value._events) {
1908
+ return '[Domain]';
1909
+ }
1910
+ if (key === 'domainEmitter') {
1911
+ return '[DomainEmitter]';
1912
+ }
1913
+ // It's safe to use `global`, `window`, and `document` here in this manner, as we are asserting using `typeof` first
1914
+ // which won't throw if they are not present.
1915
+ if (typeof global !== 'undefined' && value === global) {
1916
+ return '[Global]';
1917
+ }
1918
+ // eslint-disable-next-line no-restricted-globals
1919
+ if (typeof window !== 'undefined' && value === window) {
1920
+ return '[Window]';
1921
+ }
1922
+ // eslint-disable-next-line no-restricted-globals
1923
+ if (typeof document !== 'undefined' && value === document) {
1924
+ return '[Document]';
1925
+ }
1926
+ // React's SyntheticEvent thingy
1927
+ if (isSyntheticEvent(value)) {
1928
+ return '[SyntheticEvent]';
1929
+ }
1930
+ if (typeof value === 'number' && value !== value) {
1931
+ return '[NaN]';
1932
+ }
1933
+ // this catches `undefined` (but not `null`, which is a primitive and can be serialized on its own)
1934
+ if (value === void 0) {
1935
+ return '[undefined]';
1936
+ }
1937
+ if (typeof value === 'function') {
1938
+ return "[Function: " + getFunctionName(value) + "]";
1939
+ }
1940
+ if (typeof value === 'symbol') {
1941
+ return "[" + String(value) + "]";
1942
+ }
1943
+ // stringified BigInts are indistinguishable from regular numbers, so we need to label them to avoid confusion
1944
+ if (typeof value === 'bigint') {
1945
+ return "[BigInt: " + String(value) + "]";
1946
+ }
1947
+ // Now that we've knocked out all the special cases and the primitives, all we have left are objects. Simply casting
1948
+ // them to strings means that instances of classes which haven't defined their `toStringTag` will just come out as
1949
+ // `"[object Object]"`. If we instead look at the constructor's name (which is the same as the name of the class),
1950
+ // we can make sure that only plain objects come out that way.
1951
+ return "[object " + Object.getPrototypeOf(value).constructor.name + "]";
1964
1952
  }
1965
- if (typeof value === 'bigint') {
1966
- return "[BigInt: " + String(value) + "]";
1953
+ catch (err) {
1954
+ return "**non-serializable** (" + err + ")";
1967
1955
  }
1968
- return value;
1969
1956
  }
1970
1957
  /** Calculates bytes size of input string */
1971
1958
  function utf8Length(value) {
@@ -2384,6 +2371,13 @@ var Sentry = (function (exports) {
2384
2371
  if (items === void 0) { items = []; }
2385
2372
  return [headers, items];
2386
2373
  }
2374
+ /**
2375
+ * Get the type of the envelope. Grabs the type from the first envelope item.
2376
+ */
2377
+ function getEnvelopeType(envelope) {
2378
+ var _a = __read(envelope, 2), _b = __read(_a[1], 1), _c = __read(_b[0], 1), firstItemHeader = _c[0];
2379
+ return firstItemHeader.type;
2380
+ }
2387
2381
  /**
2388
2382
  * Serializes an envelope into a string.
2389
2383
  */
@@ -2944,12 +2938,7 @@ var Sentry = (function (exports) {
2944
2938
  * Returns the global event processors.
2945
2939
  */
2946
2940
  function getGlobalEventProcessors() {
2947
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
2948
- var global = getGlobalObject();
2949
- global.__SENTRY__ = global.__SENTRY__ || {};
2950
- global.__SENTRY__.globalEventProcessors = global.__SENTRY__.globalEventProcessors || [];
2951
- return global.__SENTRY__.globalEventProcessors;
2952
- /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
2941
+ return getGlobalSingleton('globalEventProcessors', function () { return []; });
2953
2942
  }
2954
2943
  /**
2955
2944
  * Add a EventProcessor to be kept globally.
@@ -3071,6 +3060,22 @@ var Sentry = (function (exports) {
3071
3060
  return Session;
3072
3061
  }());
3073
3062
 
3063
+ /*
3064
+ * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking
3065
+ * for users.
3066
+ *
3067
+ * Debug flags need to be declared in each package individually and must not be imported across package boundaries,
3068
+ * because some build tools have trouble tree-shaking imported guards.
3069
+ *
3070
+ * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.
3071
+ *
3072
+ * Debug flag files will contain "magic strings" like `true` that may get replaced with actual values during
3073
+ * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not
3074
+ * replaced.
3075
+ */
3076
+ /** Flag that is true for debug builds, false otherwise. */
3077
+ var IS_DEBUG_BUILD$2 = true;
3078
+
3074
3079
  /**
3075
3080
  * API compatibility version of this hub.
3076
3081
  *
@@ -3345,7 +3350,7 @@ var Sentry = (function (exports) {
3345
3350
  return client.getIntegration(integration);
3346
3351
  }
3347
3352
  catch (_oO) {
3348
- logger.warn("Cannot retrieve integration " + integration.id + " from the current Hub");
3353
+ IS_DEBUG_BUILD$2 && logger.warn("Cannot retrieve integration " + integration.id + " from the current Hub");
3349
3354
  return null;
3350
3355
  }
3351
3356
  };
@@ -3466,7 +3471,7 @@ var Sentry = (function (exports) {
3466
3471
  if (sentry && sentry.extensions && typeof sentry.extensions[method] === 'function') {
3467
3472
  return sentry.extensions[method].apply(this, args);
3468
3473
  }
3469
- logger.warn("Extension method " + method + " couldn't be found, doing nothing.");
3474
+ IS_DEBUG_BUILD$2 && logger.warn("Extension method " + method + " couldn't be found, doing nothing.");
3470
3475
  };
3471
3476
  return Hub;
3472
3477
  }());
@@ -3527,11 +3532,7 @@ var Sentry = (function (exports) {
3527
3532
  * @hidden
3528
3533
  */
3529
3534
  function getHubFromCarrier(carrier) {
3530
- if (carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub)
3531
- return carrier.__SENTRY__.hub;
3532
- carrier.__SENTRY__ = carrier.__SENTRY__ || {};
3533
- carrier.__SENTRY__.hub = new Hub();
3534
- return carrier.__SENTRY__.hub;
3535
+ return getGlobalSingleton('hub', function () { return new Hub(); }, carrier);
3535
3536
  }
3536
3537
  /**
3537
3538
  * This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute
@@ -3542,8 +3543,8 @@ var Sentry = (function (exports) {
3542
3543
  function setHubOnCarrier(carrier, hub) {
3543
3544
  if (!carrier)
3544
3545
  return false;
3545
- carrier.__SENTRY__ = carrier.__SENTRY__ || {};
3546
- carrier.__SENTRY__.hub = hub;
3546
+ var __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {});
3547
+ __SENTRY__.hub = hub;
3547
3548
  return true;
3548
3549
  }
3549
3550
 
@@ -3789,6 +3790,22 @@ var Sentry = (function (exports) {
3789
3790
  return endpoint + "?" + encodedOptions;
3790
3791
  }
3791
3792
 
3793
+ /*
3794
+ * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking
3795
+ * for users.
3796
+ *
3797
+ * Debug flags need to be declared in each package individually and must not be imported across package boundaries,
3798
+ * because some build tools have trouble tree-shaking imported guards.
3799
+ *
3800
+ * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.
3801
+ *
3802
+ * Debug flag files will contain "magic strings" like `true` that may get replaced with actual values during
3803
+ * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not
3804
+ * replaced.
3805
+ */
3806
+ /** Flag that is true for debug builds, false otherwise. */
3807
+ var IS_DEBUG_BUILD$1 = true;
3808
+
3792
3809
  var installedIntegrations = [];
3793
3810
  /**
3794
3811
  * @private
@@ -4146,7 +4163,7 @@ var Sentry = (function (exports) {
4146
4163
  if (evt) {
4147
4164
  // TODO this is more of the hack trying to solve https://github.com/getsentry/sentry-javascript/issues/2809
4148
4165
  // it is only attached as extra data to the event if the event somehow skips being normalized
4149
- evt.sdkProcessingMetadata = __assign(__assign({}, evt.sdkProcessingMetadata), { normalizeDepth: normalize(normalizeDepth) });
4166
+ evt.sdkProcessingMetadata = __assign(__assign({}, evt.sdkProcessingMetadata), { normalizeDepth: normalize(normalizeDepth) + " (" + typeof normalizeDepth + ")" });
4150
4167
  }
4151
4168
  if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
4152
4169
  return _this._normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
@@ -4190,7 +4207,7 @@ var Sentry = (function (exports) {
4190
4207
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
4191
4208
  normalized.contexts.trace = event.contexts.trace;
4192
4209
  }
4193
- event.sdkProcessingMetadata = __assign(__assign({}, event.sdkProcessingMetadata), { baseClientNormalized: true });
4210
+ normalized.sdkProcessingMetadata = __assign(__assign({}, normalized.sdkProcessingMetadata), { baseClientNormalized: true });
4194
4211
  return normalized;
4195
4212
  };
4196
4213
  /**
@@ -4416,6 +4433,32 @@ var Sentry = (function (exports) {
4416
4433
  var eventType = event.type || 'event';
4417
4434
  var transactionSampling = (event.sdkProcessingMetadata || {}).transactionSampling;
4418
4435
  var _a = transactionSampling || {}, samplingMethod = _a.method, sampleRate = _a.rate;
4436
+ // TODO: Below is a temporary hack in order to debug a serialization error - see
4437
+ // https://github.com/getsentry/sentry-javascript/issues/2809,
4438
+ // https://github.com/getsentry/sentry-javascript/pull/4425, and
4439
+ // https://github.com/getsentry/sentry-javascript/pull/4574.
4440
+ //
4441
+ // TL; DR: even though we normalize all events (which should prevent this), something is causing `JSON.stringify` to
4442
+ // throw a circular reference error.
4443
+ //
4444
+ // When it's time to remove it:
4445
+ // 1. Delete everything between here and where the request object `req` is created, EXCEPT the line deleting
4446
+ // `sdkProcessingMetadata`
4447
+ // 2. Restore the original version of the request body, which is commented out
4448
+ // 3. Search for either of the PR URLs above and pull out the companion hacks in the browser playwright tests and the
4449
+ // baseClient tests in this package
4450
+ enhanceEventWithSdkInfo(event, api.metadata.sdk);
4451
+ event.tags = event.tags || {};
4452
+ event.extra = event.extra || {};
4453
+ // In theory, all events should be marked as having gone through normalization and so
4454
+ // we should never set this tag/extra data
4455
+ if (!(event.sdkProcessingMetadata && event.sdkProcessingMetadata.baseClientNormalized)) {
4456
+ event.tags.skippedNormalization = true;
4457
+ event.extra.normalizeDepth = event.sdkProcessingMetadata ? event.sdkProcessingMetadata.normalizeDepth : 'unset';
4458
+ }
4459
+ // prevent this data from being sent to sentry
4460
+ // TODO: This is NOT part of the hack - DO NOT DELETE
4461
+ delete event.sdkProcessingMetadata;
4419
4462
  var envelopeHeaders = __assign(__assign({ event_id: event.event_id, sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
4420
4463
  var eventItem = [
4421
4464
  {
@@ -4631,9 +4674,14 @@ var Sentry = (function (exports) {
4631
4674
  */
4632
4675
  function initAndBind(clientClass, options) {
4633
4676
  if (options.debug === true) {
4634
- {
4677
+ if (IS_DEBUG_BUILD$1) {
4635
4678
  logger.enable();
4636
4679
  }
4680
+ else {
4681
+ // use `console.warn` rather than `logger.warn` since by non-debug bundles have all `logger.x` statements stripped
4682
+ // eslint-disable-next-line no-console
4683
+ console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');
4684
+ }
4637
4685
  }
4638
4686
  var hub = getCurrentHub();
4639
4687
  var scope = hub.getScope();
@@ -4644,7 +4692,61 @@ var Sentry = (function (exports) {
4644
4692
  hub.bindClient(client);
4645
4693
  }
4646
4694
 
4647
- var SDK_VERSION = '6.19.2';
4695
+ var DEFAULT_TRANSPORT_BUFFER_SIZE = 30;
4696
+ /**
4697
+ * Creates a `NewTransport`
4698
+ *
4699
+ * @param options
4700
+ * @param makeRequest
4701
+ */
4702
+ function createTransport(options, makeRequest, buffer) {
4703
+ if (buffer === void 0) { buffer = makePromiseBuffer(options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE); }
4704
+ var rateLimits = {};
4705
+ var flush = function (timeout) { return buffer.drain(timeout); };
4706
+ function send(envelope) {
4707
+ var envCategory = getEnvelopeType(envelope);
4708
+ var category = envCategory === 'event' ? 'error' : envCategory;
4709
+ var request = {
4710
+ category: category,
4711
+ body: serializeEnvelope(envelope),
4712
+ };
4713
+ // Don't add to buffer if transport is already rate-limited
4714
+ if (isRateLimited(rateLimits, category)) {
4715
+ return rejectedSyncPromise({
4716
+ status: 'rate_limit',
4717
+ reason: getRateLimitReason(rateLimits, category),
4718
+ });
4719
+ }
4720
+ var requestTask = function () {
4721
+ return makeRequest(request).then(function (_a) {
4722
+ var body = _a.body, headers = _a.headers, reason = _a.reason, statusCode = _a.statusCode;
4723
+ var status = eventStatusFromHttpCode(statusCode);
4724
+ if (headers) {
4725
+ rateLimits = updateRateLimits(rateLimits, headers);
4726
+ }
4727
+ if (status === 'success') {
4728
+ return resolvedSyncPromise({ status: status, reason: reason });
4729
+ }
4730
+ return rejectedSyncPromise({
4731
+ status: status,
4732
+ reason: reason ||
4733
+ body ||
4734
+ (status === 'rate_limit' ? getRateLimitReason(rateLimits, category) : 'Unknown transport error'),
4735
+ });
4736
+ });
4737
+ };
4738
+ return buffer.add(requestTask);
4739
+ }
4740
+ return {
4741
+ send: send,
4742
+ flush: flush,
4743
+ };
4744
+ }
4745
+ function getRateLimitReason(rateLimits, category) {
4746
+ return "Too many " + category + " requests, backing off until: " + new Date(disabledUntil(rateLimits, category)).toISOString();
4747
+ }
4748
+
4749
+ var SDK_VERSION = '6.19.5';
4648
4750
 
4649
4751
  var originalFunctionToString;
4650
4752
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4729,19 +4831,23 @@ var Sentry = (function (exports) {
4729
4831
  /** JSDoc */
4730
4832
  function _shouldDropEvent$1(event, options) {
4731
4833
  if (options.ignoreInternal && _isSentryError(event)) {
4732
- logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + getEventDescription(event));
4834
+ IS_DEBUG_BUILD$1 &&
4835
+ logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + getEventDescription(event));
4733
4836
  return true;
4734
4837
  }
4735
4838
  if (_isIgnoredError(event, options.ignoreErrors)) {
4736
- logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + getEventDescription(event));
4839
+ IS_DEBUG_BUILD$1 &&
4840
+ logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + getEventDescription(event));
4737
4841
  return true;
4738
4842
  }
4739
4843
  if (_isDeniedUrl(event, options.denyUrls)) {
4740
- logger.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + _getEventFilterUrl(event));
4844
+ IS_DEBUG_BUILD$1 &&
4845
+ logger.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + _getEventFilterUrl(event));
4741
4846
  return true;
4742
4847
  }
4743
4848
  if (!_isAllowedUrl(event, options.allowUrls)) {
4744
- logger.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + _getEventFilterUrl(event));
4849
+ IS_DEBUG_BUILD$1 &&
4850
+ logger.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + _getEventFilterUrl(event));
4745
4851
  return true;
4746
4852
  }
4747
4853
  return false;
@@ -4780,7 +4886,7 @@ var Sentry = (function (exports) {
4780
4886
  return ["" + value, type + ": " + value];
4781
4887
  }
4782
4888
  catch (oO) {
4783
- logger.error("Cannot extract message for event " + getEventDescription(event));
4889
+ IS_DEBUG_BUILD$1 && logger.error("Cannot extract message for event " + getEventDescription(event));
4784
4890
  return [];
4785
4891
  }
4786
4892
  }
@@ -4823,7 +4929,7 @@ var Sentry = (function (exports) {
4823
4929
  return frames_1 ? _getLastValidUrl(frames_1) : null;
4824
4930
  }
4825
4931
  catch (oO) {
4826
- logger.error("Cannot extract url for event " + getEventDescription(event));
4932
+ IS_DEBUG_BUILD$1 && logger.error("Cannot extract url for event " + getEventDescription(event));
4827
4933
  return null;
4828
4934
  }
4829
4935
  }
@@ -5165,6 +5271,22 @@ var Sentry = (function (exports) {
5165
5271
  return event;
5166
5272
  }
5167
5273
 
5274
+ /*
5275
+ * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking
5276
+ * for users.
5277
+ *
5278
+ * Debug flags need to be declared in each package individually and must not be imported across package boundaries,
5279
+ * because some build tools have trouble tree-shaking imported guards.
5280
+ *
5281
+ * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.
5282
+ *
5283
+ * Debug flag files will contain "magic strings" like `true` that may get replaced with actual values during
5284
+ * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not
5285
+ * replaced.
5286
+ */
5287
+ /** Flag that is true for debug builds, false otherwise. */
5288
+ var IS_DEBUG_BUILD = true;
5289
+
5168
5290
  var global$4 = getGlobalObject();
5169
5291
  var cachedFetchImpl;
5170
5292
  /**
@@ -5318,7 +5440,7 @@ var Sentry = (function (exports) {
5318
5440
  // A correct type for map-based implementation if we want to go that route
5319
5441
  // would be `Partial<Record<SentryRequestType, Partial<Record<Outcome, number>>>>`
5320
5442
  var key = requestTypeToCategory(category) + ":" + reason;
5321
- logger.log("Adding outcome: " + key);
5443
+ IS_DEBUG_BUILD && logger.log("Adding outcome: " + key);
5322
5444
  this._outcomes[key] = (_a = this._outcomes[key], (_a !== null && _a !== void 0 ? _a : 0)) + 1;
5323
5445
  };
5324
5446
  /**
@@ -5332,10 +5454,10 @@ var Sentry = (function (exports) {
5332
5454
  this._outcomes = {};
5333
5455
  // Nothing to send
5334
5456
  if (!Object.keys(outcomes).length) {
5335
- logger.log('No outcomes to flush');
5457
+ IS_DEBUG_BUILD && logger.log('No outcomes to flush');
5336
5458
  return;
5337
5459
  }
5338
- logger.log("Flushing outcomes:\n" + JSON.stringify(outcomes, null, 2));
5460
+ IS_DEBUG_BUILD && logger.log("Flushing outcomes:\n" + JSON.stringify(outcomes, null, 2));
5339
5461
  var url = getEnvelopeEndpointWithUrlEncodedAuth(this._api.dsn, this._api.tunnel);
5340
5462
  var discardedEvents = Object.keys(outcomes).map(function (key) {
5341
5463
  var _a = __read(key.split(':'), 2), category = _a[0], reason = _a[1];
@@ -5351,7 +5473,7 @@ var Sentry = (function (exports) {
5351
5473
  sendReport(url, serializeEnvelope(envelope));
5352
5474
  }
5353
5475
  catch (e) {
5354
- logger.error(e);
5476
+ IS_DEBUG_BUILD && logger.error(e);
5355
5477
  }
5356
5478
  };
5357
5479
  /**
@@ -5362,8 +5484,9 @@ var Sentry = (function (exports) {
5362
5484
  var status = eventStatusFromHttpCode(response.status);
5363
5485
  this._rateLimits = updateRateLimits(this._rateLimits, headers);
5364
5486
  // eslint-disable-next-line deprecation/deprecation
5365
- if (this._isRateLimited(requestType) && isDebugBuild()) {
5366
- // eslint-disable-next-line deprecation/deprecation
5487
+ if (this._isRateLimited(requestType)) {
5488
+ IS_DEBUG_BUILD &&
5489
+ // eslint-disable-next-line deprecation/deprecation
5367
5490
  logger.warn("Too many " + requestType + " requests, backing off until: " + this._disabledUntil(requestType));
5368
5491
  }
5369
5492
  if (status === 'success') {
@@ -5527,11 +5650,77 @@ var Sentry = (function (exports) {
5527
5650
  return XHRTransport;
5528
5651
  }(BaseTransport));
5529
5652
 
5653
+ /**
5654
+ * Creates a Transport that uses the Fetch API to send events to Sentry.
5655
+ */
5656
+ function makeNewFetchTransport(options, nativeFetch) {
5657
+ if (nativeFetch === void 0) { nativeFetch = getNativeFetchImplementation(); }
5658
+ function makeRequest(request) {
5659
+ var requestOptions = __assign({ body: request.body, method: 'POST', referrerPolicy: 'origin' }, options.requestOptions);
5660
+ return nativeFetch(options.url, requestOptions).then(function (response) {
5661
+ return response.text().then(function (body) { return ({
5662
+ body: body,
5663
+ headers: {
5664
+ 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),
5665
+ 'retry-after': response.headers.get('Retry-After'),
5666
+ },
5667
+ reason: response.statusText,
5668
+ statusCode: response.status,
5669
+ }); });
5670
+ });
5671
+ }
5672
+ return createTransport({ bufferSize: options.bufferSize }, makeRequest);
5673
+ }
5674
+
5675
+ /**
5676
+ * The DONE ready state for XmlHttpRequest
5677
+ *
5678
+ * Defining it here as a constant b/c XMLHttpRequest.DONE is not always defined
5679
+ * (e.g. during testing, it is `undefined`)
5680
+ *
5681
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState}
5682
+ */
5683
+ var XHR_READYSTATE_DONE = 4;
5684
+ /**
5685
+ * Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.
5686
+ */
5687
+ function makeNewXHRTransport(options) {
5688
+ function makeRequest(request) {
5689
+ return new SyncPromise(function (resolve, _reject) {
5690
+ var xhr = new XMLHttpRequest();
5691
+ xhr.onreadystatechange = function () {
5692
+ if (xhr.readyState === XHR_READYSTATE_DONE) {
5693
+ var response = {
5694
+ body: xhr.response,
5695
+ headers: {
5696
+ 'x-sentry-rate-limits': xhr.getResponseHeader('X-Sentry-Rate-Limits'),
5697
+ 'retry-after': xhr.getResponseHeader('Retry-After'),
5698
+ },
5699
+ reason: xhr.statusText,
5700
+ statusCode: xhr.status,
5701
+ };
5702
+ resolve(response);
5703
+ }
5704
+ };
5705
+ xhr.open('POST', options.url);
5706
+ for (var header in options.headers) {
5707
+ if (Object.prototype.hasOwnProperty.call(options.headers, header)) {
5708
+ xhr.setRequestHeader(header, options.headers[header]);
5709
+ }
5710
+ }
5711
+ xhr.send(request.body);
5712
+ });
5713
+ }
5714
+ return createTransport({ bufferSize: options.bufferSize }, makeRequest);
5715
+ }
5716
+
5530
5717
  var index = /*#__PURE__*/Object.freeze({
5531
5718
  __proto__: null,
5532
5719
  BaseTransport: BaseTransport,
5533
5720
  FetchTransport: FetchTransport,
5534
- XHRTransport: XHRTransport
5721
+ XHRTransport: XHRTransport,
5722
+ makeNewFetchTransport: makeNewFetchTransport,
5723
+ makeNewXHRTransport: makeNewXHRTransport
5535
5724
  });
5536
5725
 
5537
5726
  /**
@@ -5565,12 +5754,20 @@ var Sentry = (function (exports) {
5565
5754
  return _super.prototype._setupTransport.call(this);
5566
5755
  }
5567
5756
  var transportOptions = __assign(__assign({}, this._options.transportOptions), { dsn: this._options.dsn, tunnel: this._options.tunnel, sendClientReports: this._options.sendClientReports, _metadata: this._options._metadata });
5757
+ var api = initAPIDetails(transportOptions.dsn, transportOptions._metadata, transportOptions.tunnel);
5758
+ var url = getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel);
5568
5759
  if (this._options.transport) {
5569
5760
  return new this._options.transport(transportOptions);
5570
5761
  }
5571
5762
  if (supportsFetch()) {
5763
+ var requestOptions = __assign({}, transportOptions.fetchParameters);
5764
+ this._newTransport = makeNewFetchTransport({ requestOptions: requestOptions, url: url });
5572
5765
  return new FetchTransport(transportOptions);
5573
5766
  }
5767
+ this._newTransport = makeNewXHRTransport({
5768
+ url: url,
5769
+ headers: transportOptions.headers,
5770
+ });
5574
5771
  return new XHRTransport(transportOptions);
5575
5772
  };
5576
5773
  return BrowserBackend;
@@ -5703,11 +5900,11 @@ var Sentry = (function (exports) {
5703
5900
  return;
5704
5901
  }
5705
5902
  if (!options.eventId) {
5706
- logger.error('Missing eventId option in showReportDialog call');
5903
+ IS_DEBUG_BUILD && logger.error('Missing eventId option in showReportDialog call');
5707
5904
  return;
5708
5905
  }
5709
5906
  if (!options.dsn) {
5710
- logger.error('Missing dsn option in showReportDialog call');
5907
+ IS_DEBUG_BUILD && logger.error('Missing dsn option in showReportDialog call');
5711
5908
  return;
5712
5909
  }
5713
5910
  var script = global$2.document.createElement('script');
@@ -5899,7 +6096,7 @@ var Sentry = (function (exports) {
5899
6096
  return event;
5900
6097
  }
5901
6098
  function globalHandlerLog(type) {
5902
- logger.log("Global Handler attached: " + type);
6099
+ IS_DEBUG_BUILD && logger.log("Global Handler attached: " + type);
5903
6100
  }
5904
6101
  function addMechanismAndCapture(hub, error, event, type) {
5905
6102
  addExceptionMechanism(event, {
@@ -6478,7 +6675,7 @@ var Sentry = (function (exports) {
6478
6675
  // Juuust in case something goes wrong
6479
6676
  try {
6480
6677
  if (_shouldDropEvent(currentEvent, self._previousEvent)) {
6481
- logger.warn('Event dropped due to being a duplicate of previously captured event.');
6678
+ IS_DEBUG_BUILD && logger.warn('Event dropped due to being a duplicate of previously captured event.');
6482
6679
  return null;
6483
6680
  }
6484
6681
  }
@@ -6678,7 +6875,7 @@ var Sentry = (function (exports) {
6678
6875
  return;
6679
6876
  }
6680
6877
  if (!this._isEnabled()) {
6681
- logger.error('Trying to call showReportDialog with Sentry Client disabled');
6878
+ IS_DEBUG_BUILD && logger.error('Trying to call showReportDialog with Sentry Client disabled');
6682
6879
  return;
6683
6880
  }
6684
6881
  injectReportDialog(__assign(__assign({}, options), { dsn: options.dsn || this.getDsn() }));
@@ -6848,7 +7045,7 @@ var Sentry = (function (exports) {
6848
7045
  if (client) {
6849
7046
  return client.flush(timeout);
6850
7047
  }
6851
- logger.warn('Cannot flush events. No client defined.');
7048
+ IS_DEBUG_BUILD && logger.warn('Cannot flush events. No client defined.');
6852
7049
  return resolvedSyncPromise(false);
6853
7050
  }
6854
7051
  /**
@@ -6864,7 +7061,7 @@ var Sentry = (function (exports) {
6864
7061
  if (client) {
6865
7062
  return client.close(timeout);
6866
7063
  }
6867
- logger.warn('Cannot flush events and disable SDK. No client defined.');
7064
+ IS_DEBUG_BUILD && logger.warn('Cannot flush events and disable SDK. No client defined.');
6868
7065
  return resolvedSyncPromise(false);
6869
7066
  }
6870
7067
  /**
@@ -6889,7 +7086,7 @@ var Sentry = (function (exports) {
6889
7086
  var window = getGlobalObject();
6890
7087
  var document = window.document;
6891
7088
  if (typeof document === 'undefined') {
6892
- logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
7089
+ IS_DEBUG_BUILD && logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
6893
7090
  return;
6894
7091
  }
6895
7092
  var hub = getCurrentHub();