vviinn-widgets 0.9.4 → 0.9.8

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 (108) hide show
  1. package/dist/cjs/{app-globals-f0541d27.js → app-globals-cb302902.js} +727 -440
  2. package/dist/cjs/{cropper-handler_24.cjs.entry.js → cropper-handler_28.cjs.entry.js} +183 -44
  3. package/dist/cjs/{imageSearch.store-8df0d093.js → imageSearch.store-c5635894.js} +128 -171
  4. package/dist/cjs/{index-b17cc6fc.js → index-e31c19f6.js} +16 -357
  5. package/dist/cjs/loader.cjs.js +4 -4
  6. package/dist/cjs/{products.worker-0b7b46ba.js → products.worker-6d7701ae.js} +3 -3
  7. package/dist/cjs/products.worker-c3f8f567.js +1 -0
  8. package/dist/cjs/{vpr-slider-1b3cf3f6.js → vpr-slider-78ecd2d9.js} +3 -3
  9. package/dist/cjs/vpr-slider.cjs.entry.js +2 -2
  10. package/dist/cjs/vviinn-vpr-widget.cjs.entry.js +3 -3
  11. package/dist/cjs/vviinn-widgets.cjs.js +4 -4
  12. package/dist/collection/Image/error.js +1 -1
  13. package/dist/collection/collection-manifest.json +5 -1
  14. package/dist/collection/components/customized-slots.js +42 -0
  15. package/dist/collection/components/image-search/search-filters/search-filters.css +5 -1
  16. package/dist/collection/components/vviinn-example-images/vviinn-example-image/vviinn-example-image.css +24 -0
  17. package/dist/collection/components/vviinn-example-images/vviinn-example-image/vviinn-example-image.js +12 -1
  18. package/dist/collection/components/vviinn-example-images/vviinn-example-images.css +0 -2
  19. package/dist/collection/components/vviinn-example-images/vviinn-example-images.js +14 -5
  20. package/dist/collection/components/vviinn-icons/index.js +19 -0
  21. package/dist/collection/components/vviinn-image-selector/vviinn-image-selector.js +5 -4
  22. package/dist/collection/components/vviinn-image-view/vviinn-image-view.css +15 -0
  23. package/dist/collection/components/vviinn-image-view/vviinn-image-view.js +2 -0
  24. package/dist/collection/components/vviinn-modal/vviinn-modal.css +6 -0
  25. package/dist/collection/components/vviinn-onboarding/onboarding-cards/onboarding-card.css +41 -0
  26. package/dist/collection/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-1/vviinn-onboarding-card-1.js +26 -0
  27. package/dist/collection/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-2/vviinn-onboarding-card-2.js +26 -0
  28. package/dist/collection/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-3/vviinn-onboarding-card-3.js +26 -0
  29. package/dist/collection/components/vviinn-onboarding/vviinn-onboarding.css +1 -4
  30. package/dist/collection/components/vviinn-onboarding/vviinn-onboarding.js +3 -22
  31. package/dist/collection/components/vviinn-preloader/vviinn-preloader.css +35 -0
  32. package/dist/collection/components/vviinn-preloader/vviinn-preloader.js +15 -0
  33. package/dist/collection/components/vviinn-product-card/vviinn-product-card.js +1 -1
  34. package/dist/collection/components/vviinn-vps-button/vviinn-vps-button.css +0 -16
  35. package/dist/collection/components/vviinn-vps-button/vviinn-vps-button.js +42 -5
  36. package/dist/collection/components/vviinn-vps-widget/vviinn-vps-widget.css +28 -9
  37. package/dist/collection/global.js +2 -0
  38. package/dist/collection/store/imageSearch.store.js +4 -1
  39. package/dist/esm/{app-globals-d620fe1d.js → app-globals-6c5ba71d.js} +727 -440
  40. package/dist/esm/{cropper-handler_24.entry.js → cropper-handler_28.entry.js} +180 -45
  41. package/dist/esm/{imageSearch.store-21115251.js → imageSearch.store-2ae91a04.js} +128 -171
  42. package/dist/esm/{index-797d5e85.js → index-6fe72089.js} +16 -358
  43. package/dist/esm/loader.js +4 -4
  44. package/dist/esm/{products.worker-1845b8e1.js → products.worker-4781afb4.js} +3 -3
  45. package/dist/esm/products.worker-c3f8f567.js +1 -0
  46. package/dist/esm/{vpr-slider-52e37913.js → vpr-slider-394539c9.js} +3 -3
  47. package/dist/esm/vpr-slider.entry.js +2 -2
  48. package/dist/esm/vviinn-vpr-widget.entry.js +3 -3
  49. package/dist/esm/vviinn-widgets.js +4 -4
  50. package/dist/loader/index.d.ts +0 -1
  51. package/dist/types/components/customized-slots.d.ts +2 -0
  52. package/dist/types/components/vviinn-example-images/vviinn-example-image/vviinn-example-image.d.ts +2 -0
  53. package/dist/types/components/vviinn-example-images/vviinn-example-images.d.ts +2 -0
  54. package/dist/types/components/vviinn-icons/index.d.ts +5 -0
  55. package/dist/types/components/vviinn-image-selector/vviinn-image-selector.d.ts +2 -2
  56. package/dist/types/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-1/vviinn-onboarding-card-1.d.ts +5 -0
  57. package/dist/types/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-2/vviinn-onboarding-card-2.d.ts +5 -0
  58. package/dist/types/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-3/vviinn-onboarding-card-3.d.ts +5 -0
  59. package/dist/types/components/vviinn-preloader/vviinn-preloader.d.ts +3 -0
  60. package/dist/types/components/vviinn-vps-button/vviinn-vps-button.d.ts +17 -0
  61. package/dist/types/components.d.ts +52 -0
  62. package/dist/types/stencil-public-runtime.d.ts +1 -0
  63. package/dist/types/store/imageSearch.store.d.ts +1 -0
  64. package/dist/vviinn-widgets/p-1839b1ac.entry.js +1 -0
  65. package/dist/vviinn-widgets/p-1dec6cff.js +1 -0
  66. package/dist/vviinn-widgets/p-3464243f.entry.js +1 -0
  67. package/dist/vviinn-widgets/{p-4811373f.js → p-6b836146.js} +1 -1
  68. package/dist/vviinn-widgets/p-78e7bb76.js +15 -0
  69. package/dist/vviinn-widgets/p-803f9051.entry.js +1 -0
  70. package/dist/vviinn-widgets/p-8caf74a6.js +1 -0
  71. package/dist/vviinn-widgets/p-c3f8f567.js +1 -0
  72. package/dist/vviinn-widgets/p-f4466045.js +1 -0
  73. package/dist/vviinn-widgets/vviinn-widgets.esm.js +1 -1
  74. package/package.json +3 -3
  75. package/www/build/p-1839b1ac.entry.js +1 -0
  76. package/www/build/p-1dec6cff.js +1 -0
  77. package/www/build/p-3464243f.entry.js +1 -0
  78. package/www/build/{p-4811373f.js → p-6b836146.js} +1 -1
  79. package/www/build/p-78e7bb76.js +15 -0
  80. package/www/build/p-803f9051.entry.js +1 -0
  81. package/www/build/p-8caf74a6.js +1 -0
  82. package/www/build/p-a7f34b72.js +125 -0
  83. package/www/build/p-c3f8f567.js +1 -0
  84. package/www/build/p-e0153ae2.css +6 -0
  85. package/www/build/p-f4466045.js +1 -0
  86. package/www/build/vviinn-widgets.esm.js +1 -1
  87. package/www/build/vviinn-widgets.js +1 -1
  88. package/www/index.html +6 -1
  89. package/dist/cjs/products.worker-8da825fb.js +0 -1
  90. package/dist/esm/products.worker-8da825fb.js +0 -1
  91. package/dist/vviinn-widgets/p-05205e93.entry.js +0 -1
  92. package/dist/vviinn-widgets/p-1ee37668.entry.js +0 -1
  93. package/dist/vviinn-widgets/p-45b3bdb4.js +0 -1
  94. package/dist/vviinn-widgets/p-753a781d.js +0 -1
  95. package/dist/vviinn-widgets/p-8da825fb.js +0 -1
  96. package/dist/vviinn-widgets/p-a2616f41.entry.js +0 -1
  97. package/dist/vviinn-widgets/p-a821c5d2.js +0 -1
  98. package/dist/vviinn-widgets/p-ee78e570.js +0 -15
  99. package/www/build/p-05205e93.entry.js +0 -1
  100. package/www/build/p-1ee37668.entry.js +0 -1
  101. package/www/build/p-45b3bdb4.js +0 -1
  102. package/www/build/p-753a781d.js +0 -1
  103. package/www/build/p-8da825fb.js +0 -1
  104. package/www/build/p-a2616f41.entry.js +0 -1
  105. package/www/build/p-a67898be.css +0 -1
  106. package/www/build/p-a821c5d2.js +0 -1
  107. package/www/build/p-ece95bb2.js +0 -1
  108. package/www/build/p-ee78e570.js +0 -15
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const index = require('./index-e31c19f6.js');
4
+
3
5
  /*! *****************************************************************************
4
6
  Copyright (c) Microsoft Corporation.
5
7
 
@@ -175,7 +177,7 @@ var Status;
175
177
  Status["RateLimit"] = "rate_limit";
176
178
  /** The event could not be processed. */
177
179
  Status["Invalid"] = "invalid";
178
- /** A server-side error ocurred during submission. */
180
+ /** A server-side error occurred during submission. */
179
181
  Status["Failed"] = "failed";
180
182
  })(Status || (Status = {}));
181
183
  // eslint-disable-next-line @typescript-eslint/no-namespace, import/export
@@ -212,6 +214,102 @@ var TransactionSamplingMethod;
212
214
  TransactionSamplingMethod["Inheritance"] = "inheritance";
213
215
  })(TransactionSamplingMethod || (TransactionSamplingMethod = {}));
214
216
 
217
+ var Outcome;
218
+ (function (Outcome) {
219
+ Outcome["BeforeSend"] = "before_send";
220
+ Outcome["EventProcessor"] = "event_processor";
221
+ Outcome["NetworkError"] = "network_error";
222
+ Outcome["QueueOverflow"] = "queue_overflow";
223
+ Outcome["RateLimitBackoff"] = "ratelimit_backoff";
224
+ Outcome["SampleRate"] = "sample_rate";
225
+ })(Outcome || (Outcome = {}));
226
+
227
+ /**
228
+ * Consumes the promise and logs the error when it rejects.
229
+ * @param promise A promise to forget.
230
+ */
231
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
232
+ function forget(promise) {
233
+ void promise.then(null, function (e) {
234
+ // TODO: Use a better logging mechanism
235
+ // eslint-disable-next-line no-console
236
+ console.error(e);
237
+ });
238
+ }
239
+
240
+ /**
241
+ * NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
242
+ * you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
243
+ */
244
+ /**
245
+ * Checks whether we're in the Node.js or Browser environment
246
+ *
247
+ * @returns Answer to given question
248
+ */
249
+ function isNodeEnv() {
250
+ return Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
251
+ }
252
+ /**
253
+ * Requires a module which is protected against bundler minification.
254
+ *
255
+ * @param request The module path to resolve
256
+ */
257
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
258
+ function dynamicRequire(mod, request) {
259
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
260
+ return mod.require(request);
261
+ }
262
+ /**
263
+ * Helper for dynamically loading module that should work with linked dependencies.
264
+ * The problem is that we _should_ be using `require(require.resolve(moduleName, { paths: [cwd()] }))`
265
+ * However it's _not possible_ to do that with Webpack, as it has to know all the dependencies during
266
+ * build time. `require.resolve` is also not available in any other way, so we cannot create,
267
+ * a fake helper like we do with `dynamicRequire`.
268
+ *
269
+ * We always prefer to use local package, thus the value is not returned early from each `try/catch` block.
270
+ * That is to mimic the behavior of `require.resolve` exactly.
271
+ *
272
+ * @param moduleName module name to require
273
+ * @returns possibly required module
274
+ */
275
+ function loadModule(moduleName) {
276
+ var mod;
277
+ try {
278
+ mod = dynamicRequire(module, moduleName);
279
+ }
280
+ catch (e) {
281
+ // no-empty
282
+ }
283
+ try {
284
+ var cwd = dynamicRequire(module, 'process').cwd;
285
+ mod = dynamicRequire(module, cwd() + "/node_modules/" + moduleName);
286
+ }
287
+ catch (e) {
288
+ // no-empty
289
+ }
290
+ return mod;
291
+ }
292
+
293
+ /**
294
+ * NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
295
+ * you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
296
+ */
297
+ var fallbackGlobalObject = {};
298
+ /**
299
+ * Safely get global scope object
300
+ *
301
+ * @returns Global scope object
302
+ */
303
+ function getGlobalObject() {
304
+ return (isNodeEnv()
305
+ ? global
306
+ : typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
307
+ ? window // eslint-disable-line no-restricted-globals
308
+ : typeof self !== 'undefined'
309
+ ? self
310
+ : fallbackGlobalObject);
311
+ }
312
+
215
313
  /* eslint-disable @typescript-eslint/no-explicit-any */
