@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
  /**
@@ -36,14 +36,11 @@ var Sentry = (function (exports) {
36
36
  }
37
37
 
38
38
  /**
39
- * This module mostly exists for optimizations in the build process
40
- * through rollup and terser. We define some global constants which
41
- * are normally undefined. However terser overrides these with global
42
- * definitions which can be evaluated by the static analyzer when
43
- * creating a bundle.
44
- *
45
- * In turn the `isDebugBuild` and `isBrowserBundle` functions are pure
46
- * and can help us remove unused code from the bundles.
39
+ * This module exists for optimizations in the build process through rollup and terser. We define some global
40
+ * constants, which can be overridden during build. By guarding certain pieces of code with functions that return these
41
+ * constants, we can control whether or not they appear in the final bundle. (Any code guarded by a false condition will
42
+ * never run, and will hence be dropped during treeshaking.) The two primary uses for this are stripping out calls to
43
+ * `logger` and preventing node-related code from appearing in browser bundles.
47
44
  */
48
45
  /**
49
46
  * Figures out if we're building with debug functionality.
@@ -51,7 +48,7 @@ var Sentry = (function (exports) {
51
48
  * @returns true if this is a debug build
52
49
  */
53
50
  function isDebugBuild() {
54
- return typeof __SENTRY_NO_DEBUG__ !== 'undefined' && !true;
51
+ return true;
55
52
  }
56
53
 
57
54
  /**
@@ -415,9 +412,6 @@ var Sentry = (function (exports) {
415
412
  };
416
413
  }
417
414
  function validateDsn(dsn) {
418
- if (!isDebugBuild()) {
419
- return;
420
- }
421
415
  const { port, projectId, protocol } = dsn;
422
416
  const requiredComponents = ['protocol', 'publicKey', 'host', 'projectId'];
423
417
  requiredComponents.forEach(component => {
@@ -449,6 +443,7 @@ var Sentry = (function (exports) {
449
443
  const global$6 = getGlobalObject();
450
444
  /** Prefix for logging strings */
451
445
  const PREFIX = 'Sentry Logger ';
446
+ const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert'];
452
447
  /**
453
448
  * Temporarily unwrap `console.log` and friends in order to perform the given callback using the original methods.
454
449
  * Restores wrapping after the callback completes.
@@ -458,7 +453,6 @@ var Sentry = (function (exports) {
458
453
  */
