@sentry/browser 6.18.2 → 6.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +172 -181
  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 +198 -202
  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 +15 -13
  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.0 (b93e8d4) | 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,9 +616,13 @@ 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());
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;
625
+ }
628
626
 
629
627
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
630
628
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -1054,23 +1052,22 @@ var Sentry = (function (exports) {
1054
1052
  * @param key of object that's walked in current iteration
1055
1053
  * @param value object to be walked
1056
1054
  * @param depth Optional number indicating how deep should walking be performed
1055
+ * @param maxProperties Optional maximum number of properties/elements included in any single object/array
1057
1056
  * @param memo Optional Memo class handling decycling
1058
1057
  */
1059
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1060
- function walk(key, value, depth, memo) {
1058
+ function walk(key, value, depth, maxProperties, memo) {
1061
1059
  if (depth === void 0) { depth = +Infinity; }
1060
+ if (maxProperties === void 0) { maxProperties = +Infinity; }
1062
1061
  if (memo === void 0) { memo = memoBuilder(); }
1063
1062
  var _a = __read(memo, 2), memoize = _a[0], unmemoize = _a[1];
1064
1063
  // If we reach the maximum depth, serialize whatever is left
1065
1064
  if (depth === 0) {
1066
1065
  return serializeValue(value);
1067
1066
  }
1068
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
1069
1067
  // If value implements `toJSON` method, call it and return early
1070
1068
  if (value !== null && value !== undefined && typeof value.toJSON === 'function') {
1071
1069
  return value.toJSON();
1072
1070
  }
1073
- /* eslint-enable @typescript-eslint/no-unsafe-member-access */
1074
1071
  // `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
1075
1072
  // pass-through. If what comes back is a primitive (either because it's been stringified or because it was primitive
1076
1073
  // all along), we're done.
@@ -1087,15 +1084,21 @@ var Sentry = (function (exports) {
1087
1084
  if (memoize(value)) {
1088
1085
  return '[Circular ~]';
1089
1086
  }
1087
+ var propertyCount = 0;
1090
1088
  // Walk all keys of the source
1091
1089
  for (var innerKey in source) {
1092
1090
  // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
1093
1091
  if (!Object.prototype.hasOwnProperty.call(source, innerKey)) {
1094
1092
  continue;
1095
1093
  }
1094
+ if (propertyCount >= maxProperties) {
1095
+ acc[innerKey] = '[MaxProperties ~]';
1096
+ break;
1097
+ }
1098
+ propertyCount += 1;
1096
1099
  // Recursively walk through all the child nodes
1097
1100
  var innerValue = source[innerKey];
1098
- acc[innerKey] = walk(innerKey, innerValue, depth - 1, memo);
1101
+ acc[innerKey] = walk(innerKey, innerValue, depth - 1, maxProperties, memo);
1099
1102
  }
1100
1103
  // Once walked through all the branches, remove the parent from memo storage
1101
1104
  unmemoize(value);
@@ -1103,22 +1106,30 @@ var Sentry = (function (exports) {
1103
1106
  return acc;
1104
1107
  }
1105
1108
  /**
1106
- * normalize()
1109
+ * Recursively normalizes the given object.
1107
1110
  *
1108
1111
  * - Creates a copy to prevent original input mutation
1109
- * - Skip non-enumerablers
1110
- * - Calls `toJSON` if implemented
1112
+ * - Skips non-enumerable properties
1113
+ * - When stringifying, calls `toJSON` if implemented
1111
1114
  * - 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
1115
+ * - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format
1116
+ * - Translates known global objects/classes to a string representations
1117
+ * - Takes care of `Error` object serialization
1118
+ * - Optionally limits depth of final output
1119
+ * - Optionally limits number of properties/elements included in any single object/array
1120
+ *
1121
+ * @param input The object to be normalized.
1122
+ * @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)
1123
+ * @param maxProperties The max number of elements or properties to be included in any single array or
1124
+ * object in the normallized output..
1125
+ * @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
1116
1126
  */
1117
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1118
- function normalize(input, depth) {
1127
+ function normalize(input, depth, maxProperties) {
1128
+ if (depth === void 0) { depth = +Infinity; }
1129
+ if (maxProperties === void 0) { maxProperties = +Infinity; }
1119
1130
  try {
1120
1131
  // since we're at the outermost level, there is no key
1121
- return walk('', input, depth);
1132
+ return walk('', input, depth, maxProperties);
1122
1133
  }
1123
1134
  catch (_oO) {
1124
1135
  return '**non-serializable**';
@@ -1244,9 +1255,7 @@ var Sentry = (function (exports) {
1244
1255
  doc.head.removeChild(sandbox);
1245
1256
  }
1246
1257
  catch (err) {
1247
- if (isDebugBuild()) {
1248
- logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);
1249
- }
1258
+ logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);
1250
1259
  }
1251
1260
  }
1252
1261
  return result;
@@ -1338,6 +1347,7 @@ var Sentry = (function (exports) {
1338
1347
  break;
1339
1348
  default:
1340
1349
  logger.warn('unknown instrumentation type:', type);
1350
+ return;
1341
1351
  }
1342
1352
  }
1343
1353
  /**
@@ -1363,9 +1373,7 @@ var Sentry = (function (exports) {
1363
1373
  handler(data);
1364
1374
  }
1365
1375
  catch (e) {
1366
- if (isDebugBuild()) {
1367
- logger.error("Error while triggering instrumentation handler.\nType: " + type + "\nName: " + getFunctionName(handler) + "\nError:", e);
1368
- }
1376
+ logger.error("Error while triggering instrumentation handler.\nType: " + type + "\nName: " + getFunctionName(handler) + "\nError:", e);
1369
1377
  }
1370
1378
  }
1371
1379
  }
@@ -1382,7 +1390,7 @@ var Sentry = (function (exports) {
1382
1390
  if (!('console' in global$5)) {
1383
1391
  return;
1384
1392
  }
1385
- ['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) {
1393
+ CONSOLE_LEVELS.forEach(function (level) {
1386
1394
  if (!(level in global$5.console)) {
1387
1395
  return;
1388
1396
  }
@@ -2428,6 +2436,83 @@ var Sentry = (function (exports) {
2428
2436
  return headerDate - now;
2429
2437
  }
2430
2438
  return DEFAULT_RETRY_AFTER;
2439
+ }
2440
+ /**
2441
+ * Gets the time that given category is disabled until for rate limiting
2442
+ */
2443
+ function disabledUntil(limits, category) {
2444
+ return limits[category] || limits.all || 0;
2445
+ }
2446
+ /**
2447
+ * Checks if a category is rate limited
2448
+ */
2449
+ function isRateLimited(limits, category, now) {
2450
+ if (now === void 0) { now = Date.now(); }
2451
+ return disabledUntil(limits, category) > now;
2452
+ }
2453
+ /**
2454
+ * Update ratelimits from incoming headers.
2455
+ * Returns true if headers contains a non-empty rate limiting header.
2456
+ */
2457
+ function updateRateLimits(limits, headers, now) {
2458
+ var e_1, _a, e_2, _b;
2459
+ if (now === void 0) { now = Date.now(); }
2460
+ var updatedRateLimits = __assign({}, limits);
2461
+ // "The name is case-insensitive."
2462
+ // https://developer.mozilla.org/en-US/docs/Web/API/Headers/get
2463
+ var rateLimitHeader = headers['x-sentry-rate-limits'];
2464
+ var retryAfterHeader = headers['retry-after'];
2465
+ if (rateLimitHeader) {
2466
+ try {
2467
+ /**
2468
+ * rate limit headers are of the form
2469
+ * <header>,<header>,..
2470
+ * where each <header> is of the form
2471
+ * <retry_after>: <categories>: <scope>: <reason_code>
2472
+ * where
2473
+ * <retry_after> is a delay in seconds
2474
+ * <categories> is the event type(s) (error, transaction, etc) being rate limited and is of the form
2475
+ * <category>;<category>;...
2476
+ * <scope> is what's being limited (org, project, or key) - ignored by SDK
2477
+ * <reason_code> is an arbitrary string like "org_quota" - ignored by SDK
2478
+ */
2479
+ for (var _c = __values(rateLimitHeader.trim().split(',')), _d = _c.next(); !_d.done; _d = _c.next()) {
2480
+ var limit = _d.value;
2481
+ var parameters = limit.split(':', 2);
2482
+ var headerDelay = parseInt(parameters[0], 10);
2483
+ var delay = (!isNaN(headerDelay) ? headerDelay : 60) * 1000; // 60sec default
2484
+ if (!parameters[1]) {
2485
+ updatedRateLimits.all = now + delay;
2486
+ }
2487
+ else {
2488
+ try {
2489
+ for (var _e = (e_2 = void 0, __values(parameters[1].split(';'))), _f = _e.next(); !_f.done; _f = _e.next()) {
2490
+ var category = _f.value;
2491
+ updatedRateLimits[category] = now + delay;
2492
+ }
2493
+ }
2494
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2495
+ finally {
2496
+ try {
2497
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
2498
+ }
2499
+ finally { if (e_2) throw e_2.error; }
2500
+ }
2501
+ }
2502
+ }
2503
+ }
2504
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2505
+ finally {
2506
+ try {
2507
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2508
+ }
2509
+ finally { if (e_1) throw e_1.error; }
2510
+ }
2511
+ }
2512
+ else if (retryAfterHeader) {
2513
+ updatedRateLimits.all = now + parseRetryAfterHeader(retryAfterHeader, now);
2514
+ }
2515
+ return updatedRateLimits;
2431
2516
  }
2432
2517
 
2433
2518
  /**
@@ -3487,13 +3572,7 @@ var Sentry = (function (exports) {
3487
3572
  */
3488
3573
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3489
3574
  function captureException(exception, captureContext) {
3490
- var syntheticException;
3491
- try {
3492
- throw new Error('Sentry syntheticException');
3493
- }
3494
- catch (exception) {
3495
- syntheticException = exception;
3496
- }
3575
+ var syntheticException = new Error('Sentry syntheticException');
3497
3576
  return callOnHub('captureException', exception, {
3498
3577
  captureContext: captureContext,
3499
3578
  originalException: exception,
@@ -3508,13 +3587,7 @@ var Sentry = (function (exports) {
3508
3587
  * @returns The generated eventId.
3509
3588
  */
3510
3589
  function captureMessage(message, captureContext) {
3511
- var syntheticException;
3512
- try {
3513
- throw new Error(message);
3514
- }
3515
- catch (exception) {
3516
- syntheticException = exception;
3517
- }
3590
+ var syntheticException = new Error(message);
3518
3591
  // This is necessary to provide explicit scopes upgrade, without changing the original
3519
3592
  // arity of the `captureMessage(message, level)` method.
3520
3593
  var level = typeof captureContext === 'string' ? captureContext : undefined;
@@ -3885,15 +3958,11 @@ var Sentry = (function (exports) {
3885
3958
  */
3886
3959
  BaseClient.prototype.captureSession = function (session) {
3887
3960
  if (!this._isEnabled()) {
3888
- if (isDebugBuild()) {
3889
- logger.warn('SDK not enabled, will not capture session.');
3890
- }
3961
+ logger.warn('SDK not enabled, will not capture session.');
3891
3962
  return;
3892
3963
  }
3893
3964
  if (!(typeof session.release === 'string')) {
3894
- if (isDebugBuild()) {
3895
- logger.warn('Discarded session because of missing or non-string release');
3896
- }
3965
+ logger.warn('Discarded session because of missing or non-string release');
3897
3966
  }
3898
3967
  else {
3899
3968
  this._sendSession(session);
@@ -4054,7 +4123,7 @@ var Sentry = (function (exports) {
4054
4123
  */
4055
4124
  BaseClient.prototype._prepareEvent = function (event, scope, hint) {
4056
4125
  var _this = this;
4057
- var _a = this.getOptions().normalizeDepth, normalizeDepth = _a === void 0 ? 3 : _a;
4126
+ var _a = this.getOptions(), _b = _a.normalizeDepth, normalizeDepth = _b === void 0 ? 3 : _b, _c = _a.normalizeMaxBreadth, normalizeMaxBreadth = _c === void 0 ? 1000 : _c;
4058
4127
  var prepared = __assign(__assign({}, event), { event_id: event.event_id || (hint && hint.event_id ? hint.event_id : uuid4()), timestamp: event.timestamp || dateTimestampInSeconds() });
4059
4128
  this._applyClientOptions(prepared);
4060
4129
  this._applyIntegrationsMetadata(prepared);
@@ -4079,7 +4148,7 @@ var Sentry = (function (exports) {
4079
4148
  evt.sdkProcessingMetadata = __assign(__assign({}, evt.sdkProcessingMetadata), { normalizeDepth: normalize(normalizeDepth) });
4080
4149
  }
4081
4150
  if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
4082
- return _this._normalizeEvent(evt, normalizeDepth);
4151
+ return _this._normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
4083
4152
  }
4084
4153
  return evt;
4085
4154
  });
@@ -4094,20 +4163,20 @@ var Sentry = (function (exports) {
4094
4163
  * @param event Event
4095
4164
  * @returns Normalized event
4096
4165
  */
4097
- BaseClient.prototype._normalizeEvent = function (event, depth) {
4166
+ BaseClient.prototype._normalizeEvent = function (event, depth, maxBreadth) {
4098
4167
  if (!event) {
4099
4168
  return null;
4100
4169
  }
4101
4170
  var normalized = __assign(__assign(__assign(__assign(__assign({}, event), (event.breadcrumbs && {
4102
4171
  breadcrumbs: event.breadcrumbs.map(function (b) { return (__assign(__assign({}, b), (b.data && {
4103
- data: normalize(b.data, depth),
4172
+ data: normalize(b.data, depth, maxBreadth),
4104
4173
  }))); }),
4105
4174
  })), (event.user && {
4106
- user: normalize(event.user, depth),
4175
+ user: normalize(event.user, depth, maxBreadth),
4107
4176
  })), (event.contexts && {
4108
- contexts: normalize(event.contexts, depth),
4177
+ contexts: normalize(event.contexts, depth, maxBreadth),
4109
4178
  })), (event.extra && {
4110
- extra: normalize(event.extra, depth),
4179
+ extra: normalize(event.extra, depth, maxBreadth),
4111
4180
  }));
4112
4181
  // event.contexts.trace stores information about a Transaction. Similarly,
4113
4182
  // event.spans[] stores information about child Spans. Given that a
@@ -4347,9 +4416,7 @@ var Sentry = (function (exports) {
4347
4416
  */
4348
4417
  BaseBackend.prototype.sendEvent = function (event) {
4349
4418
  void this._transport.sendEvent(event).then(null, function (reason) {
4350
- if (isDebugBuild()) {
4351
- logger.error('Error while sending event:', reason);
4352
- }
4419
+ logger.error('Error while sending event:', reason);
4353
4420
  });
4354
4421
  };
4355
4422
  /**
@@ -4357,15 +4424,11 @@ var Sentry = (function (exports) {
4357
4424
  */
4358
4425
  BaseBackend.prototype.sendSession = function (session) {
4359
4426
  if (!this._transport.sendSession) {
4360
- if (isDebugBuild()) {
4361
- logger.warn("Dropping session because custom transport doesn't implement sendSession");
4362
- }
4427
+ logger.warn("Dropping session because custom transport doesn't implement sendSession");
4363
4428
  return;
4364
4429
  }
4365
4430
  void this._transport.sendSession(session).then(null, function (reason) {
4366
- if (isDebugBuild()) {
4367
- logger.error('Error while sending session:', reason);
4368
- }
4431
+ logger.error('Error while sending session:', reason);
4369
4432
  });
4370
4433
  };
4371
4434
  /**
@@ -4517,7 +4580,9 @@ var Sentry = (function (exports) {
4517
4580
  */
4518
4581
  function initAndBind(clientClass, options) {
4519
4582
  if (options.debug === true) {
4520
- logger.enable();
4583
+ {
4584
+ logger.enable();
4585
+ }
4521
4586
  }
4522
4587
  var hub = getCurrentHub();
4523
4588
  var scope = hub.getScope();
@@ -4528,7 +4593,7 @@ var Sentry = (function (exports) {
4528
4593
  hub.bindClient(client);
4529
4594
  }
4530
4595
 
4531
- var SDK_VERSION = '6.18.2';
4596
+ var SDK_VERSION = '6.19.0';
4532
4597
 
4533
4598
  var originalFunctionToString;
4534
4599
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4605,27 +4670,19 @@ var Sentry = (function (exports) {
4605
4670
  /** JSDoc */
4606
4671
  InboundFilters.prototype._shouldDropEvent = function (event, options) {
4607
4672
  if (this._isSentryError(event, options)) {
4608
- if (isDebugBuild()) {
4609
- logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + getEventDescription(event));
4610
- }
4673
+ logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + getEventDescription(event));
4611
4674
  return true;
4612
4675
  }
4613
4676
  if (this._isIgnoredError(event, options)) {
4614
- if (isDebugBuild()) {
4615
- logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + getEventDescription(event));
4616
- }
4677
+ logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + getEventDescription(event));
4617
4678
  return true;
4618
4679
  }
4619
4680
  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
- }
4681
+ logger.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + this._getEventFilterUrl(event));
4623
4682
  return true;
4624
4683
  }
4625
4684
  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
- }
4685
+ logger.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + this._getEventFilterUrl(event));
4629
4686
  return true;
4630
4687
  }
4631
4688
  return false;
@@ -4694,9 +4751,7 @@ var Sentry = (function (exports) {
4694
4751
  return ["" + value, type + ": " + value];
4695
4752
  }
4696
4753
  catch (oO) {
4697
- if (isDebugBuild()) {
4698
- logger.error("Cannot extract message for event " + getEventDescription(event));
4699
- }
4754
+ logger.error("Cannot extract message for event " + getEventDescription(event));
4700
4755
  return [];
4701
4756
  }
4702
4757
  }
@@ -4730,9 +4785,7 @@ var Sentry = (function (exports) {
4730
4785
  return frames_1 ? this._getLastValidUrl(frames_1) : null;
4731
4786
  }
4732
4787
  catch (oO) {
4733
- if (isDebugBuild()) {
4734
- logger.error("Cannot extract url for event " + getEventDescription(event));
4735
- }
4788
+ logger.error("Cannot extract url for event " + getEventDescription(event));
4736
4789
  return null;
4737
4790
  }
4738
4791
  };
@@ -5144,9 +5197,7 @@ var Sentry = (function (exports) {
5144
5197
  document.head.removeChild(sandbox);
5145
5198
  }
5146
5199
  catch (e) {
5147
- if (isDebugBuild()) {
5148
- logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
5149
- }
5200
+ logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
5150
5201
  }
5151
5202
  }
5152
5203
  return (cachedFetchImpl = fetchImpl.bind(global$4));
@@ -5277,13 +5328,11 @@ var Sentry = (function (exports) {
5277
5328
  BaseTransport.prototype._handleResponse = function (_a) {
5278
5329
  var requestType = _a.requestType, response = _a.response, headers = _a.headers, resolve = _a.resolve, reject = _a.reject;
5279
5330
  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));
5331
+ this._rateLimits = updateRateLimits(this._rateLimits, headers);
5332
+ // eslint-disable-next-line deprecation/deprecation
5333
+ if (this._isRateLimited(requestType) && isDebugBuild()) {
5334
+ // eslint-disable-next-line deprecation/deprecation
5335
+ logger.warn("Too many " + requestType + " requests, backing off until: " + this._disabledUntil(requestType));
5287
5336
  }
5288
5337
  if (status === 'success') {
5289
5338
  resolve({ status: status });
@@ -5293,71 +5342,21 @@ var Sentry = (function (exports) {
5293
5342
  };
5294
5343
  /**
5295
5344
  * Gets the time that given category is disabled until for rate limiting
5345
+ *
5346
+ * @deprecated Please use `disabledUntil` from @sentry/utils
5296
5347
  */
5297
5348
  BaseTransport.prototype._disabledUntil = function (requestType) {
5298
5349
  var category = requestTypeToCategory(requestType);
5299
- return this._rateLimits[category] || this._rateLimits.all;
5350
+ return new Date(disabledUntil(this._rateLimits, category));
5300
5351
  };
5301
5352
  /**
5302
5353
  * Checks if a category is rate limited
5354
+ *
5355
+ * @deprecated Please use `isRateLimited` from @sentry/utils
5303
5356
  */
5304
5357
  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;
5358
+ var category = requestTypeToCategory(requestType);
5359
+ return isRateLimited(this._rateLimits, category);
5361
5360
  };
5362
5361
  return BaseTransport;
5363
5362
  }());
@@ -5377,11 +5376,13 @@ var Sentry = (function (exports) {
5377
5376
  */
5378
5377
  FetchTransport.prototype._sendRequest = function (sentryRequest, originalPayload) {
5379
5378
  var _this = this;
5379
+ // eslint-disable-next-line deprecation/deprecation
5380
5380
  if (this._isRateLimited(sentryRequest.type)) {
5381
5381
  this.recordLostEvent('ratelimit_backoff', sentryRequest.type);
5382
5382
  return Promise.reject({
5383
5383
  event: originalPayload,
5384
5384
  type: sentryRequest.type,
5385
+ // eslint-disable-next-line deprecation/deprecation
5385
5386
  reason: "Transport for " + sentryRequest.type + " requests locked till " + this._disabledUntil(sentryRequest.type) + " due to too many requests.",
5386
5387
  status: 429,
5387
5388
  });
@@ -5447,11 +5448,13 @@ var Sentry = (function (exports) {
5447
5448
  */
5448
5449
  XHRTransport.prototype._sendRequest = function (sentryRequest, originalPayload) {
5449
5450
  var _this = this;
5451
+ // eslint-disable-next-line deprecation/deprecation
5450
5452
  if (this._isRateLimited(sentryRequest.type)) {
5451
5453
  this.recordLostEvent('ratelimit_backoff', sentryRequest.type);
5452
5454
  return Promise.reject({
5453
5455
  event: originalPayload,
5454
5456
  type: sentryRequest.type,
5457
+ // eslint-disable-next-line deprecation/deprecation
5455
5458
  reason: "Transport for " + sentryRequest.type + " requests locked till " + this._disabledUntil(sentryRequest.type) + " due to too many requests.",
5456
5459
  status: 429,
5457
5460
  });
@@ -5668,15 +5671,11 @@ var Sentry = (function (exports) {
5668
5671
  return;
5669
5672
  }
5670
5673
  if (!options.eventId) {
5671
- if (isDebugBuild()) {
5672
- logger.error('Missing eventId option in showReportDialog call');
5673
- }
5674
+ logger.error('Missing eventId option in showReportDialog call');
5674
5675
  return;
5675
5676
  }
5676
5677
  if (!options.dsn) {
5677
- if (isDebugBuild()) {
5678
- logger.error('Missing dsn option in showReportDialog call');
5679
- }
5678
+ logger.error('Missing dsn option in showReportDialog call');
5680
5679
  return;
5681
5680
  }
5682
5681
  var script = global$2.document.createElement('script');
@@ -5868,9 +5867,7 @@ var Sentry = (function (exports) {
5868
5867
  return event;
5869
5868
  }
5870
5869
  function globalHandlerLog(type) {
5871
- if (isDebugBuild()) {
5872
- logger.log("Global Handler attached: " + type);
5873
- }
5870
+ logger.log("Global Handler attached: " + type);
5874
5871
  }
5875
5872
  function addMechanismAndCapture(hub, error, event, type) {
5876
5873
  addExceptionMechanism(event, {
@@ -5986,16 +5983,18 @@ var Sentry = (function (exports) {
5986
5983
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5987
5984
  return function (callback) {
5988
5985
  // 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),
5986
+ return original.apply(this, [
5987
+ wrap$1(callback, {
5988
+ mechanism: {
5989
+ data: {
5990
+ function: 'requestAnimationFrame',
5991
+ handler: getFunctionName(original),
5992
+ },
5993
+ handled: true,
5994
+ type: 'instrument',
5994
5995
  },
5995
- handled: true,
5996
- type: 'instrument',
5997
- },
5998
- }));
5996
+ }),
5997
+ ]);
5999
5998
  };
6000
5999
  }
6001
6000
  /** JSDoc */
@@ -6066,19 +6065,22 @@ var Sentry = (function (exports) {
6066
6065
  catch (err) {
6067
6066
  // can sometimes get 'Permission denied to access property "handle Event'
6068
6067
  }
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,
6068
+ return original.apply(this, [
6069
+ 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,
6077
+ },
6078
+ handled: true,
6079
+ type: 'instrument',
6077
6080
  },
6078
- handled: true,
6079
- type: 'instrument',
6080
- },
6081
- }), options);
6081
+ }),
6082
+ options,
6083
+ ]);
6082
6084
  };
6083
6085
  });
6084
6086
  fill(proto, 'removeEventListener', function (originalRemoveEventListener) {
@@ -6814,9 +6816,7 @@ var Sentry = (function (exports) {
6814
6816
  if (client) {
6815
6817
  return client.flush(timeout);
6816
6818
  }
6817
- if (isDebugBuild()) {
6818
- logger.warn('Cannot flush events. No client defined.');
6819
- }
6819
+ logger.warn('Cannot flush events. No client defined.');
6820
6820
  return resolvedSyncPromise(false);
6821
6821
  }
6822
6822
  /**
@@ -6832,9 +6832,7 @@ var Sentry = (function (exports) {
6832
6832
  if (client) {
6833
6833
  return client.close(timeout);
6834
6834
  }
6835
- if (isDebugBuild()) {
6836
- logger.warn('Cannot flush events and disable SDK. No client defined.');
6837
- }
6835
+ logger.warn('Cannot flush events and disable SDK. No client defined.');
6838
6836
  return resolvedSyncPromise(false);
6839
6837
  }
6840
6838
  /**
@@ -6859,9 +6857,7 @@ var Sentry = (function (exports) {
6859
6857
  var window = getGlobalObject();
6860
6858
  var document = window.document;
6861
6859
  if (typeof document === 'undefined') {
6862
- if (isDebugBuild()) {
6863
- logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
6864
- }
6860
+ logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
6865
6861
  return;
6866
6862
  }
6867
6863
  var hub = getCurrentHub();