@sentry/browser 6.13.3 → 6.14.3
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 +310 -250
- 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 +311 -252
- 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 +1 -4
- 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.js +1 -1
- package/dist/transports/base.js.map +1 -1
- 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 +1 -4
- 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.js +2 -2
- package/esm/transports/base.js.map +1 -1
- package/esm/transports/xhr.js +1 -1
- package/esm/transports/xhr.js.map +1 -1
- package/package.json +23 -23
package/build/bundle.es6.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @sentry/browser 6.
|
|
1
|
+
/*! @sentry/browser 6.14.3 (3807d99) | https://github.com/getsentry/sentry-javascript */
|
|
2
2
|
var Sentry = (function (exports) {
|
|
3
3
|
/** Console logging verbosity for the SDK. */
|
|
4
4
|
var LogLevel;
|
|
@@ -157,6 +157,49 @@ var Sentry = (function (exports) {
|
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
|
|
162
|
+
* you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
|
|
163
|
+
*/
|
|
164
|
+
/**
|
|
165
|
+
* Checks whether we're in the Node.js or Browser environment
|
|
166
|
+
*
|
|
167
|
+
* @returns Answer to given question
|
|
168
|
+
*/
|
|
169
|
+
function isNodeEnv() {
|
|
170
|
+
return Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Requires a module which is protected against bundler minification.
|
|
174
|
+
*
|
|
175
|
+
* @param request The module path to resolve
|
|
176
|
+
*/
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
178
|
+
function dynamicRequire(mod, request) {
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
180
|
+
return mod.require(request);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
|
|
185
|
+
* you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
|
|
186
|
+
*/
|
|
187
|
+
const fallbackGlobalObject = {};
|
|
188
|
+
/**
|
|
189
|
+
* Safely get global scope object
|
|
190
|
+
*
|
|
191
|
+
* @returns Global scope object
|
|
192
|
+
*/
|
|
193
|
+
function getGlobalObject() {
|
|
194
|
+
return (isNodeEnv()
|
|
195
|
+
? global
|
|
196
|
+
: typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
|
|
197
|
+
? window // eslint-disable-line no-restricted-globals
|
|
198
|
+
: typeof self !== 'undefined'
|
|
199
|
+
? self
|
|
200
|
+
: fallbackGlobalObject);
|
|
201
|
+
}
|
|
202
|
+
|
|
160
203
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
161
204
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
162
205
|
/**
|
|
@@ -392,6 +435,18 @@ var Sentry = (function (exports) {
|
|
|
392
435
|
}
|
|
393
436
|
}
|
|
394
437
|
return out.join('');
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* A safe form of location.href
|
|
441
|
+
*/
|
|
442
|
+
function getLocationHref() {
|
|
443
|
+
const global = getGlobalObject();
|
|
444
|
+
try {
|
|
445
|
+
return global.document.location.href;
|
|
446
|
+
}
|
|
447
|
+
catch (oO) {
|
|
448
|
+
return '';
|
|
449
|
+
}
|
|
395
450
|
}
|
|
396
451
|
|
|
397
452
|
const setPrototypeOf = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties);
|
|
@@ -410,8 +465,7 @@ var Sentry = (function (exports) {
|
|
|
410
465
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
411
466
|
function mixinProperties(obj, proto) {
|
|
412
467
|
for (const prop in proto) {
|
|
413
|
-
|
|
414
|
-
if (!obj.hasOwnProperty(prop)) {
|
|
468
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
415
469
|
// @ts-ignore typescript complains about indexing so we remove
|
|
416
470
|
obj[prop] = proto[prop];
|
|
417
471
|
}
|
|
@@ -515,174 +569,17 @@ var Sentry = (function (exports) {
|
|
|
515
569
|
}
|
|
516
570
|
}
|
|
517
571
|
|
|
572
|
+
// TODO: Implement different loggers for different environments
|
|
573
|
+
const global$1 = getGlobalObject();
|
|
574
|
+
/** Prefix for logging strings */
|
|
575
|
+
const PREFIX = 'Sentry Logger ';
|
|
518
576
|
/**
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
* @returns Answer to given question
|
|
522
|
-
*/
|
|
523
|
-
function isNodeEnv() {
|
|
524
|
-
return Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Requires a module which is protected against bundler minification.
|
|
528
|
-
*
|
|
529
|
-
* @param request The module path to resolve
|
|
530
|
-
*/
|
|
531
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
532
|
-
function dynamicRequire(mod, request) {
|
|
533
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
534
|
-
return mod.require(request);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
/**
|
|
538
|
-
* Truncates given string to the maximum characters count
|
|
539
|
-
*
|
|
540
|
-
* @param str An object that contains serializable values
|
|
541
|
-
* @param max Maximum number of characters in truncated string (0 = unlimited)
|
|
542
|
-
* @returns string Encoded
|
|
543
|
-
*/
|
|
544
|
-
function truncate(str, max = 0) {
|
|
545
|
-
if (typeof str !== 'string' || max === 0) {
|
|
546
|
-
return str;
|
|
547
|
-
}
|
|
548
|
-
return str.length <= max ? str : `${str.substr(0, max)}...`;
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* Join values in array
|
|
552
|
-
* @param input array of values to be joined together
|
|
553
|
-
* @param delimiter string to be placed in-between values
|
|
554
|
-
* @returns Joined values
|
|
555
|
-
*/
|
|
556
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
557
|
-
function safeJoin(input, delimiter) {
|
|
558
|
-
if (!Array.isArray(input)) {
|
|
559
|
-
return '';
|
|
560
|
-
}
|
|
561
|
-
const output = [];
|
|
562
|
-
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
563
|
-
for (let i = 0; i < input.length; i++) {
|
|
564
|
-
const value = input[i];
|
|
565
|
-
try {
|
|
566
|
-
output.push(String(value));
|
|
567
|
-
}
|
|
568
|
-
catch (e) {
|
|
569
|
-
output.push('[value cannot be serialized]');
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
return output.join(delimiter);
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* Checks if the value matches a regex or includes the string
|
|
576
|
-
* @param value The string value to be checked against
|
|
577
|
-
* @param pattern Either a regex or a string that must be contained in value
|
|
578
|
-
*/
|
|
579
|
-
function isMatchingPattern(value, pattern) {
|
|
580
|
-
if (!isString(value)) {
|
|
581
|
-
return false;
|
|
582
|
-
}
|
|
583
|
-
if (isRegExp(pattern)) {
|
|
584
|
-
return pattern.test(value);
|
|
585
|
-
}
|
|
586
|
-
if (typeof pattern === 'string') {
|
|
587
|
-
return value.indexOf(pattern) !== -1;
|
|
588
|
-
}
|
|
589
|
-
return false;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
const fallbackGlobalObject = {};
|
|
593
|
-
/**
|
|
594
|
-
* Safely get global scope object
|
|
595
|
-
*
|
|
596
|
-
* @returns Global scope object
|
|
597
|
-
*/
|
|
598
|
-
function getGlobalObject() {
|
|
599
|
-
return (isNodeEnv()
|
|
600
|
-
? global
|
|
601
|
-
: typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
|
|
602
|
-
? window // eslint-disable-line no-restricted-globals
|
|
603
|
-
: typeof self !== 'undefined'
|
|
604
|
-
? self
|
|
605
|
-
: fallbackGlobalObject);
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* UUID4 generator
|
|
577
|
+
* Temporarily unwrap `console.log` and friends in order to perform the given callback using the original methods.
|
|
578
|
+
* Restores wrapping after the callback completes.
|
|
609
579
|
*
|
|
610
|
-
* @
|
|
580
|
+
* @param callback The function to run against the original `console` messages
|
|
581
|
+
* @returns The results of the callback
|
|
611
582
|
*/
|
|
612
|
-
function uuid4() {
|
|
613
|
-
const global = getGlobalObject();
|
|
614
|
-
const crypto = global.crypto || global.msCrypto;
|
|
615
|
-
if (!(crypto === void 0) && crypto.getRandomValues) {
|
|
616
|
-
// Use window.crypto API if available
|
|
617
|
-
const arr = new Uint16Array(8);
|
|
618
|
-
crypto.getRandomValues(arr);
|
|
619
|
-
// set 4 in byte 7
|
|
620
|
-
// eslint-disable-next-line no-bitwise
|
|
621
|
-
arr[3] = (arr[3] & 0xfff) | 0x4000;
|
|
622
|
-
// set 2 most significant bits of byte 9 to '10'
|
|
623
|
-
// eslint-disable-next-line no-bitwise
|
|
624
|
-
arr[4] = (arr[4] & 0x3fff) | 0x8000;
|
|
625
|
-
const pad = (num) => {
|
|
626
|
-
let v = num.toString(16);
|
|
627
|
-
while (v.length < 4) {
|
|
628
|
-
v = `0${v}`;
|
|
629
|
-
}
|
|
630
|
-
return v;
|
|
631
|
-
};
|
|
632
|
-
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]));
|
|
633
|
-
}
|
|
634
|
-
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
|
|
635
|
-
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
636
|
-
// eslint-disable-next-line no-bitwise
|
|
637
|
-
const r = (Math.random() * 16) | 0;
|
|
638
|
-
// eslint-disable-next-line no-bitwise
|
|
639
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
640
|
-
return v.toString(16);
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
/**
|
|
644
|
-
* Parses string form of URL into an object
|
|
645
|
-
* // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B
|
|
646
|
-
* // intentionally using regex and not <a/> href parsing trick because React Native and other
|
|
647
|
-
* // environments where DOM might not be available
|
|
648
|
-
* @returns parsed URL object
|
|
649
|
-
*/
|
|
650
|
-
function parseUrl(url) {
|
|
651
|
-
if (!url) {
|
|
652
|
-
return {};
|
|
653
|
-
}
|
|
654
|
-
const match = url.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);
|
|
655
|
-
if (!match) {
|
|
656
|
-
return {};
|
|
657
|
-
}
|
|
658
|
-
// coerce to undefined values to empty string so we don't get 'undefined'
|
|
659
|
-
const query = match[6] || '';
|
|
660
|
-
const fragment = match[8] || '';
|
|
661
|
-
return {
|
|
662
|
-
host: match[4],
|
|
663
|
-
path: match[5],
|
|
664
|
-
protocol: match[2],
|
|
665
|
-
relative: match[5] + query + fragment,
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
/**
|
|
669
|
-
* Extracts either message or type+value from an event that can be used for user-facing logs
|
|
670
|
-
* @returns event's description
|
|
671
|
-
*/
|
|
672
|
-
function getEventDescription(event) {
|
|
673
|
-
if (event.message) {
|
|
674
|
-
return event.message;
|
|
675
|
-
}
|
|
676
|
-
if (event.exception && event.exception.values && event.exception.values[0]) {
|
|
677
|
-
const exception = event.exception.values[0];
|
|
678
|
-
if (exception.type && exception.value) {
|
|
679
|
-
return `${exception.type}: ${exception.value}`;
|
|
680
|
-
}
|
|
681
|
-
return exception.type || exception.value || event.event_id || '<unknown>';
|
|
682
|
-
}
|
|
683
|
-
return event.event_id || '<unknown>';
|
|
684
|
-
}
|
|
685
|
-
/** JSDoc */
|
|
686
583
|
function consoleSandbox(callback) {
|
|
687
584
|
const global = getGlobalObject();
|
|
688
585
|
const levels = ['debug', 'info', 'warn', 'error', 'log', 'assert'];
|
|
@@ -708,80 +605,6 @@ var Sentry = (function (exports) {
|
|
|
708
605
|
});
|
|
709
606
|
return result;
|
|
710
607
|
}
|
|
711
|
-
/**
|
|
712
|
-
* Adds exception values, type and value to an synthetic Exception.
|
|
713
|
-
* @param event The event to modify.
|
|
714
|
-
* @param value Value of the exception.
|
|
715
|
-
* @param type Type of the exception.
|
|
716
|
-
* @hidden
|
|
717
|
-
*/
|
|
718
|
-
function addExceptionTypeValue(event, value, type) {
|
|
719
|
-
event.exception = event.exception || {};
|
|
720
|
-
event.exception.values = event.exception.values || [];
|
|
721
|
-
event.exception.values[0] = event.exception.values[0] || {};
|
|
722
|
-
event.exception.values[0].value = event.exception.values[0].value || value || '';
|
|
723
|
-
event.exception.values[0].type = event.exception.values[0].type || type || 'Error';
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* Adds exception mechanism to a given event.
|
|
727
|
-
* @param event The event to modify.
|
|
728
|
-
* @param mechanism Mechanism of the mechanism.
|
|
729
|
-
* @hidden
|
|
730
|
-
*/
|
|
731
|
-
function addExceptionMechanism(event, mechanism = {}) {
|
|
732
|
-
// TODO: Use real type with `keyof Mechanism` thingy and maybe make it better?
|
|
733
|
-
try {
|
|
734
|
-
// @ts-ignore Type 'Mechanism | {}' is not assignable to type 'Mechanism | undefined'
|
|
735
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
736
|
-
event.exception.values[0].mechanism = event.exception.values[0].mechanism || {};
|
|
737
|
-
Object.keys(mechanism).forEach(key => {
|
|
738
|
-
// @ts-ignore Mechanism has no index signature
|
|
739
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
740
|
-
event.exception.values[0].mechanism[key] = mechanism[key];
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
catch (_oO) {
|
|
744
|
-
// no-empty
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
/**
|
|
748
|
-
* A safe form of location.href
|
|
749
|
-
*/
|
|
750
|
-
function getLocationHref() {
|
|
751
|
-
const global = getGlobalObject();
|
|
752
|
-
try {
|
|
753
|
-
return global.document.location.href;
|
|
754
|
-
}
|
|
755
|
-
catch (oO) {
|
|
756
|
-
return '';
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
const defaultRetryAfter = 60 * 1000; // 60 seconds
|
|
760
|
-
/**
|
|
761
|
-
* Extracts Retry-After value from the request header or returns default value
|
|
762
|
-
* @param now current unix timestamp
|
|
763
|
-
* @param header string representation of 'Retry-After' header
|
|
764
|
-
*/
|
|
765
|
-
function parseRetryAfterHeader(now, header) {
|
|
766
|
-
if (!header) {
|
|
767
|
-
return defaultRetryAfter;
|
|
768
|
-
}
|
|
769
|
-
const headerDelay = parseInt(`${header}`, 10);
|
|
770
|
-
if (!isNaN(headerDelay)) {
|
|
771
|
-
return headerDelay * 1000;
|
|
772
|
-
}
|
|
773
|
-
const headerDate = Date.parse(`${header}`);
|
|
774
|
-
if (!isNaN(headerDate)) {
|
|
775
|
-
return headerDate - now;
|
|
776
|
-
}
|
|
777
|
-
return defaultRetryAfter;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
781
|
-
// TODO: Implement different loggers for different environments
|
|
782
|
-
const global$1 = getGlobalObject();
|
|
783
|
-
/** Prefix for logging strings */
|
|
784
|
-
const PREFIX = 'Sentry Logger ';
|
|
785
608
|
/** JSDoc */
|
|
786
609
|
class Logger {
|
|
787
610
|
/** JSDoc */
|
|
@@ -898,6 +721,61 @@ var Sentry = (function (exports) {
|
|
|
898
721
|
}
|
|
899
722
|
}
|
|
900
723
|
|
|
724
|
+
/**
|
|
725
|
+
* Truncates given string to the maximum characters count
|
|
726
|
+
*
|
|
727
|
+
* @param str An object that contains serializable values
|
|
728
|
+
* @param max Maximum number of characters in truncated string (0 = unlimited)
|
|
729
|
+
* @returns string Encoded
|
|
730
|
+
*/
|
|
731
|
+
function truncate(str, max = 0) {
|
|
732
|
+
if (typeof str !== 'string' || max === 0) {
|
|
733
|
+
return str;
|
|
734
|
+
}
|
|
735
|
+
return str.length <= max ? str : `${str.substr(0, max)}...`;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Join values in array
|
|
739
|
+
* @param input array of values to be joined together
|
|
740
|
+
* @param delimiter string to be placed in-between values
|
|
741
|
+
* @returns Joined values
|
|
742
|
+
*/
|
|
743
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
744
|
+
function safeJoin(input, delimiter) {
|
|
745
|
+
if (!Array.isArray(input)) {
|
|
746
|
+
return '';
|
|
747
|
+
}
|
|
748
|
+
const output = [];
|
|
749
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
750
|
+
for (let i = 0; i < input.length; i++) {
|
|
751
|
+
const value = input[i];
|
|
752
|
+
try {
|
|
753
|
+
output.push(String(value));
|
|
754
|
+
}
|
|
755
|
+
catch (e) {
|
|
756
|
+
output.push('[value cannot be serialized]');
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
return output.join(delimiter);
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Checks if the value matches a regex or includes the string
|
|
763
|
+
* @param value The string value to be checked against
|
|
764
|
+
* @param pattern Either a regex or a string that must be contained in value
|
|
765
|
+
*/
|
|
766
|
+
function isMatchingPattern(value, pattern) {
|
|
767
|
+
if (!isString(value)) {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
if (isRegExp(pattern)) {
|
|
771
|
+
return pattern.test(value);
|
|
772
|
+
}
|
|
773
|
+
if (typeof pattern === 'string') {
|
|
774
|
+
return value.indexOf(pattern) !== -1;
|
|
775
|
+
}
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
|
|
901
779
|
/**
|
|
902
780
|
* Replace a method in an object with a wrapped version of itself.
|
|
903
781
|
*
|
|
@@ -1815,6 +1693,179 @@ var Sentry = (function (exports) {
|
|
|
1815
1693
|
};
|
|
1816
1694
|
}
|
|
1817
1695
|
|
|
1696
|
+
/**
|
|
1697
|
+
* UUID4 generator
|
|
1698
|
+
*
|
|
1699
|
+
* @returns string Generated UUID4.
|
|
1700
|
+
*/
|
|
1701
|
+
function uuid4() {
|
|
1702
|
+
const global = getGlobalObject();
|
|
1703
|
+
const crypto = global.crypto || global.msCrypto;
|
|
1704
|
+
if (!(crypto === void 0) && crypto.getRandomValues) {
|
|
1705
|
+
// Use window.crypto API if available
|
|
1706
|
+
const arr = new Uint16Array(8);
|
|
1707
|
+
crypto.getRandomValues(arr);
|
|
1708
|
+
// set 4 in byte 7
|
|
1709
|
+
// eslint-disable-next-line no-bitwise
|
|
1710
|
+
arr[3] = (arr[3] & 0xfff) | 0x4000;
|
|
1711
|
+
// set 2 most significant bits of byte 9 to '10'
|
|
1712
|
+
// eslint-disable-next-line no-bitwise
|
|
1713
|
+
arr[4] = (arr[4] & 0x3fff) | 0x8000;
|
|
1714
|
+
const pad = (num) => {
|
|
1715
|
+
let v = num.toString(16);
|
|
1716
|
+
while (v.length < 4) {
|
|
1717
|
+
v = `0${v}`;
|
|
1718
|
+
}
|
|
1719
|
+
return v;
|
|
1720
|
+
};
|
|
1721
|
+
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]));
|
|
1722
|
+
}
|
|
1723
|
+
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
|
|
1724
|
+
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
1725
|
+
// eslint-disable-next-line no-bitwise
|
|
1726
|
+
const r = (Math.random() * 16) | 0;
|
|
1727
|
+
// eslint-disable-next-line no-bitwise
|
|
1728
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
1729
|
+
return v.toString(16);
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Parses string form of URL into an object
|
|
1734
|
+
* // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B
|
|
1735
|
+
* // intentionally using regex and not <a/> href parsing trick because React Native and other
|
|
1736
|
+
* // environments where DOM might not be available
|
|
1737
|
+
* @returns parsed URL object
|
|
1738
|
+
*/
|
|
1739
|
+
function parseUrl(url) {
|
|
1740
|
+
if (!url) {
|
|
1741
|
+
return {};
|
|
1742
|
+
}
|
|
1743
|
+
const match = url.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);
|
|
1744
|
+
if (!match) {
|
|
1745
|
+
return {};
|
|
1746
|
+
}
|
|
1747
|
+
// coerce to undefined values to empty string so we don't get 'undefined'
|
|
1748
|
+
const query = match[6] || '';
|
|
1749
|
+
const fragment = match[8] || '';
|
|
1750
|
+
return {
|
|
1751
|
+
host: match[4],
|
|
1752
|
+
path: match[5],
|
|
1753
|
+
protocol: match[2],
|
|
1754
|
+
relative: match[5] + query + fragment,
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* Extracts either message or type+value from an event that can be used for user-facing logs
|
|
1759
|
+
* @returns event's description
|
|
1760
|
+
*/
|
|
1761
|
+
function getEventDescription(event) {
|
|
1762
|
+
if (event.message) {
|
|
1763
|
+
return event.message;
|
|
1764
|
+
}
|
|
1765
|
+
if (event.exception && event.exception.values && event.exception.values[0]) {
|
|
1766
|
+
const exception = event.exception.values[0];
|
|
1767
|
+
if (exception.type && exception.value) {
|
|
1768
|
+
return `${exception.type}: ${exception.value}`;
|
|
1769
|
+
}
|
|
1770
|
+
return exception.type || exception.value || event.event_id || '<unknown>';
|
|
1771
|
+
}
|
|
1772
|
+
return event.event_id || '<unknown>';
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Adds exception values, type and value to an synthetic Exception.
|
|
1776
|
+
* @param event The event to modify.
|
|
1777
|
+
* @param value Value of the exception.
|
|
1778
|
+
* @param type Type of the exception.
|
|
1779
|
+
* @hidden
|
|
1780
|
+
*/
|
|
1781
|
+
function addExceptionTypeValue(event, value, type) {
|
|
1782
|
+
event.exception = event.exception || {};
|
|
1783
|
+
event.exception.values = event.exception.values || [];
|
|
1784
|
+
event.exception.values[0] = event.exception.values[0] || {};
|
|
1785
|
+
event.exception.values[0].value = event.exception.values[0].value || value || '';
|
|
1786
|
+
event.exception.values[0].type = event.exception.values[0].type || type || 'Error';
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* Adds exception mechanism data to a given event. Uses defaults if the second parameter is not passed.
|
|
1790
|
+
*
|
|
1791
|
+
* @param event The event to modify.
|
|
1792
|
+
* @param newMechanism Mechanism data to add to the event.
|
|
1793
|
+
* @hidden
|
|
1794
|
+
*/
|
|
1795
|
+
function addExceptionMechanism(event, newMechanism) {
|
|
1796
|
+
var _a;
|
|
1797
|
+
if (!event.exception || !event.exception.values) {
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
const exceptionValue0 = event.exception.values[0];
|
|
1801
|
+
const defaultMechanism = { type: 'generic', handled: true };
|
|
1802
|
+
const currentMechanism = exceptionValue0.mechanism;
|
|
1803
|
+
exceptionValue0.mechanism = Object.assign(Object.assign(Object.assign({}, defaultMechanism), currentMechanism), newMechanism);
|
|
1804
|
+
if (newMechanism && 'data' in newMechanism) {
|
|
1805
|
+
const mergedData = Object.assign(Object.assign({}, (_a = currentMechanism) === null || _a === void 0 ? void 0 : _a.data), newMechanism.data);
|
|
1806
|
+
exceptionValue0.mechanism.data = mergedData;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
const defaultRetryAfter = 60 * 1000; // 60 seconds
|
|
1810
|
+
/**
|
|
1811
|
+
* Extracts Retry-After value from the request header or returns default value
|
|
1812
|
+
* @param now current unix timestamp
|
|
1813
|
+
* @param header string representation of 'Retry-After' header
|
|
1814
|
+
*/
|
|
1815
|
+
function parseRetryAfterHeader(now, header) {
|
|
1816
|
+
if (!header) {
|
|
1817
|
+
return defaultRetryAfter;
|
|
1818
|
+
}
|
|
1819
|
+
const headerDelay = parseInt(`${header}`, 10);
|
|
1820
|
+
if (!isNaN(headerDelay)) {
|
|
1821
|
+
return headerDelay * 1000;
|
|
1822
|
+
}
|
|
1823
|
+
const headerDate = Date.parse(`${header}`);
|
|
1824
|
+
if (!isNaN(headerDate)) {
|
|
1825
|
+
return headerDate - now;
|
|
1826
|
+
}
|
|
1827
|
+
return defaultRetryAfter;
|
|
1828
|
+
}
|
|
1829
|
+
/**
|
|
1830
|
+
* Checks whether or not we've already captured the given exception (note: not an identical exception - the very object
|
|
1831
|
+
* in question), and marks it captured if not.
|
|
1832
|
+
*
|
|
1833
|
+
* This is useful because it's possible for an error to get captured by more than one mechanism. After we intercept and
|
|
1834
|
+
* record an error, we rethrow it (assuming we've intercepted it before it's reached the top-level global handlers), so
|
|
1835
|
+
* that we don't interfere with whatever effects the error might have had were the SDK not there. At that point, because
|
|
1836
|
+
* the error has been rethrown, it's possible for it to bubble up to some other code we've instrumented. If it's not
|
|
1837
|
+
* caught after that, it will bubble all the way up to the global handlers (which of course we also instrument). This
|
|
1838
|
+
* function helps us ensure that even if we encounter the same error more than once, we only record it the first time we
|
|
1839
|
+
* see it.
|
|
1840
|
+
*
|
|
1841
|
+
* Note: It will ignore primitives (always return `false` and not mark them as seen), as properties can't be set on
|
|
1842
|
+
* them. {@link: Object.objectify} can be used on exceptions to convert any that are primitives into their equivalent
|
|
1843
|
+
* object wrapper forms so that this check will always work. However, because we need to flag the exact object which
|
|
1844
|
+
* will get rethrown, and because that rethrowing happens outside of the event processing pipeline, the objectification
|
|
1845
|
+
* must be done before the exception captured.
|
|
1846
|
+
*
|
|
1847
|
+
* @param A thrown exception to check or flag as having been seen
|
|
1848
|
+
* @returns `true` if the exception has already been captured, `false` if not (with the side effect of marking it seen)
|
|
1849
|
+
*/
|
|
1850
|
+
function checkOrSetAlreadyCaught(exception) {
|
|
1851
|
+
var _a;
|
|
1852
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1853
|
+
if ((_a = exception) === null || _a === void 0 ? void 0 : _a.__sentry_captured__) {
|
|
1854
|
+
return true;
|
|
1855
|
+
}
|
|
1856
|
+
try {
|
|
1857
|
+
// set it this way rather than by assignment so that it's not ennumerable and therefore isn't recorded by the
|
|
1858
|
+
// `ExtraErrorData` integration
|
|
1859
|
+
Object.defineProperty(exception, '__sentry_captured__', {
|
|
1860
|
+
value: true,
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
catch (err) {
|
|
1864
|
+
// `exception` is a primitive, so we can't mark it seen
|
|
1865
|
+
}
|
|
1866
|
+
return false;
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1818
1869
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1819
1870
|
/** SyncPromise internal states */
|
|
1820
1871
|
var States;
|
|
@@ -3620,6 +3671,7 @@ var Sentry = (function (exports) {
|
|
|
3620
3671
|
}
|
|
3621
3672
|
|
|
3622
3673
|
/* eslint-disable max-lines */
|
|
3674
|
+
const ALREADY_SEEN_ERROR = "Not capturing exception because it's already been captured.";
|
|
3623
3675
|
/**
|
|
3624
3676
|
* Base implementation for all JavaScript SDK clients.
|
|
3625
3677
|
*
|
|
@@ -3675,6 +3727,11 @@ var Sentry = (function (exports) {
|
|
|
3675
3727
|
*/
|
|
3676
3728
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
3677
3729
|
captureException(exception, hint, scope) {
|
|
3730
|
+
// ensure we haven't captured this very object before
|
|
3731
|
+
if (checkOrSetAlreadyCaught(exception)) {
|
|
3732
|
+
logger.log(ALREADY_SEEN_ERROR);
|
|
3733
|
+
return;
|
|
3734
|
+
}
|
|
3678
3735
|
let eventId = hint && hint.event_id;
|
|
3679
3736
|
this._process(this._getBackend()
|
|
3680
3737
|
.eventFromException(exception, hint)
|
|
@@ -3703,6 +3760,12 @@ var Sentry = (function (exports) {
|
|
|
3703
3760
|
* @inheritDoc
|
|
3704
3761
|
*/
|
|
3705
3762
|
captureEvent(event, hint, scope) {
|
|
3763
|
+
var _a;
|
|
3764
|
+
// ensure we haven't captured this very object before
|
|
3765
|
+
if (((_a = hint) === null || _a === void 0 ? void 0 : _a.originalException) && checkOrSetAlreadyCaught(hint.originalException)) {
|
|
3766
|
+
logger.log(ALREADY_SEEN_ERROR);
|
|
3767
|
+
return;
|
|
3768
|
+
}
|
|
3706
3769
|
let eventId = hint && hint.event_id;
|
|
3707
3770
|
this._process(this._captureEvent(event, hint, scope).then(result => {
|
|
3708
3771
|
eventId = result;
|
|
@@ -4298,7 +4361,7 @@ var Sentry = (function (exports) {
|
|
|
4298
4361
|
hub.bindClient(client);
|
|
4299
4362
|
}
|
|
4300
4363
|
|
|
4301
|
-
const SDK_VERSION = '6.
|
|
4364
|
+
const SDK_VERSION = '6.14.3';
|
|
4302
4365
|
|
|
4303
4366
|
let originalFunctionToString;
|
|
4304
4367
|
/** Patch toString calls to return proper name for wrapped functions */
|
|
@@ -4869,10 +4932,7 @@ var Sentry = (function (exports) {
|
|
|
4869
4932
|
const event = eventFromUnknownInput(exception, syntheticException, {
|
|
4870
4933
|
attachStacktrace: options.attachStacktrace,
|
|
4871
4934
|
});
|
|
4872
|
-
addExceptionMechanism(event,
|
|
4873
|
-
handled: true,
|
|
4874
|
-
type: 'generic',
|
|
4875
|
-
});
|
|
4935
|
+
addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
|
|
4876
4936
|
event.level = exports.Severity.Error;
|
|
4877
4937
|
if (hint && hint.event_id) {
|
|
4878
4938
|
event.event_id = hint.event_id;
|
|
@@ -5139,7 +5199,7 @@ var Sentry = (function (exports) {
|
|
|
5139
5199
|
logger.log(`Flushing outcomes:\n${JSON.stringify(outcomes, null, 2)}`);
|
|
5140
5200
|
const url = this._api.getEnvelopeEndpointWithUrlEncodedAuth();
|
|
5141
5201
|
// Envelope header is required to be at least an empty object
|
|
5142
|
-
const envelopeHeader = JSON.stringify({});
|
|
5202
|
+
const envelopeHeader = JSON.stringify(Object.assign({}, (this.options.tunnel && { dsn: this._api.getDsn().toString() })));
|
|
5143
5203
|
const itemHeaders = JSON.stringify({
|
|
5144
5204
|
type: 'client_report',
|
|
5145
5205
|
});
|
|
@@ -5349,7 +5409,7 @@ var Sentry = (function (exports) {
|
|
|
5349
5409
|
};
|
|
5350
5410
|
request.open('POST', sentryRequest.url);
|
|
5351
5411
|
for (const header in this.options.headers) {
|
|
5352
|
-
if (this.options.headers
|
|
5412
|
+
if (Object.prototype.hasOwnProperty.call(this.options.headers, header)) {
|
|
5353
5413
|
request.setRequestHeader(header, this.options.headers[header]);
|
|
5354
5414
|
}
|
|
5355
5415
|
}
|
|
@@ -5869,7 +5929,7 @@ var Sentry = (function (exports) {
|
|
|
5869
5929
|
const global = getGlobalObject();
|
|
5870
5930
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
5871
5931
|
const proto = global[target] && global[target].prototype;
|
|
5872
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
5932
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
|
|
5873
5933
|
if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
|
|
5874
5934
|
return;
|
|
5875
5935
|
}
|