459
454
  function consoleSandbox(callback) {
460
455
  const global = getGlobalObject();
461
- const levels = ['debug', 'info', 'warn', 'error', 'log', 'assert'];
462
456
  if (!('console' in global)) {
463
457
  return callback();
464
458
  }
@@ -466,7 +460,7 @@ var Sentry = (function (exports) {
466
460
  const originalConsole = global.console;
467
461
  const wrappedLevels = {};
468
462
  // Restore all wrapped console methods
469
- levels.forEach(level => {
463
+ CONSOLE_LEVELS.forEach(level => {
470
464
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
471
465
  if (level in global.console && originalConsole[level].__sentry_original__) {
472
466
  wrappedLevels[level] = originalConsole[level];
@@ -523,9 +517,13 @@ var Sentry = (function (exports) {
523
517
  });
524
518
  }
525
519
  }
526
- // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
527
- global$6.__SENTRY__ = global$6.__SENTRY__ || {};
528
- const logger = global$6.__SENTRY__.logger || (global$6.__SENTRY__.logger = new Logger());
520
+ const sentryGlobal = global$6.__SENTRY__ || {};
521
+ const logger = sentryGlobal.logger || new Logger();
522
+ {
523
+ // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
524
+ sentryGlobal.logger = logger;
525
+ global$6.__SENTRY__ = sentryGlobal;
526
+ }
529
527
 
530
528
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
531
529
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -926,21 +924,19 @@ var Sentry = (function (exports) {
926
924
  * @param key of object that's walked in current iteration
927
925
  * @param value object to be walked
928
926
  * @param depth Optional number indicating how deep should walking be performed
927
+ * @param maxProperties Optional maximum number of properties/elements included in any single object/array
929
928
  * @param memo Optional Memo class handling decycling
930
929
  */
931
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
932
- function walk(key, value, depth = +Infinity, memo = memoBuilder()) {
930
+ function walk(key, value, depth = +Infinity, maxProperties = +Infinity, memo = memoBuilder()) {
933
931
  const [memoize, unmemoize] = memo;
934
932
  // If we reach the maximum depth, serialize whatever is left
935
933
  if (depth === 0) {
936
934
  return serializeValue(value);
937
935
  }
938
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
939
936
  // If value implements `toJSON` method, call it and return early
940
937
  if (value !== null && value !== undefined && typeof value.toJSON === 'function') {
941
938
  return value.toJSON();
942
939
  }
943
- /* eslint-enable @typescript-eslint/no-unsafe-member-access */
944
940
  // `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
945
941
  // pass-through. If what comes back is a primitive (either because it's been stringified or because it was primitive
946
942
  // all along), we're done.
@@ -957,15 +953,21 @@ var Sentry = (function (exports) {
957
953
  if (memoize(value)) {
958
954
  return '[Circular ~]';
959
955
  }
956
+ let propertyCount = 0;
960
957
  // Walk all keys of the source
961
958
  for (const innerKey in source) {
962
959
  // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
963
960
  if (!Object.prototype.hasOwnProperty.call(source, innerKey)) {
964
961
  continue;
965
962
  }
963
+ if (propertyCount >= maxProperties) {
964
+ acc[innerKey] = '[MaxProperties ~]';
965
+ break;
966
+ }
967
+ propertyCount += 1;
966
968
  // Recursively walk through all the child nodes
967
969
  const innerValue = source[innerKey];
968
- acc[innerKey] = walk(innerKey, innerValue, depth - 1, memo);
970
+ acc[innerKey] = walk(innerKey, innerValue, depth - 1, maxProperties, memo);
969
971
  }
970
972
  // Once walked through all the branches, remove the parent from memo storage
971
973
  unmemoize(value);
@@ -973,22 +975,28 @@ var Sentry = (function (exports) {
973
975
  return acc;
974
976
  }
975
977
  /**
976
- * normalize()
978
+ * Recursively normalizes the given object.
977
979
  *
978
980
  * - Creates a copy to prevent original input mutation
979
- * - Skip non-enumerablers
980
- * - Calls `toJSON` if implemented
981
+ * - Skips non-enumerable properties
982
+ * - When stringifying, calls `toJSON` if implemented
981
983
  * - Removes circular references
982
- * - Translates non-serializeable values (undefined/NaN/Functions) to serializable format
983
- * - Translates known global objects/Classes to a string representations
984
- * - Takes care of Error objects serialization
985
- * - Optionally limit depth of final output
984
+ * - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format
985
+ * - Translates known global objects/classes to a string representations
986
+ * - Takes care of `Error` object serialization
987
+ * - Optionally limits depth of final output
988
+ * - Optionally limits number of properties/elements included in any single object/array
989
+ *
990
+ * @param input The object to be normalized.
991
+ * @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)
992
+ * @param maxProperties The max number of elements or properties to be included in any single array or
993
+ * object in the normallized output..
994
+ * @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
986
995
  */
987
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
988
- function normalize(input, depth) {
996
+ function normalize(input, depth = +Infinity, maxProperties = +Infinity) {
989
997
  try {
990
998
  // since we're at the outermost level, there is no key
991
- return walk('', input, depth);
999
+ return walk('', input, depth, maxProperties);
992
1000
  }
993
1001
  catch (_oO) {
994
1002
  return '**non-serializable**';
@@ -1102,9 +1110,7 @@ var Sentry = (function (exports) {
1102
1110
  doc.head.removeChild(sandbox);
1103
1111
  }
1104
1112
  catch (err) {
1105
- if (isDebugBuild()) {
1106
- logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);
1107
- }
1113
+ logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);
1108
1114
  }
1109
1115
  }
1110
1116
  return result;
@@ -1196,6 +1202,7 @@ var Sentry = (function (exports) {
1196
1202
  break;
1197
1203
  default:
1198
1204
  logger.warn('unknown instrumentation type:', type);
1205
+ return;
1199
1206
  }
1200
1207
  }
1201
1208
  /**
@@ -1218,9 +1225,7 @@ var Sentry = (function (exports) {
1218
1225
  handler(data);
1219
1226
  }
1220
1227
  catch (e) {
1221
- if (isDebugBuild()) {
1222
- logger.error(`Error while triggering instrumentation handler.\nType: ${type}\nName: ${getFunctionName(handler)}\nError:`, e);
1223
- }
1228
+ logger.error(`Error while triggering instrumentation handler.\nType: ${type}\nName: ${getFunctionName(handler)}\nError:`, e);
1224
1229
  }
1225
1230
  }
1226
1231
  }
@@ -1229,7 +1234,7 @@ var Sentry = (function (exports) {
1229
1234
  if (!('console' in global$5)) {
1230
1235
  return;
1231
1236
  }
1232
- ['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) {
1237
+ CONSOLE_LEVELS.forEach(function (level) {
1233
1238
  if (!(level in global$5.console)) {
1234
1239
  return;
1235
1240
  }
@@ -2236,6 +2241,60 @@ var Sentry = (function (exports) {
2236
2241
  return headerDate - now;
2237
2242
  }
2238
2243
  return DEFAULT_RETRY_AFTER;
2244
+ }
2245
+ /**
2246
+ * Gets the time that given category is disabled until for rate limiting
2247
+ */
2248
+ function disabledUntil(limits, category) {
2249
+ return limits[category] || limits.all || 0;
2250
+ }
2251
+ /**
2252
+ * Checks if a category is rate limited
2253
+ */
2254
+ function isRateLimited(limits, category, now = Date.now()) {
2255
+ return disabledUntil(limits, category) > now;
2256
+ }
2257
+ /**
2258
+ * Update ratelimits from incoming headers.
2259
+ * Returns true if headers contains a non-empty rate limiting header.
2260
+ */
2261
+ function updateRateLimits(limits, headers, now = Date.now()) {
2262
+ const updatedRateLimits = Object.assign({}, limits);
2263
+ // "The name is case-insensitive."
2264
+ // https://developer.mozilla.org/en-US/docs/Web/API/Headers/get
2265
+ const rateLimitHeader = headers['x-sentry-rate-limits'];
2266
+ const retryAfterHeader = headers['retry-after'];
2267
+ if (rateLimitHeader) {
2268
+ /**
2269
+ * rate limit headers are of the form
2270
+ * <header>,<header>,..
2271
+ * where each <header> is of the form
2272
+ * <retry_after>: <categories>: <scope>: <reason_code>
2273
+ * where
2274
+ * <retry_after> is a delay in seconds
2275
+ * <categories> is the event type(s) (error, transaction, etc) being rate limited and is of the form
2276
+ * <category>;<category>;...
2277
+ * <scope> is what's being limited (org, project, or key) - ignored by SDK
2278
+ * <reason_code> is an arbitrary string like "org_quota" - ignored by SDK
2279
+ */
2280
+ for (const limit of rateLimitHeader.trim().split(',')) {
2281
+ const parameters = limit.split(':', 2);
2282
+ const headerDelay = parseInt(parameters[0], 10);
2283
+ const delay = (!isNaN(headerDelay) ? headerDelay : 60) * 1000; // 60sec default
2284
+ if (!parameters[1]) {
2285
+ updatedRateLimits.all = now + delay;
2286
+ }
2287
+ else {
2288
+ for (const category of parameters[1].split(';')) {
2289
+ updatedRateLimits[category] = now + delay;
2290
+ }
2291
+ }
2292
+ }
2293
+ }
2294
+ else if (retryAfterHeader) {
2295
+ updatedRateLimits.all = now + parseRetryAfterHeader(retryAfterHeader, now);
2296
+ }
2297
+ return updatedRateLimits;
2239
2298
  }
2240
2299
 
2241
2300
  /**
@@ -3269,13 +3328,7 @@ var Sentry = (function (exports) {
3269
3328
  */
3270
3329
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3271
3330
  function captureException(exception, captureContext) {
3272
- let syntheticException;
3273
- try {
3274
- throw new Error('Sentry syntheticException');
3275
- }
3276
- catch (exception) {
3277
- syntheticException = exception;
3278
- }
3331
+ const syntheticException = new Error('Sentry syntheticException');
3279
3332
  return callOnHub('captureException', exception, {
3280
3333
  captureContext,
3281
3334
  originalException: exception,
@@ -3290,13 +3343,7 @@ var Sentry = (function (exports) {
3290
3343
  * @returns The generated eventId.
3291
3344
  */
3292
3345
  function captureMessage(message, captureContext) {
3293
- let syntheticException;
3294
- try {
3295
- throw new Error(message);
3296
- }
3297
- catch (exception) {
3298
- syntheticException = exception;
3299
- }
3346
+ const syntheticException = new Error(message);
3300
3347
  // This is necessary to provide explicit scopes upgrade, without changing the original
3301
3348
  // arity of the `captureMessage(message, level)` method.
3302
3349
  const level = typeof captureContext === 'string' ? captureContext : undefined;
@@ -3668,15 +3715,11 @@ var Sentry = (function (exports) {
3668
3715
  */
3669
3716
  captureSession(session) {
3670
3717
  if (!this._isEnabled()) {
3671
- if (isDebugBuild()) {
3672
- logger.warn('SDK not enabled, will not capture session.');
3673
- }
3718
+ logger.warn('SDK not enabled, will not capture session.');
3674
3719
  return;
3675
3720
  }
3676
3721
  if (!(typeof session.release === 'string')) {
3677
- if (isDebugBuild()) {
3678
- logger.warn('Discarded session because of missing or non-string release');
3679
- }
3722
+ logger.warn('Discarded session because of missing or non-string release');
3680
3723
  }
3681
3724
  else {
3682
3725
  this._sendSession(session);
@@ -3822,7 +3865,7 @@ var Sentry = (function (exports) {
3822
3865
  * @returns A new event with more information.
3823
3866
  */
3824
3867
  _prepareEvent(event, scope, hint) {
3825
- const { normalizeDepth = 3 } = this.getOptions();
3868
+ const { normalizeDepth = 3, normalizeMaxBreadth = 1000 } = this.getOptions();
3826
3869
  const prepared = Object.assign(Object.assign({}, event), { event_id: event.event_id || (hint && hint.event_id ? hint.event_id : uuid4()), timestamp: event.timestamp || dateTimestampInSeconds() });
3827
3870
  this._applyClientOptions(prepared);
3828
3871
  this._applyIntegrationsMetadata(prepared);
@@ -3847,7 +3890,7 @@ var Sentry = (function (exports) {
3847
3890
  evt.sdkProcessingMetadata = Object.assign(Object.assign({}, evt.sdkProcessingMetadata), { normalizeDepth: normalize(normalizeDepth) });
3848
3891
  }
3849
3892
  if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
3850
- return this._normalizeEvent(evt, normalizeDepth);
3893
+ return this._normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
3851
3894
  }
3852
3895
  return evt;
3853
3896
  });
@@ -3862,20 +3905,20 @@ var Sentry = (function (exports) {
3862
3905
  * @param event Event
3863
3906
  * @returns Normalized event
3864
3907
  */
3865
- _normalizeEvent(event, depth) {
3908
+ _normalizeEvent(event, depth, maxBreadth) {
3866
3909
  if (!event) {
3867
3910
  return null;
3868
3911
  }
3869
3912
  const normalized = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, event), (event.breadcrumbs && {
3870
3913
  breadcrumbs: event.breadcrumbs.map(b => (Object.assign(Object.assign({}, b), (b.data && {
3871
- data: normalize(b.data, depth),
3914
+ data: normalize(b.data, depth, maxBreadth),
3872
3915
  })))),
3873
3916
  })), (event.user && {
3874
- user: normalize(event.user, depth),
3917
+ user: normalize(event.user, depth, maxBreadth),
3875
3918
  })), (event.contexts && {
3876
- contexts: normalize(event.contexts, depth),
3919
+ contexts: normalize(event.contexts, depth, maxBreadth),
3877
3920
  })), (event.extra && {
3878
- extra: normalize(event.extra, depth),
3921
+ extra: normalize(event.extra, depth, maxBreadth),
3879
3922
  }));
3880
3923
  // event.contexts.trace stores information about a Transaction. Similarly,
3881
3924
  // event.spans[] stores information about child Spans. Given that a
@@ -4109,9 +4152,7 @@ var Sentry = (function (exports) {
4109
4152
  */
4110
4153
  sendEvent(event) {
4111
4154
  void this._transport.sendEvent(event).then(null, reason => {
4112
- if (isDebugBuild()) {
4113
- logger.error('Error while sending event:', reason);
4114
- }
4155
+ logger.error('Error while sending event:', reason);
4115
4156
  });
4116
4157
  }
4117
4158
  /**
@@ -4119,15 +4160,11 @@ var Sentry = (function (exports) {
4119
4160
  */
4120
4161
  sendSession(session) {
4121
4162
  if (!this._transport.sendSession) {
4122
- if (isDebugBuild()) {
4123
- logger.warn("Dropping session because custom transport doesn't implement sendSession");
4124
- }
4163
+ logger.warn("Dropping session because custom transport doesn't implement sendSession");
4125
4164
  return;
4126
4165
  }
4127
4166
  void this._transport.sendSession(session).then(null, reason => {
4128
- if (isDebugBuild()) {
4129
- logger.error('Error while sending session:', reason);
4130
- }
4167
+ logger.error('Error while sending session:', reason);
4131
4168
  });
4132
4169
  }
4133
4170
  /**
@@ -4278,7 +4315,9 @@ var Sentry = (function (exports) {
4278
4315
  */
4279
4316
  function initAndBind(clientClass, options) {
4280
4317
  if (options.debug === true) {
4281
- logger.enable();
4318
+ {
4319
+ logger.enable();
4320
+ }
4282
4321
  }
4283
4322
  const hub = getCurrentHub();
4284
4323
  const scope = hub.getScope();
@@ -4289,7 +4328,7 @@ var Sentry = (function (exports) {
4289
4328
  hub.bindClient(client);
4290
4329
  }
4291
4330
 
4292
- const SDK_VERSION = '6.18.2';
4331
+ const SDK_VERSION = '6.19.0';
4293
4332
 
4294
4333
  let originalFunctionToString;
4295
4334
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4360,27 +4399,19 @@ var Sentry = (function (exports) {
4360
4399
  /** JSDoc */
4361
4400
  _shouldDropEvent(event, options) {
4362
4401
  if (this._isSentryError(event, options)) {
4363
- if (isDebugBuild()) {
4364
- logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${getEventDescription(event)}`);
4365
- }
4402
+ logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${getEventDescription(event)}`);
4366
4403
  return true;
4367
4404
  }
4368
4405
  if (this._isIgnoredError(event, options)) {
4369
- if (isDebugBuild()) {
4370
- logger.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${getEventDescription(event)}`);
4371
- }
4406
+ logger.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${getEventDescription(event)}`);
4372
4407
  return true;
4373
4408
  }
4374
4409
  if (this._isDeniedUrl(event, options)) {
4375
- if (isDebugBuild()) {
4376
- logger.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
4377
- }
4410
+ logger.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
4378
4411
  return true;
4379
4412
  }
4380
4413
  if (!this._isAllowedUrl(event, options)) {
4381
- if (isDebugBuild()) {
4382
- logger.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
4383
- }
4414
+ logger.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
4384
4415
  return true;
4385
4416
  }
4386
4417
  return false;
@@ -4465,9 +4496,7 @@ var Sentry = (function (exports) {
4465
4496
  return [`${value}`, `${type}: ${value}`];
4466
4497
  }
4467
4498
  catch (oO) {
4468
- if (isDebugBuild()) {
4469
- logger.error(`Cannot extract message for event ${getEventDescription(event)}`);
4470
- }
4499
+ logger.error(`Cannot extract message for event ${getEventDescription(event)}`);
4471
4500
  return [];
4472
4501
  }
4473
4502
  }
@@ -4500,9 +4529,7 @@ var Sentry = (function (exports) {
4500
4529
  return frames ? this._getLastValidUrl(frames) : null;
4501
4530
  }
4502
4531
  catch (oO) {
4503
- if (isDebugBuild()) {
4504
- logger.error(`Cannot extract url for event ${getEventDescription(event)}`);
4505
- }
4532
+ logger.error(`Cannot extract url for event ${getEventDescription(event)}`);
4506
4533
  return null;
4507
4534
  }
4508
4535
  }
@@ -4911,9 +4938,7 @@ var Sentry = (function (exports) {
4911
4938
  document.head.removeChild(sandbox);
4912
4939
  }
4913
4940
  catch (e) {
4914
- if (isDebugBuild()) {
4915
- logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
4916
- }
4941
+ logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
4917
4942
  }
4918
4943
  }
4919
4944
  return (cachedFetchImpl = fetchImpl.bind(global$4));
@@ -5042,13 +5067,11 @@ var Sentry = (function (exports) {
5042
5067
  */
5043
5068
  _handleResponse({ requestType, response, headers, resolve, reject, }) {
5044
5069
  const status = eventStatusFromHttpCode(response.status);
5045
- /**
5046
- * "The name is case-insensitive."
5047
- * https://developer.mozilla.org/en-US/docs/Web/API/Headers/get
5048
- */
5049
- const limited = this._handleRateLimit(headers);
5050
- if (limited && isDebugBuild()) {
5051
- logger.warn(`Too many ${requestType} requests, backing off until: ${this._disabledUntil(requestType)}`);
5070
+ this._rateLimits = updateRateLimits(this._rateLimits, headers);
5071
+ // eslint-disable-next-line deprecation/deprecation
5072
+ if (this._isRateLimited(requestType) && isDebugBuild()) {
5073
+ // eslint-disable-next-line deprecation/deprecation
5074
+ logger.warn(`Too many ${requestType} requests, backing off until: ${this._disabledUntil(requestType)}`);
5052
5075
  }
5053
5076
  if (status === 'success') {
5054
5077
  resolve({ status });
@@ -5058,50 +5081,21 @@ var Sentry = (function (exports) {
5058
5081
  }
5059
5082
  /**
5060
5083
  * Gets the time that given category is disabled until for rate limiting
5084
+ *
5085
+ * @deprecated Please use `disabledUntil` from @sentry/utils
5061
5086
  */
5062
5087
  _disabledUntil(requestType) {
5063
5088
  const category = requestTypeToCategory(requestType);
5064
- return this._rateLimits[category] || this._rateLimits.all;
5089
+ return new Date(disabledUntil(this._rateLimits, category));
5065
5090
  }
5066
5091
  /**
5067
5092
  * Checks if a category is rate limited
5093
+ *
5094
+ * @deprecated Please use `isRateLimited` from @sentry/utils
5068
5095
  */
5069
5096
  _isRateLimited(requestType) {
5070
- return this._disabledUntil(requestType) > new Date(Date.now());
5071
- }
5072
- /**
5073
- * Sets internal _rateLimits from incoming headers. Returns true if headers contains a non-empty rate limiting header.
5074
- */
5075
- _handleRateLimit(headers) {
5076
- const now = Date.now();
5077
- const rlHeader = headers['x-sentry-rate-limits'];
5078
- const raHeader = headers['retry-after'];
5079
- if (rlHeader) {
5080
- // rate limit headers are of the form
5081
- // <header>,<header>,..
5082
- // where each <header> is of the form
5083
- // <retry_after>: <categories>: <scope>: <reason_code>
5084
- // where
5085
- // <retry_after> is a delay in ms
5086
- // <categories> is the event type(s) (error, transaction, etc) being rate limited and is of the form
5087
- // <category>;<category>;...
5088
- // <scope> is what's being limited (org, project, or key) - ignored by SDK
5089
- // <reason_code> is an arbitrary string like "org_quota" - ignored by SDK
5090
- for (const limit of rlHeader.trim().split(',')) {
5091
- const parameters = limit.split(':', 2);
5092
- const headerDelay = parseInt(parameters[0], 10);
5093
- const delay = (!isNaN(headerDelay) ? headerDelay : 60) * 1000; // 60sec default
5094
- for (const category of parameters[1].split(';')) {
5095
- this._rateLimits[category || 'all'] = new Date(now + delay);
5096
- }
5097
- }
5098
- return true;
5099
- }
5100
- else if (raHeader) {
5101
- this._rateLimits.all = new Date(now + parseRetryAfterHeader(raHeader, now));
5102
- return true;
5103
- }
5104
- return false;
5097
+ const category = requestTypeToCategory(requestType);
5098
+ return isRateLimited(this._rateLimits, category);
5105
5099
  }
5106
5100
  }
5107
5101
 
@@ -5116,11 +5110,13 @@ var Sentry = (function (exports) {
5116
5110
  * @param originalPayload Original payload used to create SentryRequest
5117
5111
  */
5118
5112
  _sendRequest(sentryRequest, originalPayload) {
5113
+ // eslint-disable-next-line deprecation/deprecation
5119
5114
  if (this._isRateLimited(sentryRequest.type)) {
5120
5115
  this.recordLostEvent('ratelimit_backoff', sentryRequest.type);
5121
5116
  return Promise.reject({
5122
5117
  event: originalPayload,
5123
5118
  type: sentryRequest.type,
5119
+ // eslint-disable-next-line deprecation/deprecation
5124
5120
  reason: `Transport for ${sentryRequest.type} requests locked till ${this._disabledUntil(sentryRequest.type)} due to too many requests.`,
5125
5121
  status: 429,
5126
5122
  });
@@ -5178,11 +5174,13 @@ var Sentry = (function (exports) {
5178
5174
  * @param originalPayload Original payload used to create SentryRequest
5179
5175
  */
5180
5176
  _sendRequest(sentryRequest, originalPayload) {
5177
+ // eslint-disable-next-line deprecation/deprecation
5181
5178
  if (this._isRateLimited(sentryRequest.type)) {
5182
5179
  this.recordLostEvent('ratelimit_backoff', sentryRequest.type);
5183
5180
  return Promise.reject({
5184
5181
  event: originalPayload,
5185
5182
  type: sentryRequest.type,
5183
+ // eslint-disable-next-line deprecation/deprecation
5186
5184
  reason: `Transport for ${sentryRequest.type} requests locked till ${this._disabledUntil(sentryRequest.type)} due to too many requests.`,
5187
5185
  status: 429,
5188
5186
  });
@@ -5388,15 +5386,11 @@ var Sentry = (function (exports) {
5388
5386
  return;
5389
5387
  }
5390
5388
  if (!options.eventId) {
5391
- if (isDebugBuild()) {
5392
- logger.error('Missing eventId option in showReportDialog call');
5393
- }
5389
+ logger.error('Missing eventId option in showReportDialog call');
5394
5390
  return;
5395
5391
  }
5396
5392
  if (!options.dsn) {
5397
- if (isDebugBuild()) {
5398
- logger.error('Missing dsn option in showReportDialog call');
5399
- }
5393
+ logger.error('Missing dsn option in showReportDialog call');
5400
5394
  return;
5401
5395
  }
5402
5396
  const script = global$2.document.createElement('script');
@@ -5588,9 +5582,7 @@ var Sentry = (function (exports) {
5588
5582
  return event;
5589
5583
  }
5590
5584
  function globalHandlerLog(type) {
5591
- if (isDebugBuild()) {
5592
- logger.log(`Global Handler attached: ${type}`);
5593
- }
5585
+ logger.log(`Global Handler attached: ${type}`);
5594
5586
  }
5595
5587
  function addMechanismAndCapture(hub, error, event, type) {
5596
5588
  addExceptionMechanism(event, {
@@ -5701,16 +5693,18 @@ var Sentry = (function (exports) {
5701
5693
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5702
5694
  return function (callback) {
5703
5695
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5704
- return original.call(this, wrap$1(callback, {
5705
- mechanism: {
5706
- data: {
5707
- function: 'requestAnimationFrame',
5708
- handler: getFunctionName(original),
5696
+ return original.apply(this, [
5697
+ wrap$1(callback, {
5698
+ mechanism: {
5699
+ data: {
5700
+ function: 'requestAnimationFrame',
5701
+ handler: getFunctionName(original),
5702
+ },
5703
+ handled: true,
5704
+ type: 'instrument',
5709
5705
  },
5710
- handled: true,
5711
- type: 'instrument',
5712
- },
5713
- }));
5706
+ }),
5707
+ ]);
5714
5708
  };
5715
5709
  }
5716
5710
  /** JSDoc */
@@ -5777,19 +5771,22 @@ var Sentry = (function (exports) {
5777
5771
  catch (err) {
5778
5772
  // can sometimes get 'Permission denied to access property "handle Event'
5779
5773
  }
5780
- return original.call(this, eventName,
5781
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5782
- wrap$1(fn, {
5783
- mechanism: {
5784
- data: {
5785
- function: 'addEventListener',
5786
- handler: getFunctionName(fn),
5787
- target,
5774
+ return original.apply(this, [
5775
+ eventName,
5776
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5777
+ wrap$1(fn, {
5778
+ mechanism: {
5779
+ data: {
5780
+ function: 'addEventListener',
5781
+ handler: getFunctionName(fn),
5782
+ target,
5783
+ },
5784
+ handled: true,
5785
+ type: 'instrument',
5788
5786
  },
5789
- handled: true,
5790
- type: 'instrument',
5791
- },
5792
- }), options);
5787
+ }),
5788
+ options,
5789
+ ]);
5793
5790
  };
5794
5791
  });
5795
5792
  fill(proto, 'removeEventListener', function (originalRemoveEventListener) {
@@ -6512,9 +6509,7 @@ var Sentry = (function (exports) {
6512
6509
  if (client) {
6513
6510
  return client.flush(timeout);
6514
6511
  }
6515
- if (isDebugBuild()) {
6516
- logger.warn('Cannot flush events. No client defined.');
6517
- }
6512
+ logger.warn('Cannot flush events. No client defined.');
6518
6513
  return resolvedSyncPromise(false);
6519
6514
  }
6520
6515
  /**
@@ -6530,9 +6525,7 @@ var Sentry = (function (exports) {
6530
6525
  if (client) {
6531
6526
  return client.close(timeout);
6532
6527
  }
6533
- if (isDebugBuild()) {
6534
- logger.warn('Cannot flush events and disable SDK. No client defined.');
6535
- }
6528
+ logger.warn('Cannot flush events and disable SDK. No client defined.');
6536
6529
  return resolvedSyncPromise(false);
6537
6530
  }
6538
6531
  /**
@@ -6557,9 +6550,7 @@ var Sentry = (function (exports) {
6557
6550
  const window = getGlobalObject();
6558
6551
  const document = window.document;
6559
6552
  if (typeof document === 'undefined') {
6560
- if (isDebugBuild()) {
6561
- logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
6562
- }
6553
+ logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
6563
6554
  return;
6564
6555
  }
6565
6556
  const hub = getCurrentHub();