216
314
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
217
315
  /**
@@ -448,6 +546,18 @@ function _htmlElementAsString(el, keyAttrs) {
448
546
  }
449
547
  return out.join('');
450
548
  }
549
+ /**
550
+ * A safe form of location.href
551
+ */
552
+ function getLocationHref() {
553
+ var global = getGlobalObject();
554
+ try {
555
+ return global.document.location.href;
556
+ }
557
+ catch (oO) {
558
+ return '';
559
+ }
560
+ }
451
561
 
452
562
  var setPrototypeOf = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties);
453
563
  /**
@@ -465,8 +575,7 @@ function setProtoOf(obj, proto) {
465
575
  // eslint-disable-next-line @typescript-eslint/ban-types
466
576
  function mixinProperties(obj, proto) {
467
577
  for (var prop in proto) {
468
- // eslint-disable-next-line no-prototype-builtins
469
- if (!obj.hasOwnProperty(prop)) {
578
+ if (!Object.prototype.hasOwnProperty.call(obj, prop)) {
470
579
  // @ts-ignore typescript complains about indexing so we remove
471
580
  obj[prop] = proto[prop];
472
581
  }
@@ -575,207 +684,19 @@ var Dsn = /** @class */ (function () {
575
684
  }
576
685
  };
577
686
  return Dsn;
578
- }());
579
-
580
- /**
581
- * Checks whether we're in the Node.js or Browser environment
582
- *
583
- * @returns Answer to given question
584
- */
585
- function isNodeEnv() {
586
- return Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
587
- }
588
- /**
589
- * Requires a module which is protected against bundler minification.
590
- *
591
- * @param request The module path to resolve
592
- */
593
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
594
- function dynamicRequire(mod, request) {
595
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
596
- return mod.require(request);
597
- }
598
- /**
599
- * Helper for dynamically loading module that should work with linked dependencies.
600
- * The problem is that we _should_ be using `require(require.resolve(moduleName, { paths: [cwd()] }))`
601
- * However it's _not possible_ to do that with Webpack, as it has to know all the dependencies during
602
- * build time. `require.resolve` is also not available in any other way, so we cannot create,
603
- * a fake helper like we do with `dynamicRequire`.
604
- *
605
- * We always prefer to use local package, thus the value is not returned early from each `try/catch` block.
606
- * That is to mimic the behavior of `require.resolve` exactly.
607
- *
608
- * @param moduleName module name to require
609
- * @returns possibly required module
610
- */
611
- function loadModule(moduleName) {
612
- var mod;
613
- try {
614
- mod = dynamicRequire(module, moduleName);
615
- }
616
- catch (e) {
617
- // no-empty
618
- }
619
- try {
620
- var cwd = dynamicRequire(module, 'process').cwd;
621
- mod = dynamicRequire(module, cwd() + "/node_modules/" + moduleName);
622
- }
623
- catch (e) {
624
- // no-empty
625
- }
626
- return mod;
627
- }
628
-
629
- /**
630
- * Truncates given string to the maximum characters count
631
- *
632
- * @param str An object that contains serializable values
633
- * @param max Maximum number of characters in truncated string (0 = unlimited)
634
- * @returns string Encoded
635
- */
636
- function truncate(str, max) {
637
- if (max === void 0) { max = 0; }
638
- if (typeof str !== 'string' || max === 0) {
639
- return str;
640
- }
641
- return str.length <= max ? str : str.substr(0, max) + "...";
642
- }
643
- /**
644
- * Join values in array
645
- * @param input array of values to be joined together
646
- * @param delimiter string to be placed in-between values
647
- * @returns Joined values
648
- */
649
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
650
- function safeJoin(input, delimiter) {
651
- if (!Array.isArray(input)) {
652
- return '';
653
- }
654
- var output = [];
655
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
656
- for (var i = 0; i < input.length; i++) {
657
- var value = input[i];
658
- try {
659
- output.push(String(value));
660
- }
661
- catch (e) {
662
- output.push('[value cannot be serialized]');
663
- }
664
- }
665
- return output.join(delimiter);
666
- }
667
- /**
668
- * Checks if the value matches a regex or includes the string
669
- * @param value The string value to be checked against
670
- * @param pattern Either a regex or a string that must be contained in value
671
- */
672
- function isMatchingPattern(value, pattern) {
673
- if (!isString(value)) {
674
- return false;
675
- }
676
- if (isRegExp(pattern)) {
677
- return pattern.test(value);
678
- }
679
- if (typeof pattern === 'string') {
680
- return value.indexOf(pattern) !== -1;
681
- }
682
- return false;
683
- }
684
-
685
- var fallbackGlobalObject = {};
686
- /**
687
- * Safely get global scope object
688
- *
689
- * @returns Global scope object
690
- */
691
- function getGlobalObject() {
692
- return (isNodeEnv()
693
- ? global
694
- : typeof window !== 'undefined'
695
- ? window
696
- : typeof self !== 'undefined'
697
- ? self
698
- : fallbackGlobalObject);
699
- }
700
- /**
701
- * UUID4 generator
702
- *
703
- * @returns string Generated UUID4.
704
- */
705
- function uuid4() {
706
- var global = getGlobalObject();
707
- var crypto = global.crypto || global.msCrypto;
708
- if (!(crypto === void 0) && crypto.getRandomValues) {
709
- // Use window.crypto API if available
710
- var arr = new Uint16Array(8);
711
- crypto.getRandomValues(arr);
712
- // set 4 in byte 7
713
- // eslint-disable-next-line no-bitwise
714
- arr[3] = (arr[3] & 0xfff) | 0x4000;
715
- // set 2 most significant bits of byte 9 to '10'
716
- // eslint-disable-next-line no-bitwise
717
- arr[4] = (arr[4] & 0x3fff) | 0x8000;
718
- var pad = function (num) {
719
- var v = num.toString(16);
720
- while (v.length < 4) {
721
- v = "0" + v;
722
- }
723
- return v;
724
- };
725
- return (pad(arr[0]) + pad(arr[1]) + pad(arr[2]) + pad(arr[3]) + pad(arr[4]) + pad(arr[5]) + pad(arr[6]) + pad(arr[7]));
726
- }
727
- // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
728
- return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
729
- // eslint-disable-next-line no-bitwise
730
- var r = (Math.random() * 16) | 0;
731
- // eslint-disable-next-line no-bitwise
732
- var v = c === 'x' ? r : (r & 0x3) | 0x8;
733
- return v.toString(16);
734
- });
735
- }
736
- /**
737
- * Parses string form of URL into an object
738
- * // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B
739
- * // intentionally using regex and not <a/> href parsing trick because React Native and other
740
- * // environments where DOM might not be available
741
- * @returns parsed URL object
742
- */
743
- function parseUrl(url) {
744
- if (!url) {
745
- return {};
746
- }
747
- var match = url.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);
748
- if (!match) {
749
- return {};
750
- }
751
- // coerce to undefined values to empty string so we don't get 'undefined'
752
- var query = match[6] || '';
753
- var fragment = match[8] || '';
754
- return {
755
- host: match[4],
756
- path: match[5],
757
- protocol: match[2],
758
- relative: match[5] + query + fragment,
759
- };
760
- }
687
+ }());
688
+
689
+ // TODO: Implement different loggers for different environments
690
+ var global$9 = getGlobalObject();
691
+ /** Prefix for logging strings */
692
+ var PREFIX = 'Sentry Logger ';
761
693
  /**
762
- * Extracts either message or type+value from an event that can be used for user-facing logs
763
- * @returns event's description
694
+ * Temporarily unwrap `console.log` and friends in order to perform the given callback using the original methods.
695
+ * Restores wrapping after the callback completes.
696
+ *
697
+ * @param callback The function to run against the original `console` messages
698
+ * @returns The results of the callback
764
699
  */
765
- function getEventDescription(event) {
766
- if (event.message) {
767
- return event.message;
768
- }
769
- if (event.exception && event.exception.values && event.exception.values[0]) {
770
- var exception = event.exception.values[0];
771
- if (exception.type && exception.value) {
772
- return exception.type + ": " + exception.value;
773
- }
774
- return exception.type || exception.value || event.event_id || '<unknown>';
775
- }
776
- return event.event_id || '<unknown>';
777
- }
778
- /** JSDoc */
779
700
  function consoleSandbox(callback) {
780
701
  var global = getGlobalObject();
781
702
  var levels = ['debug', 'info', 'warn', 'error', 'log', 'assert'];
@@ -801,80 +722,6 @@ function consoleSandbox(callback) {
801
722
  });
802
723
  return result;
803
724
  }
804
- /**
805
- * Adds exception values, type and value to an synthetic Exception.
806
- * @param event The event to modify.
807
- * @param value Value of the exception.
808
- * @param type Type of the exception.
809
- * @hidden
810
- */
811
- function addExceptionTypeValue(event, value, type) {
812
- event.exception = event.exception || {};
813
- event.exception.values = event.exception.values || [];
814
- event.exception.values[0] = event.exception.values[0] || {};
815
- event.exception.values[0].value = event.exception.values[0].value || value || '';
816
- event.exception.values[0].type = event.exception.values[0].type || type || 'Error';
817
- }
818
- /**
819
- * Adds exception mechanism to a given event.
820
- * @param event The event to modify.
821
- * @param mechanism Mechanism of the mechanism.
822
- * @hidden
823
- */
824
- function addExceptionMechanism(event, mechanism) {
825
- if (mechanism === void 0) { mechanism = {}; }
826
- // TODO: Use real type with `keyof Mechanism` thingy and maybe make it better?
827
- try {
828
- // @ts-ignore Type 'Mechanism | {}' is not assignable to type 'Mechanism | undefined'
829
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
830
- event.exception.values[0].mechanism = event.exception.values[0].mechanism || {};
831
- Object.keys(mechanism).forEach(function (key) {
832
- // @ts-ignore Mechanism has no index signature
833
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
834
- event.exception.values[0].mechanism[key] = mechanism[key];
835
- });
836
- }
837
- catch (_oO) {
838
- // no-empty
839
- }
840
- }
841
- /**
842
- * A safe form of location.href
843
- */
844
- function getLocationHref() {
845
- try {
846
- return document.location.href;
847
- }
848
- catch (oO) {
849
- return '';
850
- }
851
- }
852
- var defaultRetryAfter = 60 * 1000; // 60 seconds
853
- /**
854
- * Extracts Retry-After value from the request header or returns default value
855
- * @param now current unix timestamp
856
- * @param header string representation of 'Retry-After' header
857
- */
858
- function parseRetryAfterHeader(now, header) {
859
- if (!header) {
860
- return defaultRetryAfter;
861
- }
862
- var headerDelay = parseInt("" + header, 10);
863
- if (!isNaN(headerDelay)) {
864
- return headerDelay * 1000;
865
- }
866
- var headerDate = Date.parse("" + header);
867
- if (!isNaN(headerDate)) {
868
- return headerDate - now;
869
- }
870
- return defaultRetryAfter;
871
- }
872
-
873
- /* eslint-disable @typescript-eslint/no-explicit-any */
874
- // TODO: Implement different loggers for different environments
875
- var global$6 = getGlobalObject();
876
- /** Prefix for logging strings */
877
- var PREFIX = 'Sentry Logger ';
878
725
  /** JSDoc */
