@sentry/browser 6.13.2 → 6.14.2
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.
- package/build/bundle.es6.js +455 -354
- package/build/bundle.es6.js.map +1 -1
- package/build/bundle.es6.min.js +2 -2
- package/build/bundle.es6.min.js.map +1 -1
- package/build/bundle.js +456 -356
- package/build/bundle.js.map +1 -1
- package/build/bundle.min.js +2 -2
- package/build/bundle.min.js.map +1 -1
- package/dist/eventbuilder.d.ts.map +1 -1
- package/dist/eventbuilder.js +3 -7
- package/dist/eventbuilder.js.map +1 -1
- package/dist/integrations/trycatch.js +1 -1
- package/dist/integrations/trycatch.js.map +1 -1
- package/dist/transports/base.d.ts.map +1 -1
- package/dist/transports/base.js +8 -6
- package/dist/transports/base.js.map +1 -1
- package/dist/transports/fetch.d.ts +1 -2
- package/dist/transports/fetch.d.ts.map +1 -1
- package/dist/transports/fetch.js +2 -67
- package/dist/transports/fetch.js.map +1 -1
- package/dist/transports/utils.d.ts +48 -0
- package/dist/transports/utils.d.ts.map +1 -0
- package/dist/transports/utils.js +99 -0
- package/dist/transports/utils.js.map +1 -0
- package/dist/transports/xhr.js +1 -1
- package/dist/transports/xhr.js.map +1 -1
- package/esm/eventbuilder.d.ts.map +1 -1
- package/esm/eventbuilder.js +3 -7
- package/esm/eventbuilder.js.map +1 -1
- package/esm/integrations/trycatch.js +1 -1
- package/esm/integrations/trycatch.js.map +1 -1
- package/esm/transports/base.d.ts.map +1 -1
- package/esm/transports/base.js +9 -7
- package/esm/transports/base.js.map +1 -1
- package/esm/transports/fetch.d.ts +1 -2
- package/esm/transports/fetch.d.ts.map +1 -1
- package/esm/transports/fetch.js +2 -67
- package/esm/transports/fetch.js.map +1 -1
- package/esm/transports/utils.d.ts +48 -0
- package/esm/transports/utils.d.ts.map +1 -0
- package/esm/transports/utils.js +96 -0
- package/esm/transports/utils.js.map +1 -0
- package/esm/transports/xhr.js +1 -1
- package/esm/transports/xhr.js.map +1 -1
- package/package.json +23 -23
package/build/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @sentry/browser 6.
|
|
1
|
+
/*! @sentry/browser 6.14.2 (9a623dd) | https://github.com/getsentry/sentry-javascript */
|
|
2
2
|
var Sentry = (function (exports) {
|
|
3
3
|
/*! *****************************************************************************
|
|
4
4
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -228,6 +228,62 @@ var Sentry = (function (exports) {
|
|
|
228
228
|
Outcome["SampleRate"] = "sample_rate";
|
|
229
229
|
})(Outcome || (Outcome = {}));
|
|
230
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Consumes the promise and logs the error when it rejects.
|
|
233
|
+
* @param promise A promise to forget.
|
|
234
|
+
*/
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
236
|
+
function forget(promise) {
|
|
237
|
+
void promise.then(null, function (e) {
|
|
238
|
+
// TODO: Use a better logging mechanism
|
|
239
|
+
// eslint-disable-next-line no-console
|
|
240
|
+
console.error(e);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
|
|
246
|
+
* you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
|
|
247
|
+
*/
|
|
248
|
+
/**
|
|
249
|
+
* Checks whether we're in the Node.js or Browser environment
|
|
250
|
+
*
|
|
251
|
+
* @returns Answer to given question
|
|
252
|
+
*/
|
|
253
|
+
function isNodeEnv() {
|
|
254
|
+
return Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Requires a module which is protected against bundler minification.
|
|
258
|
+
*
|
|
259
|
+
* @param request The module path to resolve
|
|
260
|
+
*/
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
262
|
+
function dynamicRequire(mod, request) {
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
264
|
+
return mod.require(request);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
|
|
269
|
+
* you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
|
|
270
|
+
*/
|
|
271
|
+
var fallbackGlobalObject = {};
|
|
272
|
+
/**
|
|
273
|
+
* Safely get global scope object
|
|
274
|
+
*
|
|
275
|
+
* @returns Global scope object
|
|
276
|
+
*/
|
|
277
|
+
function getGlobalObject() {
|
|
278
|
+
return (isNodeEnv()
|
|
279
|
+
? global
|
|
280
|
+
: typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
|
|
281
|
+
? window // eslint-disable-line no-restricted-globals
|
|
282
|
+
: typeof self !== 'undefined'
|
|
283
|
+
? self
|
|
284
|
+
: fallbackGlobalObject);
|
|
285
|
+
}
|
|
286
|
+
|
|
231
287
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
232
288
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
233
289
|
/**
|
|
@@ -280,7 +336,7 @@ var Sentry = (function (exports) {
|
|
|
280
336
|
return Object.prototype.toString.call(wat) === '[object DOMException]';
|
|
281
337
|
}
|
|
282
338
|
/**
|
|
283
|
-
* Checks whether given value's type is
|
|
339
|
+
* Checks whether the given value's type is string
|
|
284
340
|
* {@link isString}.
|
|
285
341
|
*
|
|
286
342
|
* @param wat A value to be checked.
|
|
@@ -463,6 +519,18 @@ var Sentry = (function (exports) {
|
|
|
463
519
|
}
|
|
464
520
|
}
|
|
465
521
|
return out.join('');
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* A safe form of location.href
|
|
525
|
+
*/
|
|
526
|
+
function getLocationHref() {
|
|
527
|
+
var global = getGlobalObject();
|
|
528
|
+
try {
|
|
529
|
+
return global.document.location.href;
|
|
530
|
+
}
|
|
531
|
+
catch (oO) {
|
|
532
|
+
return '';
|
|
533
|
+
}
|
|
466
534
|
}
|
|
467
535
|
|
|
468
536
|
var setPrototypeOf = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties);
|
|
@@ -481,8 +549,7 @@ var Sentry = (function (exports) {
|
|
|
481
549
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
482
550
|
function mixinProperties(obj, proto) {
|
|
483
551
|
for (var prop in proto) {
|
|
484
|
-
|
|
485
|
-
if (!obj.hasOwnProperty(prop)) {
|
|
552
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
486
553
|
// @ts-ignore typescript complains about indexing so we remove
|
|
487
554
|
obj[prop] = proto[prop];
|
|
488
555
|
}
|
|
@@ -593,175 +660,17 @@ var Sentry = (function (exports) {
|
|
|
593
660
|
return Dsn;
|
|
594
661
|
}());
|
|
595
662
|
|
|
663
|
+
// TODO: Implement different loggers for different environments
|
|
664
|
+
var global$1 = getGlobalObject();
|
|
665
|
+
/** Prefix for logging strings */
|
|
666
|
+
var PREFIX = 'Sentry Logger ';
|
|
596
667
|
/**
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
* @returns Answer to given question
|
|
600
|
-
*/
|
|
601
|
-
function isNodeEnv() {
|
|
602
|
-
return Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* Requires a module which is protected against bundler minification.
|
|
606
|
-
*
|
|
607
|
-
* @param request The module path to resolve
|
|
608
|
-
*/
|
|
609
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
610
|
-
function dynamicRequire(mod, request) {
|
|
611
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
612
|
-
return mod.require(request);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
/**
|
|
616
|
-
* Truncates given string to the maximum characters count
|
|
617
|
-
*
|
|
618
|
-
* @param str An object that contains serializable values
|
|
619
|
-
* @param max Maximum number of characters in truncated string (0 = unlimited)
|
|
620
|
-
* @returns string Encoded
|
|
621
|
-
*/
|
|
622
|
-
function truncate(str, max) {
|
|
623
|
-
if (max === void 0) { max = 0; }
|
|
624
|
-
if (typeof str !== 'string' || max === 0) {
|
|
625
|
-
return str;
|
|
626
|
-
}
|
|
627
|
-
return str.length <= max ? str : str.substr(0, max) + "...";
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* Join values in array
|
|
631
|
-
* @param input array of values to be joined together
|
|
632
|
-
* @param delimiter string to be placed in-between values
|
|
633
|
-
* @returns Joined values
|
|
634
|
-
*/
|
|
635
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
636
|
-
function safeJoin(input, delimiter) {
|
|
637
|
-
if (!Array.isArray(input)) {
|
|
638
|
-
return '';
|
|
639
|
-
}
|
|
640
|
-
var output = [];
|
|
641
|
-
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
642
|
-
for (var i = 0; i < input.length; i++) {
|
|
643
|
-
var value = input[i];
|
|
644
|
-
try {
|
|
645
|
-
output.push(String(value));
|
|
646
|
-
}
|
|
647
|
-
catch (e) {
|
|
648
|
-
output.push('[value cannot be serialized]');
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
return output.join(delimiter);
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Checks if the value matches a regex or includes the string
|
|
655
|
-
* @param value The string value to be checked against
|
|
656
|
-
* @param pattern Either a regex or a string that must be contained in value
|
|
657
|
-
*/
|
|
658
|
-
function isMatchingPattern(value, pattern) {
|
|
659
|
-
if (!isString(value)) {
|
|
660
|
-
return false;
|
|
661
|
-
}
|
|
662
|
-
if (isRegExp(pattern)) {
|
|
663
|
-
return pattern.test(value);
|
|
664
|
-
}
|
|
665
|
-
if (typeof pattern === 'string') {
|
|
666
|
-
return value.indexOf(pattern) !== -1;
|
|
667
|
-
}
|
|
668
|
-
return false;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
var fallbackGlobalObject = {};
|
|
672
|
-
/**
|
|
673
|
-
* Safely get global scope object
|
|
674
|
-
*
|
|
675
|
-
* @returns Global scope object
|
|
676
|
-
*/
|
|
677
|
-
function getGlobalObject() {
|
|
678
|
-
return (isNodeEnv()
|
|
679
|
-
? global
|
|
680
|
-
: typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
|
|
681
|
-
? window // eslint-disable-line no-restricted-globals
|
|
682
|
-
: typeof self !== 'undefined'
|
|
683
|
-
? self
|
|
684
|
-
: fallbackGlobalObject);
|
|
685
|
-
}
|
|
686
|
-
/**
|
|
687
|
-
* UUID4 generator
|
|
668
|
+
* Temporarily unwrap `console.log` and friends in order to perform the given callback using the original methods.
|
|
669
|
+
* Restores wrapping after the callback completes.
|
|
688
670
|
*
|
|
689
|
-
* @
|
|
690
|
-
|
|
691
|
-
function uuid4() {
|
|
692
|
-
var global = getGlobalObject();
|
|
693
|
-
var crypto = global.crypto || global.msCrypto;
|
|
694
|
-
if (!(crypto === void 0) && crypto.getRandomValues) {
|
|
695
|
-
// Use window.crypto API if available
|
|
696
|
-
var arr = new Uint16Array(8);
|
|
697
|
-
crypto.getRandomValues(arr);
|
|
698
|
-
// set 4 in byte 7
|
|
699
|
-
// eslint-disable-next-line no-bitwise
|
|
700
|
-
arr[3] = (arr[3] & 0xfff) | 0x4000;
|
|
701
|
-
// set 2 most significant bits of byte 9 to '10'
|
|
702
|
-
// eslint-disable-next-line no-bitwise
|
|
703
|
-
arr[4] = (arr[4] & 0x3fff) | 0x8000;
|
|
704
|
-
var pad = function (num) {
|
|
705
|
-
var v = num.toString(16);
|
|
706
|
-
while (v.length < 4) {
|
|
707
|
-
v = "0" + v;
|
|
708
|
-
}
|
|
709
|
-
return v;
|
|
710
|
-
};
|
|
711
|
-
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]));
|
|
712
|
-
}
|
|
713
|
-
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
|
|
714
|
-
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
715
|
-
// eslint-disable-next-line no-bitwise
|
|
716
|
-
var r = (Math.random() * 16) | 0;
|
|
717
|
-
// eslint-disable-next-line no-bitwise
|
|
718
|
-
var v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
719
|
-
return v.toString(16);
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* Parses string form of URL into an object
|
|
724
|
-
* // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B
|
|
725
|
-
* // intentionally using regex and not <a/> href parsing trick because React Native and other
|
|
726
|
-
* // environments where DOM might not be available
|
|
727
|
-
* @returns parsed URL object
|
|
728
|
-
*/
|
|
729
|
-
function parseUrl(url) {
|
|
730
|
-
if (!url) {
|
|
731
|
-
return {};
|
|
732
|
-
}
|
|
733
|
-
var match = url.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);
|
|
734
|
-
if (!match) {
|
|
735
|
-
return {};
|
|
736
|
-
}
|
|
737
|
-
// coerce to undefined values to empty string so we don't get 'undefined'
|
|
738
|
-
var query = match[6] || '';
|
|
739
|
-
var fragment = match[8] || '';
|
|
740
|
-
return {
|
|
741
|
-
host: match[4],
|
|
742
|
-
path: match[5],
|
|
743
|
-
protocol: match[2],
|
|
744
|
-
relative: match[5] + query + fragment,
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
/**
|
|
748
|
-
* Extracts either message or type+value from an event that can be used for user-facing logs
|
|
749
|
-
* @returns event's description
|
|
671
|
+
* @param callback The function to run against the original `console` messages
|
|
672
|
+
* @returns The results of the callback
|
|
750
673
|
*/
|
|
751
|
-
function getEventDescription(event) {
|
|
752
|
-
if (event.message) {
|
|
753
|
-
return event.message;
|
|
754
|
-
}
|
|
755
|
-
if (event.exception && event.exception.values && event.exception.values[0]) {
|
|
756
|
-
var exception = event.exception.values[0];
|
|
757
|
-
if (exception.type && exception.value) {
|
|
758
|
-
return exception.type + ": " + exception.value;
|
|
759
|
-
}
|
|
760
|
-
return exception.type || exception.value || event.event_id || '<unknown>';
|
|
761
|
-
}
|
|
762
|
-
return event.event_id || '<unknown>';
|
|
763
|
-
}
|
|
764
|
-
/** JSDoc */
|
|
765
674
|
function consoleSandbox(callback) {
|
|
766
675
|
var global = getGlobalObject();
|
|
767
676
|
var levels = ['debug', 'info', 'warn', 'error', 'log', 'assert'];
|
|
@@ -787,81 +696,6 @@ var Sentry = (function (exports) {
|
|
|
787
696
|
});
|
|
788
697
|
return result;
|
|
789
698
|
}
|
|
790
|
-
/**
|
|
791
|
-
* Adds exception values, type and value to an synthetic Exception.
|
|
792
|
-
* @param event The event to modify.
|
|
793
|
-
* @param value Value of the exception.
|
|
794
|
-
* @param type Type of the exception.
|
|
795
|
-
* @hidden
|
|
796
|
-
*/
|
|
797
|
-
function addExceptionTypeValue(event, value, type) {
|
|
798
|
-
event.exception = event.exception || {};
|
|
799
|
-
event.exception.values = event.exception.values || [];
|
|
800
|
-
event.exception.values[0] = event.exception.values[0] || {};
|
|
801
|
-
event.exception.values[0].value = event.exception.values[0].value || value || '';
|
|
802
|
-
event.exception.values[0].type = event.exception.values[0].type || type || 'Error';
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Adds exception mechanism to a given event.
|
|
806
|
-
* @param event The event to modify.
|
|
807
|
-
* @param mechanism Mechanism of the mechanism.
|
|
808
|
-
* @hidden
|
|
809
|
-
*/
|
|
810
|
-
function addExceptionMechanism(event, mechanism) {
|
|
811
|
-
if (mechanism === void 0) { mechanism = {}; }
|
|
812
|
-
// TODO: Use real type with `keyof Mechanism` thingy and maybe make it better?
|
|
813
|
-
try {
|
|
814
|
-
// @ts-ignore Type 'Mechanism | {}' is not assignable to type 'Mechanism | undefined'
|
|
815
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
816
|
-
event.exception.values[0].mechanism = event.exception.values[0].mechanism || {};
|
|
817
|
-
Object.keys(mechanism).forEach(function (key) {
|
|
818
|
-
// @ts-ignore Mechanism has no index signature
|
|
819
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
820
|
-
event.exception.values[0].mechanism[key] = mechanism[key];
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
catch (_oO) {
|
|
824
|
-
// no-empty
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
/**
|
|
828
|
-
* A safe form of location.href
|
|
829
|
-
*/
|
|
830
|
-
function getLocationHref() {
|
|
831
|
-
var global = getGlobalObject();
|
|
832
|
-
try {
|
|
833
|
-
return global.document.location.href;
|
|
834
|
-
}
|
|
835
|
-
catch (oO) {
|
|
836
|
-
return '';
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
var defaultRetryAfter = 60 * 1000; // 60 seconds
|
|
840
|
-
/**
|
|
841
|
-
* Extracts Retry-After value from the request header or returns default value
|
|
842
|
-
* @param now current unix timestamp
|
|
843
|
-
* @param header string representation of 'Retry-After' header
|
|
844
|
-
*/
|
|
845
|
-
function parseRetryAfterHeader(now, header) {
|
|
846
|
-
if (!header) {
|
|
847
|
-
return defaultRetryAfter;
|
|
848
|
-
}
|
|
849
|
-
var headerDelay = parseInt("" + header, 10);
|
|
850
|
-
if (!isNaN(headerDelay)) {
|
|
851
|
-
return headerDelay * 1000;
|
|
852
|
-
}
|
|
853
|
-
var headerDate = Date.parse("" + header);
|
|
854
|
-
if (!isNaN(headerDate)) {
|
|
855
|
-
return headerDate - now;
|
|
856
|
-
}
|
|
857
|
-
return defaultRetryAfter;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
861
|
-
// TODO: Implement different loggers for different environments
|
|
862
|
-
var global$1 = getGlobalObject();
|
|
863
|
-
/** Prefix for logging strings */
|
|
864
|
-
var PREFIX = 'Sentry Logger ';
|
|
865
699
|
/** JSDoc */
|
|
866
700
|
var Logger = /** @class */ (function () {
|
|
867
701
|
/** JSDoc */
|
|
@@ -992,6 +826,62 @@ var Sentry = (function (exports) {
|
|
|
992
826
|
}
|
|
993
827
|
}
|
|
994
828
|
|
|
829
|
+
/**
|
|
830
|
+
* Truncates given string to the maximum characters count
|
|
831
|
+
*
|
|
832
|
+
* @param str An object that contains serializable values
|
|
833
|
+
* @param max Maximum number of characters in truncated string (0 = unlimited)
|
|
834
|
+
* @returns string Encoded
|
|
835
|
+
*/
|
|
836
|
+
function truncate(str, max) {
|
|
837
|
+
if (max === void 0) { max = 0; }
|
|
838
|
+
if (typeof str !== 'string' || max === 0) {
|
|
839
|
+
return str;
|
|
840
|
+
}
|
|
841
|
+
return str.length <= max ? str : str.substr(0, max) + "...";
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Join values in array
|
|
845
|
+
* @param input array of values to be joined together
|
|
846
|
+
* @param delimiter string to be placed in-between values
|
|
847
|
+
* @returns Joined values
|
|
848
|
+
*/
|
|
849
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
850
|
+
function safeJoin(input, delimiter) {
|
|
851
|
+
if (!Array.isArray(input)) {
|
|
852
|
+
return '';
|
|
853
|
+
}
|
|
854
|
+
var output = [];
|
|
855
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
856
|
+
for (var i = 0; i < input.length; i++) {
|
|
857
|
+
var value = input[i];
|
|
858
|
+
try {
|
|
859
|
+
output.push(String(value));
|
|
860
|
+
}
|
|
861
|
+
catch (e) {
|
|
862
|
+
output.push('[value cannot be serialized]');
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return output.join(delimiter);
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Checks if the value matches a regex or includes the string
|
|
869
|
+
* @param value The string value to be checked against
|
|
870
|
+
* @param pattern Either a regex or a string that must be contained in value
|
|
871
|
+
*/
|
|
872
|
+
function isMatchingPattern(value, pattern) {
|
|
873
|
+
if (!isString(value)) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
if (isRegExp(pattern)) {
|
|
877
|
+
return pattern.test(value);
|
|
878
|
+
}
|
|
879
|
+
if (typeof pattern === 'string') {
|
|
880
|
+
return value.indexOf(pattern) !== -1;
|
|
881
|
+
}
|
|
882
|
+
return false;
|
|
883
|
+
}
|
|
884
|
+
|
|
995
885
|
/**
|
|
996
886
|
* Replace a method in an object with a wrapped version of itself.
|
|
997
887
|
*
|
|
@@ -1295,10 +1185,9 @@ var Sentry = (function (exports) {
|
|
|
1295
1185
|
* Given any object, return the new object with removed keys that value was `undefined`.
|
|
1296
1186
|
* Works recursively on objects and arrays.
|
|
1297
1187
|
*/
|
|
1298
|
-
function dropUndefinedKeys(
|
|
1188
|
+
function dropUndefinedKeys(obj) {
|
|
1299
1189
|
var e_1, _a;
|
|
1300
|
-
if (isPlainObject(
|
|
1301
|
-
var obj = val;
|
|
1190
|
+
if (isPlainObject(obj)) {
|
|
1302
1191
|
var rv = {};
|
|
1303
1192
|
try {
|
|
1304
1193
|
for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -1317,10 +1206,10 @@ var Sentry = (function (exports) {
|
|
|
1317
1206
|
}
|
|
1318
1207
|
return rv;
|
|
1319
1208
|
}
|
|
1320
|
-
if (Array.isArray(
|
|
1321
|
-
return
|
|
1209
|
+
if (Array.isArray(obj)) {
|
|
1210
|
+
return obj.map(dropUndefinedKeys);
|
|
1322
1211
|
}
|
|
1323
|
-
return
|
|
1212
|
+
return obj;
|
|
1324
1213
|
}
|
|
1325
1214
|
|
|
1326
1215
|
/**
|
|
@@ -1953,18 +1842,191 @@ var Sentry = (function (exports) {
|
|
|
1953
1842
|
return false;
|
|
1954
1843
|
};
|
|
1955
1844
|
}
|
|
1956
|
-
var _oldOnUnhandledRejectionHandler = null;
|
|
1957
|
-
/** JSDoc */
|
|
1958
|
-
function instrumentUnhandledRejection() {
|
|
1959
|
-
_oldOnUnhandledRejectionHandler = global$2.onunhandledrejection;
|
|
1960
|
-
global$2.onunhandledrejection = function (e) {
|
|
1961
|
-
triggerHandlers('unhandledrejection', e);
|
|
1962
|
-
if (_oldOnUnhandledRejectionHandler) {
|
|
1963
|
-
// eslint-disable-next-line prefer-rest-params
|
|
1964
|
-
return _oldOnUnhandledRejectionHandler.apply(this, arguments);
|
|
1845
|
+
var _oldOnUnhandledRejectionHandler = null;
|
|
1846
|
+
/** JSDoc */
|
|
1847
|
+
function instrumentUnhandledRejection() {
|
|
1848
|
+
_oldOnUnhandledRejectionHandler = global$2.onunhandledrejection;
|
|
1849
|
+
global$2.onunhandledrejection = function (e) {
|
|
1850
|
+
triggerHandlers('unhandledrejection', e);
|
|
1851
|
+
if (_oldOnUnhandledRejectionHandler) {
|
|
1852
|
+
// eslint-disable-next-line prefer-rest-params
|
|
1853
|
+
return _oldOnUnhandledRejectionHandler.apply(this, arguments);
|
|
1854
|
+
}
|
|
1855
|
+
return true;
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
/**
|
|
1860
|
+
* UUID4 generator
|
|
1861
|
+
*
|
|
1862
|
+
* @returns string Generated UUID4.
|
|
1863
|
+
*/
|
|
1864
|
+
function uuid4() {
|
|
1865
|
+
var global = getGlobalObject();
|
|
1866
|
+
var crypto = global.crypto || global.msCrypto;
|
|
1867
|
+
if (!(crypto === void 0) && crypto.getRandomValues) {
|
|
1868
|
+
// Use window.crypto API if available
|
|
1869
|
+
var arr = new Uint16Array(8);
|
|
1870
|
+
crypto.getRandomValues(arr);
|
|
1871
|
+
// set 4 in byte 7
|
|
1872
|
+
// eslint-disable-next-line no-bitwise
|
|
1873
|
+
arr[3] = (arr[3] & 0xfff) | 0x4000;
|
|
1874
|
+
// set 2 most significant bits of byte 9 to '10'
|
|
1875
|
+
// eslint-disable-next-line no-bitwise
|
|
1876
|
+
arr[4] = (arr[4] & 0x3fff) | 0x8000;
|
|
1877
|
+
var pad = function (num) {
|
|
1878
|
+
var v = num.toString(16);
|
|
1879
|
+
while (v.length < 4) {
|
|
1880
|
+
v = "0" + v;
|
|
1881
|
+
}
|
|
1882
|
+
return v;
|
|
1883
|
+
};
|
|
1884
|
+
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]));
|
|
1885
|
+
}
|
|
1886
|
+
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
|
|
1887
|
+
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
1888
|
+
// eslint-disable-next-line no-bitwise
|
|
1889
|
+
var r = (Math.random() * 16) | 0;
|
|
1890
|
+
// eslint-disable-next-line no-bitwise
|
|
1891
|
+
var v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
1892
|
+
return v.toString(16);
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* Parses string form of URL into an object
|
|
1897
|
+
* // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B
|
|
1898
|
+
* // intentionally using regex and not <a/> href parsing trick because React Native and other
|
|
1899
|
+
* // environments where DOM might not be available
|
|
1900
|
+
* @returns parsed URL object
|
|
1901
|
+
*/
|
|
1902
|
+
function parseUrl(url) {
|
|
1903
|
+
if (!url) {
|
|
1904
|
+
return {};
|
|
1905
|
+
}
|
|
1906
|
+
var match = url.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);
|
|
1907
|
+
if (!match) {
|
|
1908
|
+
return {};
|
|
1909
|
+
}
|
|
1910
|
+
// coerce to undefined values to empty string so we don't get 'undefined'
|
|
1911
|
+
var query = match[6] || '';
|
|
1912
|
+
var fragment = match[8] || '';
|
|
1913
|
+
return {
|
|
1914
|
+
host: match[4],
|
|
1915
|
+
path: match[5],
|
|
1916
|
+
protocol: match[2],
|
|
1917
|
+
relative: match[5] + query + fragment,
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Extracts either message or type+value from an event that can be used for user-facing logs
|
|
1922
|
+
* @returns event's description
|
|
1923
|
+
*/
|
|
1924
|
+
function getEventDescription(event) {
|
|
1925
|
+
if (event.message) {
|
|
1926
|
+
return event.message;
|
|
1927
|
+
}
|
|
1928
|
+
if (event.exception && event.exception.values && event.exception.values[0]) {
|
|
1929
|
+
var exception = event.exception.values[0];
|
|
1930
|
+
if (exception.type && exception.value) {
|
|
1931
|
+
return exception.type + ": " + exception.value;
|
|
1965
1932
|
}
|
|
1933
|
+
return exception.type || exception.value || event.event_id || '<unknown>';
|
|
1934
|
+
}
|
|
1935
|
+
return event.event_id || '<unknown>';
|
|
1936
|
+
}
|
|
1937
|
+
/**
|
|
1938
|
+
* Adds exception values, type and value to an synthetic Exception.
|
|
1939
|
+
* @param event The event to modify.
|
|
1940
|
+
* @param value Value of the exception.
|
|
1941
|
+
* @param type Type of the exception.
|
|
1942
|
+
* @hidden
|
|
1943
|
+
*/
|
|
1944
|
+
function addExceptionTypeValue(event, value, type) {
|
|
1945
|
+
event.exception = event.exception || {};
|
|
1946
|
+
event.exception.values = event.exception.values || [];
|
|
1947
|
+
event.exception.values[0] = event.exception.values[0] || {};
|
|
1948
|
+
event.exception.values[0].value = event.exception.values[0].value || value || '';
|
|
1949
|
+
event.exception.values[0].type = event.exception.values[0].type || type || 'Error';
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* Adds exception mechanism data to a given event. Uses defaults if the second parameter is not passed.
|
|
1953
|
+
*
|
|
1954
|
+
* @param event The event to modify.
|
|
1955
|
+
* @param newMechanism Mechanism data to add to the event.
|
|
1956
|
+
* @hidden
|
|
1957
|
+
*/
|
|
1958
|
+
function addExceptionMechanism(event, newMechanism) {
|
|
1959
|
+
var _a;
|
|
1960
|
+
if (!event.exception || !event.exception.values) {
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
var exceptionValue0 = event.exception.values[0];
|
|
1964
|
+
var defaultMechanism = { type: 'generic', handled: true };
|
|
1965
|
+
var currentMechanism = exceptionValue0.mechanism;
|
|
1966
|
+
exceptionValue0.mechanism = __assign(__assign(__assign({}, defaultMechanism), currentMechanism), newMechanism);
|
|
1967
|
+
if (newMechanism && 'data' in newMechanism) {
|
|
1968
|
+
var mergedData = __assign(__assign({}, (_a = currentMechanism) === null || _a === void 0 ? void 0 : _a.data), newMechanism.data);
|
|
1969
|
+
exceptionValue0.mechanism.data = mergedData;
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
var defaultRetryAfter = 60 * 1000; // 60 seconds
|
|
1973
|
+
/**
|
|
1974
|
+
* Extracts Retry-After value from the request header or returns default value
|
|
1975
|
+
* @param now current unix timestamp
|
|
1976
|
+
* @param header string representation of 'Retry-After' header
|
|
1977
|
+
*/
|
|
1978
|
+
function parseRetryAfterHeader(now, header) {
|
|
1979
|
+
if (!header) {
|
|
1980
|
+
return defaultRetryAfter;
|
|
1981
|
+
}
|
|
1982
|
+
var headerDelay = parseInt("" + header, 10);
|
|
1983
|
+
if (!isNaN(headerDelay)) {
|
|
1984
|
+
return headerDelay * 1000;
|
|
1985
|
+
}
|
|
1986
|
+
var headerDate = Date.parse("" + header);
|
|
1987
|
+
if (!isNaN(headerDate)) {
|
|
1988
|
+
return headerDate - now;
|
|
1989
|
+
}
|
|
1990
|
+
return defaultRetryAfter;
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Checks whether or not we've already captured the given exception (note: not an identical exception - the very object
|
|
1994
|
+
* in question), and marks it captured if not.
|
|
1995
|
+
*
|
|
1996
|
+
* This is useful because it's possible for an error to get captured by more than one mechanism. After we intercept and
|
|
1997
|
+
* record an error, we rethrow it (assuming we've intercepted it before it's reached the top-level global handlers), so
|
|
1998
|
+
* that we don't interfere with whatever effects the error might have had were the SDK not there. At that point, because
|
|
1999
|
+
* the error has been rethrown, it's possible for it to bubble up to some other code we've instrumented. If it's not
|
|
2000
|
+
* caught after that, it will bubble all the way up to the global handlers (which of course we also instrument). This
|
|
2001
|
+
* function helps us ensure that even if we encounter the same error more than once, we only record it the first time we
|
|
2002
|
+
* see it.
|
|
2003
|
+
*
|
|
2004
|
+
* Note: It will ignore primitives (always return `false` and not mark them as seen), as properties can't be set on
|
|
2005
|
+
* them. {@link: Object.objectify} can be used on exceptions to convert any that are primitives into their equivalent
|
|
2006
|
+
* object wrapper forms so that this check will always work. However, because we need to flag the exact object which
|
|
2007
|
+
* will get rethrown, and because that rethrowing happens outside of the event processing pipeline, the objectification
|
|
2008
|
+
* must be done before the exception captured.
|
|
2009
|
+
*
|
|
2010
|
+
* @param A thrown exception to check or flag as having been seen
|
|
2011
|
+
* @returns `true` if the exception has already been captured, `false` if not (with the side effect of marking it seen)
|
|
2012
|
+
*/
|
|
2013
|
+
function checkOrSetAlreadyCaught(exception) {
|
|
2014
|
+
var _a;
|
|
2015
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
2016
|
+
if ((_a = exception) === null || _a === void 0 ? void 0 : _a.__sentry_captured__) {
|
|
1966
2017
|
return true;
|
|
1967
|
-
}
|
|
2018
|
+
}
|
|
2019
|
+
try {
|
|
2020
|
+
// set it this way rather than by assignment so that it's not ennumerable and therefore isn't recorded by the
|
|
2021
|
+
// `ExtraErrorData` integration
|
|
2022
|
+
Object.defineProperty(exception, '__sentry_captured__', {
|
|
2023
|
+
value: true,
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
catch (err) {
|
|
2027
|
+
// `exception` is a primitive, so we can't mark it seen
|
|
2028
|
+
}
|
|
2029
|
+
return false;
|
|
1968
2030
|
}
|
|
1969
2031
|
|
|
1970
2032
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
@@ -3806,6 +3868,7 @@ var Sentry = (function (exports) {
|
|
|
3806
3868
|
return integrations;
|
|
3807
3869
|
}
|
|
3808
3870
|
|
|
3871
|
+
var ALREADY_SEEN_ERROR = "Not capturing exception because it's already been captured.";
|
|
3809
3872
|
/**
|
|
3810
3873
|
* Base implementation for all JavaScript SDK clients.
|
|
3811
3874
|
*
|
|
@@ -3862,6 +3925,11 @@ var Sentry = (function (exports) {
|
|
|
3862
3925
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
3863
3926
|
BaseClient.prototype.captureException = function (exception, hint, scope) {
|
|
3864
3927
|
var _this = this;
|
|
3928
|
+
// ensure we haven't captured this very object before
|
|
3929
|
+
if (checkOrSetAlreadyCaught(exception)) {
|
|
3930
|
+
logger.log(ALREADY_SEEN_ERROR);
|
|
3931
|
+
return;
|
|
3932
|
+
}
|
|
3865
3933
|
var eventId = hint && hint.event_id;
|
|
3866
3934
|
this._process(this._getBackend()
|
|
3867
3935
|
.eventFromException(exception, hint)
|
|
@@ -3891,6 +3959,12 @@ var Sentry = (function (exports) {
|
|
|
3891
3959
|
* @inheritDoc
|
|
3892
3960
|
*/
|
|
3893
3961
|
BaseClient.prototype.captureEvent = function (event, hint, scope) {
|
|
3962
|
+
var _a;
|
|
3963
|
+
// ensure we haven't captured this very object before
|
|
3964
|
+
if (((_a = hint) === null || _a === void 0 ? void 0 : _a.originalException) && checkOrSetAlreadyCaught(hint.originalException)) {
|
|
3965
|
+
logger.log(ALREADY_SEEN_ERROR);
|
|
3966
|
+
return;
|
|
3967
|
+
}
|
|
3894
3968
|
var eventId = hint && hint.event_id;
|
|
3895
3969
|
this._process(this._captureEvent(event, hint, scope).then(function (result) {
|
|
3896
3970
|
eventId = result;
|
|
@@ -4483,7 +4557,7 @@ var Sentry = (function (exports) {
|
|
|
4483
4557
|
hub.bindClient(client);
|
|
4484
4558
|
}
|
|
4485
4559
|
|
|
4486
|
-
var SDK_VERSION = '6.
|
|
4560
|
+
var SDK_VERSION = '6.14.2';
|
|
4487
4561
|
|
|
4488
4562
|
var originalFunctionToString;
|
|
4489
4563
|
/** Patch toString calls to return proper name for wrapped functions */
|
|
@@ -5047,10 +5121,7 @@ var Sentry = (function (exports) {
|
|
|
5047
5121
|
var event = eventFromUnknownInput(exception, syntheticException, {
|
|
5048
5122
|
attachStacktrace: options.attachStacktrace,
|
|
5049
5123
|
});
|
|
5050
|
-
addExceptionMechanism(event,
|
|
5051
|
-
handled: true,
|
|
5052
|
-
type: 'generic',
|
|
5053
|
-
});
|
|
5124
|
+
addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
|
|
5054
5125
|
event.level = exports.Severity.Error;
|
|
5055
5126
|
if (hint && hint.event_id) {
|
|
5056
5127
|
event.event_id = hint.event_id;
|
|
@@ -5079,11 +5150,10 @@ var Sentry = (function (exports) {
|
|
|
5079
5150
|
function eventFromUnknownInput(exception, syntheticException, options) {
|
|
5080
5151
|
if (options === void 0) { options = {}; }
|
|
5081
5152
|
var event;
|
|
5082
|
-
if (isErrorEvent(exception)
|
|
5153
|
+
if (isErrorEvent(exception)) {
|
|
5083
5154
|
// If it is an ErrorEvent with `error` property, extract it to get actual Error
|
|
5084
|
-
var errorEvent = exception;
|
|
5085
5155
|
// eslint-disable-next-line no-param-reassign
|
|
5086
|
-
exception =
|
|
5156
|
+
exception = exception.error;
|
|
5087
5157
|
event = eventFromStacktrace(computeStackTrace(exception));
|
|
5088
5158
|
return event;
|
|
5089
5159
|
}
|
|
@@ -5152,13 +5222,108 @@ var Sentry = (function (exports) {
|
|
|
5152
5222
|
return event;
|
|
5153
5223
|
}
|
|
5154
5224
|
|
|
5225
|
+
var global$3 = getGlobalObject();
|
|
5226
|
+
var cachedFetchImpl;
|
|
5227
|
+
/**
|
|
5228
|
+
* A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
|
|
5229
|
+
* Whenever someone wraps the Fetch API and returns the wrong promise chain,
|
|
5230
|
+
* this chain becomes orphaned and there is no possible way to capture it's rejections
|
|
5231
|
+
* other than allowing it bubble up to this very handler. eg.
|
|
5232
|
+
*
|
|
5233
|
+
* const f = window.fetch;
|
|
5234
|
+
* window.fetch = function () {
|
|
5235
|
+
* const p = f.apply(this, arguments);
|
|
5236
|
+
*
|
|
5237
|
+
* p.then(function() {
|
|
5238
|
+
* console.log('hi.');
|
|
5239
|
+
* });
|
|
5240
|
+
*
|
|
5241
|
+
* return p;
|
|
5242
|
+
* }
|
|
5243
|
+
*
|
|
5244
|
+
* `p.then(function () { ... })` is producing a completely separate promise chain,
|
|
5245
|
+
* however, what's returned is `p` - the result of original `fetch` call.
|
|
5246
|
+
*
|
|
5247
|
+
* This mean, that whenever we use the Fetch API to send our own requests, _and_
|
|
5248
|
+
* some ad-blocker blocks it, this orphaned chain will _always_ reject,
|
|
5249
|
+
* effectively causing another event to be captured.
|
|
5250
|
+
* This makes a whole process become an infinite loop, which we need to somehow
|
|
5251
|
+
* deal with, and break it in one way or another.
|
|
5252
|
+
*
|
|
5253
|
+
* To deal with this issue, we are making sure that we _always_ use the real
|
|
5254
|
+
* browser Fetch API, instead of relying on what `window.fetch` exposes.
|
|
5255
|
+
* The only downside to this would be missing our own requests as breadcrumbs,
|
|
5256
|
+
* but because we are already not doing this, it should be just fine.
|
|
5257
|
+
*
|
|
5258
|
+
* Possible failed fetch error messages per-browser:
|
|
5259
|
+
*
|
|
5260
|
+
* Chrome: Failed to fetch
|
|
5261
|
+
* Edge: Failed to Fetch
|
|
5262
|
+
* Firefox: NetworkError when attempting to fetch resource
|
|
5263
|
+
* Safari: resource blocked by content blocker
|
|
5264
|
+
*/
|
|
5265
|
+
function getNativeFetchImplementation() {
|
|
5266
|
+
var _a, _b;
|
|
5267
|
+
if (cachedFetchImpl) {
|
|
5268
|
+
return cachedFetchImpl;
|
|
5269
|
+
}
|
|
5270
|
+
/* eslint-disable @typescript-eslint/unbound-method */
|
|
5271
|
+
// Fast path to avoid DOM I/O
|
|
5272
|
+
if (isNativeFetch(global$3.fetch)) {
|
|
5273
|
+
return (cachedFetchImpl = global$3.fetch.bind(global$3));
|
|
5274
|
+
}
|
|
5275
|
+
var document = global$3.document;
|
|
5276
|
+
var fetchImpl = global$3.fetch;
|
|
5277
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
5278
|
+
if (typeof ((_a = document) === null || _a === void 0 ? void 0 : _a.createElement) === "function") {
|
|
5279
|
+
try {
|
|
5280
|
+
var sandbox = document.createElement('iframe');
|
|
5281
|
+
sandbox.hidden = true;
|
|
5282
|
+
document.head.appendChild(sandbox);
|
|
5283
|
+
if ((_b = sandbox.contentWindow) === null || _b === void 0 ? void 0 : _b.fetch) {
|
|
5284
|
+
fetchImpl = sandbox.contentWindow.fetch;
|
|
5285
|
+
}
|
|
5286
|
+
document.head.removeChild(sandbox);
|
|
5287
|
+
}
|
|
5288
|
+
catch (e) {
|
|
5289
|
+
logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
|
|
5290
|
+
}
|
|
5291
|
+
}
|
|
5292
|
+
return (cachedFetchImpl = fetchImpl.bind(global$3));
|
|
5293
|
+
/* eslint-enable @typescript-eslint/unbound-method */
|
|
5294
|
+
}
|
|
5295
|
+
/**
|
|
5296
|
+
* Sends sdk client report using sendBeacon or fetch as a fallback if available
|
|
5297
|
+
*
|
|
5298
|
+
* @param url report endpoint
|
|
5299
|
+
* @param body report payload
|
|
5300
|
+
*/
|
|
5301
|
+
function sendReport(url, body) {
|
|
5302
|
+
var isRealNavigator = Object.prototype.toString.call(global$3 && global$3.navigator) === '[object Navigator]';
|
|
5303
|
+
var hasSendBeacon = isRealNavigator && typeof global$3.navigator.sendBeacon === 'function';
|
|
5304
|
+
if (hasSendBeacon) {
|
|
5305
|
+
// Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
|
|
5306
|
+
var sendBeacon = global$3.navigator.sendBeacon.bind(global$3.navigator);
|
|
5307
|
+
return sendBeacon(url, body);
|
|
5308
|
+
}
|
|
5309
|
+
if (supportsFetch()) {
|
|
5310
|
+
var fetch_1 = getNativeFetchImplementation();
|
|
5311
|
+
return forget(fetch_1(url, {
|
|
5312
|
+
body: body,
|
|
5313
|
+
method: 'POST',
|
|
5314
|
+
credentials: 'omit',
|
|
5315
|
+
keepalive: true,
|
|
5316
|
+
}));
|
|
5317
|
+
}
|
|
5318
|
+
}
|
|
5319
|
+
|
|
5155
5320
|
var CATEGORY_MAPPING = {
|
|
5156
5321
|
event: 'error',
|
|
5157
5322
|
transaction: 'transaction',
|
|
5158
5323
|
session: 'session',
|
|
5159
5324
|
attachment: 'attachment',
|
|
5160
5325
|
};
|
|
5161
|
-
var global$
|
|
5326
|
+
var global$4 = getGlobalObject();
|
|
5162
5327
|
/** Base Transport class implementation */
|
|
5163
5328
|
var BaseTransport = /** @class */ (function () {
|
|
5164
5329
|
function BaseTransport(options) {
|
|
@@ -5172,9 +5337,9 @@ var Sentry = (function (exports) {
|
|
|
5172
5337
|
this._api = new API(options.dsn, options._metadata, options.tunnel);
|
|
5173
5338
|
// eslint-disable-next-line deprecation/deprecation
|
|
5174
5339
|
this.url = this._api.getStoreEndpointWithUrlEncodedAuth();
|
|
5175
|
-
if (this.options.sendClientReports && global$
|
|
5176
|
-
global$
|
|
5177
|
-
if (global$
|
|
5340
|
+
if (this.options.sendClientReports && global$4.document) {
|
|
5341
|
+
global$4.document.addEventListener('visibilitychange', function () {
|
|
5342
|
+
if (global$4.document.visibilityState === 'hidden') {
|
|
5178
5343
|
_this._flushOutcomes();
|
|
5179
5344
|
}
|
|
5180
5345
|
});
|
|
@@ -5216,10 +5381,6 @@ var Sentry = (function (exports) {
|
|
|
5216
5381
|
if (!this.options.sendClientReports) {
|
|
5217
5382
|
return;
|
|
5218
5383
|
}
|
|
5219
|
-
if (!global$3.navigator || typeof global$3.navigator.sendBeacon !== 'function') {
|
|
5220
|
-
logger.warn('Beacon API not available, skipping sending outcomes.');
|
|
5221
|
-
return;
|
|
5222
|
-
}
|
|
5223
5384
|
var outcomes = this._outcomes;
|
|
5224
5385
|
this._outcomes = {};
|
|
5225
5386
|
// Nothing to send
|
|
@@ -5230,7 +5391,7 @@ var Sentry = (function (exports) {
|
|
|
5230
5391
|
logger.log("Flushing outcomes:\n" + JSON.stringify(outcomes, null, 2));
|
|
5231
5392
|
var url = this._api.getEnvelopeEndpointWithUrlEncodedAuth();
|
|
5232
5393
|
// Envelope header is required to be at least an empty object
|
|
5233
|
-
var envelopeHeader = JSON.stringify({});
|
|
5394
|
+
var envelopeHeader = JSON.stringify(__assign({}, (this.options.tunnel && { dsn: this._api.getDsn().toString() })));
|
|
5234
5395
|
var itemHeaders = JSON.stringify({
|
|
5235
5396
|
type: 'client_report',
|
|
5236
5397
|
});
|
|
@@ -5246,7 +5407,12 @@ var Sentry = (function (exports) {
|
|
|
5246
5407
|
}),
|
|
5247
5408
|
});
|
|
5248
5409
|
var envelope = envelopeHeader + "\n" + itemHeaders + "\n" + item;
|
|
5249
|
-
|
|
5410
|
+
try {
|
|
5411
|
+
sendReport(url, envelope);
|
|
5412
|
+
}
|
|
5413
|
+
catch (e) {
|
|
5414
|
+
logger.error(e);
|
|
5415
|
+
}
|
|
5250
5416
|
};
|
|
5251
5417
|
/**
|
|
5252
5418
|
* Handle Sentry repsonse for promise-based transports.
|
|
@@ -5338,72 +5504,6 @@ var Sentry = (function (exports) {
|
|
|
5338
5504
|
return BaseTransport;
|
|
5339
5505
|
}());
|
|
5340
5506
|
|
|
5341
|
-
/**
|
|
5342
|
-
* A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
|
|
5343
|
-
* Whenever someone wraps the Fetch API and returns the wrong promise chain,
|
|
5344
|
-
* this chain becomes orphaned and there is no possible way to capture it's rejections
|
|
5345
|
-
* other than allowing it bubble up to this very handler. eg.
|
|
5346
|
-
*
|
|
5347
|
-
* const f = window.fetch;
|
|
5348
|
-
* window.fetch = function () {
|
|
5349
|
-
* const p = f.apply(this, arguments);
|
|
5350
|
-
*
|
|
5351
|
-
* p.then(function() {
|
|
5352
|
-
* console.log('hi.');
|
|
5353
|
-
* });
|
|
5354
|
-
*
|
|
5355
|
-
* return p;
|
|
5356
|
-
* }
|
|
5357
|
-
*
|
|
5358
|
-
* `p.then(function () { ... })` is producing a completely separate promise chain,
|
|
5359
|
-
* however, what's returned is `p` - the result of original `fetch` call.
|
|
5360
|
-
*
|
|
5361
|
-
* This mean, that whenever we use the Fetch API to send our own requests, _and_
|
|
5362
|
-
* some ad-blocker blocks it, this orphaned chain will _always_ reject,
|
|
5363
|
-
* effectively causing another event to be captured.
|
|
5364
|
-
* This makes a whole process become an infinite loop, which we need to somehow
|
|
5365
|
-
* deal with, and break it in one way or another.
|
|
5366
|
-
*
|
|
5367
|
-
* To deal with this issue, we are making sure that we _always_ use the real
|
|
5368
|
-
* browser Fetch API, instead of relying on what `window.fetch` exposes.
|
|
5369
|
-
* The only downside to this would be missing our own requests as breadcrumbs,
|
|
5370
|
-
* but because we are already not doing this, it should be just fine.
|
|
5371
|
-
*
|
|
5372
|
-
* Possible failed fetch error messages per-browser:
|
|
5373
|
-
*
|
|
5374
|
-
* Chrome: Failed to fetch
|
|
5375
|
-
* Edge: Failed to Fetch
|
|
5376
|
-
* Firefox: NetworkError when attempting to fetch resource
|
|
5377
|
-
* Safari: resource blocked by content blocker
|
|
5378
|
-
*/
|
|
5379
|
-
function getNativeFetchImplementation() {
|
|
5380
|
-
/* eslint-disable @typescript-eslint/unbound-method */
|
|
5381
|
-
var _a, _b;
|
|
5382
|
-
// Fast path to avoid DOM I/O
|
|
5383
|
-
var global = getGlobalObject();
|
|
5384
|
-
if (isNativeFetch(global.fetch)) {
|
|
5385
|
-
return global.fetch.bind(global);
|
|
5386
|
-
}
|
|
5387
|
-
var document = global.document;
|
|
5388
|
-
var fetchImpl = global.fetch;
|
|
5389
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
5390
|
-
if (typeof ((_a = document) === null || _a === void 0 ? void 0 : _a.createElement) === "function") {
|
|
5391
|
-
try {
|
|
5392
|
-
var sandbox = document.createElement('iframe');
|
|
5393
|
-
sandbox.hidden = true;
|
|
5394
|
-
document.head.appendChild(sandbox);
|
|
5395
|
-
if ((_b = sandbox.contentWindow) === null || _b === void 0 ? void 0 : _b.fetch) {
|
|
5396
|
-
fetchImpl = sandbox.contentWindow.fetch;
|
|
5397
|
-
}
|
|
5398
|
-
document.head.removeChild(sandbox);
|
|
5399
|
-
}
|
|
5400
|
-
catch (e) {
|
|
5401
|
-
logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
|
|
5402
|
-
}
|
|
5403
|
-
}
|
|
5404
|
-
return fetchImpl.bind(global);
|
|
5405
|
-
/* eslint-enable @typescript-eslint/unbound-method */
|
|
5406
|
-
}
|
|
5407
5507
|
/** `fetch` based transport */
|
|
5408
5508
|
var FetchTransport = /** @class */ (function (_super) {
|
|
5409
5509
|
__extends(FetchTransport, _super);
|
|
@@ -5537,7 +5637,7 @@ var Sentry = (function (exports) {
|
|
|
5537
5637
|
};
|
|
5538
5638
|
request.open('POST', sentryRequest.url);
|
|
5539
5639
|
for (var header in _this.options.headers) {
|
|
5540
|
-
if (_this.options.headers
|
|
5640
|
+
if (Object.prototype.hasOwnProperty.call(_this.options.headers, header)) {
|
|
5541
5641
|
request.setRequestHeader(header, _this.options.headers[header]);
|
|
5542
5642
|
}
|
|
5543
5643
|
}
|
|
@@ -5609,7 +5709,7 @@ var Sentry = (function (exports) {
|
|
|
5609
5709
|
return BrowserBackend;
|
|
5610
5710
|
}(BaseBackend));
|
|
5611
5711
|
|
|
5612
|
-
var global$
|
|
5712
|
+
var global$5 = getGlobalObject();
|
|
5613
5713
|
var ignoreOnError = 0;
|
|
5614
5714
|
/**
|
|
5615
5715
|
* @hidden
|
|
@@ -5747,7 +5847,7 @@ var Sentry = (function (exports) {
|
|
|
5747
5847
|
*/
|
|
5748
5848
|
function injectReportDialog(options) {
|
|
5749
5849
|
if (options === void 0) { options = {}; }
|
|
5750
|
-
if (!global$
|
|
5850
|
+
if (!global$5.document) {
|
|
5751
5851
|
return;
|
|
5752
5852
|
}
|
|
5753
5853
|
if (!options.eventId) {
|
|
@@ -5758,14 +5858,14 @@ var Sentry = (function (exports) {
|
|
|
5758
5858
|
logger.error("Missing dsn option in showReportDialog call");
|
|
5759
5859
|
return;
|
|
5760
5860
|
}
|
|
5761
|
-
var script = global$
|
|
5861
|
+
var script = global$5.document.createElement('script');
|
|
5762
5862
|
script.async = true;
|
|
5763
5863
|
script.src = new API(options.dsn).getReportDialogEndpoint(options);
|
|
5764
5864
|
if (options.onLoad) {
|
|
5765
5865
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
5766
5866
|
script.onload = options.onLoad;
|
|
5767
5867
|
}
|
|
5768
|
-
var injectionPoint = global$
|
|
5868
|
+
var injectionPoint = global$5.document.head || global$5.document.body;
|
|
5769
5869
|
if (injectionPoint) {
|
|
5770
5870
|
injectionPoint.appendChild(script);
|
|
5771
5871
|
}
|
|
@@ -6073,7 +6173,7 @@ var Sentry = (function (exports) {
|
|
|
6073
6173
|
var global = getGlobalObject();
|
|
6074
6174
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
6075
6175
|
var proto = global[target] && global[target].prototype;
|
|
6076
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
6176
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
|
|
6077
6177
|
if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
|
|
6078
6178
|
return;
|
|
6079
6179
|
}
|
|
@@ -6510,7 +6610,7 @@ var Sentry = (function (exports) {
|
|
|
6510
6610
|
return LinkedErrors;
|
|
6511
6611
|
}());
|
|
6512
6612
|
|
|
6513
|
-
var global$
|
|
6613
|
+
var global$6 = getGlobalObject();
|
|
6514
6614
|
/** UserAgent */
|
|
6515
6615
|
var UserAgent = /** @class */ (function () {
|
|
6516
6616
|
function UserAgent() {
|
|
@@ -6527,13 +6627,13 @@ var Sentry = (function (exports) {
|
|
|
6527
6627
|
var _a, _b, _c;
|
|
6528
6628
|
if (getCurrentHub().getIntegration(UserAgent)) {
|
|
6529
6629
|
// if none of the information we want exists, don't bother
|
|
6530
|
-
if (!global$
|
|
6630
|
+
if (!global$6.navigator && !global$6.location && !global$6.document) {
|
|
6531
6631
|
return event;
|
|
6532
6632
|
}
|
|
6533
6633
|
// grab as much info as exists and add it to the event
|
|
6534
|
-
var url = ((_a = event.request) === null || _a === void 0 ? void 0 : _a.url) || ((_b = global$
|
|
6535
|
-
var referrer = (global$
|
|
6536
|
-
var userAgent = (global$
|
|
6634
|
+
var url = ((_a = event.request) === null || _a === void 0 ? void 0 : _a.url) || ((_b = global$6.location) === null || _b === void 0 ? void 0 : _b.href);
|
|
6635
|
+
var referrer = (global$6.document || {}).referrer;
|
|
6636
|
+
var userAgent = (global$6.navigator || {}).userAgent;
|
|
6537
6637
|
var headers = __assign(__assign(__assign({}, (_c = event.request) === null || _c === void 0 ? void 0 : _c.headers), (referrer && { Referer: referrer })), (userAgent && { 'User-Agent': userAgent }));
|
|
6538
6638
|
var request = __assign(__assign({}, (url && { url: url })), { headers: headers });
|
|
6539
6639
|
return __assign(__assign({}, event), { request: request });
|