@sentry/browser 6.18.1-beta.0 → 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 (187) 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 +270 -278
  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 +305 -306
  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 +2 -2
  15. package/dist/backend.js.map +1 -1
  16. package/dist/client.d.ts.map +1 -1
  17. package/dist/client.js +1 -1
  18. package/dist/client.js.map +1 -1
  19. package/dist/eventbuilder.d.ts +24 -10
  20. package/dist/eventbuilder.d.ts.map +1 -1
  21. package/dist/eventbuilder.js +119 -23
  22. package/dist/eventbuilder.js.map +1 -1
  23. package/dist/exports.d.ts.map +1 -1
  24. package/dist/exports.js.map +1 -1
  25. package/dist/helpers.d.ts.map +1 -1
  26. package/dist/helpers.js +2 -6
  27. package/dist/helpers.js.map +1 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/integrations/breadcrumbs.d.ts.map +1 -1
  31. package/dist/integrations/breadcrumbs.js.map +1 -1
  32. package/dist/integrations/dedupe.d.ts.map +1 -1
  33. package/dist/integrations/dedupe.js +1 -1
  34. package/dist/integrations/dedupe.js.map +1 -1
  35. package/dist/integrations/globalhandlers.d.ts.map +1 -1
  36. package/dist/integrations/globalhandlers.js +3 -11
  37. package/dist/integrations/globalhandlers.js.map +1 -1
  38. package/dist/integrations/index.d.ts.map +1 -1
  39. package/dist/integrations/index.js.map +1 -1
  40. package/dist/integrations/linkederrors.d.ts.map +1 -1
  41. package/dist/integrations/linkederrors.js +2 -2
  42. package/dist/integrations/linkederrors.js.map +1 -1
  43. package/dist/integrations/trycatch.d.ts.map +1 -1
  44. package/dist/integrations/trycatch.js +26 -21
  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 +3 -9
  50. package/dist/sdk.js.map +1 -1
  51. package/dist/stack-parsers.d.ts +5 -5
  52. package/dist/stack-parsers.d.ts.map +1 -1
  53. package/dist/stack-parsers.js +16 -6
  54. package/dist/stack-parsers.js.map +1 -1
  55. package/dist/transports/base.d.ts +6 -6
  56. package/dist/transports/base.d.ts.map +1 -1
  57. package/dist/transports/base.js +17 -68
  58. package/dist/transports/base.js.map +1 -1
  59. package/dist/transports/fetch.d.ts.map +1 -1
  60. package/dist/transports/fetch.js +2 -0
  61. package/dist/transports/fetch.js.map +1 -1
  62. package/dist/transports/index.d.ts.map +1 -1
  63. package/dist/transports/index.js.map +1 -1
  64. package/dist/transports/utils.d.ts.map +1 -1
  65. package/dist/transports/utils.js +2 -3
  66. package/dist/transports/utils.js.map +1 -1
  67. package/dist/transports/xhr.d.ts.map +1 -1
  68. package/dist/transports/xhr.js +2 -0
  69. package/dist/transports/xhr.js.map +1 -1
  70. package/dist/version.d.ts.map +1 -1
  71. package/dist/version.js.map +1 -1
  72. package/esm/backend.d.ts.map +1 -1
  73. package/esm/backend.js +2 -2
  74. package/esm/backend.js.map +1 -1
  75. package/esm/client.d.ts.map +1 -1
  76. package/esm/client.js +2 -2
  77. package/esm/client.js.map +1 -1
  78. package/esm/eventbuilder.d.ts +24 -10
  79. package/esm/eventbuilder.d.ts.map +1 -1
  80. package/esm/eventbuilder.js +113 -21
  81. package/esm/eventbuilder.js.map +1 -1
  82. package/esm/exports.d.ts.map +1 -1
  83. package/esm/exports.js.map +1 -1
  84. package/esm/helpers.d.ts.map +1 -1
  85. package/esm/helpers.js +2 -6
  86. package/esm/helpers.js.map +1 -1
  87. package/esm/index.d.ts.map +1 -1
  88. package/esm/index.js.map +1 -1
  89. package/esm/integrations/breadcrumbs.d.ts.map +1 -1
  90. package/esm/integrations/breadcrumbs.js.map +1 -1
  91. package/esm/integrations/dedupe.d.ts.map +1 -1
  92. package/esm/integrations/dedupe.js +2 -2
  93. package/esm/integrations/dedupe.js.map +1 -1
  94. package/esm/integrations/globalhandlers.d.ts.map +1 -1
  95. package/esm/integrations/globalhandlers.js +3 -11
  96. package/esm/integrations/globalhandlers.js.map +1 -1
  97. package/esm/integrations/index.d.ts.map +1 -1
  98. package/esm/integrations/index.js.map +1 -1
  99. package/esm/integrations/linkederrors.d.ts.map +1 -1
  100. package/esm/integrations/linkederrors.js +1 -1
  101. package/esm/integrations/linkederrors.js.map +1 -1
  102. package/esm/integrations/trycatch.d.ts.map +1 -1
  103. package/esm/integrations/trycatch.js +26 -21
  104. package/esm/integrations/trycatch.js.map +1 -1
  105. package/esm/integrations/useragent.d.ts.map +1 -1
  106. package/esm/integrations/useragent.js.map +1 -1
  107. package/esm/sdk.d.ts.map +1 -1
  108. package/esm/sdk.js +3 -9
  109. package/esm/sdk.js.map +1 -1
  110. package/esm/stack-parsers.d.ts +5 -5
  111. package/esm/stack-parsers.d.ts.map +1 -1
  112. package/esm/stack-parsers.js +16 -6
  113. package/esm/stack-parsers.js.map +1 -1
  114. package/esm/transports/base.d.ts +6 -6
  115. package/esm/transports/base.d.ts.map +1 -1
  116. package/esm/transports/base.js +19 -70
  117. package/esm/transports/base.js.map +1 -1
  118. package/esm/transports/fetch.d.ts.map +1 -1
  119. package/esm/transports/fetch.js +2 -0
  120. package/esm/transports/fetch.js.map +1 -1
  121. package/esm/transports/index.d.ts.map +1 -1
  122. package/esm/transports/index.js.map +1 -1
  123. package/esm/transports/utils.d.ts.map +1 -1
  124. package/esm/transports/utils.js +2 -3
  125. package/esm/transports/utils.js.map +1 -1
  126. package/esm/transports/xhr.d.ts.map +1 -1
  127. package/esm/transports/xhr.js +2 -0
  128. package/esm/transports/xhr.js.map +1 -1
  129. package/esm/version.d.ts.map +1 -1
  130. package/esm/version.js.map +1 -1
  131. package/package.json +16 -14
  132. package/types/backend.d.ts +43 -0
  133. package/types/backend.d.ts.map +1 -0
  134. package/types/client.d.ts +33 -0
  135. package/types/client.d.ts.map +1 -0
  136. package/types/eventbuilder.d.ts +39 -0
  137. package/types/eventbuilder.d.ts.map +1 -0
  138. package/types/exports.d.ts +10 -0
  139. package/types/exports.d.ts.map +1 -0
  140. package/types/helpers.d.ts +52 -0
  141. package/types/helpers.d.ts.map +1 -0
  142. package/types/index.d.ts +16 -0
  143. package/types/index.d.ts.map +1 -0
  144. package/types/integrations/breadcrumbs.d.ts +47 -0
  145. package/types/integrations/breadcrumbs.d.ts.map +1 -0
  146. package/types/integrations/dedupe.d.ts +21 -0
  147. package/types/integrations/dedupe.d.ts.map +1 -0
  148. package/types/integrations/globalhandlers.d.ts +30 -0
  149. package/types/integrations/globalhandlers.d.ts.map +1 -0
  150. package/types/integrations/index.d.ts +7 -0
  151. package/types/integrations/index.d.ts.map +1 -0
  152. package/types/integrations/linkederrors.d.ts +42 -0
  153. package/types/integrations/linkederrors.d.ts.map +1 -0
  154. package/types/integrations/trycatch.d.ts +33 -0
  155. package/types/integrations/trycatch.d.ts.map +1 -0
  156. package/types/integrations/useragent.d.ts +17 -0
  157. package/types/integrations/useragent.d.ts.map +1 -0
  158. package/types/sdk.d.ts +112 -0
  159. package/types/sdk.d.ts.map +1 -0
  160. package/types/stack-parsers.d.ts +7 -0
  161. package/types/stack-parsers.d.ts.map +1 -0
  162. package/types/transports/base.d.ts +65 -0
  163. package/types/transports/base.d.ts.map +1 -0
  164. package/types/transports/fetch.d.ts +17 -0
  165. package/types/transports/fetch.d.ts.map +1 -0
  166. package/types/transports/index.d.ts +4 -0
  167. package/types/transports/index.d.ts.map +1 -0
  168. package/types/transports/utils.d.ts +48 -0
  169. package/types/transports/utils.d.ts.map +1 -0
  170. package/types/transports/xhr.d.ts +11 -0
  171. package/types/transports/xhr.d.ts.map +1 -0
  172. package/types/version.d.ts +2 -0
  173. package/types/version.d.ts.map +1 -0
  174. package/build/bundle.es6.js.map +0 -1
  175. package/build/bundle.es6.min.js +0 -3
  176. package/build/bundle.es6.min.js.map +0 -1
  177. package/build/bundle.js.map +0 -1
  178. package/build/bundle.min.js +0 -3
  179. package/build/bundle.min.js.map +0 -1
  180. package/dist/parsers.d.ts +0 -21
  181. package/dist/parsers.d.ts.map +0 -1
  182. package/dist/parsers.js +0 -108
  183. package/dist/parsers.js.map +0 -1
  184. package/esm/parsers.d.ts +0 -21
  185. package/esm/parsers.d.ts.map +0 -1
  186. package/esm/parsers.js +0 -103
  187. package/esm/parsers.js.map +0 -1