879
726
  var Logger = /** @class */ (function () {
880
727
  /** JSDoc */
@@ -899,7 +746,7 @@ var Logger = /** @class */ (function () {
899
746
  return;
900
747
  }
901
748
  consoleSandbox(function () {
902
- global$6.console.log(PREFIX + "[Log]: " + args.join(' '));
749
+ global$9.console.log(PREFIX + "[Log]: " + args.join(' '));
903
750
  });
904
751
  };
905
752
  /** JSDoc */
@@ -912,7 +759,7 @@ var Logger = /** @class */ (function () {
912
759
  return;
913
760
  }
914
761
  consoleSandbox(function () {
915
- global$6.console.warn(PREFIX + "[Warn]: " + args.join(' '));
762
+ global$9.console.warn(PREFIX + "[Warn]: " + args.join(' '));
916
763
  });
917
764
  };
918
765
  /** JSDoc */
@@ -925,14 +772,14 @@ var Logger = /** @class */ (function () {
925
772
  return;
926
773
  }
927
774
  consoleSandbox(function () {
928
- global$6.console.error(PREFIX + "[Error]: " + args.join(' '));
775
+ global$9.console.error(PREFIX + "[Error]: " + args.join(' '));
929
776
  });
930
777
  };
931
778
  return Logger;
932
779
  }());
933
780
  // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
934
- global$6.__SENTRY__ = global$6.__SENTRY__ || {};
935
- var logger = global$6.__SENTRY__.logger || (global$6.__SENTRY__.logger = new Logger());
781
+ global$9.__SENTRY__ = global$9.__SENTRY__ || {};
782
+ var logger = global$9.__SENTRY__.logger || (global$9.__SENTRY__.logger = new Logger());
936
783
 
937
784
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
938
785
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -1005,6 +852,62 @@ function getFunctionName(fn) {
1005
852
  }
1006
853
  }
1007
854
 
855
+ /**
856
+ * Truncates given string to the maximum characters count
857
+ *
858
+ * @param str An object that contains serializable values
859
+ * @param max Maximum number of characters in truncated string (0 = unlimited)
860
+ * @returns string Encoded
861
+ */
862
+ function truncate(str, max) {
863
+ if (max === void 0) { max = 0; }
864
+ if (typeof str !== 'string' || max === 0) {
865
+ return str;
866
+ }
867
+ return str.length <= max ? str : str.substr(0, max) + "...";
868
+ }
869
+ /**
870
+ * Join values in array
871
+ * @param input array of values to be joined together
872
+ * @param delimiter string to be placed in-between values
873
+ * @returns Joined values
874
+ */
875
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
876
+ function safeJoin(input, delimiter) {
877
+ if (!Array.isArray(input)) {
878
+ return '';
879
+ }
880
+ var output = [];
881
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
882
+ for (var i = 0; i < input.length; i++) {
883
+ var value = input[i];
884
+ try {
885
+ output.push(String(value));
886
+ }
887
+ catch (e) {
888
+ output.push('[value cannot be serialized]');
889
+ }
890
+ }
891
+ return output.join(delimiter);
892
+ }
893
+ /**
894
+ * Checks if the value matches a regex or includes the string
895
+ * @param value The string value to be checked against
896
+ * @param pattern Either a regex or a string that must be contained in value
897
+ */
898
+ function isMatchingPattern(value, pattern) {
899
+ if (!isString(value)) {
900
+ return false;
901
+ }
902
+ if (isRegExp(pattern)) {
903
+ return pattern.test(value);
904
+ }
905
+ if (typeof pattern === 'string') {
906
+ return value.indexOf(pattern) !== -1;
907
+ }
908
+ return false;
909
+ }
910
+
1008
911
  /**
1009
912
  * Replace a method in an object with a wrapped version of itself.
1010
913
  *
@@ -1174,9 +1077,13 @@ function normalizeValue(value, key) {
1174
1077
  if (typeof global !== 'undefined' && value === global) {
1175
1078
  return '[Global]';
1176
1079
  }
1080
+ // It's safe to use `window` and `document` here in this manner, as we are asserting using `typeof` first
1081
+ // which won't throw if they are not present.
1082
+ // eslint-disable-next-line no-restricted-globals
1177
1083
  if (typeof window !== 'undefined' && value === window) {
1178
1084
  return '[Window]';
1179
1085
  }
1086
+ // eslint-disable-next-line no-restricted-globals
1180
1087
  if (typeof document !== 'undefined' && value === document) {
1181
1088
  return '[Document]';
1182
1089
  }
@@ -1441,7 +1348,7 @@ function supportsHistory() {
1441
1348
  return !isChromePackagedApp && hasHistoryApi;
1442
1349
  }
1443
1350
 
1444
- var global$5 = getGlobalObject();
1351
+ var global$8 = getGlobalObject();
1445
1352
  /**
1446
1353
  * Instrument native APIs to call handlers that can be used to create breadcrumbs, APM spans etc.
1447
1354
  * - Console API
@@ -1526,14 +1433,14 @@ function triggerHandlers(type, data) {
1526
1433
  }
1527
1434
  /** JSDoc */
1528
1435
  function instrumentConsole() {
1529
- if (!('console' in global$5)) {
1436
+ if (!('console' in global$8)) {
1530
1437
  return;
1531
1438
  }
1532
1439
  ['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) {
1533
- if (!(level in global$5.console)) {
1440
+ if (!(level in global$8.console)) {
1534
1441
  return;
1535
1442
  }
1536
- fill(global$5.console, level, function (originalConsoleLevel) {
1443
+ fill(global$8.console, level, function (originalConsoleLevel) {
1537
1444
  return function () {
1538
1445
  var args = [];
1539
1446
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1542,7 +1449,7 @@ function instrumentConsole() {
1542
1449
  triggerHandlers('console', { args: args, level: level });
1543
1450
  // this fails for some browsers. :(
1544
1451
  if (originalConsoleLevel) {
1545
- Function.prototype.apply.call(originalConsoleLevel, global$5.console, args);
1452
+ Function.prototype.apply.call(originalConsoleLevel, global$8.console, args);
1546
1453
  }
1547
1454
  };
1548
1455
  });
@@ -1553,7 +1460,7 @@ function instrumentFetch() {
1553
1460
  if (!supportsNativeFetch()) {
1554
1461
  return;
1555
1462
  }
1556
- fill(global$5, 'fetch', function (originalFetch) {
1463
+ fill(global$8, 'fetch', function (originalFetch) {
1557
1464
  return function () {
1558
1465
  var args = [];
1559
1466
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1569,7 +1476,7 @@ function instrumentFetch() {
1569
1476
  };
1570
1477
  triggerHandlers('fetch', __assign({}, handlerData));
1571
1478
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1572
- return originalFetch.apply(global$5, args).then(function (response) {
1479
+ return originalFetch.apply(global$8, args).then(function (response) {
1573
1480
  triggerHandlers('fetch', __assign(__assign({}, handlerData), { endTimestamp: Date.now(), response: response }));
1574
1481
  return response;
1575
1482
  }, function (error) {
@@ -1586,7 +1493,7 @@ function instrumentFetch() {
1586
1493
  /** Extract `method` from fetch call arguments */
1587
1494
  function getFetchMethod(fetchArgs) {
1588
1495
  if (fetchArgs === void 0) { fetchArgs = []; }
1589
- if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request) && fetchArgs[0].method) {
1496
+ if ('Request' in global$8 && isInstanceOf(fetchArgs[0], Request) && fetchArgs[0].method) {
1590
1497
  return String(fetchArgs[0].method).toUpperCase();
1591
1498
  }
1592
1499
  if (fetchArgs[1] && fetchArgs[1].method) {
@@ -1600,7 +1507,7 @@ function getFetchUrl(fetchArgs) {
1600
1507
  if (typeof fetchArgs[0] === 'string') {
1601
1508
  return fetchArgs[0];
1602
1509
  }
1603
- if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request)) {
1510
+ if ('Request' in global$8 && isInstanceOf(fetchArgs[0], Request)) {
1604
1511
  return fetchArgs[0].url;
1605
1512
  }
1606
1513
  return String(fetchArgs[0]);
@@ -1608,7 +1515,7 @@ function getFetchUrl(fetchArgs) {
1608
1515
  /* eslint-enable @typescript-eslint/no-unsafe-member-access */
1609
1516
  /** JSDoc */
1610
1517
  function instrumentXHR() {
1611
- if (!('XMLHttpRequest' in global$5)) {
1518
+ if (!('XMLHttpRequest' in global$8)) {
1612
1519
  return;
1613
1520
  }
1614
1521
  // Poor man's implementation of ES6 `Map`, tracking and keeping in sync key and value separately.
@@ -1709,13 +1616,13 @@ function instrumentHistory() {
1709
1616
  if (!supportsHistory()) {
1710
1617
  return;
1711
1618
  }
1712
- var oldOnPopState = global$5.onpopstate;
1713
- global$5.onpopstate = function () {
1619
+ var oldOnPopState = global$8.onpopstate;
1620
+ global$8.onpopstate = function () {
1714
1621
  var args = [];
1715
1622
  for (var _i = 0; _i < arguments.length; _i++) {
1716
1623
  args[_i] = arguments[_i];
1717
1624
  }
1718
- var to = global$5.location.href;
1625
+ var to = global$8.location.href;
1719
1626
  // keep track of the current URL state, as we always receive only the updated state
1720
1627
  var from = lastHref;
1721
1628
  lastHref = to;
@@ -1757,8 +1664,8 @@ function instrumentHistory() {
1757
1664
  return originalHistoryFunction.apply(this, args);
1758
1665
  };
1759
1666
  }
1760
- fill(global$5.history, 'pushState', historyReplacementFunction);
1761
- fill(global$5.history, 'replaceState', historyReplacementFunction);
1667
+ fill(global$8.history, 'pushState', historyReplacementFunction);
1668
+ fill(global$8.history, 'replaceState', historyReplacementFunction);
1762
1669
  }
1763
1670
  var debounceDuration = 1000;
1764
1671
  var debounceTimerID;
@@ -1861,14 +1768,14 @@ function makeDOMEventHandler(handler, globalListener) {
1861
1768
  }
1862
1769
  // Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together.
1863
1770
  clearTimeout(debounceTimerID);
1864
- debounceTimerID = global$5.setTimeout(function () {
1771
+ debounceTimerID = global$8.setTimeout(function () {
1865
1772
  debounceTimerID = undefined;
1866
1773
  }, debounceDuration);
1867
1774
  };
1868
1775
  }
1869
1776
  /** JSDoc */
1870
1777
  function instrumentDOM() {
1871
- if (!('document' in global$5)) {
1778
+ if (!('document' in global$8)) {
1872
1779
  return;
1873
1780
  }
1874
1781
  // Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom
@@ -1876,8 +1783,8 @@ function instrumentDOM() {
1876
1783
  // we instrument `addEventListener` so that we don't end up attaching this handler twice.
1877
1784
  var triggerDOMHandler = triggerHandlers.bind(null, 'dom');
1878
1785
  var globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true);
1879
- global$5.document.addEventListener('click', globalDOMEventHandler, false);
1880
- global$5.document.addEventListener('keypress', globalDOMEventHandler, false);
1786
+ global$8.document.addEventListener('click', globalDOMEventHandler, false);
1787
+ global$8.document.addEventListener('keypress', globalDOMEventHandler, false);
1881
1788
  // After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled
1882
1789
  // clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That
1883
1790
  // way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler
@@ -1885,7 +1792,7 @@ function instrumentDOM() {
1885
1792
  // guaranteed to fire at least once.)
1886
1793
  ['EventTarget', 'Node'].forEach(function (target) {
1887
1794
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1888
- var proto = global$5[target] && global$5[target].prototype;
1795
+ var proto = global$8[target] && global$8[target].prototype;
1889
1796
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
1890
1797
  if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
1891
1798
  return;
@@ -1946,8 +1853,8 @@ function instrumentDOM() {
1946
1853
  var _oldOnErrorHandler = null;
1947
1854
  /** JSDoc */
1948
1855
  function instrumentError() {
1949
- _oldOnErrorHandler = global$5.onerror;
1950
- global$5.onerror = function (msg, url, line, column, error) {
1856
+ _oldOnErrorHandler = global$8.onerror;
1857
+ global$8.onerror = function (msg, url, line, column, error) {
1951
1858
  triggerHandlers('error', {
1952
1859
  column: column,
1953
1860
  error: error,
@@ -1962,18 +1869,191 @@ function instrumentError() {
1962
1869
  return false;
1963
1870
  };
1964
1871
  }
1965
- var _oldOnUnhandledRejectionHandler = null;
1966
- /** JSDoc */
1967
- function instrumentUnhandledRejection() {
1968
- _oldOnUnhandledRejectionHandler = global$5.onunhandledrejection;
1969
- global$5.onunhandledrejection = function (e) {
1970
- triggerHandlers('unhandledrejection', e);
1971
- if (_oldOnUnhandledRejectionHandler) {
1972
- // eslint-disable-next-line prefer-rest-params
1973
- return _oldOnUnhandledRejectionHandler.apply(this, arguments);
1974
- }
1872
+ var _oldOnUnhandledRejectionHandler = null;
1873
+ /** JSDoc */
1874
+ function instrumentUnhandledRejection() {
1875
+ _oldOnUnhandledRejectionHandler = global$8.onunhandledrejection;
1876
+ global$8.onunhandledrejection = function (e) {
1877
+ triggerHandlers('unhandledrejection', e);
1878
+ if (_oldOnUnhandledRejectionHandler) {
1879
+ // eslint-disable-next-line prefer-rest-params
1880
+ return _oldOnUnhandledRejectionHandler.apply(this, arguments);
1881
+ }
1882
+ return true;
1883
+ };
1884
+ }
1885
+
1886
+ /**
1887
+ * UUID4 generator
1888
+ *
1889
+ * @returns string Generated UUID4.
1890
+ */
1891
+ function uuid4() {
1892
+ var global = getGlobalObject();
1893
+ var crypto = global.crypto || global.msCrypto;
1894
+ if (!(crypto === void 0) && crypto.getRandomValues) {
1895
+ // Use window.crypto API if available
1896
+ var arr = new Uint16Array(8);
1897
+ crypto.getRandomValues(arr);
1898
+ // set 4 in byte 7
1899
+ // eslint-disable-next-line no-bitwise
1900
+ arr[3] = (arr[3] & 0xfff) | 0x4000;
1901
+ // set 2 most significant bits of byte 9 to '10'
1902
+ // eslint-disable-next-line no-bitwise
1903
+ arr[4] = (arr[4] & 0x3fff) | 0x8000;
1904
+ var pad = function (num) {
1905
+ var v = num.toString(16);
1906
+ while (v.length < 4) {
1907
+ v = "0" + v;
1908
+ }
1909
+ return v;
1910
+ };
1911
+ return (pad(arr[0]) + pad(arr[1]) + pad(arr[2]) + pad(arr[3]) + pad(arr[4]) + pad(arr[5]) + pad(arr[6]) + pad(arr[7]));
1912
+ }
1913
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
1914
+ return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
1915
+ // eslint-disable-next-line no-bitwise
1916
+ var r = (Math.random() * 16) | 0;
1917
+ // eslint-disable-next-line no-bitwise
1918
+ var v = c === 'x' ? r : (r & 0x3) | 0x8;
1919
+ return v.toString(16);
1920
+ });
1921
+ }
1922
+ /**
1923
+ * Parses string form of URL into an object
1924
+ * // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B
1925
+ * // intentionally using regex and not <a/> href parsing trick because React Native and other
1926
+ * // environments where DOM might not be available
1927
+ * @returns parsed URL object
1928
+ */
1929
+ function parseUrl(url) {
1930
+ if (!url) {
1931
+ return {};
1932
+ }
1933
+ var match = url.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);
1934
+ if (!match) {
1935
+ return {};
1936
+ }
1937
+ // coerce to undefined values to empty string so we don't get 'undefined'
1938
+ var query = match[6] || '';
1939
+ var fragment = match[8] || '';
1940
+ return {
1941
+ host: match[4],
1942
+ path: match[5],
1943
+ protocol: match[2],
1944
+ relative: match[5] + query + fragment,
1945
+ };
1946
+ }
1947
+ /**
1948
+ * Extracts either message or type+value from an event that can be used for user-facing logs
1949
+ * @returns event's description
1950
+ */
1951
+ function getEventDescription(event) {
1952
+ if (event.message) {
1953
+ return event.message;
1954
+ }
1955
+ if (event.exception && event.exception.values && event.exception.values[0]) {
1956
+ var exception = event.exception.values[0];
1957
+ if (exception.type && exception.value) {
1958
+ return exception.type + ": " + exception.value;
1959
+ }
1960
+ return exception.type || exception.value || event.event_id || '<unknown>';
1961
+ }
1962
+ return event.event_id || '<unknown>';
1963
+ }
1964
+ /**
1965
+ * Adds exception values, type and value to an synthetic Exception.
1966
+ * @param event The event to modify.
1967
+ * @param value Value of the exception.
1968
+ * @param type Type of the exception.
1969
+ * @hidden
1970
+ */
1971
+ function addExceptionTypeValue(event, value, type) {
1972
+ event.exception = event.exception || {};
1973
+ event.exception.values = event.exception.values || [];
1974
+ event.exception.values[0] = event.exception.values[0] || {};
1975
+ event.exception.values[0].value = event.exception.values[0].value || value || '';
1976
+ event.exception.values[0].type = event.exception.values[0].type || type || 'Error';
1977
+ }
1978
+ /**
1979
+ * Adds exception mechanism data to a given event. Uses defaults if the second parameter is not passed.
1980
+ *
1981
+ * @param event The event to modify.
1982
+ * @param newMechanism Mechanism data to add to the event.
1983
+ * @hidden
1984
+ */
1985
+ function addExceptionMechanism(event, newMechanism) {
1986
+ var _a;
1987
+ if (!event.exception || !event.exception.values) {
1988
+ return;
1989
+ }
1990
+ var exceptionValue0 = event.exception.values[0];
1991
+ var defaultMechanism = { type: 'generic', handled: true };
1992
+ var currentMechanism = exceptionValue0.mechanism;
1993
+ exceptionValue0.mechanism = __assign(__assign(__assign({}, defaultMechanism), currentMechanism), newMechanism);
1994
+ if (newMechanism && 'data' in newMechanism) {
1995
+ var mergedData = __assign(__assign({}, (_a = currentMechanism) === null || _a === void 0 ? void 0 : _a.data), newMechanism.data);
1996
+ exceptionValue0.mechanism.data = mergedData;
1997
+ }
1998
+ }
1999
+ var defaultRetryAfter = 60 * 1000; // 60 seconds
2000
+ /**
2001
+ * Extracts Retry-After value from the request header or returns default value
2002
+ * @param now current unix timestamp
2003
+ * @param header string representation of 'Retry-After' header
2004
+ */
2005
+ function parseRetryAfterHeader(now, header) {
2006
+ if (!header) {
2007
+ return defaultRetryAfter;
2008
+ }
2009
+ var headerDelay = parseInt("" + header, 10);
2010
+ if (!isNaN(headerDelay)) {
2011
+ return headerDelay * 1000;
2012
+ }
2013
+ var headerDate = Date.parse("" + header);
2014
+ if (!isNaN(headerDate)) {
2015
+ return headerDate - now;
2016
+ }
2017
+ return defaultRetryAfter;
2018
+ }
2019
+ /**
2020
+ * Checks whether or not we've already captured the given exception (note: not an identical exception - the very object
2021
+ * in question), and marks it captured if not.
2022
+ *
2023
+ * This is useful because it's possible for an error to get captured by more than one mechanism. After we intercept and
2024
+ * record an error, we rethrow it (assuming we've intercepted it before it's reached the top-level global handlers), so
2025
+ * that we don't interfere with whatever effects the error might have had were the SDK not there. At that point, because
2026
+ * the error has been rethrown, it's possible for it to bubble up to some other code we've instrumented. If it's not
2027
+ * caught after that, it will bubble all the way up to the global handlers (which of course we also instrument). This
2028
+ * function helps us ensure that even if we encounter the same error more than once, we only record it the first time we
2029
+ * see it.
2030
+ *
2031
+ * Note: It will ignore primitives (always return `false` and not mark them as seen), as properties can't be set on
2032
+ * them. {@link: Object.objectify} can be used on exceptions to convert any that are primitives into their equivalent
2033
+ * object wrapper forms so that this check will always work. However, because we need to flag the exact object which
2034
+ * will get rethrown, and because that rethrowing happens outside of the event processing pipeline, the objectification
2035
+ * must be done before the exception captured.
2036
+ *
2037
+ * @param A thrown exception to check or flag as having been seen
2038
+ * @returns `true` if the exception has already been captured, `false` if not (with the side effect of marking it seen)
2039
+ */
2040
+ function checkOrSetAlreadyCaught(exception) {
2041
+ var _a;
2042
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2043
+ if ((_a = exception) === null || _a === void 0 ? void 0 : _a.__sentry_captured__) {
1975
2044
  return true;
1976
- };
2045
+ }
2046
+ try {
2047
+ // set it this way rather than by assignment so that it's not ennumerable and therefore isn't recorded by the
2048
+ // `ExtraErrorData` integration
2049
+ Object.defineProperty(exception, '__sentry_captured__', {
2050
+ value: true,
2051
+ });
2052
+ }
2053
+ catch (err) {
2054
+ // `exception` is a primitive, so we can't mark it seen
2055
+ }
2056
+ return false;
1977
2057
  }
1978
2058
 
1979
2059
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
@@ -3107,7 +3187,10 @@ var Hub = /** @class */ (function () {
3107
3187
  * @inheritDoc
3108
3188
  */
3109
3189
  Hub.prototype.captureEvent = function (event, hint) {
3110
- var eventId = (this._lastEventId = uuid4());
3190
+ var eventId = uuid4();
3191
+ if (event.type !== 'transaction') {
3192
+ this._lastEventId = eventId;
3193
+ }
3111
3194
  this._invokeClient('captureEvent', event, __assign(__assign({}, hint), { event_id: eventId }));
3112
3195
  return eventId;
3113
3196
  };
@@ -3696,6 +3779,7 @@ function setupIntegrations(options) {
3696
3779
  return integrations;
3697
3780
  }
3698
3781
 
3782
+ var ALREADY_SEEN_ERROR = "Not capturing exception because it's already been captured.";
3699
3783
  /**
3700
3784
  * Base implementation for all JavaScript SDK clients.
3701
3785
  *
@@ -3752,6 +3836,11 @@ var BaseClient = /** @class */ (function () {
3752
3836
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3753
3837
  BaseClient.prototype.captureException = function (exception, hint, scope) {
3754
3838
  var _this = this;
3839
+ // ensure we haven't captured this very object before
3840
+ if (checkOrSetAlreadyCaught(exception)) {
3841
+ logger.log(ALREADY_SEEN_ERROR);
3842
+ return;
3843
+ }
3755
3844
  var eventId = hint && hint.event_id;
3756
3845
  this._process(this._getBackend()
3757
3846
  .eventFromException(exception, hint)
@@ -3781,6 +3870,12 @@ var BaseClient = /** @class */ (function () {
3781
3870
  * @inheritDoc
3782
3871
  */
3783
3872
  BaseClient.prototype.captureEvent = function (event, hint, scope) {
3873
+ var _a;
3874
+ // ensure we haven't captured this very object before
3875
+ if (((_a = hint) === null || _a === void 0 ? void 0 : _a.originalException) && checkOrSetAlreadyCaught(hint.originalException)) {
3876
+ logger.log(ALREADY_SEEN_ERROR);
3877
+ return;
3878
+ }
3784
3879
  var eventId = hint && hint.event_id;
3785
3880
  this._process(this._captureEvent(event, hint, scope).then(function (result) {
3786
3881
  eventId = result;
@@ -3816,14 +3911,19 @@ var BaseClient = /** @class */ (function () {
3816
3911
  BaseClient.prototype.getOptions = function () {
3817
3912
  return this._options;
3818
3913
  };
3914
+ /**
3915
+ * @inheritDoc
3916
+ */
3917
+ BaseClient.prototype.getTransport = function () {
3918
+ return this._getBackend().getTransport();
3919
+ };
3819
3920
  /**
3820
3921
  * @inheritDoc
3821
3922
  */
3822
3923
  BaseClient.prototype.flush = function (timeout) {
3823
3924
  var _this = this;
3824
3925
  return this._isClientDoneProcessing(timeout).then(function (clientFinished) {
3825
- return _this._getBackend()
3826
- .getTransport()
3926
+ return _this.getTransport()
3827
3927
  .close(timeout)
3828
3928
  .then(function (transportFlushed) { return clientFinished && transportFlushed; });
3829
3929
  });
@@ -4096,8 +4196,10 @@ var BaseClient = /** @class */ (function () {
4096
4196
  */
4097
4197
  BaseClient.prototype._processEvent = function (event, hint, scope) {
4098
4198
  var _this = this;
4199
+ var _a, _b;
4099
4200
  // eslint-disable-next-line @typescript-eslint/unbound-method
4100
- var _a = this.getOptions(), beforeSend = _a.beforeSend, sampleRate = _a.sampleRate;
4201
+ var _c = this.getOptions(), beforeSend = _c.beforeSend, sampleRate = _c.sampleRate;
4202
+ var transport = this.getTransport();
4101
4203
  if (!this._isEnabled()) {
4102
4204
  return SyncPromise.reject(new SentryError('SDK not enabled, will not capture event.'));
4103
4205
  }
@@ -4106,11 +4208,14 @@ var BaseClient = /** @class */ (function () {
4106
4208
  // 0.0 === 0% events are sent
4107
4209
  // Sampling for transaction happens somewhere else
4108
4210
  if (!isTransaction && typeof sampleRate === 'number' && Math.random() > sampleRate) {
4211
+ (_b = (_a = transport).recordLostEvent) === null || _b === void 0 ? void 0 : _b.call(_a, Outcome.SampleRate, 'event');
4109
4212
  return SyncPromise.reject(new SentryError("Discarding event because it's not included in the random sample (sampling rate = " + sampleRate + ")"));
4110
4213
  }
4111
4214
  return this._prepareEvent(event, scope, hint)
4112
4215
  .then(function (prepared) {
4216
+ var _a, _b;
4113
4217
  if (prepared === null) {
4218
+ (_b = (_a = transport).recordLostEvent) === null || _b === void 0 ? void 0 : _b.call(_a, Outcome.EventProcessor, event.type || 'event');
4114
4219
  throw new SentryError('An event processor returned null, will not send event.');
4115
4220
  }
4116
4221
  var isInternalException = hint && hint.data && hint.data.__sentry__ === true;
@@ -4121,7 +4226,9 @@ var BaseClient = /** @class */ (function () {
4121
4226
  return _this._ensureBeforeSendRv(beforeSendResult);
4122
4227
  })
4123
4228
  .then(function (processedEvent) {
4229
+ var _a, _b;
4124
4230
  if (processedEvent === null) {
4231
+ (_b = (_a = transport).recordLostEvent) === null || _b === void 0 ? void 0 : _b.call(_a, Outcome.BeforeSend, event.type || 'event');
4125
4232
  throw new SentryError('`beforeSend` returned `null`, will not send event.');
4126
4233
  }
4127
4234
  var session = scope && scope.getSession && scope.getSession();
@@ -4361,7 +4468,7 @@ function initAndBind(clientClass, options) {
4361
4468
  hub.bindClient(client);
4362
4469
  }
4363
4470
 
4364
- var SDK_VERSION = '6.11.0';
4471
+ var SDK_VERSION = '6.15.0';
4365
4472
 
4366
4473
  var originalFunctionToString;
4367
4474
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4530,10 +4637,10 @@ var InboundFilters = /** @class */ (function () {
4530
4637
  /** JSDoc */
4531
4638
  InboundFilters.prototype._getLastValidUrl = function (frames) {
4532
4639
  if (frames === void 0) { frames = []; }
4533
- var _a;
4640
+ var _a, _b;
4534
4641
  for (var i = frames.length - 1; i >= 0; i--) {
4535
4642
  var frame = frames[i];
4536
- if (((_a = frame) === null || _a === void 0 ? void 0 : _a.filename) !== '<anonymous>') {
4643
+ if (((_a = frame) === null || _a === void 0 ? void 0 : _a.filename) !== '<anonymous>' && ((_b = frame) === null || _b === void 0 ? void 0 : _b.filename) !== '[native code]') {
4537
4644
  return frame.filename || null;
4538
4645
  }
4539
4646
  }
@@ -4625,6 +4732,7 @@ function computeStackTrace(ex) {
4625
4732
  /** JSDoc */
4626
4733
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, complexity
4627
4734
  function computeStackTraceFromStackProp(ex) {
4735
+ var _a, _b;
4628
4736
  if (!ex || !ex.stack) {
4629
4737
  return null;
4630
4738
  }
@@ -4650,12 +4758,7 @@ function computeStackTraceFromStackProp(ex) {
4650
4758
  // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now
4651
4759
  // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)
4652
4760
  var func = parts[1] || UNKNOWN_FUNCTION;
4653
- var isSafariExtension = func.indexOf('safari-extension') !== -1;
4654
- var isSafariWebExtension = func.indexOf('safari-web-extension') !== -1;
4655
- if (isSafariExtension || isSafariWebExtension) {
4656
- func = func.indexOf('@') !== -1 ? func.split('@')[0] : UNKNOWN_FUNCTION;
4657
- url = isSafariExtension ? "safari-extension:" + url : "safari-web-extension:" + url;
4658
- }
4761
+ _a = __read(extractSafariExtensionDetails(func, url), 2), func = _a[0], url = _a[1];
4659
4762
  element = {
4660
4763
  url: url,
4661
4764
  func: func,
@@ -4689,9 +4792,12 @@ function computeStackTraceFromStackProp(ex) {
4689
4792
  // NOTE: this hack doesn't work if top-most frame is eval
4690
4793
  stack[0].column = ex.columnNumber + 1;
4691
4794
  }
4795
+ var url = parts[3];
4796
+ var func = parts[1] || UNKNOWN_FUNCTION;
4797
+ _b = __read(extractSafariExtensionDetails(func, url), 2), func = _b[0], url = _b[1];
4692
4798
  element = {
4693
- url: parts[3],
4694
- func: parts[1] || UNKNOWN_FUNCTION,
4799
+ url: url,
4800
+ func: func,
4695
4801
  args: parts[2] ? parts[2].split(',') : [],
4696
4802
  line: parts[4] ? +parts[4] : null,
4697
4803
  column: parts[5] ? +parts[5] : null,
@@ -4765,6 +4871,36 @@ function computeStackTraceFromStacktraceProp(ex) {
4765
4871
  stack: stack,
4766
4872
  };
4767
4873
  }
4874
+ /**
4875
+ * Safari web extensions, starting version unknown, can produce "frames-only" stacktraces.
4876
+ * What it means, is that instead of format like:
4877
+ *
4878
+ * Error: wat
4879
+ * at function@url:row:col
4880
+ * at function@url:row:col
4881
+ * at function@url:row:col
4882
+ *
4883
+ * it produces something like:
4884
+ *
4885
+ * function@url:row:col
4886
+ * function@url:row:col
4887
+ * function@url:row:col
4888
+ *
4889
+ * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.
4890
+ * This function is extracted so that we can use it in both places without duplicating the logic.
4891
+ * Unfortunatelly "just" changing RegExp is too complicated now and making it pass all tests
4892
+ * and fix this case seems like an impossible, or at least way too time-consuming task.
4893
+ */
4894
+ var extractSafariExtensionDetails = function (func, url) {
4895
+ var isSafariExtension = func.indexOf('safari-extension') !== -1;
4896
+ var isSafariWebExtension = func.indexOf('safari-web-extension') !== -1;
4897
+ return isSafariExtension || isSafariWebExtension
4898
+ ? [
4899
+ func.indexOf('@') !== -1 ? func.split('@')[0] : UNKNOWN_FUNCTION,
4900
+ isSafariExtension ? "safari-extension:" + url : "safari-web-extension:" + url,
4901
+ ]
4902
+ : [func, url];
4903
+ };
4768
4904
  /** Remove N number of frames from the stack */
4769
4905
  function popFrames(stacktrace, popSize) {
4770
4906
  try {
@@ -4888,10 +5024,7 @@ function eventFromException(options, exception, hint) {
4888
5024
  var event = eventFromUnknownInput(exception, syntheticException, {
4889
5025
  attachStacktrace: options.attachStacktrace,
4890
5026
  });
4891
- addExceptionMechanism(event, {
4892
- handled: true,
4893
- type: 'generic',
4894
- });
5027
+ addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
4895
5028
  event.level = Severity.Error;
4896
5029
  if (hint && hint.event_id) {
4897
5030
  event.event_id = hint.event_id;
@@ -4928,16 +5061,24 @@ function eventFromUnknownInput(exception, syntheticException, options) {
4928
5061
  event = eventFromStacktrace(computeStackTrace(exception));
4929
5062
  return event;
4930
5063
  }
5064
+ // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name
5065
+ // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be
5066
+ // `Error`s, but that's not the case in IE11, so in that case we treat it the same as we do a `DOMError`.
5067
+ //
5068
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMError
5069
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMException
5070
+ // https://webidl.spec.whatwg.org/#es-DOMException-specialness
4931
5071
  if (isDOMError(exception) || isDOMException(exception)) {
4932
- // If it is a DOMError or DOMException (which are legacy APIs, but still supported in some browsers)
4933
- // then we just extract the name, code, and message, as they don't provide anything else
4934
- // https://developer.mozilla.org/en-US/docs/Web/API/DOMError
4935
- // https://developer.mozilla.org/en-US/docs/Web/API/DOMException
4936
5072
  var domException = exception;
4937
- var name_1 = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');
4938
- var message = domException.message ? name_1 + ": " + domException.message : name_1;
4939
- event = eventFromString(message, syntheticException, options);
4940
- addExceptionTypeValue(event, message);
5073
+ if ('stack' in exception) {
5074
+ event = eventFromStacktrace(computeStackTrace(exception));
5075
+ }
5076
+ else {
5077
+ var name_1 = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');
5078
+ var message = domException.message ? name_1 + ": " + domException.message : name_1;
5079
+ event = eventFromString(message, syntheticException, options);
5080
+ addExceptionTypeValue(event, message);
5081
+ }
4941
5082
  if ('code' in domException) {
4942
5083
  event.tags = __assign(__assign({}, event.tags), { 'DOMException.code': "" + domException.code });
4943
5084
  }
@@ -4993,23 +5134,128 @@ function eventFromString(input, syntheticException, options) {
4993
5134
  return event;
4994
5135
  }
4995
5136
 
5137
+ var global$7 = getGlobalObject();
5138
+ var cachedFetchImpl;
5139
+ /**
5140
+ * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
5141
+ * Whenever someone wraps the Fetch API and returns the wrong promise chain,
5142
+ * this chain becomes orphaned and there is no possible way to capture it's rejections
5143
+ * other than allowing it bubble up to this very handler. eg.
5144
+ *
5145
+ * const f = window.fetch;
5146
+ * window.fetch = function () {
5147
+ * const p = f.apply(this, arguments);
5148
+ *
5149
+ * p.then(function() {
5150
+ * console.log('hi.');
5151
+ * });
5152
+ *
5153
+ * return p;
5154
+ * }
5155
+ *
5156
+ * `p.then(function () { ... })` is producing a completely separate promise chain,
5157
+ * however, what's returned is `p` - the result of original `fetch` call.
5158
+ *
5159
+ * This mean, that whenever we use the Fetch API to send our own requests, _and_
5160
+ * some ad-blocker blocks it, this orphaned chain will _always_ reject,
5161
+ * effectively causing another event to be captured.
5162
+ * This makes a whole process become an infinite loop, which we need to somehow
5163
+ * deal with, and break it in one way or another.
5164
+ *
5165
+ * To deal with this issue, we are making sure that we _always_ use the real
5166
+ * browser Fetch API, instead of relying on what `window.fetch` exposes.
5167
+ * The only downside to this would be missing our own requests as breadcrumbs,
5168
+ * but because we are already not doing this, it should be just fine.
5169
+ *
5170
+ * Possible failed fetch error messages per-browser:
5171
+ *
5172
+ * Chrome: Failed to fetch
5173
+ * Edge: Failed to Fetch
5174
+ * Firefox: NetworkError when attempting to fetch resource
5175
+ * Safari: resource blocked by content blocker
5176
+ */
5177
+ function getNativeFetchImplementation() {
5178
+ var _a, _b;
5179
+ if (cachedFetchImpl) {
5180
+ return cachedFetchImpl;
5181
+ }
5182
+ /* eslint-disable @typescript-eslint/unbound-method */
5183
+ // Fast path to avoid DOM I/O
5184
+ if (isNativeFetch(global$7.fetch)) {
5185
+ return (cachedFetchImpl = global$7.fetch.bind(global$7));
5186
+ }
5187
+ var document = global$7.document;
5188
+ var fetchImpl = global$7.fetch;
5189
+ // eslint-disable-next-line deprecation/deprecation
5190
+ if (typeof ((_a = document) === null || _a === void 0 ? void 0 : _a.createElement) === "function") {
5191
+ try {
5192
+ var sandbox = document.createElement('iframe');
5193
+ sandbox.hidden = true;
5194
+ document.head.appendChild(sandbox);
5195
+ if ((_b = sandbox.contentWindow) === null || _b === void 0 ? void 0 : _b.fetch) {
5196
+ fetchImpl = sandbox.contentWindow.fetch;
5197
+ }
5198
+ document.head.removeChild(sandbox);
5199
+ }
5200
+ catch (e) {
5201
+ logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
5202
+ }
5203
+ }
5204
+ return (cachedFetchImpl = fetchImpl.bind(global$7));
5205
+ /* eslint-enable @typescript-eslint/unbound-method */
5206
+ }
5207
+ /**
5208
+ * Sends sdk client report using sendBeacon or fetch as a fallback if available
5209
+ *
5210
+ * @param url report endpoint
5211
+ * @param body report payload
5212
+ */
5213
+ function sendReport(url, body) {
5214
+ var isRealNavigator = Object.prototype.toString.call(global$7 && global$7.navigator) === '[object Navigator]';
5215
+ var hasSendBeacon = isRealNavigator && typeof global$7.navigator.sendBeacon === 'function';
5216
+ if (hasSendBeacon) {
5217
+ // Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
5218
+ var sendBeacon = global$7.navigator.sendBeacon.bind(global$7.navigator);
5219
+ return sendBeacon(url, body);
5220
+ }
5221
+ if (supportsFetch()) {
5222
+ var fetch_1 = getNativeFetchImplementation();
5223
+ return forget(fetch_1(url, {
5224
+ body: body,
5225
+ method: 'POST',
5226
+ credentials: 'omit',
5227
+ keepalive: true,
5228
+ }));
5229
+ }
5230
+ }
5231
+
4996
5232
  var CATEGORY_MAPPING = {
4997
5233
  event: 'error',
4998
5234
  transaction: 'transaction',
4999
5235
  session: 'session',
5000
5236
  attachment: 'attachment',
5001
5237
  };
5238
+ var global$6 = getGlobalObject();
5002
5239
  /** Base Transport class implementation */
5003
5240
  var BaseTransport = /** @class */ (function () {
5004
5241
  function BaseTransport(options) {
5242
+ var _this = this;
5005
5243
  this.options = options;
5006
5244
  /** A simple buffer holding all requests. */
5007
5245
  this._buffer = new PromiseBuffer(30);
5008
5246
  /** Locks transport after receiving rate limits in a response */
5009
5247
  this._rateLimits = {};
5248
+ this._outcomes = {};
5010
5249
  this._api = new API(options.dsn, options._metadata, options.tunnel);
5011
5250
  // eslint-disable-next-line deprecation/deprecation
5012
5251
  this.url = this._api.getStoreEndpointWithUrlEncodedAuth();
5252
+ if (this.options.sendClientReports && global$6.document) {
5253
+ global$6.document.addEventListener('visibilitychange', function () {
5254
+ if (global$6.document.visibilityState === 'hidden') {
5255
+ _this._flushOutcomes();
5256
+ }
5257
+ });
5258
+ }
5013
5259
  }
5014
5260
  /**
5015
5261
  * @inheritDoc
@@ -5023,6 +5269,63 @@ var BaseTransport = /** @class */ (function () {
5023
5269
  BaseTransport.prototype.close = function (timeout) {
5024
5270
  return this._buffer.drain(timeout);
5025
5271
  };
5272
+ /**
5273
+ * @inheritDoc
5274
+ */
5275
+ BaseTransport.prototype.recordLostEvent = function (reason, category) {
5276
+ var _a;
5277
+ if (!this.options.sendClientReports) {
5278
+ return;
5279
+ }
5280
+ // We want to track each category (event, transaction, session) separately
5281
+ // but still keep the distinction between different type of outcomes.
5282
+ // We could use nested maps, but it's much easier to read and type this way.
5283
+ // A correct type for map-based implementation if we want to go that route
5284
+ // would be `Partial<Record<SentryRequestType, Partial<Record<Outcome, number>>>>`
5285
+ var key = CATEGORY_MAPPING[category] + ":" + reason;
5286
+ logger.log("Adding outcome: " + key);
5287
+ this._outcomes[key] = (_a = this._outcomes[key], (_a !== null && _a !== void 0 ? _a : 0)) + 1;
5288
+ };
5289
+ /**
5290
+ * Send outcomes as an envelope
5291
+ */
5292
+ BaseTransport.prototype._flushOutcomes = function () {
5293
+ if (!this.options.sendClientReports) {
5294
+ return;
5295
+ }
5296
+ var outcomes = this._outcomes;
5297
+ this._outcomes = {};
5298
+ // Nothing to send
5299
+ if (!Object.keys(outcomes).length) {
5300
+ logger.log('No outcomes to flush');
5301
+ return;
5302
+ }
5303
+ logger.log("Flushing outcomes:\n" + JSON.stringify(outcomes, null, 2));
5304
+ var url = this._api.getEnvelopeEndpointWithUrlEncodedAuth();
5305
+ // Envelope header is required to be at least an empty object
5306
+ var envelopeHeader = JSON.stringify(__assign({}, (this.options.tunnel && { dsn: this._api.getDsn().toString() })));
5307
+ var itemHeaders = JSON.stringify({
5308
+ type: 'client_report',
5309
+ });
5310
+ var item = JSON.stringify({
5311
+ timestamp: dateTimestampInSeconds(),
5312
+ discarded_events: Object.keys(outcomes).map(function (key) {
5313
+ var _a = __read(key.split(':'), 2), category = _a[0], reason = _a[1];
5314
+ return {
5315
+ reason: reason,
5316
+ category: category,
5317
+ quantity: outcomes[key],
5318
+ };
5319
+ }),
5320
+ });
5321
+ var envelope = envelopeHeader + "\n" + itemHeaders + "\n" + item;
5322
+ try {
5323
+ sendReport(url, envelope);
5324
+ }
5325
+ catch (e) {
5326
+ logger.error(e);
5327
+ }
5328
+ };
5026
5329
  /**
5027
5330
  * Handle Sentry repsonse for promise-based transports.
5028
5331
  */
@@ -5113,72 +5416,6 @@ var BaseTransport = /** @class */ (function () {
5113
5416
  return BaseTransport;
5114
5417
  }());
5115
5418
 
5116
- /**
5117
- * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
5118
- * Whenever someone wraps the Fetch API and returns the wrong promise chain,
5119
- * this chain becomes orphaned and there is no possible way to capture it's rejections
5120
- * other than allowing it bubble up to this very handler. eg.
5121
- *
5122
- * const f = window.fetch;
5123
- * window.fetch = function () {
5124
- * const p = f.apply(this, arguments);
5125
- *
5126
- * p.then(function() {
5127
- * console.log('hi.');
5128
- * });
5129
- *
5130
- * return p;
5131
- * }
5132
- *
5133
- * `p.then(function () { ... })` is producing a completely separate promise chain,
5134
- * however, what's returned is `p` - the result of original `fetch` call.
5135
- *
5136
- * This mean, that whenever we use the Fetch API to send our own requests, _and_
5137
- * some ad-blocker blocks it, this orphaned chain will _always_ reject,
5138
- * effectively causing another event to be captured.
5139
- * This makes a whole process become an infinite loop, which we need to somehow
5140
- * deal with, and break it in one way or another.
5141
- *
5142
- * To deal with this issue, we are making sure that we _always_ use the real
5143
- * browser Fetch API, instead of relying on what `window.fetch` exposes.
5144
- * The only downside to this would be missing our own requests as breadcrumbs,
5145
- * but because we are already not doing this, it should be just fine.
5146
- *
5147
- * Possible failed fetch error messages per-browser:
5148
- *
5149
- * Chrome: Failed to fetch
5150
- * Edge: Failed to Fetch
5151
- * Firefox: NetworkError when attempting to fetch resource
5152
- * Safari: resource blocked by content blocker
5153
- */
5154
- function getNativeFetchImplementation() {
5155
- /* eslint-disable @typescript-eslint/unbound-method */
5156
- var _a, _b;
5157
- // Fast path to avoid DOM I/O
5158
- var global = getGlobalObject();
5159
- if (isNativeFetch(global.fetch)) {
5160
- return global.fetch.bind(global);
5161
- }
5162
- var document = global.document;
5163
- var fetchImpl = global.fetch;
5164
- // eslint-disable-next-line deprecation/deprecation
5165
- if (typeof ((_a = document) === null || _a === void 0 ? void 0 : _a.createElement) === "function") {
5166
- try {
5167
- var sandbox = document.createElement('iframe');
5168
- sandbox.hidden = true;
5169
- document.head.appendChild(sandbox);
5170
- if ((_b = sandbox.contentWindow) === null || _b === void 0 ? void 0 : _b.fetch) {
5171
- fetchImpl = sandbox.contentWindow.fetch;
5172
- }
5173
- document.head.removeChild(sandbox);
5174
- }
5175
- catch (e) {
5176
- logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
5177
- }
5178
- }
5179
- return fetchImpl.bind(global);
5180
- /* eslint-enable @typescript-eslint/unbound-method */
5181
- }
5182
5419
  /** `fetch` based transport */
5183
5420
  var FetchTransport = /** @class */ (function (_super) {
5184
5421
  __extends(FetchTransport, _super);
@@ -5207,6 +5444,7 @@ var FetchTransport = /** @class */ (function (_super) {
5207
5444
  FetchTransport.prototype._sendRequest = function (sentryRequest, originalPayload) {
5208
5445
  var _this = this;
5209
5446
  if (this._isRateLimited(sentryRequest.type)) {
5447
+ this.recordLostEvent(Outcome.RateLimitBackoff, sentryRequest.type);
5210
5448
  return Promise.reject({
5211
5449
  event: originalPayload,
5212
5450
  type: sentryRequest.type,
@@ -5229,7 +5467,8 @@ var FetchTransport = /** @class */ (function (_super) {
5229
5467
  if (this.options.headers !== undefined) {
5230
5468
  options.headers = this.options.headers;
5231
5469
  }
5232
- return this._buffer.add(function () {
5470
+ return this._buffer
5471
+ .add(function () {
5233
5472
  return new SyncPromise(function (resolve, reject) {
5234
5473
  void _this._fetch(sentryRequest.url, options)
5235
5474
  .then(function (response) {
@@ -5247,6 +5486,16 @@ var FetchTransport = /** @class */ (function (_super) {
5247
5486
  })
5248
5487
  .catch(reject);
5249
5488
  });
5489
+ })
5490
+ .then(undefined, function (reason) {
5491
+ // It's either buffer rejection or any other xhr/fetch error, which are treated as NetworkError.
5492
+ if (reason instanceof SentryError) {
5493
+ _this.recordLostEvent(Outcome.QueueOverflow, sentryRequest.type);
5494
+ }
5495
+ else {
5496
+ _this.recordLostEvent(Outcome.NetworkError, sentryRequest.type);
5497
+ }
5498
+ throw reason;
5250
5499
  });
5251
5500
  };
5252
5501
  return FetchTransport;
@@ -5277,6 +5526,7 @@ var XHRTransport = /** @class */ (function (_super) {
5277
5526
  XHRTransport.prototype._sendRequest = function (sentryRequest, originalPayload) {
5278
5527
  var _this = this;
5279
5528
  if (this._isRateLimited(sentryRequest.type)) {
5529
+ this.recordLostEvent(Outcome.RateLimitBackoff, sentryRequest.type);
5280
5530
  return Promise.reject({
5281
5531
  event: originalPayload,
5282
5532
  type: sentryRequest.type,
@@ -5284,7 +5534,8 @@ var XHRTransport = /** @class */ (function (_super) {
5284
5534
  status: 429,
5285
5535
  });
5286
5536
  }
5287
- return this._buffer.add(function () {
5537
+ return this._buffer
5538
+ .add(function () {
5288
5539
  return new SyncPromise(function (resolve, reject) {
5289
5540
  var request = new XMLHttpRequest();
5290
5541
  request.onreadystatechange = function () {
@@ -5298,12 +5549,22 @@ var XHRTransport = /** @class */ (function (_super) {
5298
5549
  };
5299
5550
  request.open('POST', sentryRequest.url);
5300
5551
  for (var header in _this.options.headers) {
5301
- if (_this.options.headers.hasOwnProperty(header)) {
5552
+ if (Object.prototype.hasOwnProperty.call(_this.options.headers, header)) {
5302
5553
  request.setRequestHeader(header, _this.options.headers[header]);
5303
5554
  }
5304
5555
  }
5305
5556
  request.send(sentryRequest.body);
5306
5557
  });
5558
+ })
5559
+ .then(undefined, function (reason) {
5560
+ // It's either buffer rejection or any other xhr/fetch error, which are treated as NetworkError.
5561
+ if (reason instanceof SentryError) {
5562
+ _this.recordLostEvent(Outcome.QueueOverflow, sentryRequest.type);
5563
+ }
5564
+ else {
5565
+ _this.recordLostEvent(Outcome.NetworkError, sentryRequest.type);
5566
+ }
5567
+ throw reason;
5307
5568
  });
5308
5569
  };
5309
5570
  return XHRTransport;
@@ -5339,7 +5600,7 @@ var BrowserBackend = /** @class */ (function (_super) {
5339
5600
  // We return the noop transport here in case there is no Dsn.
5340
5601
  return _super.prototype._setupTransport.call(this);
5341
5602
  }
5342
- var transportOptions = __assign(__assign({}, this._options.transportOptions), { dsn: this._options.dsn, tunnel: this._options.tunnel, _metadata: this._options._metadata });
5603
+ var transportOptions = __assign(__assign({}, this._options.transportOptions), { dsn: this._options.dsn, tunnel: this._options.tunnel, sendClientReports: this._options.sendClientReports, _metadata: this._options._metadata });
5343
5604
  if (this._options.transport) {
5344
5605
  return new this._options.transport(transportOptions);
5345
5606
  }
@@ -5351,6 +5612,7 @@ var BrowserBackend = /** @class */ (function (_super) {
5351
5612
  return BrowserBackend;
5352
5613
  }(BaseBackend));
5353
5614
 
5615
+ var global$5 = getGlobalObject();
5354
5616
  var ignoreOnError = 0;
5355
5617
  /**
5356
5618
  * @hidden
@@ -5488,6 +5750,9 @@ function wrap$1(fn, options, before) {
5488
5750
  */
5489
5751
  function injectReportDialog(options) {
5490
5752
  if (options === void 0) { options = {}; }
5753
+ if (!global$5.document) {
5754
+ return;
5755
+ }
5491
5756
  if (!options.eventId) {
5492
5757
  logger.error("Missing eventId option in showReportDialog call");
5493
5758
  return;
@@ -5496,14 +5761,17 @@ function injectReportDialog(options) {
5496
5761
  logger.error("Missing dsn option in showReportDialog call");
5497
5762
  return;
5498
5763
  }
5499
- var script = document.createElement('script');
5764
+ var script = global$5.document.createElement('script');
5500
5765
  script.async = true;
5501
5766
  script.src = new API(options.dsn).getReportDialogEndpoint(options);
5502
5767
  if (options.onLoad) {
5503
5768
  // eslint-disable-next-line @typescript-eslint/unbound-method
5504
5769
  script.onload = options.onLoad;
5505
5770
  }
5506
- (document.head || document.body).appendChild(script);
5771
+ var injectionPoint = global$5.document.head || global$5.document.body;
5772
+ if (injectionPoint) {
5773
+ injectionPoint.appendChild(script);
5774
+ }
5507
5775
  }
5508
5776
 
5509
5777
  /** Global handlers */
@@ -5808,7 +6076,7 @@ var TryCatch = /** @class */ (function () {
5808
6076
  var global = getGlobalObject();
5809
6077
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5810
6078
  var proto = global[target] && global[target].prototype;
5811
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6079
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
5812
6080
  if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
5813
6081
  return;
5814
6082
  }
@@ -6301,6 +6569,7 @@ var Dedupe = /** @class */ (function () {
6301
6569
  // Juuust in case something goes wrong
6302
6570
  try {
6303
6571
  if (self._shouldDropEvent(currentEvent, self._previousEvent)) {
6572
+ logger.warn("Event dropped due to being a duplicate of previously captured event.");
6304
6573
  return null;
6305
6574
  }
6306
6575
  }
@@ -6597,6 +6866,9 @@ function init(options) {
6597
6866
  if (options.autoSessionTracking === undefined) {
6598
6867
  options.autoSessionTracking = true;
6599
6868
  }
6869
+ if (options.sendClientReports === undefined) {
6870
+ options.sendClientReports = true;
6871
+ }
6600
6872
  initAndBind(BrowserClient, options);
6601
6873
  if (options.autoSessionTracking) {
6602
6874
  startSessionTracking();
@@ -7127,6 +7399,7 @@ var Transaction = /** @class */ (function (_super) {
7127
7399
  */
7128
7400
  Transaction.prototype.finish = function (endTimestamp) {
7129
7401
  var _this = this;
7402
+ var _a, _b, _c, _d, _e;
7130
7403
  // This transaction is already finished, so we should not flush it again.
7131
7404
  if (this.endTimestamp !== undefined) {
7132
7405
  return undefined;
@@ -7140,6 +7413,8 @@ var Transaction = /** @class */ (function (_super) {
7140
7413
  if (this.sampled !== true) {
7141
7414
  // At this point if `sampled !== true` we want to discard the transaction.
7142
7415
  logger.log('[Tracing] Discarding transaction because its trace was not chosen to be sampled.');
7416
+ (_e = (_c = (_a = this._hub
7417
+ .getClient()) === null || _a === void 0 ? void 0 : (_b = _a).getTransport) === null || _c === void 0 ? void 0 : (_d = _c.call(_b)).recordLostEvent) === null || _e === void 0 ? void 0 : _e.call(_d, Outcome.SampleRate, 'transaction');
7143
7418
  return undefined;
7144
7419
  }
7145
7420
  var finishedSpans = this.spanRecorder ? this.spanRecorder.spans.filter(function (s) { return s !== _this && s.endTimestamp; }) : [];
@@ -7192,6 +7467,7 @@ var Transaction = /** @class */ (function (_super) {
7192
7467
  }(Span));
7193
7468
 
7194
7469
  var DEFAULT_IDLE_TIMEOUT = 1000;
7470
+ var HEARTBEAT_INTERVAL = 5000;
7195
7471
  /**
7196
7472
  * @inheritDoc
7197
7473
  */
@@ -7235,7 +7511,10 @@ var IdleTransactionSpanRecorder = /** @class */ (function (_super) {
7235
7511
  var IdleTransaction = /** @class */ (function (_super) {
7236
7512
  __extends(IdleTransaction, _super);
7237
7513
  function IdleTransaction(transactionContext, _idleHub,
7238
- // The time to wait in ms until the idle transaction will be finished. Default: 1000
7514
+ /**
7515
+ * The time to wait in ms until the idle transaction will be finished.
7516
+ * @default 1000
7517
+ */
7239
7518
  _idleTimeout,
7240
7519
  // If an idle transaction should be put itself on and off the scope automatically.
7241
7520
  _onScope) {
@@ -7247,8 +7526,6 @@ var IdleTransaction = /** @class */ (function (_super) {
7247
7526
  _this._onScope = _onScope;
7248
7527
  // Activities store a list of active spans
7249
7528
  _this.activities = {};
7250
- // Stores reference to the timeout that calls _beat().
7251
- _this._heartbeatTimer = 0;
7252
7529
  // Amount of times heartbeat has counted. Will cause transaction to finish after 3 beats.
7253
7530
  _this._heartbeatCounter = 0;
7254
7531
  // We should not use heartbeat if we finished a transaction
@@ -7396,13 +7673,11 @@ var IdleTransaction = /** @class */ (function (_super) {
7396
7673
  * If this occurs we finish the transaction.
7397
7674
  */
7398
7675
  IdleTransaction.prototype._beat = function () {
7399
- clearTimeout(this._heartbeatTimer);
7400
7676
  // We should not be running heartbeat if the idle transaction is finished.
7401
7677
  if (this._finished) {
7402
7678
  return;
7403
7679
  }
7404
- var keys = Object.keys(this.activities);
7405
- var heartbeatString = keys.length ? keys.reduce(function (prev, current) { return prev + current; }) : '';
7680
+ var heartbeatString = Object.keys(this.activities).join('');
7406
7681
  if (heartbeatString === this._prevHeartbeatString) {
7407
7682
  this._heartbeatCounter += 1;
7408
7683
  }
@@ -7426,9 +7701,9 @@ var IdleTransaction = /** @class */ (function (_super) {
7426
7701
  IdleTransaction.prototype._pingHeartbeat = function () {
7427
7702
  var _this = this;
7428
7703
  logger.log("pinging Heartbeat -> current counter: " + this._heartbeatCounter);
7429
- this._heartbeatTimer = setTimeout(function () {
7704
+ setTimeout(function () {
7430
7705
  _this._beat();
7431
- }, 5000);
7706
+ }, HEARTBEAT_INTERVAL);
7432
7707
  };
7433
7708
  return IdleTransaction;
7434
7709
  }(Transaction));
@@ -7474,7 +7749,7 @@ function traceHeaders() {
7474
7749
  */
7475
7750
  function sample(transaction, options, samplingContext) {
7476
7751
  // nothing to do if tracing is not enabled
7477
- if (!hasTracingEnabled()) {
7752
+ if (!hasTracingEnabled(options)) {
7478
7753
  transaction.sampled = false;
7479
7754
  return transaction;
7480
7755
  }
@@ -7621,19 +7896,19 @@ function _autoloadDatabaseIntegrations() {
7621
7896
  }
7622
7897
  var packageToIntegrationMapping = {
7623
7898
  mongodb: function () {
7624
- var integration = dynamicRequire(module, './integrations/mongo');
7899
+ var integration = dynamicRequire(module, './integrations/node/mongo');
7625
7900
  return new integration.Mongo();
7626
7901
  },
7627
7902
  mongoose: function () {
7628
- var integration = dynamicRequire(module, './integrations/mongo');
7903
+ var integration = dynamicRequire(module, './integrations/node/mongo');
7629
7904
  return new integration.Mongo({ mongoose: true });
7630
7905
  },
7631
7906
  mysql: function () {
7632
- var integration = dynamicRequire(module, './integrations/mysql');
7907
+ var integration = dynamicRequire(module, './integrations/node/mysql');
7633
7908
  return new integration.Mysql();
7634
7909
  },
7635
7910
  pg: function () {
7636
- var integration = dynamicRequire(module, './integrations/postgres');
7911
+ var integration = dynamicRequire(module, './integrations/node/postgres');
7637
7912
  return new integration.Postgres();
7638
7913
  },
7639
7914
  };
@@ -7833,7 +8108,7 @@ var observe = function (type, callback) {
7833
8108
  */
7834
8109
  var onHidden = function (cb, once) {
7835
8110
  var onHiddenOrPageHide = function (event) {
7836
- if (event.type === 'pagehide' || document.visibilityState === 'hidden') {
8111
+ if (event.type === 'pagehide' || getGlobalObject().document.visibilityState === 'hidden') {
7837
8112
  cb(event);
7838
8113
  if (once) {
7839
8114
  removeEventListener('visibilitychange', onHiddenOrPageHide, true);
@@ -7925,7 +8200,7 @@ var getCLS = function (onReport, reportAllChanges) {
7925
8200
  */
7926
8201
  var firstHiddenTime = -1;
7927
8202
  var initHiddenTime = function () {
7928
- return document.visibilityState === 'hidden' ? 0 : Infinity;
8203
+ return getGlobalObject().document.visibilityState === 'hidden' ? 0 : Infinity;
7929
8204
  };
7930
8205
  var trackChanges = function () {
7931
8206
  // Update the time if/when the document becomes hidden.
@@ -8043,18 +8318,21 @@ var getLCP = function (onReport, reportAllChanges) {
8043
8318
  };
8044
8319
 
8045
8320
  var global$2 = getGlobalObject();
8321
+ var DEFAULT_METRICS_INSTR_OPTIONS = {
8322
+ _reportAllChanges: false,
8323
+ };
8046
8324
  /** Class tracking metrics */
8047
8325
  var MetricsInstrumentation = /** @class */ (function () {
8048
- function MetricsInstrumentation() {
8049
- var _a;
8326
+ function MetricsInstrumentation(_options) {
8327
+ var _a, _b;
8050
8328
  this._measurements = {};
8051
8329
  this._performanceCursor = 0;
8052
- if (!isNodeEnv() && ((_a = global$2) === null || _a === void 0 ? void 0 : _a.performance)) {
8330
+ if (!isNodeEnv() && ((_a = global$2) === null || _a === void 0 ? void 0 : _a.performance) && ((_b = global$2) === null || _b === void 0 ? void 0 : _b.document)) {
8053
8331
  if (global$2.performance.mark) {
8054
8332
  global$2.performance.mark('sentry-tracing-init');
8055
8333
  }
8056
8334
  this._trackCLS();
8057
- this._trackLCP();
8335
+ this._trackLCP(_options._reportAllChanges);
8058
8336
  this._trackFID();
8059
8337
  }
8060
8338
  }
@@ -8124,7 +8402,7 @@ var MetricsInstrumentation = /** @class */ (function () {
8124
8402
  break;
8125
8403
  }
8126
8404
  case 'resource': {
8127
- var resourceName = entry.name.replace(window.location.origin, '');
8405
+ var resourceName = entry.name.replace(global$2.location.origin, '');
8128
8406
  var endTimestamp = addResourceSpans(transaction, entry, resourceName, startTime, duration, timeOrigin);
8129
8407
  // We remember the entry script end time to calculate the difference to the first init mark
8130
8408
  if (entryScriptStartTimestamp === undefined && (entryScriptSrc || '').indexOf(resourceName) > -1) {
@@ -8266,7 +8544,7 @@ var MetricsInstrumentation = /** @class */ (function () {
8266
8544
  }
8267
8545
  };
8268
8546
  /** Starts tracking the Largest Contentful Paint on the current page. */
8269
- MetricsInstrumentation.prototype._trackLCP = function () {
8547
+ MetricsInstrumentation.prototype._trackLCP = function (reportAllChanges) {
8270
8548
  var _this = this;
8271
8549
  getLCP(function (metric) {
8272
8550
  var entry = metric.entries.pop();
@@ -8279,7 +8557,7 @@ var MetricsInstrumentation = /** @class */ (function () {
8279
8557
  _this._measurements['lcp'] = { value: metric.value };
8280
8558
  _this._measurements['mark.lcp'] = { value: timeOrigin + startTime };
8281
8559
  _this._lcpEntry = entry;
8282
- });
8560
+ }, reportAllChanges);
8283
8561
  };
8284
8562
  /** Starts tracking the First Input Delay on the current page. */
8285
8563
  MetricsInstrumentation.prototype._trackFID = function () {
@@ -8626,7 +8904,6 @@ var BrowserTracing = /** @class */ (function () {
8626
8904
  * @inheritDoc
8627
8905
  */
8628
8906
  this.name = BrowserTracing.id;
8629
- this._metrics = new MetricsInstrumentation();
8630
8907
  this._emitOptionsWarning = false;
8631
8908
  var tracingOrigins = defaultRequestInstrumentationOptions.tracingOrigins;
8632
8909
  // NOTE: Logger doesn't work in constructors, as it's initialized after integrations instances
@@ -8640,6 +8917,7 @@ var BrowserTracing = /** @class */ (function () {
8640
8917
  this._emitOptionsWarning = true;
8641
8918
  }
8642
8919
  this.options = __assign(__assign(__assign({}, DEFAULT_BROWSER_TRACING_OPTIONS), _options), { tracingOrigins: tracingOrigins });
8920
+ this._metrics = new MetricsInstrumentation(__assign(__assign({}, DEFAULT_METRICS_INSTR_OPTIONS), this.options._metricOptions));
8643
8921
  }
8644
8922
  /**
8645
8923
  * @inheritDoc
@@ -8707,7 +8985,7 @@ function getHeaderContext() {
8707
8985
  }
8708
8986
  /** Returns the value of a meta tag */
8709
8987
  function getMetaContent(metaName) {
8710
- var el = document.querySelector("meta[name=" + metaName + "]");
8988
+ var el = getGlobalObject().document.querySelector("meta[name=" + metaName + "]");
8711
8989
  return el ? el.getAttribute('content') : null;
8712
8990
  }
8713
8991
  /** Adjusts transaction value based on max transaction duration */
@@ -8880,21 +9158,29 @@ function instrumentMiddlewares(router, methods) {
8880
9158
 
8881
9159
  /** Tracing integration for node-postgres package */
8882
9160
  var Postgres = /** @class */ (function () {
8883
- function Postgres() {
9161
+ function Postgres(options) {
9162
+ if (options === void 0) { options = {}; }
8884
9163
  /**
8885
9164
  * @inheritDoc
8886
9165
  */
8887
9166
  this.name = Postgres.id;
9167
+ this._usePgNative = !!options.usePgNative;
8888
9168
  }
8889
9169
  /**
8890
9170
  * @inheritDoc
8891
9171
  */
8892
9172
  Postgres.prototype.setupOnce = function (_, getCurrentHub) {
9173
+ var _a;
8893
9174
  var pkg = loadModule('pg');
8894
9175
  if (!pkg) {
8895
9176
  logger.error('Postgres Integration was unable to require `pg` package.');
8896
9177
  return;
8897
9178
  }
9179
+ if (this._usePgNative && !((_a = pkg.native) === null || _a === void 0 ? void 0 : _a.Client)) {
9180
+ logger.error("Postgres Integration was unable to access 'pg-native' bindings.");
9181
+ return;
9182
+ }
9183
+ var Client = (this._usePgNative ? pkg.native : pkg).Client;
8898
9184
  /**
8899
9185
  * function (query, callback) => void
8900
9186
  * function (query, params, callback) => void
@@ -8902,7 +9188,7 @@ var Postgres = /** @class */ (function () {
8902
9188
  * function (query, params) => Promise
8903
9189
  * function (pg.Cursor) => pg.Cursor
8904
9190
  */
8905
- fill(pkg.Client.prototype, 'query', function (orig) {
9191
+ fill(Client.prototype, 'query', function (orig) {
8906
9192
  return function (config, values, callback) {
8907
9193
  var _a, _b, _c;
8908
9194
  var scope = getCurrentHub().getScope();
@@ -9206,6 +9492,7 @@ const setupSentry = () => {
9206
9492
  init({
9207
9493
  dsn: "https://70bcf561598b44148bd3cabc7c142a6c@o1015876.ingest.sentry.io/5983034",
9208
9494
  integrations: [new Integrations.BrowserTracing()],
9495
+ release: `${index.Env.packageName}@${index.Env.packageVersion}`,
9209
9496
  tracesSampleRate: 1.0,
9210
9497
  maxBreadcrumbs: 4,
9211
9498
  allowUrls: [/https?:\/\/.+vviinn-widgets.+.js/],