@@ -1,4 +1,4 @@
1
- /*! @sentry/browser 6.18.1-beta.0 (8443996) | 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];
@@ -501,7 +495,7 @@ var Sentry = (function (exports) {
501
495
  return;
502
496
  }
503
497
  consoleSandbox(() => {
504
- global$6.console.log(`${PREFIX}[Log]: ${args.join(' ')}`);
498
+ global$6.console.log(`${PREFIX}[Log]:`, ...args);
505
499
  });
506
500
  }
507
501
  /** JSDoc */
@@ -510,7 +504,7 @@ var Sentry = (function (exports) {
510
504
  return;
511
505
  }
512
506
  consoleSandbox(() => {
513
- global$6.console.warn(`${PREFIX}[Warn]: ${args.join(' ')}`);
507
+ global$6.console.warn(`${PREFIX}[Warn]:`, ...args);
514
508
  });
515
509
  }
516
510
  /** JSDoc */
@@ -519,13 +513,17 @@ var Sentry = (function (exports) {
519
513
  return;
520
514
  }
521
515
  consoleSandbox(() => {
522
- global$6.console.error(`${PREFIX}[Error]: ${args.join(' ')}`);
516
+ global$6.console.error(`${PREFIX}[Error]:`, ...args);
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 */
@@ -576,12 +574,13 @@ var Sentry = (function (exports) {
576
574
  * StackFrames are returned in the correct order for Sentry Exception
577
575
  * frames and with Sentry SDK internal frames removed from the top and bottom
578
576
  *
579
- * */
577
+ */
580
578
  function createStackParser(...parsers) {
579
+ const sortedParsers = parsers.sort((a, b) => a[0] - b[0]).map(p => p[1]);
581
580
  return (stack, skipFirst = 0) => {
582
581
  const frames = [];
583
582
  for (const line of stack.split('\n').slice(skipFirst)) {
584
- for (const parser of parsers) {
583
+ for (const parser of sortedParsers) {
585
584
  const frame = parser(line);
586
585
  if (frame) {
587
586
  frames.push(frame);
@@ -865,19 +864,19 @@ var Sentry = (function (exports) {
865
864
  if (type === '[object Array]') {
866
865
  return '[Array]';
867
866
  }
868
- const normalized = normalizeValue(value);
869
- return isPrimitive(normalized) ? normalized : type;
867
+ // `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
868
+ // pass-through.
869
+ const serializable = makeSerializable(value);
870
+ return isPrimitive(serializable) ? serializable : type;
870
871
  }
871
872
  /**
872
- * normalizeValue()
873
+ * makeSerializable()
873
874
  *
874
- * Takes unserializable input and make it serializable friendly
875
+ * Takes unserializable input and make it serializer-friendly.
875
876
  *
876
- * - translates undefined/NaN values to "[undefined]"/"[NaN]" respectively,
877
- * - serializes Error objects
878
- * - filter global objects
877
+ * Handles globals, functions, `undefined`, `NaN`, and other non-serializable values.
879
878
  */
880
- function normalizeValue(value, key) {
879
+ function makeSerializable(value, key) {
881
880
  if (key === 'domain' && value && typeof value === 'object' && value._events) {
882
881
  return '[Domain]';
883
882
  }
@@ -925,24 +924,25 @@ var Sentry = (function (exports) {
925
924
  * @param key of object that's walked in current iteration
926
925
  * @param value object to be walked
927
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
928
928
  * @param memo Optional Memo class handling decycling
929
929
  */
930
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
931
- function walk(key, value, depth = +Infinity, memo = memoBuilder()) {
930
+ function walk(key, value, depth = +Infinity, maxProperties = +Infinity, memo = memoBuilder()) {
931
+ const [memoize, unmemoize] = memo;
932
932
  // If we reach the maximum depth, serialize whatever is left
933
933
  if (depth === 0) {
934
934
  return serializeValue(value);
935
935
  }
936
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
937
936
  // If value implements `toJSON` method, call it and return early
938
937
  if (value !== null && value !== undefined && typeof value.toJSON === 'function') {
939
938
  return value.toJSON();
940
939
  }
941
- /* eslint-enable @typescript-eslint/no-unsafe-member-access */
942
- // If normalized value is a primitive, there are no branches left to walk, so bail out
943
- const normalized = normalizeValue(value, key);
944
- if (isPrimitive(normalized)) {
945
- return normalized;
940
+ // `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
941
+ // pass-through. If what comes back is a primitive (either because it's been stringified or because it was primitive
942
+ // all along), we're done.
943
+ const serializable = makeSerializable(value, key);
944
+ if (isPrimitive(serializable)) {
945
+ return serializable;
946
946
  }
947
947
  // Create source that we will use for the next iteration. It will either be an objectified error object (`Error` type
948
948
  // with extracted key:value pairs) or the input itself.
@@ -950,39 +950,53 @@ var Sentry = (function (exports) {
950
950
  // Create an accumulator that will act as a parent for all future itterations of that branch
951
951
  const acc = Array.isArray(value) ? [] : {};
952
952
  // If we already walked that branch, bail out, as it's circular reference
953
- if (memo[0](value)) {
953
+ if (memoize(value)) {
954
954
  return '[Circular ~]';
955
955
  }
956
+ let propertyCount = 0;
956
957
  // Walk all keys of the source
957
958
  for (const innerKey in source) {
958
959
  // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
959
960
  if (!Object.prototype.hasOwnProperty.call(source, innerKey)) {
960
961
  continue;
961
962
  }
963
+ if (propertyCount >= maxProperties) {
964
+ acc[innerKey] = '[MaxProperties ~]';
965
+ break;
966
+ }
967
+ propertyCount += 1;
962
968
  // Recursively walk through all the child nodes
963
- acc[innerKey] = walk(innerKey, source[innerKey], depth - 1, memo);
969
+ const innerValue = source[innerKey];
970
+ acc[innerKey] = walk(innerKey, innerValue, depth - 1, maxProperties, memo);
964
971
  }
965
972
  // Once walked through all the branches, remove the parent from memo storage
966
- memo[1](value);
973
+ unmemoize(value);
967
974
  // Return accumulated values
968
975
  return acc;
969
976
  }
970
977
  /**
971
- * normalize()
978
+ * Recursively normalizes the given object.
972
979
  *
973
980
  * - Creates a copy to prevent original input mutation
974
- * - Skip non-enumerablers
975
- * - Calls `toJSON` if implemented
981
+ * - Skips non-enumerable properties
982
+ * - When stringifying, calls `toJSON` if implemented
976
983
  * - Removes circular references
977
- * - Translates non-serializeable values (undefined/NaN/Functions) to serializable format
978
- * - Translates known global objects/Classes to a string representations
979
- * - Takes care of Error objects serialization
980
- * - 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.
981
995
  */
982
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
983
- function normalize(input, depth) {
996
+ function normalize(input, depth = +Infinity, maxProperties = +Infinity) {
984
997
  try {
985
- return JSON.parse(JSON.stringify(input, (key, value) => walk(key, value, depth)));
998
+ // since we're at the outermost level, there is no key
999
+ return walk('', input, depth, maxProperties);
986
1000
  }
987
1001
  catch (_oO) {
988
1002
  return '**non-serializable**';
@@ -1084,7 +1098,7 @@ var Sentry = (function (exports) {
1084
1098
  let result = false;
1085
1099
  const doc = global.document;
1086
1100
  // eslint-disable-next-line deprecation/deprecation
1087
- if (doc && typeof doc.createElement === `function`) {
1101
+ if (doc && typeof doc.createElement === 'function') {
1088
1102
  try {
1089
1103
  const sandbox = doc.createElement('iframe');
1090
1104
  sandbox.hidden = true;
@@ -1096,9 +1110,7 @@ var Sentry = (function (exports) {
1096
1110
  doc.head.removeChild(sandbox);
1097
1111
  }
1098
1112
  catch (err) {
1099
- if (isDebugBuild()) {
1100
- logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);
1101
- }
1113
+ logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);
1102
1114
  }
1103
1115
  }
1104
1116
  return result;
@@ -1190,6 +1202,7 @@ var Sentry = (function (exports) {
1190
1202
  break;
1191
1203
  default:
1192
1204
  logger.warn('unknown instrumentation type:', type);
1205
+ return;
1193
1206
  }
1194
1207
  }
1195
1208
  /**
@@ -1212,9 +1225,7 @@ var Sentry = (function (exports) {
1212
1225
  handler(data);
1213
1226
  }
1214
1227
  catch (e) {
1215
- if (isDebugBuild()) {
1216
- logger.error(`Error while triggering instrumentation handler.\nType: ${type}\nName: ${getFunctionName(handler)}\nError: ${e}`);
1217
- }
1228
+ logger.error(`Error while triggering instrumentation handler.\nType: ${type}\nName: ${getFunctionName(handler)}\nError:`, e);
1218
1229
  }
1219
1230
  }
1220
1231
  }
@@ -1223,7 +1234,7 @@ var Sentry = (function (exports) {
1223
1234
  if (!('console' in global$5)) {
1224
1235
  return;
1225
1236
  }
1226
- ['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) {
1237
+ CONSOLE_LEVELS.forEach(function (level) {
1227
1238
  if (!(level in global$5.console)) {
1228
1239
  return;
1229
1240
  }
@@ -1741,26 +1752,6 @@ var Sentry = (function (exports) {
1741
1752
  firstException.mechanism.data = mergedData;
1742
1753
  }
1743
1754
  }
1744
- const defaultRetryAfter = 60 * 1000; // 60 seconds
1745
- /**
1746
- * Extracts Retry-After value from the request header or returns default value
1747
- * @param now current unix timestamp
1748
- * @param header string representation of 'Retry-After' header
1749
- */
1750
- function parseRetryAfterHeader(now, header) {
1751
- if (!header) {
1752
- return defaultRetryAfter;
1753
- }
1754
- const headerDelay = parseInt(`${header}`, 10);
1755
- if (!isNaN(headerDelay)) {
1756
- return headerDelay * 1000;
1757
- }
1758
- const headerDate = Date.parse(`${header}`);
1759
- if (!isNaN(headerDate)) {
1760
- return headerDate - now;
1761
- }
1762
- return defaultRetryAfter;
1763
- }
1764
1755
  /**
1765
1756
  * Checks whether or not we've already captured the given exception (note: not an identical exception - the very object
1766
1757
  * in question), and marks it captured if not.
@@ -2211,7 +2202,9 @@ var Sentry = (function (exports) {
2211
2202
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2212
2203
  return items.reduce((acc, item) => {
2213
2204
  const [itemHeaders, payload] = item;
2214
- return `${acc}\n${JSON.stringify(itemHeaders)}\n${JSON.stringify(payload)}`;
2205
+ // We do not serialize payloads that are primitives
2206
+ const serializedPayload = isPrimitive(payload) ? String(payload) : JSON.stringify(payload);
2207
+ return `${acc}\n${JSON.stringify(itemHeaders)}\n${serializedPayload}`;
2215
2208
  }, serializedHeaders);
2216
2209
  }
2217
2210
 
@@ -2231,6 +2224,79 @@ var Sentry = (function (exports) {
2231
2224
  return createEnvelope(dsn ? { dsn } : {}, [clientReportItem]);
2232
2225
  }
2233
2226
 
2227
+ const DEFAULT_RETRY_AFTER = 60 * 1000; // 60 seconds
2228
+ /**
2229
+ * Extracts Retry-After value from the request header or returns default value
2230
+ * @param header string representation of 'Retry-After' header
2231
+ * @param now current unix timestamp
2232
+ *
2233
+ */
2234
+ function parseRetryAfterHeader(header, now = Date.now()) {
2235
+ const headerDelay = parseInt(`${header}`, 10);
2236
+ if (!isNaN(headerDelay)) {
2237
+ return headerDelay * 1000;
2238
+ }
2239
+ const headerDate = Date.parse(`${header}`);
2240
+ if (!isNaN(headerDate)) {
2241
+ return headerDate - now;
2242
+ }
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;
2298
+ }
2299
+
2234
2300
  /**
2235
2301
  * Absolute maximum number of breadcrumbs added to an event.
2236
2302
  * The `maxBreadcrumbs` option cannot be higher than this value.
@@ -3262,13 +3328,7 @@ var Sentry = (function (exports) {
3262
3328
  */
3263
3329
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3264
3330
  function captureException(exception, captureContext) {
3265
- let syntheticException;
3266
- try {
3267
- throw new Error('Sentry syntheticException');
3268
- }
3269
- catch (exception) {
3270
- syntheticException = exception;
3271
- }
3331
+ const syntheticException = new Error('Sentry syntheticException');
3272
3332
  return callOnHub('captureException', exception, {
3273
3333
  captureContext,
3274
3334
  originalException: exception,
@@ -3283,13 +3343,7 @@ var Sentry = (function (exports) {
3283
3343
  * @returns The generated eventId.
3284
3344
  */
3285
3345
  function captureMessage(message, captureContext) {
3286
- let syntheticException;
3287
- try {
3288
- throw new Error(message);
3289
- }
3290
- catch (exception) {
3291
- syntheticException = exception;
3292
- }
3346
+ const syntheticException = new Error(message);
3293
3347
  // This is necessary to provide explicit scopes upgrade, without changing the original
3294
3348
  // arity of the `captureMessage(message, level)` method.
3295
3349
  const level = typeof captureContext === 'string' ? captureContext : undefined;
@@ -3661,15 +3715,11 @@ var Sentry = (function (exports) {
3661
3715
  */
3662
3716
  captureSession(session) {
3663
3717
  if (!this._isEnabled()) {
3664
- if (isDebugBuild()) {
3665
- logger.warn('SDK not enabled, will not capture session.');
3666
- }
3718
+ logger.warn('SDK not enabled, will not capture session.');
3667
3719
  return;
3668
3720
  }
3669
3721
  if (!(typeof session.release === 'string')) {
3670
- if (isDebugBuild()) {
3671
- logger.warn('Discarded session because of missing or non-string release');
3672
- }
3722
+ logger.warn('Discarded session because of missing or non-string release');
3673
3723
  }
3674
3724
  else {
3675
3725
  this._sendSession(session);
@@ -3815,7 +3865,7 @@ var Sentry = (function (exports) {
3815
3865
  * @returns A new event with more information.
3816
3866
  */
3817
3867
  _prepareEvent(event, scope, hint) {
3818
- const { normalizeDepth = 3 } = this.getOptions();
3868
+ const { normalizeDepth = 3, normalizeMaxBreadth = 1000 } = this.getOptions();
3819
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() });
3820
3870
  this._applyClientOptions(prepared);
3821
3871
  this._applyIntegrationsMetadata(prepared);
@@ -3840,7 +3890,7 @@ var Sentry = (function (exports) {
3840
3890
  evt.sdkProcessingMetadata = Object.assign(Object.assign({}, evt.sdkProcessingMetadata), { normalizeDepth: normalize(normalizeDepth) });
3841
3891
  }
3842
3892
  if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
3843
- return this._normalizeEvent(evt, normalizeDepth);
3893
+ return this._normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
3844
3894
  }
3845
3895
  return evt;
3846
3896
  });
@@ -3855,20 +3905,20 @@ var Sentry = (function (exports) {
3855
3905
  * @param event Event
3856
3906
  * @returns Normalized event
3857
3907
  */
3858
- _normalizeEvent(event, depth) {
3908
+ _normalizeEvent(event, depth, maxBreadth) {
3859
3909
  if (!event) {
3860
3910
  return null;
3861
3911
  }
3862
3912
  const normalized = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, event), (event.breadcrumbs && {
3863
3913
  breadcrumbs: event.breadcrumbs.map(b => (Object.assign(Object.assign({}, b), (b.data && {
3864
- data: normalize(b.data, depth),
3914
+ data: normalize(b.data, depth, maxBreadth),
3865
3915
  })))),
3866
3916
  })), (event.user && {
3867
- user: normalize(event.user, depth),
3917
+ user: normalize(event.user, depth, maxBreadth),
3868
3918
  })), (event.contexts && {
3869
- contexts: normalize(event.contexts, depth),
3919
+ contexts: normalize(event.contexts, depth, maxBreadth),
3870
3920
  })), (event.extra && {
3871
- extra: normalize(event.extra, depth),
3921
+ extra: normalize(event.extra, depth, maxBreadth),
3872
3922
  }));
3873
3923
  // event.contexts.trace stores information about a Transaction. Similarly,
3874
3924
  // event.spans[] stores information about child Spans. Given that a
@@ -4059,7 +4109,7 @@ var Sentry = (function (exports) {
4059
4109
  */
4060
4110
  sendEvent(_) {
4061
4111
  return resolvedSyncPromise({
4062
- reason: `NoopTransport: Event has been skipped because no Dsn is configured.`,
4112
+ reason: 'NoopTransport: Event has been skipped because no Dsn is configured.',
4063
4113
  status: 'skipped',
4064
4114
  });
4065
4115
  }
@@ -4102,9 +4152,7 @@ var Sentry = (function (exports) {
4102
4152
  */
4103
4153
  sendEvent(event) {
4104
4154
  void this._transport.sendEvent(event).then(null, reason => {
4105
- if (isDebugBuild()) {
4106
- logger.error(`Error while sending event: ${reason}`);
4107
- }
4155
+ logger.error('Error while sending event:', reason);
4108
4156
  });
4109
4157
  }
4110
4158
  /**
@@ -4112,15 +4160,11 @@ var Sentry = (function (exports) {
4112
4160
  */
4113
4161
  sendSession(session) {
4114
4162
  if (!this._transport.sendSession) {
4115
- if (isDebugBuild()) {
4116
- logger.warn("Dropping session because custom transport doesn't implement sendSession");
4117
- }
4163
+ logger.warn("Dropping session because custom transport doesn't implement sendSession");
4118
4164
  return;
4119
4165
  }
4120
4166
  void this._transport.sendSession(session).then(null, reason => {
4121
- if (isDebugBuild()) {
4122
- logger.error(`Error while sending session: ${reason}`);
4123
- }
4167
+ logger.error('Error while sending session:', reason);
4124
4168
  });
4125
4169
  }
4126
4170
  /**
@@ -4163,14 +4207,14 @@ var Sentry = (function (exports) {
4163
4207
  /** Creates a SentryRequest from a Session. */
4164
4208
  function sessionToSentryRequest(session, api) {
4165
4209
  const sdkInfo = getSdkMetadataForEnvelopeHeader(api);
4166
- const envelopeHeaders = JSON.stringify(Object.assign(Object.assign({ sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) })));
4167
- // I know this is hacky but we don't want to add `session` to request type since it's never rate limited
4210
+ const envelopeHeaders = Object.assign(Object.assign({ sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
4211
+ // I know this is hacky but we don't want to add `sessions` to request type since it's never rate limited
4168
4212
  const type = 'aggregates' in session ? 'sessions' : 'session';
4169
- const itemHeaders = JSON.stringify({
4170
- type,
4171
- });
4213
+ // TODO (v7) Have to cast type because envelope items do not accept a `SentryRequestType`
4214
+ const envelopeItem = [{ type }, session];
4215
+ const envelope = createEnvelope(envelopeHeaders, [envelopeItem]);
4172
4216
  return {
4173
- body: `${envelopeHeaders}\n${itemHeaders}\n${JSON.stringify(session)}`,
4217
+ body: serializeEnvelope(envelope),
4174
4218
  type,
4175
4219
  url: getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel),
4176
4220
  };
@@ -4248,19 +4292,16 @@ var Sentry = (function (exports) {
4248
4292
  // deserialization. Instead, we only implement a minimal subset of the spec to
4249
4293
  // serialize events inline here.
4250
4294
  if (useEnvelope) {
4251
- const envelopeHeaders = JSON.stringify(Object.assign(Object.assign({ event_id: event.event_id, sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) })));
4252
- const itemHeaders = JSON.stringify({
4253
- type: eventType,
4254
- // TODO: Right now, sampleRate may or may not be defined (it won't be in the cases of inheritance and
4255
- // explicitly-set sampling decisions). Are we good with that?
4256
- sample_rates: [{ id: samplingMethod, rate: sampleRate }],
4257
- });
4258
- // The trailing newline is optional. We intentionally don't send it to avoid
4259
- // sending unnecessary bytes.
4260
- //
4261
- // const envelope = `${envelopeHeaders}\n${itemHeaders}\n${req.body}\n`;
4262
- const envelope = `${envelopeHeaders}\n${itemHeaders}\n${req.body}`;
4263
- req.body = envelope;
4295
+ const envelopeHeaders = Object.assign(Object.assign({ event_id: event.event_id, sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
4296
+ const eventItem = [
4297
+ {
4298
+ type: eventType,
4299
+ sample_rates: [{ id: samplingMethod, rate: sampleRate }],
4300
+ },
4301
+ req.body,
4302
+ ];
4303
+ const envelope = createEnvelope(envelopeHeaders, [eventItem]);
4304
+ req.body = serializeEnvelope(envelope);
4264
4305
  }
4265
4306
  return req;
4266
4307
  }
@@ -4274,7 +4315,9 @@ var Sentry = (function (exports) {
4274
4315
  */
4275
4316
  function initAndBind(clientClass, options) {
4276
4317
  if (options.debug === true) {
4277
- logger.enable();
4318
+ {
4319
+ logger.enable();
4320
+ }
4278
4321
  }
4279
4322
  const hub = getCurrentHub();
4280
4323
  const scope = hub.getScope();
@@ -4285,7 +4328,7 @@ var Sentry = (function (exports) {
4285
4328
  hub.bindClient(client);
4286
4329
  }
4287
4330
 
4288
- const SDK_VERSION = '6.18.1-beta.0';
4331
+ const SDK_VERSION = '6.19.0';
4289
4332
 
4290
4333
  let originalFunctionToString;
4291
4334
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4356,27 +4399,19 @@ var Sentry = (function (exports) {
4356
4399
  /** JSDoc */
4357
4400
  _shouldDropEvent(event, options) {
4358
4401
  if (this._isSentryError(event, options)) {
4359
- if (isDebugBuild()) {
4360
- logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${getEventDescription(event)}`);
4361
- }
4402
+ logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${getEventDescription(event)}`);
4362
4403
  return true;
4363
4404
  }
4364
4405
  if (this._isIgnoredError(event, options)) {
4365
- if (isDebugBuild()) {
4366
- logger.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${getEventDescription(event)}`);
4367
- }
4406
+ logger.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${getEventDescription(event)}`);
4368
4407
  return true;
4369
4408
  }
4370
4409
  if (this._isDeniedUrl(event, options)) {
4371
- if (isDebugBuild()) {
4372
- logger.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
4373
- }
4410
+ logger.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
4374
4411
  return true;
4375
4412
  }
4376
4413
  if (!this._isAllowedUrl(event, options)) {
4377
- if (isDebugBuild()) {
4378
- logger.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
4379
- }
4414
+ logger.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${getEventDescription(event)}.\nUrl: ${this._getEventFilterUrl(event)}`);
4380
4415
  return true;
4381
4416
  }
4382
4417
  return false;
@@ -4461,9 +4496,7 @@ var Sentry = (function (exports) {
4461
4496
  return [`${value}`, `${type}: ${value}`];
4462
4497
  }
4463
4498
  catch (oO) {
4464
- if (isDebugBuild()) {
4465
- logger.error(`Cannot extract message for event ${getEventDescription(event)}`);
4466
- }
4499
+ logger.error(`Cannot extract message for event ${getEventDescription(event)}`);
4467
4500
  return [];
4468
4501
  }
4469
4502
  }
@@ -4496,9 +4529,7 @@ var Sentry = (function (exports) {
4496
4529
  return frames ? this._getLastValidUrl(frames) : null;
4497
4530
  }
4498
4531
  catch (oO) {
4499
- if (isDebugBuild()) {
4500
- logger.error(`Cannot extract url for event ${getEventDescription(event)}`);
4501
- }
4532
+ logger.error(`Cannot extract url for event ${getEventDescription(event)}`);
4502
4533
  return null;
4503
4534
  }
4504
4535
  }
@@ -4516,6 +4547,11 @@ var Sentry = (function (exports) {
4516
4547
 
4517
4548
  // global reference to slice
4518
4549
  const UNKNOWN_FUNCTION = '?';
4550
+ const OPERA10_PRIORITY = 10;
4551
+ const OPERA11_PRIORITY = 20;
4552
+ const CHROME_PRIORITY = 30;
4553
+ const WINJS_PRIORITY = 40;
4554
+ const GECKO_PRIORITY = 50;
4519
4555
  function createFrame(filename, func, lineno, colno) {
4520
4556
  const frame = {
4521
4557
  filename,
@@ -4554,6 +4590,7 @@ var Sentry = (function (exports) {
4554
4590
  }
4555
4591
  return;
4556
4592
  };
4593
+ const chromeStackParser = [CHROME_PRIORITY, chrome];
4557
4594
  // gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
4558
4595
  // generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
4559
4596
  // We need this specific case for now because we want no other regex to match.
@@ -4567,7 +4604,7 @@ var Sentry = (function (exports) {
4567
4604
  const subMatch = geckoEvalRegex.exec(parts[3]);
4568
4605
  if (subMatch) {
4569
4606
  // throw out eval line/column and use top-most line number
4570
- parts[1] = parts[1] || `eval`;
4607
+ parts[1] = parts[1] || 'eval';
4571
4608
  parts[3] = subMatch[1];
4572
4609
  parts[4] = subMatch[2];
4573
4610
  parts[5] = ''; // no column when eval
@@ -4580,6 +4617,7 @@ var Sentry = (function (exports) {
4580
4617
  }
4581
4618
  return;
4582
4619
  };
4620
+ const geckoStackParser = [GECKO_PRIORITY, gecko];
4583
4621
  const winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
4584
4622
  const winjs = line => {
4585
4623
  const parts = winjsRegex.exec(line);
@@ -4587,16 +4625,19 @@ var Sentry = (function (exports) {
4587
4625
  ? createFrame(parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined)
4588
4626
  : undefined;
4589
4627
  };
4628
+ const winjsStackParser = [WINJS_PRIORITY, winjs];
4590
4629
  const opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
4591
4630
  const opera10 = line => {
4592
4631
  const parts = opera10Regex.exec(line);
4593
4632
  return parts ? createFrame(parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined;
4594
4633
  };
4634
+ const opera10StackParser = [OPERA10_PRIORITY, opera10];
4595
4635
  const opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
4596
4636
  const opera11 = line => {
4597
4637
  const parts = opera11Regex.exec(line);
4598
4638
  return parts ? createFrame(parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;
4599
4639
  };
4640
+ const opera11StackParser = [OPERA11_PRIORITY, opera11];
4600
4641
  /**
4601
4642
  * Safari web extensions, starting version unknown, can produce "frames-only" stacktraces.
4602
4643
  * What it means, is that instead of format like:
@@ -4640,7 +4681,7 @@ var Sentry = (function (exports) {
4640
4681
  type: ex && ex.name,
4641
4682
  value: extractMessage(ex),
4642
4683
  };
4643
- if (frames && frames.length) {
4684
+ if (frames.length) {
4644
4685
  exception.stacktrace = { frames };
4645
4686
  }
4646
4687
  if (exception.type === undefined && exception.value === '') {
@@ -4651,13 +4692,13 @@ var Sentry = (function (exports) {
4651
4692
  /**
4652
4693
  * @hidden
4653
4694
  */
4654
- function eventFromPlainObject(exception, syntheticException, rejection) {
4695
+ function eventFromPlainObject(exception, syntheticException, isUnhandledRejection) {
4655
4696
  const event = {
4656
4697
  exception: {
4657
4698
  values: [
4658
4699
  {
4659
- type: isEvent(exception) ? exception.constructor.name : rejection ? 'UnhandledRejection' : 'Error',
4660
- value: `Non-Error ${rejection ? 'promise rejection' : 'exception'} captured with keys: ${extractExceptionKeysForMessage(exception)}`,
4700
+ type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error',
4701
+ value: `Non-Error ${isUnhandledRejection ? 'promise rejection' : 'exception'} captured with keys: ${extractExceptionKeysForMessage(exception)}`,
4661
4702
  },
4662
4703
  ],
4663
4704
  },
@@ -4691,8 +4732,7 @@ var Sentry = (function (exports) {
4691
4732
  const stacktrace = ex.stacktrace || ex.stack || '';
4692
4733
  const popSize = getPopSize(ex);
4693
4734
  try {
4694
- // The order of the parsers in important
4695
- return createStackParser(opera10, opera11, chrome, winjs, gecko)(stacktrace, popSize);
4735
+ return createStackParser(opera10StackParser, opera11StackParser, chromeStackParser, winjsStackParser, geckoStackParser)(stacktrace, popSize);
4696
4736
  }
4697
4737
  catch (e) {
4698
4738
  // no-empty
@@ -4717,7 +4757,6 @@ var Sentry = (function (exports) {
4717
4757
  * https://github.com/getsentry/sentry-javascript/issues/1949
4718
4758
  * In this specific case we try to extract stacktrace.message.error.message
4719
4759
  */
4720
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4721
4760
  function extractMessage(ex) {
4722
4761
  const message = ex && ex.message;
4723
4762
  if (!message) {
@@ -4727,17 +4766,14 @@ var Sentry = (function (exports) {
4727
4766
  return message.error.message;
4728
4767
  }
4729
4768
  return message;
4730
- }
4731
-
4769
+ }
4732
4770
  /**
4733
4771
  * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.
4734
4772
  * @hidden
4735
4773
  */
4736
- function eventFromException(options, exception, hint) {
4774
+ function eventFromException(exception, hint, attachStacktrace) {
4737
4775
  const syntheticException = (hint && hint.syntheticException) || undefined;
4738
- const event = eventFromUnknownInput(exception, syntheticException, {
4739
- attachStacktrace: options.attachStacktrace,
4740
- });
4776
+ const event = eventFromUnknownInput(exception, syntheticException, attachStacktrace);
4741
4777
  addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
4742
4778
  event.level = exports.Severity.Error;
4743
4779
  if (hint && hint.event_id) {
@@ -4749,11 +4785,9 @@ var Sentry = (function (exports) {
4749
4785
  * Builds and Event from a Message
4750
4786
  * @hidden
4751
4787
  */
4752
- function eventFromMessage(options, message, level = exports.Severity.Info, hint) {
4788
+ function eventFromMessage(message, level = exports.Severity.Info, hint, attachStacktrace) {
4753
4789
  const syntheticException = (hint && hint.syntheticException) || undefined;
4754
- const event = eventFromString(message, syntheticException, {
4755
- attachStacktrace: options.attachStacktrace,
4756
- });
4790
+ const event = eventFromString(message, syntheticException, attachStacktrace);
4757
4791
  event.level = level;
4758
4792
  if (hint && hint.event_id) {
4759
4793
  event.event_id = hint.event_id;
@@ -4763,7 +4797,7 @@ var Sentry = (function (exports) {
4763
4797
  /**
4764
4798
  * @hidden
4765
4799
  */
4766
- function eventFromUnknownInput(exception, syntheticException, options = {}) {
4800
+ function eventFromUnknownInput(exception, syntheticException, attachStacktrace, isUnhandledRejection) {
4767
4801
  let event;
4768
4802
  if (isErrorEvent(exception) && exception.error) {
4769
4803
  // If it is an ErrorEvent with `error` property, extract it to get actual Error
@@ -4785,7 +4819,7 @@ var Sentry = (function (exports) {
4785
4819
  else {
4786
4820
  const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');
4787
4821
  const message = domException.message ? `${name}: ${domException.message}` : name;
4788
- event = eventFromString(message, syntheticException, options);
4822
+ event = eventFromString(message, syntheticException, attachStacktrace);
4789
4823
  addExceptionTypeValue(event, message);
4790
4824
  }
4791
4825
  if ('code' in domException) {
@@ -4802,7 +4836,7 @@ var Sentry = (function (exports) {
4802
4836
  // it manually. This will allow us to group events based on top-level keys which is much better than creating a new
4803
4837
  // group on any key/value change.
4804
4838
  const objectException = exception;
4805
- event = eventFromPlainObject(objectException, syntheticException, options.isRejection);
4839
+ event = eventFromPlainObject(objectException, syntheticException, isUnhandledRejection);
4806
4840
  addExceptionMechanism(event, {
4807
4841
  synthetic: true,
4808
4842
  });
@@ -4817,7 +4851,7 @@ var Sentry = (function (exports) {
4817
4851
  // - a plain Object
4818
4852
  //
4819
4853
  // So bail out and capture it as a simple message:
4820
- event = eventFromString(exception, syntheticException, options);
4854
+ event = eventFromString(exception, syntheticException, attachStacktrace);
4821
4855
  addExceptionTypeValue(event, `${exception}`, undefined);
4822
4856
  addExceptionMechanism(event, {
4823
4857
  synthetic: true,
@@ -4827,11 +4861,11 @@ var Sentry = (function (exports) {
4827
4861
  /**
4828
4862
  * @hidden
4829
4863
  */
4830
- function eventFromString(input, syntheticException, options = {}) {
4864
+ function eventFromString(input, syntheticException, attachStacktrace) {
4831
4865
  const event = {
4832
4866
  message: input,
4833
4867
  };
4834
- if (options.attachStacktrace && syntheticException) {
4868
+ if (attachStacktrace && syntheticException) {
4835
4869
  const frames = parseStackFrames(syntheticException);
4836
4870
  if (frames.length) {
4837
4871
  event.stacktrace = { frames };
@@ -4892,7 +4926,7 @@ var Sentry = (function (exports) {
4892
4926
  const document = global$4.document;
4893
4927
  let fetchImpl = global$4.fetch;
4894
4928
  // eslint-disable-next-line deprecation/deprecation
4895
- if (document && typeof document.createElement === `function`) {
4929
+ if (document && typeof document.createElement === 'function') {
4896
4930
  try {
4897
4931
  const sandbox = document.createElement('iframe');
4898
4932
  sandbox.hidden = true;
@@ -4904,9 +4938,7 @@ var Sentry = (function (exports) {
4904
4938
  document.head.removeChild(sandbox);
4905
4939
  }
4906
4940
  catch (e) {
4907
- if (isDebugBuild()) {
4908
- logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
4909
- }
4941
+ logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
4910
4942
  }
4911
4943
  }
4912
4944
  return (cachedFetchImpl = fetchImpl.bind(global$4));
@@ -5035,13 +5067,11 @@ var Sentry = (function (exports) {
5035
5067
  */
5036
5068
  _handleResponse({ requestType, response, headers, resolve, reject, }) {
5037
5069
  const status = eventStatusFromHttpCode(response.status);
5038
- /**
5039
- * "The name is case-insensitive."
5040
- * https://developer.mozilla.org/en-US/docs/Web/API/Headers/get
5041
- */
5042
- const limited = this._handleRateLimit(headers);
5043
- if (limited && isDebugBuild()) {
5044
- 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)}`);
5045
5075
  }
5046
5076
  if (status === 'success') {
5047
5077
  resolve({ status });
@@ -5051,50 +5081,21 @@ var Sentry = (function (exports) {
5051
5081
  }
5052
5082
  /**
5053
5083
  * Gets the time that given category is disabled until for rate limiting
5084
+ *
5085
+ * @deprecated Please use `disabledUntil` from @sentry/utils
5054
5086
  */
5055
5087
  _disabledUntil(requestType) {
5056
5088
  const category = requestTypeToCategory(requestType);
5057
- return this._rateLimits[category] || this._rateLimits.all;
5089
+ return new Date(disabledUntil(this._rateLimits, category));
5058
5090
  }
5059
5091
  /**
5060
5092
  * Checks if a category is rate limited
5093
+ *
5094
+ * @deprecated Please use `isRateLimited` from @sentry/utils
5061
5095
  */
5062
5096
  _isRateLimited(requestType) {
5063
- return this._disabledUntil(requestType) > new Date(Date.now());
5064
- }
5065
- /**
5066
- * Sets internal _rateLimits from incoming headers. Returns true if headers contains a non-empty rate limiting header.
5067
- */
5068
- _handleRateLimit(headers) {
5069
- const now = Date.now();
5070
- const rlHeader = headers['x-sentry-rate-limits'];
5071
- const raHeader = headers['retry-after'];
5072
- if (rlHeader) {
5073
- // rate limit headers are of the form
5074
- // <header>,<header>,..
5075
- // where each <header> is of the form
5076
- // <retry_after>: <categories>: <scope>: <reason_code>
5077
- // where
5078
- // <retry_after> is a delay in ms
5079
- // <categories> is the event type(s) (error, transaction, etc) being rate limited and is of the form
5080
- // <category>;<category>;...
5081
- // <scope> is what's being limited (org, project, or key) - ignored by SDK
5082
- // <reason_code> is an arbitrary string like "org_quota" - ignored by SDK
5083
- for (const limit of rlHeader.trim().split(',')) {
5084
- const parameters = limit.split(':', 2);
5085
- const headerDelay = parseInt(parameters[0], 10);
5086
- const delay = (!isNaN(headerDelay) ? headerDelay : 60) * 1000; // 60sec default
5087
- for (const category of parameters[1].split(';')) {
5088
- this._rateLimits[category || 'all'] = new Date(now + delay);
5089
- }
5090
- }
5091
- return true;
5092
- }
5093
- else if (raHeader) {
5094
- this._rateLimits.all = new Date(now + parseRetryAfterHeader(now, raHeader));
5095
- return true;
5096
- }
5097
- return false;
5097
+ const category = requestTypeToCategory(requestType);
5098
+ return isRateLimited(this._rateLimits, category);
5098
5099
  }
5099
5100
  }
5100
5101
 
@@ -5109,11 +5110,13 @@ var Sentry = (function (exports) {
5109
5110
  * @param originalPayload Original payload used to create SentryRequest
5110
5111
  */
5111
5112
  _sendRequest(sentryRequest, originalPayload) {
5113
+ // eslint-disable-next-line deprecation/deprecation
5112
5114
  if (this._isRateLimited(sentryRequest.type)) {
5113
5115
  this.recordLostEvent('ratelimit_backoff', sentryRequest.type);
5114
5116
  return Promise.reject({
5115
5117
  event: originalPayload,
5116
5118
  type: sentryRequest.type,
5119
+ // eslint-disable-next-line deprecation/deprecation
5117
5120
  reason: `Transport for ${sentryRequest.type} requests locked till ${this._disabledUntil(sentryRequest.type)} due to too many requests.`,
5118
5121
  status: 429,
5119
5122
  });
@@ -5171,11 +5174,13 @@ var Sentry = (function (exports) {
5171
5174
  * @param originalPayload Original payload used to create SentryRequest
5172
5175
  */
5173
5176
  _sendRequest(sentryRequest, originalPayload) {
5177
+ // eslint-disable-next-line deprecation/deprecation
5174
5178
  if (this._isRateLimited(sentryRequest.type)) {
5175
5179
  this.recordLostEvent('ratelimit_backoff', sentryRequest.type);
5176
5180
  return Promise.reject({
5177
5181
  event: originalPayload,
5178
5182
  type: sentryRequest.type,
5183
+ // eslint-disable-next-line deprecation/deprecation
5179
5184
  reason: `Transport for ${sentryRequest.type} requests locked till ${this._disabledUntil(sentryRequest.type)} due to too many requests.`,
5180
5185
  status: 429,
5181
5186
  });
@@ -5229,13 +5234,13 @@ var Sentry = (function (exports) {
5229
5234
  * @inheritDoc
5230
5235
  */
5231
5236
  eventFromException(exception, hint) {
5232
- return eventFromException(this._options, exception, hint);
5237
+ return eventFromException(exception, hint, this._options.attachStacktrace);
5233
5238
  }
5234
5239
  /**
5235
5240
  * @inheritDoc
5236
5241
  */
5237
5242
  eventFromMessage(message, level = exports.Severity.Info, hint) {
5238
- return eventFromMessage(this._options, message, level, hint);
5243
+ return eventFromMessage(message, level, hint, this._options.attachStacktrace);
5239
5244
  }
5240
5245
  /**
5241
5246
  * @inheritDoc
@@ -5381,15 +5386,11 @@ var Sentry = (function (exports) {
5381
5386
  return;
5382
5387
  }
5383
5388
  if (!options.eventId) {
5384
- if (isDebugBuild()) {
5385
- logger.error(`Missing eventId option in showReportDialog call`);
5386
- }
5389
+ logger.error('Missing eventId option in showReportDialog call');
5387
5390
  return;
5388
5391
  }
5389
5392
  if (!options.dsn) {
5390
- if (isDebugBuild()) {
5391
- logger.error(`Missing dsn option in showReportDialog call`);
5392
- }
5393
+ logger.error('Missing dsn option in showReportDialog call');
5393
5394
  return;
5394
5395
  }
5395
5396
  const script = global$2.document.createElement('script');
@@ -5462,10 +5463,7 @@ var Sentry = (function (exports) {
5462
5463
  }
5463
5464
  const event = error === undefined && isString(msg)
5464
5465
  ? _eventFromIncompleteOnError(msg, url, line, column)
5465
- : _enhanceEventWithInitialFrame(eventFromUnknownInput(error || msg, undefined, {
5466
- attachStacktrace,
5467
- isRejection: false,
5468
- }), url, line, column);
5466
+ : _enhanceEventWithInitialFrame(eventFromUnknownInput(error || msg, undefined, attachStacktrace, false), url, line, column);
5469
5467
  event.level = exports.Severity.Error;
5470
5468
  addMechanismAndCapture(hub, error, event, 'onerror');
5471
5469
  });
@@ -5504,10 +5502,7 @@ var Sentry = (function (exports) {
5504
5502
  }
5505
5503
  const event = isPrimitive(error)
5506
5504
  ? _eventFromRejectionWithPrimitive(error)
5507
- : eventFromUnknownInput(error, undefined, {
5508
- attachStacktrace,
5509
- isRejection: true,
5510
- });
5505
+ : eventFromUnknownInput(error, undefined, attachStacktrace, true);
5511
5506
  event.level = exports.Severity.Error;
5512
5507
  addMechanismAndCapture(hub, error, event, 'onunhandledrejection');
5513
5508
  return;
@@ -5587,9 +5582,7 @@ var Sentry = (function (exports) {
5587
5582
  return event;
5588
5583
  }
5589
5584
  function globalHandlerLog(type) {
5590
- if (isDebugBuild()) {
5591
- logger.log(`Global Handler attached: ${type}`);
5592
- }
5585
+ logger.log(`Global Handler attached: ${type}`);
5593
5586
  }
5594
5587
  function addMechanismAndCapture(hub, error, event, type) {
5595
5588
  addExceptionMechanism(event, {
@@ -5700,16 +5693,18 @@ var Sentry = (function (exports) {
5700
5693
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5701
5694
  return function (callback) {
5702
5695
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5703
- return original.call(this, wrap$1(callback, {
5704
- mechanism: {
5705
- data: {
5706
- function: 'requestAnimationFrame',
5707
- 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',
5708
5705
  },
5709
- handled: true,
5710
- type: 'instrument',
5711
- },
5712
- }));
5706
+ }),
5707
+ ]);
5713
5708
  };
5714
5709
  }
5715
5710
  /** JSDoc */
@@ -5776,19 +5771,22 @@ var Sentry = (function (exports) {
5776
5771
  catch (err) {
5777
5772
  // can sometimes get 'Permission denied to access property "handle Event'
5778
5773
  }
5779
- return original.call(this, eventName,
5780
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5781
- wrap$1(fn, {
5782
- mechanism: {
5783
- data: {
5784
- function: 'addEventListener',
5785
- handler: getFunctionName(fn),
5786
- 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',
5787
5786
  },
5788
- handled: true,
5789
- type: 'instrument',
5790
- },
5791
- }), options);
5787
+ }),
5788
+ options,
5789
+ ]);
5792
5790
  };
5793
5791
  });
5794
5792
  fill(proto, 'removeEventListener', function (originalRemoveEventListener) {
@@ -6150,7 +6148,7 @@ var Sentry = (function (exports) {
6150
6148
  // Juuust in case something goes wrong
6151
6149
  try {
6152
6150
  if (_shouldDropEvent(currentEvent, self._previousEvent)) {
6153
- logger.warn(`Event dropped due to being a duplicate of previously captured event.`);
6151
+ logger.warn('Event dropped due to being a duplicate of previously captured event.');
6154
6152
  return null;
6155
6153
  }
6156
6154
  }
@@ -6511,9 +6509,7 @@ var Sentry = (function (exports) {
6511
6509
  if (client) {
6512
6510
  return client.flush(timeout);
6513
6511
  }
6514
- if (isDebugBuild()) {
6515
- logger.warn('Cannot flush events. No client defined.');
6516
- }
6512
+ logger.warn('Cannot flush events. No client defined.');
6517
6513
  return resolvedSyncPromise(false);
6518
6514
  }
6519
6515
  /**
@@ -6529,9 +6525,7 @@ var Sentry = (function (exports) {
6529
6525
  if (client) {
6530
6526
  return client.close(timeout);
6531
6527
  }
6532
- if (isDebugBuild()) {
6533
- logger.warn('Cannot flush events and disable SDK. No client defined.');
6534
- }
6528
+ logger.warn('Cannot flush events and disable SDK. No client defined.');
6535
6529
  return resolvedSyncPromise(false);
6536
6530
  }
6537
6531
  /**
@@ -6556,9 +6550,7 @@ var Sentry = (function (exports) {
6556
6550
  const window = getGlobalObject();
6557
6551
  const document = window.document;
6558
6552
  if (typeof document === 'undefined') {
6559
- if (isDebugBuild()) {
6560
- logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
6561
- }
6553
+ logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
6562
6554
  return;
6563
6555
  }
6564
6556
  const hub = getCurrentHub();