@sentry/browser 6.19.0 → 6.19.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/bundles/bundle.debug.min.js +2 -2
- package/bundles/bundle.debug.min.js.map +1 -1
- package/bundles/bundle.es6.debug.min.js +2 -2
- package/bundles/bundle.es6.debug.min.js.map +1 -1
- package/bundles/bundle.es6.js +736 -558
- package/bundles/bundle.es6.js.map +1 -1
- package/bundles/bundle.es6.min.js +2 -2
- package/bundles/bundle.es6.min.js.map +1 -1
- package/bundles/bundle.js +776 -591
- package/bundles/bundle.js.map +1 -1
- package/bundles/bundle.min.js +2 -2
- package/bundles/bundle.min.js.map +1 -1
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +8 -0
- package/dist/backend.js.map +1 -1
- package/dist/eventbuilder.js.map +1 -1
- package/dist/transports/index.d.ts +2 -0
- package/dist/transports/index.d.ts.map +1 -1
- package/dist/transports/index.js +4 -0
- package/dist/transports/index.js.map +1 -1
- package/dist/transports/new-fetch.d.ts +10 -0
- package/dist/transports/new-fetch.d.ts.map +1 -0
- package/dist/transports/new-fetch.js +27 -0
- package/dist/transports/new-fetch.js.map +1 -0
- package/dist/transports/new-xhr.d.ts +11 -0
- package/dist/transports/new-xhr.d.ts.map +1 -0
- package/dist/transports/new-xhr.js +46 -0
- package/dist/transports/new-xhr.js.map +1 -0
- package/esm/backend.d.ts.map +1 -1
- package/esm/backend.js +10 -2
- package/esm/backend.js.map +1 -1
- package/esm/eventbuilder.js.map +1 -1
- package/esm/transports/index.d.ts +2 -0
- package/esm/transports/index.d.ts.map +1 -1
- package/esm/transports/index.js +2 -0
- package/esm/transports/index.js.map +1 -1
- package/esm/transports/new-fetch.d.ts +10 -0
- package/esm/transports/new-fetch.d.ts.map +1 -0
- package/esm/transports/new-fetch.js +25 -0
- package/esm/transports/new-fetch.js.map +1 -0
- package/esm/transports/new-xhr.d.ts +11 -0
- package/esm/transports/new-xhr.d.ts.map +1 -0
- package/esm/transports/new-xhr.js +44 -0
- package/esm/transports/new-xhr.js.map +1 -0
- package/package.json +6 -6
- package/types/backend.d.ts.map +1 -1
- package/types/transports/index.d.ts +2 -0
- package/types/transports/index.d.ts.map +1 -1
- package/types/transports/new-fetch.d.ts +10 -0
- package/types/transports/new-fetch.d.ts.map +1 -0
- package/types/transports/new-xhr.d.ts +11 -0
- package/types/transports/new-xhr.d.ts.map +1 -0
package/bundles/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @sentry/browser 6.19.
|
|
1
|
+
/*! @sentry/browser 6.19.3 (fe6f7b3) | https://github.com/getsentry/sentry-javascript */
|
|
2
2
|
var Sentry = (function (exports) {
|
|
3
3
|
|
|
4
4
|
/*! *****************************************************************************
|
|
@@ -279,6 +279,16 @@ var Sentry = (function (exports) {
|
|
|
279
279
|
function isSyntheticEvent(wat) {
|
|
280
280
|
return isPlainObject(wat) && 'nativeEvent' in wat && 'preventDefault' in wat && 'stopPropagation' in wat;
|
|
281
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Checks whether given value is NaN
|
|
284
|
+
* {@link isNaN}.
|
|
285
|
+
*
|
|
286
|
+
* @param wat A value to be checked.
|
|
287
|
+
* @returns A boolean representing the result.
|
|
288
|
+
*/
|
|
289
|
+
function isNaN$1(wat) {
|
|
290
|
+
return typeof wat === 'number' && wat !== wat;
|
|
291
|
+
}
|
|
282
292
|
/**
|
|
283
293
|
* Checks whether given value's type is an instance of provided constructor.
|
|
284
294
|
* {@link isInstanceOf}.
|
|
@@ -624,140 +634,6 @@ var Sentry = (function (exports) {
|
|
|
624
634
|
global$6.__SENTRY__ = sentryGlobal;
|
|
625
635
|
}
|
|
626
636
|
|
|
627
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
628
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
629
|
-
/**
|
|
630
|
-
* Helper to decycle json objects
|
|
631
|
-
*/
|
|
632
|
-
function memoBuilder() {
|
|
633
|
-
var hasWeakSet = typeof WeakSet === 'function';
|
|
634
|
-
var inner = hasWeakSet ? new WeakSet() : [];
|
|
635
|
-
function memoize(obj) {
|
|
636
|
-
if (hasWeakSet) {
|
|
637
|
-
if (inner.has(obj)) {
|
|
638
|
-
return true;
|
|
639
|
-
}
|
|
640
|
-
inner.add(obj);
|
|
641
|
-
return false;
|
|
642
|
-
}
|
|
643
|
-
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
644
|
-
for (var i = 0; i < inner.length; i++) {
|
|
645
|
-
var value = inner[i];
|
|
646
|
-
if (value === obj) {
|
|
647
|
-
return true;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
inner.push(obj);
|
|
651
|
-
return false;
|
|
652
|
-
}
|
|
653
|
-
function unmemoize(obj) {
|
|
654
|
-
if (hasWeakSet) {
|
|
655
|
-
inner.delete(obj);
|
|
656
|
-
}
|
|
657
|
-
else {
|
|
658
|
-
for (var i = 0; i < inner.length; i++) {
|
|
659
|
-
if (inner[i] === obj) {
|
|
660
|
-
inner.splice(i, 1);
|
|
661
|
-
break;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
return [memoize, unmemoize];
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
var STACKTRACE_LIMIT = 50;
|
|
670
|
-
/**
|
|
671
|
-
* Creates a stack parser with the supplied line parsers
|
|
672
|
-
*
|
|
673
|
-
* StackFrames are returned in the correct order for Sentry Exception
|
|
674
|
-
* frames and with Sentry SDK internal frames removed from the top and bottom
|
|
675
|
-
*
|
|
676
|
-
*/
|
|
677
|
-
function createStackParser() {
|
|
678
|
-
var parsers = [];
|
|
679
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
680
|
-
parsers[_i] = arguments[_i];
|
|
681
|
-
}
|
|
682
|
-
var sortedParsers = parsers.sort(function (a, b) { return a[0] - b[0]; }).map(function (p) { return p[1]; });
|
|
683
|
-
return function (stack, skipFirst) {
|
|
684
|
-
var e_1, _a, e_2, _b;
|
|
685
|
-
if (skipFirst === void 0) { skipFirst = 0; }
|
|
686
|
-
var frames = [];
|
|
687
|
-
try {
|
|
688
|
-
for (var _c = __values(stack.split('\n').slice(skipFirst)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
689
|
-
var line = _d.value;
|
|
690
|
-
try {
|
|
691
|
-
for (var sortedParsers_1 = (e_2 = void 0, __values(sortedParsers)), sortedParsers_1_1 = sortedParsers_1.next(); !sortedParsers_1_1.done; sortedParsers_1_1 = sortedParsers_1.next()) {
|
|
692
|
-
var parser = sortedParsers_1_1.value;
|
|
693
|
-
var frame = parser(line);
|
|
694
|
-
if (frame) {
|
|
695
|
-
frames.push(frame);
|
|
696
|
-
break;
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
701
|
-
finally {
|
|
702
|
-
try {
|
|
703
|
-
if (sortedParsers_1_1 && !sortedParsers_1_1.done && (_b = sortedParsers_1.return)) _b.call(sortedParsers_1);
|
|
704
|
-
}
|
|
705
|
-
finally { if (e_2) throw e_2.error; }
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
710
|
-
finally {
|
|
711
|
-
try {
|
|
712
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
713
|
-
}
|
|
714
|
-
finally { if (e_1) throw e_1.error; }
|
|
715
|
-
}
|
|
716
|
-
return stripSentryFramesAndReverse(frames);
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
/**
|
|
720
|
-
* @hidden
|
|
721
|
-
*/
|
|
722
|
-
function stripSentryFramesAndReverse(stack) {
|
|
723
|
-
if (!stack.length) {
|
|
724
|
-
return [];
|
|
725
|
-
}
|
|
726
|
-
var localStack = stack;
|
|
727
|
-
var firstFrameFunction = localStack[0].function || '';
|
|
728
|
-
var lastFrameFunction = localStack[localStack.length - 1].function || '';
|
|
729
|
-
// If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
|
|
730
|
-
if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
|
|
731
|
-
localStack = localStack.slice(1);
|
|
732
|
-
}
|
|
733
|
-
// If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
|
|
734
|
-
if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
|
|
735
|
-
localStack = localStack.slice(0, -1);
|
|
736
|
-
}
|
|
737
|
-
// The frame where the crash happened, should be the last entry in the array
|
|
738
|
-
return localStack
|
|
739
|
-
.slice(0, STACKTRACE_LIMIT)
|
|
740
|
-
.map(function (frame) { return (__assign(__assign({}, frame), { filename: frame.filename || localStack[0].filename, function: frame.function || '?' })); })
|
|
741
|
-
.reverse();
|
|
742
|
-
}
|
|
743
|
-
var defaultFunctionName = '<anonymous>';
|
|
744
|
-
/**
|
|
745
|
-
* Safely extract function name from itself
|
|
746
|
-
*/
|
|
747
|
-
function getFunctionName(fn) {
|
|
748
|
-
try {
|
|
749
|
-
if (!fn || typeof fn !== 'function') {
|
|
750
|
-
return defaultFunctionName;
|
|
751
|
-
}
|
|
752
|
-
return fn.name || defaultFunctionName;
|
|
753
|
-
}
|
|
754
|
-
catch (e) {
|
|
755
|
-
// Just accessing custom props in some Selenium environments
|
|
756
|
-
// can cause a "Permission denied" exception (see raven-js#495).
|
|
757
|
-
return defaultFunctionName;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
|
|
761
637
|
/**
|
|
762
638
|
* Truncates given string to the maximum characters count
|
|
763
639
|
*
|
|
@@ -898,242 +774,38 @@ var Sentry = (function (exports) {
|
|
|
898
774
|
*
|
|
899
775
|
* @param value Initial source that we have to transform in order for it to be usable by the serializer
|
|
900
776
|
*/
|
|
901
|
-
function
|
|
777
|
+
function convertToPlainObject(value) {
|
|
778
|
+
var newObj = value;
|
|
902
779
|
if (isError(value)) {
|
|
903
|
-
|
|
904
|
-
var err = {
|
|
905
|
-
message: error.message,
|
|
906
|
-
name: error.name,
|
|
907
|
-
stack: error.stack,
|
|
908
|
-
};
|
|
909
|
-
for (var i in error) {
|
|
910
|
-
if (Object.prototype.hasOwnProperty.call(error, i)) {
|
|
911
|
-
err[i] = error[i];
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
return err;
|
|
780
|
+
newObj = __assign({ message: value.message, name: value.name, stack: value.stack }, getOwnProperties(value));
|
|
915
781
|
}
|
|
916
|
-
if (isEvent(value)) {
|
|
782
|
+
else if (isEvent(value)) {
|
|
917
783
|
var event_1 = value;
|
|
918
|
-
|
|
919
|
-
// Accessing event attributes can throw (see https://github.com/getsentry/sentry-javascript/issues/768 and
|
|
920
|
-
// https://github.com/getsentry/sentry-javascript/issues/838), but accessing `type` hasn't been wrapped in a
|
|
921
|
-
// try-catch in at least two years and no one's complained, so that's likely not an issue anymore
|
|
922
|
-
source.type = event_1.type;
|
|
923
|
-
try {
|
|
924
|
-
source.target = isElement(event_1.target)
|
|
925
|
-
? htmlTreeAsString(event_1.target)
|
|
926
|
-
: Object.prototype.toString.call(event_1.target);
|
|
927
|
-
}
|
|
928
|
-
catch (_oO) {
|
|
929
|
-
source.target = '<unknown>';
|
|
930
|
-
}
|
|
931
|
-
try {
|
|
932
|
-
source.currentTarget = isElement(event_1.currentTarget)
|
|
933
|
-
? htmlTreeAsString(event_1.currentTarget)
|
|
934
|
-
: Object.prototype.toString.call(event_1.currentTarget);
|
|
935
|
-
}
|
|
936
|
-
catch (_oO) {
|
|
937
|
-
source.currentTarget = '<unknown>';
|
|
938
|
-
}
|
|
784
|
+
newObj = __assign({ type: event_1.type, target: serializeEventTarget(event_1.target), currentTarget: serializeEventTarget(event_1.currentTarget) }, getOwnProperties(event_1));
|
|
939
785
|
if (typeof CustomEvent !== 'undefined' && isInstanceOf(value, CustomEvent)) {
|
|
940
|
-
|
|
941
|
-
}
|
|
942
|
-
for (var attr in event_1) {
|
|
943
|
-
if (Object.prototype.hasOwnProperty.call(event_1, attr)) {
|
|
944
|
-
source[attr] = event_1[attr];
|
|
945
|
-
}
|
|
786
|
+
newObj.detail = event_1.detail;
|
|
946
787
|
}
|
|
947
|
-
return source;
|
|
948
788
|
}
|
|
949
|
-
return
|
|
950
|
-
}
|
|
951
|
-
/** Calculates bytes size of input string */
|
|
952
|
-
function utf8Length(value) {
|
|
953
|
-
// eslint-disable-next-line no-bitwise
|
|
954
|
-
return ~-encodeURI(value).split(/%..|./).length;
|
|
789
|
+
return newObj;
|
|
955
790
|
}
|
|
956
|
-
/**
|
|
957
|
-
function
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
/** JSDoc */
|
|
961
|
-
function normalizeToSize(object,
|
|
962
|
-
// Default Node.js REPL depth
|
|
963
|
-
depth,
|
|
964
|
-
// 100kB, as 200kB is max payload size, so half sounds reasonable
|
|
965
|
-
maxSize) {
|
|
966
|
-
if (depth === void 0) { depth = 3; }
|
|
967
|
-
if (maxSize === void 0) { maxSize = 100 * 1024; }
|
|
968
|
-
var serialized = normalize(object, depth);
|
|
969
|
-
if (jsonSize(serialized) > maxSize) {
|
|
970
|
-
return normalizeToSize(object, depth - 1, maxSize);
|
|
971
|
-
}
|
|
972
|
-
return serialized;
|
|
973
|
-
}
|
|
974
|
-
/**
|
|
975
|
-
* Transform any non-primitive, BigInt, or Symbol-type value into a string. Acts as a no-op on strings, numbers,
|
|
976
|
-
* booleans, null, and undefined.
|
|
977
|
-
*
|
|
978
|
-
* @param value The value to stringify
|
|
979
|
-
* @returns For non-primitive, BigInt, and Symbol-type values, a string denoting the value's type, type and value, or
|
|
980
|
-
* type and `description` property, respectively. For non-BigInt, non-Symbol primitives, returns the original value,
|
|
981
|
-
* unchanged.
|
|
982
|
-
*/
|
|
983
|
-
function serializeValue(value) {
|
|
984
|
-
// Node.js REPL notation
|
|
985
|
-
if (typeof value === 'string') {
|
|
986
|
-
return value;
|
|
987
|
-
}
|
|
988
|
-
var type = Object.prototype.toString.call(value);
|
|
989
|
-
if (type === '[object Object]') {
|
|
990
|
-
return '[Object]';
|
|
991
|
-
}
|
|
992
|
-
if (type === '[object Array]') {
|
|
993
|
-
return '[Array]';
|
|
994
|
-
}
|
|
995
|
-
// `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
|
|
996
|
-
// pass-through.
|
|
997
|
-
var serializable = makeSerializable(value);
|
|
998
|
-
return isPrimitive(serializable) ? serializable : type;
|
|
999
|
-
}
|
|
1000
|
-
/**
|
|
1001
|
-
* makeSerializable()
|
|
1002
|
-
*
|
|
1003
|
-
* Takes unserializable input and make it serializer-friendly.
|
|
1004
|
-
*
|
|
1005
|
-
* Handles globals, functions, `undefined`, `NaN`, and other non-serializable values.
|
|
1006
|
-
*/
|
|
1007
|
-
function makeSerializable(value, key) {
|
|
1008
|
-
if (key === 'domain' && value && typeof value === 'object' && value._events) {
|
|
1009
|
-
return '[Domain]';
|
|
1010
|
-
}
|
|
1011
|
-
if (key === 'domainEmitter') {
|
|
1012
|
-
return '[DomainEmitter]';
|
|
1013
|
-
}
|
|
1014
|
-
if (typeof global !== 'undefined' && value === global) {
|
|
1015
|
-
return '[Global]';
|
|
1016
|
-
}
|
|
1017
|
-
// It's safe to use `window` and `document` here in this manner, as we are asserting using `typeof` first
|
|
1018
|
-
// which won't throw if they are not present.
|
|
1019
|
-
// eslint-disable-next-line no-restricted-globals
|
|
1020
|
-
if (typeof window !== 'undefined' && value === window) {
|
|
1021
|
-
return '[Window]';
|
|
1022
|
-
}
|
|
1023
|
-
// eslint-disable-next-line no-restricted-globals
|
|
1024
|
-
if (typeof document !== 'undefined' && value === document) {
|
|
1025
|
-
return '[Document]';
|
|
1026
|
-
}
|
|
1027
|
-
// React's SyntheticEvent thingy
|
|
1028
|
-
if (isSyntheticEvent(value)) {
|
|
1029
|
-
return '[SyntheticEvent]';
|
|
1030
|
-
}
|
|
1031
|
-
if (typeof value === 'number' && value !== value) {
|
|
1032
|
-
return '[NaN]';
|
|
1033
|
-
}
|
|
1034
|
-
if (value === void 0) {
|
|
1035
|
-
return '[undefined]';
|
|
1036
|
-
}
|
|
1037
|
-
if (typeof value === 'function') {
|
|
1038
|
-
return "[Function: " + getFunctionName(value) + "]";
|
|
1039
|
-
}
|
|
1040
|
-
// symbols and bigints are considered primitives by TS, but aren't natively JSON-serilaizable
|
|
1041
|
-
if (typeof value === 'symbol') {
|
|
1042
|
-
return "[" + String(value) + "]";
|
|
791
|
+
/** Creates a string representation of the target of an `Event` object */
|
|
792
|
+
function serializeEventTarget(target) {
|
|
793
|
+
try {
|
|
794
|
+
return isElement(target) ? htmlTreeAsString(target) : Object.prototype.toString.call(target);
|
|
1043
795
|
}
|
|
1044
|
-
|
|
1045
|
-
return
|
|
796
|
+
catch (_oO) {
|
|
797
|
+
return '<unknown>';
|
|
1046
798
|
}
|
|
1047
|
-
return value;
|
|
1048
799
|
}
|
|
1049
|
-
/**
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
* @param maxProperties Optional maximum number of properties/elements included in any single object/array
|
|
1056
|
-
* @param memo Optional Memo class handling decycling
|
|
1057
|
-
*/
|
|
1058
|
-
function walk(key, value, depth, maxProperties, memo) {
|
|
1059
|
-
if (depth === void 0) { depth = +Infinity; }
|
|
1060
|
-
if (maxProperties === void 0) { maxProperties = +Infinity; }
|
|
1061
|
-
if (memo === void 0) { memo = memoBuilder(); }
|
|
1062
|
-
var _a = __read(memo, 2), memoize = _a[0], unmemoize = _a[1];
|
|
1063
|
-
// If we reach the maximum depth, serialize whatever is left
|
|
1064
|
-
if (depth === 0) {
|
|
1065
|
-
return serializeValue(value);
|
|
1066
|
-
}
|
|
1067
|
-
// If value implements `toJSON` method, call it and return early
|
|
1068
|
-
if (value !== null && value !== undefined && typeof value.toJSON === 'function') {
|
|
1069
|
-
return value.toJSON();
|
|
1070
|
-
}
|
|
1071
|
-
// `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
|
|
1072
|
-
// pass-through. If what comes back is a primitive (either because it's been stringified or because it was primitive
|
|
1073
|
-
// all along), we're done.
|
|
1074
|
-
var serializable = makeSerializable(value, key);
|
|
1075
|
-
if (isPrimitive(serializable)) {
|
|
1076
|
-
return serializable;
|
|
1077
|
-
}
|
|
1078
|
-
// Create source that we will use for the next iteration. It will either be an objectified error object (`Error` type
|
|
1079
|
-
// with extracted key:value pairs) or the input itself.
|
|
1080
|
-
var source = getWalkSource(value);
|
|
1081
|
-
// Create an accumulator that will act as a parent for all future itterations of that branch
|
|
1082
|
-
var acc = Array.isArray(value) ? [] : {};
|
|
1083
|
-
// If we already walked that branch, bail out, as it's circular reference
|
|
1084
|
-
if (memoize(value)) {
|
|
1085
|
-
return '[Circular ~]';
|
|
1086
|
-
}
|
|
1087
|
-
var propertyCount = 0;
|
|
1088
|
-
// Walk all keys of the source
|
|
1089
|
-
for (var innerKey in source) {
|
|
1090
|
-
// Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
|
|
1091
|
-
if (!Object.prototype.hasOwnProperty.call(source, innerKey)) {
|
|
1092
|
-
continue;
|
|
1093
|
-
}
|
|
1094
|
-
if (propertyCount >= maxProperties) {
|
|
1095
|
-
acc[innerKey] = '[MaxProperties ~]';
|
|
1096
|
-
break;
|
|
800
|
+
/** Filters out all but an object's own properties */
|
|
801
|
+
function getOwnProperties(obj) {
|
|
802
|
+
var extractedProps = {};
|
|
803
|
+
for (var property in obj) {
|
|
804
|
+
if (Object.prototype.hasOwnProperty.call(obj, property)) {
|
|
805
|
+
extractedProps[property] = obj[property];
|
|
1097
806
|
}
|
|
1098
|
-
propertyCount += 1;
|
|
1099
|
-
// Recursively walk through all the child nodes
|
|
1100
|
-
var innerValue = source[innerKey];
|
|
1101
|
-
acc[innerKey] = walk(innerKey, innerValue, depth - 1, maxProperties, memo);
|
|
1102
|
-
}
|
|
1103
|
-
// Once walked through all the branches, remove the parent from memo storage
|
|
1104
|
-
unmemoize(value);
|
|
1105
|
-
// Return accumulated values
|
|
1106
|
-
return acc;
|
|
1107
|
-
}
|
|
1108
|
-
/**
|
|
1109
|
-
* Recursively normalizes the given object.
|
|
1110
|
-
*
|
|
1111
|
-
* - Creates a copy to prevent original input mutation
|
|
1112
|
-
* - Skips non-enumerable properties
|
|
1113
|
-
* - When stringifying, calls `toJSON` if implemented
|
|
1114
|
-
* - Removes circular references
|
|
1115
|
-
* - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format
|
|
1116
|
-
* - Translates known global objects/classes to a string representations
|
|
1117
|
-
* - Takes care of `Error` object serialization
|
|
1118
|
-
* - Optionally limits depth of final output
|
|
1119
|
-
* - Optionally limits number of properties/elements included in any single object/array
|
|
1120
|
-
*
|
|
1121
|
-
* @param input The object to be normalized.
|
|
1122
|
-
* @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)
|
|
1123
|
-
* @param maxProperties The max number of elements or properties to be included in any single array or
|
|
1124
|
-
* object in the normallized output..
|
|
1125
|
-
* @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
|
|
1126
|
-
*/
|
|
1127
|
-
function normalize(input, depth, maxProperties) {
|
|
1128
|
-
if (depth === void 0) { depth = +Infinity; }
|
|
1129
|
-
if (maxProperties === void 0) { maxProperties = +Infinity; }
|
|
1130
|
-
try {
|
|
1131
|
-
// since we're at the outermost level, there is no key
|
|
1132
|
-
return walk('', input, depth, maxProperties);
|
|
1133
|
-
}
|
|
1134
|
-
catch (_oO) {
|
|
1135
|
-
return '**non-serializable**';
|
|
1136
807
|
}
|
|
808
|
+
return extractedProps;
|
|
1137
809
|
}
|
|
1138
810
|
/**
|
|
1139
811
|
* Given any captured exception, extract its keys and create a sorted
|
|
@@ -1143,7 +815,7 @@ var Sentry = (function (exports) {
|
|
|
1143
815
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1144
816
|
function extractExceptionKeysForMessage(exception, maxLength) {
|
|
1145
817
|
if (maxLength === void 0) { maxLength = 40; }
|
|
1146
|
-
var keys = Object.keys(
|
|
818
|
+
var keys = Object.keys(convertToPlainObject(exception));
|
|
1147
819
|
keys.sort();
|
|
1148
820
|
if (!keys.length) {
|
|
1149
821
|
return '[object has no keys]';
|
|
@@ -1170,13 +842,12 @@ var Sentry = (function (exports) {
|
|
|
1170
842
|
function dropUndefinedKeys(val) {
|
|
1171
843
|
var e_1, _a;
|
|
1172
844
|
if (isPlainObject(val)) {
|
|
1173
|
-
var obj = val;
|
|
1174
845
|
var rv = {};
|
|
1175
846
|
try {
|
|
1176
|
-
for (var _b = __values(Object.keys(
|
|
847
|
+
for (var _b = __values(Object.keys(val)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1177
848
|
var key = _c.value;
|
|
1178
|
-
if (typeof
|
|
1179
|
-
rv[key] = dropUndefinedKeys(
|
|
849
|
+
if (typeof val[key] !== 'undefined') {
|
|
850
|
+
rv[key] = dropUndefinedKeys(val[key]);
|
|
1180
851
|
}
|
|
1181
852
|
}
|
|
1182
853
|
}
|
|
@@ -1187,12 +858,104 @@ var Sentry = (function (exports) {
|
|
|
1187
858
|
}
|
|
1188
859
|
finally { if (e_1) throw e_1.error; }
|
|
1189
860
|
}
|
|
1190
|
-
return rv;
|
|
861
|
+
return rv;
|
|
862
|
+
}
|
|
863
|
+
if (Array.isArray(val)) {
|
|
864
|
+
return val.map(dropUndefinedKeys);
|
|
865
|
+
}
|
|
866
|
+
return val;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
var STACKTRACE_LIMIT = 50;
|
|
870
|
+
/**
|
|
871
|
+
* Creates a stack parser with the supplied line parsers
|
|
872
|
+
*
|
|
873
|
+
* StackFrames are returned in the correct order for Sentry Exception
|
|
874
|
+
* frames and with Sentry SDK internal frames removed from the top and bottom
|
|
875
|
+
*
|
|
876
|
+
*/
|
|
877
|
+
function createStackParser() {
|
|
878
|
+
var parsers = [];
|
|
879
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
880
|
+
parsers[_i] = arguments[_i];
|
|
881
|
+
}
|
|
882
|
+
var sortedParsers = parsers.sort(function (a, b) { return a[0] - b[0]; }).map(function (p) { return p[1]; });
|
|
883
|
+
return function (stack, skipFirst) {
|
|
884
|
+
var e_1, _a, e_2, _b;
|
|
885
|
+
if (skipFirst === void 0) { skipFirst = 0; }
|
|
886
|
+
var frames = [];
|
|
887
|
+
try {
|
|
888
|
+
for (var _c = __values(stack.split('\n').slice(skipFirst)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
889
|
+
var line = _d.value;
|
|
890
|
+
try {
|
|
891
|
+
for (var sortedParsers_1 = (e_2 = void 0, __values(sortedParsers)), sortedParsers_1_1 = sortedParsers_1.next(); !sortedParsers_1_1.done; sortedParsers_1_1 = sortedParsers_1.next()) {
|
|
892
|
+
var parser = sortedParsers_1_1.value;
|
|
893
|
+
var frame = parser(line);
|
|
894
|
+
if (frame) {
|
|
895
|
+
frames.push(frame);
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
901
|
+
finally {
|
|
902
|
+
try {
|
|
903
|
+
if (sortedParsers_1_1 && !sortedParsers_1_1.done && (_b = sortedParsers_1.return)) _b.call(sortedParsers_1);
|
|
904
|
+
}
|
|
905
|
+
finally { if (e_2) throw e_2.error; }
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
910
|
+
finally {
|
|
911
|
+
try {
|
|
912
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
913
|
+
}
|
|
914
|
+
finally { if (e_1) throw e_1.error; }
|
|
915
|
+
}
|
|
916
|
+
return stripSentryFramesAndReverse(frames);
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* @hidden
|
|
921
|
+
*/
|
|
922
|
+
function stripSentryFramesAndReverse(stack) {
|
|
923
|
+
if (!stack.length) {
|
|
924
|
+
return [];
|
|
925
|
+
}
|
|
926
|
+
var localStack = stack;
|
|
927
|
+
var firstFrameFunction = localStack[0].function || '';
|
|
928
|
+
var lastFrameFunction = localStack[localStack.length - 1].function || '';
|
|
929
|
+
// If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
|
|
930
|
+
if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
|
|
931
|
+
localStack = localStack.slice(1);
|
|
932
|
+
}
|
|
933
|
+
// If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
|
|
934
|
+
if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
|
|
935
|
+
localStack = localStack.slice(0, -1);
|
|
936
|
+
}
|
|
937
|
+
// The frame where the crash happened, should be the last entry in the array
|
|
938
|
+
return localStack
|
|
939
|
+
.slice(0, STACKTRACE_LIMIT)
|
|
940
|
+
.map(function (frame) { return (__assign(__assign({}, frame), { filename: frame.filename || localStack[0].filename, function: frame.function || '?' })); })
|
|
941
|
+
.reverse();
|
|
942
|
+
}
|
|
943
|
+
var defaultFunctionName = '<anonymous>';
|
|
944
|
+
/**
|
|
945
|
+
* Safely extract function name from itself
|
|
946
|
+
*/
|
|
947
|
+
function getFunctionName(fn) {
|
|
948
|
+
try {
|
|
949
|
+
if (!fn || typeof fn !== 'function') {
|
|
950
|
+
return defaultFunctionName;
|
|
951
|
+
}
|
|
952
|
+
return fn.name || defaultFunctionName;
|
|
1191
953
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
954
|
+
catch (e) {
|
|
955
|
+
// Just accessing custom props in some Selenium environments
|
|
956
|
+
// can cause a "Permission denied" exception (see raven-js#495).
|
|
957
|
+
return defaultFunctionName;
|
|
1194
958
|
}
|
|
1195
|
-
return val;
|
|
1196
959
|
}
|
|
1197
960
|
|
|
1198
961
|
/**
|
|
@@ -1819,6 +1582,48 @@ var Sentry = (function (exports) {
|
|
|
1819
1582
|
};
|
|
1820
1583
|
}
|
|
1821
1584
|
|
|
1585
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
1586
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1587
|
+
/**
|
|
1588
|
+
* Helper to decycle json objects
|
|
1589
|
+
*/
|
|
1590
|
+
function memoBuilder() {
|
|
1591
|
+
var hasWeakSet = typeof WeakSet === 'function';
|
|
1592
|
+
var inner = hasWeakSet ? new WeakSet() : [];
|
|
1593
|
+
function memoize(obj) {
|
|
1594
|
+
if (hasWeakSet) {
|
|
1595
|
+
if (inner.has(obj)) {
|
|
1596
|
+
return true;
|
|
1597
|
+
}
|
|
1598
|
+
inner.add(obj);
|
|
1599
|
+
return false;
|
|
1600
|
+
}
|
|
1601
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
1602
|
+
for (var i = 0; i < inner.length; i++) {
|
|
1603
|
+
var value = inner[i];
|
|
1604
|
+
if (value === obj) {
|
|
1605
|
+
return true;
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
inner.push(obj);
|
|
1609
|
+
return false;
|
|
1610
|
+
}
|
|
1611
|
+
function unmemoize(obj) {
|
|
1612
|
+
if (hasWeakSet) {
|
|
1613
|
+
inner.delete(obj);
|
|
1614
|
+
}
|
|
1615
|
+
else {
|
|
1616
|
+
for (var i = 0; i < inner.length; i++) {
|
|
1617
|
+
if (inner[i] === obj) {
|
|
1618
|
+
inner.splice(i, 1);
|
|
1619
|
+
break;
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
return [memoize, unmemoize];
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1822
1627
|
/**
|
|
1823
1628
|
* UUID4 generator
|
|
1824
1629
|
*
|
|
@@ -1976,6 +1781,194 @@ var Sentry = (function (exports) {
|
|
|
1976
1781
|
return false;
|
|
1977
1782
|
}
|
|
1978
1783
|
|
|
1784
|
+
/**
|
|
1785
|
+
* Recursively normalizes the given object.
|
|
1786
|
+
*
|
|
1787
|
+
* - Creates a copy to prevent original input mutation
|
|
1788
|
+
* - Skips non-enumerable properties
|
|
1789
|
+
* - When stringifying, calls `toJSON` if implemented
|
|
1790
|
+
* - Removes circular references
|
|
1791
|
+
* - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format
|
|
1792
|
+
* - Translates known global objects/classes to a string representations
|
|
1793
|
+
* - Takes care of `Error` object serialization
|
|
1794
|
+
* - Optionally limits depth of final output
|
|
1795
|
+
* - Optionally limits number of properties/elements included in any single object/array
|
|
1796
|
+
*
|
|
1797
|
+
* @param input The object to be normalized.
|
|
1798
|
+
* @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)
|
|
1799
|
+
* @param maxProperties The max number of elements or properties to be included in any single array or
|
|
1800
|
+
* object in the normallized output..
|
|
1801
|
+
* @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
|
|
1802
|
+
*/
|
|
1803
|
+
function normalize(input, depth, maxProperties) {
|
|
1804
|
+
if (depth === void 0) { depth = +Infinity; }
|
|
1805
|
+
if (maxProperties === void 0) { maxProperties = +Infinity; }
|
|
1806
|
+
try {
|
|
1807
|
+
// since we're at the outermost level, there is no key
|
|
1808
|
+
return visit('', input, depth, maxProperties);
|
|
1809
|
+
}
|
|
1810
|
+
catch (err) {
|
|
1811
|
+
return { ERROR: "**non-serializable** (" + err + ")" };
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
/** JSDoc */
|
|
1815
|
+
function normalizeToSize(object,
|
|
1816
|
+
// Default Node.js REPL depth
|
|
1817
|
+
depth,
|
|
1818
|
+
// 100kB, as 200kB is max payload size, so half sounds reasonable
|
|
1819
|
+
maxSize) {
|
|
1820
|
+
if (depth === void 0) { depth = 3; }
|
|
1821
|
+
if (maxSize === void 0) { maxSize = 100 * 1024; }
|
|
1822
|
+
var normalized = normalize(object, depth);
|
|
1823
|
+
if (jsonSize(normalized) > maxSize) {
|
|
1824
|
+
return normalizeToSize(object, depth - 1, maxSize);
|
|
1825
|
+
}
|
|
1826
|
+
return normalized;
|
|
1827
|
+
}
|
|
1828
|
+
/**
|
|
1829
|
+
* Visits a node to perform normalization on it
|
|
1830
|
+
*
|
|
1831
|
+
* @param key The key corresponding to the given node
|
|
1832
|
+
* @param value The node to be visited
|
|
1833
|
+
* @param depth Optional number indicating the maximum recursion depth
|
|
1834
|
+
* @param maxProperties Optional maximum number of properties/elements included in any single object/array
|
|
1835
|
+
* @param memo Optional Memo class handling decycling
|
|
1836
|
+
*/
|
|
1837
|
+
function visit(key, value, depth, maxProperties, memo) {
|
|
1838
|
+
if (depth === void 0) { depth = +Infinity; }
|
|
1839
|
+
if (maxProperties === void 0) { maxProperties = +Infinity; }
|
|
1840
|
+
if (memo === void 0) { memo = memoBuilder(); }
|
|
1841
|
+
var _a = __read(memo, 2), memoize = _a[0], unmemoize = _a[1];
|
|
1842
|
+
// If the value has a `toJSON` method, see if we can bail and let it do the work
|
|
1843
|
+
var valueWithToJSON = value;
|
|
1844
|
+
if (valueWithToJSON && typeof valueWithToJSON.toJSON === 'function') {
|
|
1845
|
+
try {
|
|
1846
|
+
return valueWithToJSON.toJSON();
|
|
1847
|
+
}
|
|
1848
|
+
catch (err) {
|
|
1849
|
+
// pass (The built-in `toJSON` failed, but we can still try to do it ourselves)
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
// Get the simple cases out of the way first
|
|
1853
|
+
if (value === null || (['number', 'boolean', 'string'].includes(typeof value) && !isNaN$1(value))) {
|
|
1854
|
+
return value;
|
|
1855
|
+
}
|
|
1856
|
+
var stringified = stringifyValue(key, value);
|
|
1857
|
+
// Anything we could potentially dig into more (objects or arrays) will have come back as `"[object XXXX]"`.
|
|
1858
|
+
// Everything else will have already been serialized, so if we don't see that pattern, we're done.
|
|
1859
|
+
if (!stringified.startsWith('[object ')) {
|
|
1860
|
+
return stringified;
|
|
1861
|
+
}
|
|
1862
|
+
// We're also done if we've reached the max depth
|
|
1863
|
+
if (depth === 0) {
|
|
1864
|
+
// At this point we know `serialized` is a string of the form `"[object XXXX]"`. Clean it up so it's just `"[XXXX]"`.
|
|
1865
|
+
return stringified.replace('object ', '');
|
|
1866
|
+
}
|
|
1867
|
+
// If we've already visited this branch, bail out, as it's circular reference. If not, note that we're seeing it now.
|
|
1868
|
+
if (memoize(value)) {
|
|
1869
|
+
return '[Circular ~]';
|
|
1870
|
+
}
|
|
1871
|
+
// At this point we know we either have an object or an array, we haven't seen it before, and we're going to recurse
|
|
1872
|
+
// because we haven't yet reached the max depth. Create an accumulator to hold the results of visiting each
|
|
1873
|
+
// property/entry, and keep track of the number of items we add to it.
|
|
1874
|
+
var normalized = (Array.isArray(value) ? [] : {});
|
|
1875
|
+
var numAdded = 0;
|
|
1876
|
+
// Before we begin, convert`Error` and`Event` instances into plain objects, since some of each of their relevant
|
|
1877
|
+
// properties are non-enumerable and otherwise would get missed.
|
|
1878
|
+
var visitable = (isError(value) || isEvent(value) ? convertToPlainObject(value) : value);
|
|
1879
|
+
for (var visitKey in visitable) {
|
|
1880
|
+
// Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
|
|
1881
|
+
if (!Object.prototype.hasOwnProperty.call(visitable, visitKey)) {
|
|
1882
|
+
continue;
|
|
1883
|
+
}
|
|
1884
|
+
if (numAdded >= maxProperties) {
|
|
1885
|
+
normalized[visitKey] = '[MaxProperties ~]';
|
|
1886
|
+
break;
|
|
1887
|
+
}
|
|
1888
|
+
// Recursively visit all the child nodes
|
|
1889
|
+
var visitValue = visitable[visitKey];
|
|
1890
|
+
normalized[visitKey] = visit(visitKey, visitValue, depth - 1, maxProperties, memo);
|
|
1891
|
+
numAdded += 1;
|
|
1892
|
+
}
|
|
1893
|
+
// Once we've visited all the branches, remove the parent from memo storage
|
|
1894
|
+
unmemoize(value);
|
|
1895
|
+
// Return accumulated values
|
|
1896
|
+
return normalized;
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1899
|
+
* Stringify the given value. Handles various known special values and types.
|
|
1900
|
+
*
|
|
1901
|
+
* Not meant to be used on simple primitives which already have a string representation, as it will, for example, turn
|
|
1902
|
+
* the number 1231 into "[Object Number]", nor on `null`, as it will throw.
|
|
1903
|
+
*
|
|
1904
|
+
* @param value The value to stringify
|
|
1905
|
+
* @returns A stringified representation of the given value
|
|
1906
|
+
*/
|
|
1907
|
+
function stringifyValue(key,
|
|
1908
|
+
// this type is a tiny bit of a cheat, since this function does handle NaN (which is technically a number), but for
|
|
1909
|
+
// our internal use, it'll do
|
|
1910
|
+
value) {
|
|
1911
|
+
try {
|
|
1912
|
+
if (key === 'domain' && value && typeof value === 'object' && value._events) {
|
|
1913
|
+
return '[Domain]';
|
|
1914
|
+
}
|
|
1915
|
+
if (key === 'domainEmitter') {
|
|
1916
|
+
return '[DomainEmitter]';
|
|
1917
|
+
}
|
|
1918
|
+
// It's safe to use `global`, `window`, and `document` here in this manner, as we are asserting using `typeof` first
|
|
1919
|
+
// which won't throw if they are not present.
|
|
1920
|
+
if (typeof global !== 'undefined' && value === global) {
|
|
1921
|
+
return '[Global]';
|
|
1922
|
+
}
|
|
1923
|
+
// eslint-disable-next-line no-restricted-globals
|
|
1924
|
+
if (typeof window !== 'undefined' && value === window) {
|
|
1925
|
+
return '[Window]';
|
|
1926
|
+
}
|
|
1927
|
+
// eslint-disable-next-line no-restricted-globals
|
|
1928
|
+
if (typeof document !== 'undefined' && value === document) {
|
|
1929
|
+
return '[Document]';
|
|
1930
|
+
}
|
|
1931
|
+
// React's SyntheticEvent thingy
|
|
1932
|
+
if (isSyntheticEvent(value)) {
|
|
1933
|
+
return '[SyntheticEvent]';
|
|
1934
|
+
}
|
|
1935
|
+
if (typeof value === 'number' && value !== value) {
|
|
1936
|
+
return '[NaN]';
|
|
1937
|
+
}
|
|
1938
|
+
// this catches `undefined` (but not `null`, which is a primitive and can be serialized on its own)
|
|
1939
|
+
if (value === void 0) {
|
|
1940
|
+
return '[undefined]';
|
|
1941
|
+
}
|
|
1942
|
+
if (typeof value === 'function') {
|
|
1943
|
+
return "[Function: " + getFunctionName(value) + "]";
|
|
1944
|
+
}
|
|
1945
|
+
if (typeof value === 'symbol') {
|
|
1946
|
+
return "[" + String(value) + "]";
|
|
1947
|
+
}
|
|
1948
|
+
// stringified BigInts are indistinguishable from regular numbers, so we need to label them to avoid confusion
|
|
1949
|
+
if (typeof value === 'bigint') {
|
|
1950
|
+
return "[BigInt: " + String(value) + "]";
|
|
1951
|
+
}
|
|
1952
|
+
// Now that we've knocked out all the special cases and the primitives, all we have left are objects. Simply casting
|
|
1953
|
+
// them to strings means that instances of classes which haven't defined their `toStringTag` will just come out as
|
|
1954
|
+
// `"[object Object]"`. If we instead look at the constructor's name (which is the same as the name of the class),
|
|
1955
|
+
// we can make sure that only plain objects come out that way.
|
|
1956
|
+
return "[object " + Object.getPrototypeOf(value).constructor.name + "]";
|
|
1957
|
+
}
|
|
1958
|
+
catch (err) {
|
|
1959
|
+
return "**non-serializable** (" + err + ")";
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
/** Calculates bytes size of input string */
|
|
1963
|
+
function utf8Length(value) {
|
|
1964
|
+
// eslint-disable-next-line no-bitwise
|
|
1965
|
+
return ~-encodeURI(value).split(/%..|./).length;
|
|
1966
|
+
}
|
|
1967
|
+
/** Calculates bytes size of input object */
|
|
1968
|
+
function jsonSize(value) {
|
|
1969
|
+
return utf8Length(JSON.stringify(value));
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1979
1972
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1980
1973
|
/**
|
|
1981
1974
|
* Creates a resolved sync promise.
|
|
@@ -2383,6 +2376,13 @@ var Sentry = (function (exports) {
|
|
|
2383
2376
|
if (items === void 0) { items = []; }
|
|
2384
2377
|
return [headers, items];
|
|
2385
2378
|
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Get the type of the envelope. Grabs the type from the first envelope item.
|
|
2381
|
+
*/
|
|
2382
|
+
function getEnvelopeType(envelope) {
|
|
2383
|
+
var _a = __read(envelope, 2), _b = __read(_a[1], 1), _c = __read(_b[0], 1), firstItemHeader = _c[0];
|
|
2384
|
+
return firstItemHeader.type;
|
|
2385
|
+
}
|
|
2386
2386
|
/**
|
|
2387
2387
|
* Serializes an envelope into a string.
|
|
2388
2388
|
*/
|
|
@@ -4189,7 +4189,7 @@ var Sentry = (function (exports) {
|
|
|
4189
4189
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
4190
4190
|
normalized.contexts.trace = event.contexts.trace;
|
|
4191
4191
|
}
|
|
4192
|
-
|
|
4192
|
+
normalized.sdkProcessingMetadata = __assign(__assign({}, normalized.sdkProcessingMetadata), { baseClientNormalized: true });
|
|
4193
4193
|
return normalized;
|
|
4194
4194
|
};
|
|
4195
4195
|
/**
|
|
@@ -4363,89 +4363,6 @@ var Sentry = (function (exports) {
|
|
|
4363
4363
|
return rv;
|
|
4364
4364
|
}
|
|
4365
4365
|
|
|
4366
|
-
/** Noop transport */
|
|
4367
|
-
var NoopTransport = /** @class */ (function () {
|
|
4368
|
-
function NoopTransport() {
|
|
4369
|
-
}
|
|
4370
|
-
/**
|
|
4371
|
-
* @inheritDoc
|
|
4372
|
-
*/
|
|
4373
|
-
NoopTransport.prototype.sendEvent = function (_) {
|
|
4374
|
-
return resolvedSyncPromise({
|
|
4375
|
-
reason: 'NoopTransport: Event has been skipped because no Dsn is configured.',
|
|
4376
|
-
status: 'skipped',
|
|
4377
|
-
});
|
|
4378
|
-
};
|
|
4379
|
-
/**
|
|
4380
|
-
* @inheritDoc
|
|
4381
|
-
*/
|
|
4382
|
-
NoopTransport.prototype.close = function (_) {
|
|
4383
|
-
return resolvedSyncPromise(true);
|
|
4384
|
-
};
|
|
4385
|
-
return NoopTransport;
|
|
4386
|
-
}());
|
|
4387
|
-
|
|
4388
|
-
/**
|
|
4389
|
-
* This is the base implemention of a Backend.
|
|
4390
|
-
* @hidden
|
|
4391
|
-
*/
|
|
4392
|
-
var BaseBackend = /** @class */ (function () {
|
|
4393
|
-
/** Creates a new backend instance. */
|
|
4394
|
-
function BaseBackend(options) {
|
|
4395
|
-
this._options = options;
|
|
4396
|
-
if (!this._options.dsn) {
|
|
4397
|
-
logger.warn('No DSN provided, backend will not do anything.');
|
|
4398
|
-
}
|
|
4399
|
-
this._transport = this._setupTransport();
|
|
4400
|
-
}
|
|
4401
|
-
/**
|
|
4402
|
-
* @inheritDoc
|
|
4403
|
-
*/
|
|
4404
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
4405
|
-
BaseBackend.prototype.eventFromException = function (_exception, _hint) {
|
|
4406
|
-
throw new SentryError('Backend has to implement `eventFromException` method');
|
|
4407
|
-
};
|
|
4408
|
-
/**
|
|
4409
|
-
* @inheritDoc
|
|
4410
|
-
*/
|
|
4411
|
-
BaseBackend.prototype.eventFromMessage = function (_message, _level, _hint) {
|
|
4412
|
-
throw new SentryError('Backend has to implement `eventFromMessage` method');
|
|
4413
|
-
};
|
|
4414
|
-
/**
|
|
4415
|
-
* @inheritDoc
|
|
4416
|
-
*/
|
|
4417
|
-
BaseBackend.prototype.sendEvent = function (event) {
|
|
4418
|
-
void this._transport.sendEvent(event).then(null, function (reason) {
|
|
4419
|
-
logger.error('Error while sending event:', reason);
|
|
4420
|
-
});
|
|
4421
|
-
};
|
|
4422
|
-
/**
|
|
4423
|
-
* @inheritDoc
|
|
4424
|
-
*/
|
|
4425
|
-
BaseBackend.prototype.sendSession = function (session) {
|
|
4426
|
-
if (!this._transport.sendSession) {
|
|
4427
|
-
logger.warn("Dropping session because custom transport doesn't implement sendSession");
|
|
4428
|
-
return;
|
|
4429
|
-
}
|
|
4430
|
-
void this._transport.sendSession(session).then(null, function (reason) {
|
|
4431
|
-
logger.error('Error while sending session:', reason);
|
|
4432
|
-
});
|
|
4433
|
-
};
|
|
4434
|
-
/**
|
|
4435
|
-
* @inheritDoc
|
|
4436
|
-
*/
|
|
4437
|
-
BaseBackend.prototype.getTransport = function () {
|
|
4438
|
-
return this._transport;
|
|
4439
|
-
};
|
|
4440
|
-
/**
|
|
4441
|
-
* Sets up the transport so it can be used later to send requests.
|
|
4442
|
-
*/
|
|
4443
|
-
BaseBackend.prototype._setupTransport = function () {
|
|
4444
|
-
return new NoopTransport();
|
|
4445
|
-
};
|
|
4446
|
-
return BaseBackend;
|
|
4447
|
-
}());
|
|
4448
|
-
|
|
4449
4366
|
/** Extract sdk info from from the API metadata */
|
|
4450
4367
|
function getSdkMetadataForEnvelopeHeader(api) {
|
|
4451
4368
|
if (!api.metadata || !api.metadata.sdk) {
|
|
@@ -4469,8 +4386,8 @@ var Sentry = (function (exports) {
|
|
|
4469
4386
|
event.sdk.packages = __spread((event.sdk.packages || []), (sdkInfo.packages || []));
|
|
4470
4387
|
return event;
|
|
4471
4388
|
}
|
|
4472
|
-
/** Creates
|
|
4473
|
-
function
|
|
4389
|
+
/** Creates an envelope from a Session */
|
|
4390
|
+
function createSessionEnvelope(session, api) {
|
|
4474
4391
|
var sdkInfo = getSdkMetadataForEnvelopeHeader(api);
|
|
4475
4392
|
var envelopeHeaders = __assign(__assign({ sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
|
|
4476
4393
|
// I know this is hacky but we don't want to add `sessions` to request type since it's never rate limited
|
|
@@ -4478,12 +4395,62 @@ var Sentry = (function (exports) {
|
|
|
4478
4395
|
// TODO (v7) Have to cast type because envelope items do not accept a `SentryRequestType`
|
|
4479
4396
|
var envelopeItem = [{ type: type }, session];
|
|
4480
4397
|
var envelope = createEnvelope(envelopeHeaders, [envelopeItem]);
|
|
4398
|
+
return [envelope, type];
|
|
4399
|
+
}
|
|
4400
|
+
/** Creates a SentryRequest from a Session. */
|
|
4401
|
+
function sessionToSentryRequest(session, api) {
|
|
4402
|
+
var _a = __read(createSessionEnvelope(session, api), 2), envelope = _a[0], type = _a[1];
|
|
4481
4403
|
return {
|
|
4482
4404
|
body: serializeEnvelope(envelope),
|
|
4483
4405
|
type: type,
|
|
4484
4406
|
url: getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel),
|
|
4485
4407
|
};
|
|
4486
4408
|
}
|
|
4409
|
+
/**
|
|
4410
|
+
* Create an Envelope from an event. Note that this is duplicated from below,
|
|
4411
|
+
* but on purpose as this will be refactored in v7.
|
|
4412
|
+
*/
|
|
4413
|
+
function createEventEnvelope(event, api) {
|
|
4414
|
+
var sdkInfo = getSdkMetadataForEnvelopeHeader(api);
|
|
4415
|
+
var eventType = event.type || 'event';
|
|
4416
|
+
var transactionSampling = (event.sdkProcessingMetadata || {}).transactionSampling;
|
|
4417
|
+
var _a = transactionSampling || {}, samplingMethod = _a.method, sampleRate = _a.rate;
|
|
4418
|
+
// TODO: Below is a temporary hack in order to debug a serialization error - see
|
|
4419
|
+
// https://github.com/getsentry/sentry-javascript/issues/2809,
|
|
4420
|
+
// https://github.com/getsentry/sentry-javascript/pull/4425, and
|
|
4421
|
+
// https://github.com/getsentry/sentry-javascript/pull/4574.
|
|
4422
|
+
//
|
|
4423
|
+
// TL; DR: even though we normalize all events (which should prevent this), something is causing `JSON.stringify` to
|
|
4424
|
+
// throw a circular reference error.
|
|
4425
|
+
//
|
|
4426
|
+
// When it's time to remove it:
|
|
4427
|
+
// 1. Delete everything between here and where the request object `req` is created, EXCEPT the line deleting
|
|
4428
|
+
// `sdkProcessingMetadata`
|
|
4429
|
+
// 2. Restore the original version of the request body, which is commented out
|
|
4430
|
+
// 3. Search for either of the PR URLs above and pull out the companion hacks in the browser playwright tests and the
|
|
4431
|
+
// baseClient tests in this package
|
|
4432
|
+
enhanceEventWithSdkInfo(event, api.metadata.sdk);
|
|
4433
|
+
event.tags = event.tags || {};
|
|
4434
|
+
event.extra = event.extra || {};
|
|
4435
|
+
// In theory, all events should be marked as having gone through normalization and so
|
|
4436
|
+
// we should never set this tag/extra data
|
|
4437
|
+
if (!(event.sdkProcessingMetadata && event.sdkProcessingMetadata.baseClientNormalized)) {
|
|
4438
|
+
event.tags.skippedNormalization = true;
|
|
4439
|
+
event.extra.normalizeDepth = event.sdkProcessingMetadata ? event.sdkProcessingMetadata.normalizeDepth : 'unset';
|
|
4440
|
+
}
|
|
4441
|
+
// prevent this data from being sent to sentry
|
|
4442
|
+
// TODO: This is NOT part of the hack - DO NOT DELETE
|
|
4443
|
+
delete event.sdkProcessingMetadata;
|
|
4444
|
+
var envelopeHeaders = __assign(__assign({ event_id: event.event_id, sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
|
|
4445
|
+
var eventItem = [
|
|
4446
|
+
{
|
|
4447
|
+
type: eventType,
|
|
4448
|
+
sample_rates: [{ id: samplingMethod, rate: sampleRate }],
|
|
4449
|
+
},
|
|
4450
|
+
event,
|
|
4451
|
+
];
|
|
4452
|
+
return createEnvelope(envelopeHeaders, [eventItem]);
|
|
4453
|
+
}
|
|
4487
4454
|
/** Creates a SentryRequest from an event. */
|
|
4488
4455
|
function eventToSentryRequest(event, api) {
|
|
4489
4456
|
var sdkInfo = getSdkMetadataForEnvelopeHeader(api);
|
|
@@ -4571,6 +4538,115 @@ var Sentry = (function (exports) {
|
|
|
4571
4538
|
return req;
|
|
4572
4539
|
}
|
|
4573
4540
|
|
|
4541
|
+
/** Noop transport */
|
|
4542
|
+
var NoopTransport = /** @class */ (function () {
|
|
4543
|
+
function NoopTransport() {
|
|
4544
|
+
}
|
|
4545
|
+
/**
|
|
4546
|
+
* @inheritDoc
|
|
4547
|
+
*/
|
|
4548
|
+
NoopTransport.prototype.sendEvent = function (_) {
|
|
4549
|
+
return resolvedSyncPromise({
|
|
4550
|
+
reason: 'NoopTransport: Event has been skipped because no Dsn is configured.',
|
|
4551
|
+
status: 'skipped',
|
|
4552
|
+
});
|
|
4553
|
+
};
|
|
4554
|
+
/**
|
|
4555
|
+
* @inheritDoc
|
|
4556
|
+
*/
|
|
4557
|
+
NoopTransport.prototype.close = function (_) {
|
|
4558
|
+
return resolvedSyncPromise(true);
|
|
4559
|
+
};
|
|
4560
|
+
return NoopTransport;
|
|
4561
|
+
}());
|
|
4562
|
+
|
|
4563
|
+
/**
|
|
4564
|
+
* This is the base implemention of a Backend.
|
|
4565
|
+
* @hidden
|
|
4566
|
+
*/
|
|
4567
|
+
var BaseBackend = /** @class */ (function () {
|
|
4568
|
+
/** Creates a new backend instance. */
|
|
4569
|
+
function BaseBackend(options) {
|
|
4570
|
+
this._options = options;
|
|
4571
|
+
if (!this._options.dsn) {
|
|
4572
|
+
logger.warn('No DSN provided, backend will not do anything.');
|
|
4573
|
+
}
|
|
4574
|
+
this._transport = this._setupTransport();
|
|
4575
|
+
}
|
|
4576
|
+
/**
|
|
4577
|
+
* @inheritDoc
|
|
4578
|
+
*/
|
|
4579
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
4580
|
+
BaseBackend.prototype.eventFromException = function (_exception, _hint) {
|
|
4581
|
+
throw new SentryError('Backend has to implement `eventFromException` method');
|
|
4582
|
+
};
|
|
4583
|
+
/**
|
|
4584
|
+
* @inheritDoc
|
|
4585
|
+
*/
|
|
4586
|
+
BaseBackend.prototype.eventFromMessage = function (_message, _level, _hint) {
|
|
4587
|
+
throw new SentryError('Backend has to implement `eventFromMessage` method');
|
|
4588
|
+
};
|
|
4589
|
+
/**
|
|
4590
|
+
* @inheritDoc
|
|
4591
|
+
*/
|
|
4592
|
+
BaseBackend.prototype.sendEvent = function (event) {
|
|
4593
|
+
// TODO(v7): Remove the if-else
|
|
4594
|
+
if (this._newTransport &&
|
|
4595
|
+
this._options.dsn &&
|
|
4596
|
+
this._options._experiments &&
|
|
4597
|
+
this._options._experiments.newTransport) {
|
|
4598
|
+
var api = initAPIDetails(this._options.dsn, this._options._metadata, this._options.tunnel);
|
|
4599
|
+
var env = createEventEnvelope(event, api);
|
|
4600
|
+
void this._newTransport.send(env).then(null, function (reason) {
|
|
4601
|
+
logger.error('Error while sending event:', reason);
|
|
4602
|
+
});
|
|
4603
|
+
}
|
|
4604
|
+
else {
|
|
4605
|
+
void this._transport.sendEvent(event).then(null, function (reason) {
|
|
4606
|
+
logger.error('Error while sending event:', reason);
|
|
4607
|
+
});
|
|
4608
|
+
}
|
|
4609
|
+
};
|
|
4610
|
+
/**
|
|
4611
|
+
* @inheritDoc
|
|
4612
|
+
*/
|
|
4613
|
+
BaseBackend.prototype.sendSession = function (session) {
|
|
4614
|
+
if (!this._transport.sendSession) {
|
|
4615
|
+
logger.warn("Dropping session because custom transport doesn't implement sendSession");
|
|
4616
|
+
return;
|
|
4617
|
+
}
|
|
4618
|
+
// TODO(v7): Remove the if-else
|
|
4619
|
+
if (this._newTransport &&
|
|
4620
|
+
this._options.dsn &&
|
|
4621
|
+
this._options._experiments &&
|
|
4622
|
+
this._options._experiments.newTransport) {
|
|
4623
|
+
var api = initAPIDetails(this._options.dsn, this._options._metadata, this._options.tunnel);
|
|
4624
|
+
var _a = __read(createSessionEnvelope(session, api), 1), env = _a[0];
|
|
4625
|
+
void this._newTransport.send(env).then(null, function (reason) {
|
|
4626
|
+
logger.error('Error while sending session:', reason);
|
|
4627
|
+
});
|
|
4628
|
+
}
|
|
4629
|
+
else {
|
|
4630
|
+
void this._transport.sendSession(session).then(null, function (reason) {
|
|
4631
|
+
logger.error('Error while sending session:', reason);
|
|
4632
|
+
});
|
|
4633
|
+
}
|
|
4634
|
+
};
|
|
4635
|
+
/**
|
|
4636
|
+
* @inheritDoc
|
|
4637
|
+
*/
|
|
4638
|
+
BaseBackend.prototype.getTransport = function () {
|
|
4639
|
+
return this._transport;
|
|
4640
|
+
};
|
|
4641
|
+
/**
|
|
4642
|
+
* Sets up the transport so it can be used later to send requests.
|
|
4643
|
+
*/
|
|
4644
|
+
BaseBackend.prototype._setupTransport = function () {
|
|
4645
|
+
return new NoopTransport();
|
|
4646
|
+
};
|
|
4647
|
+
return BaseBackend;
|
|
4648
|
+
}());
|
|
4649
|
+
|
|
4574
4650
|
/**
|
|
4575
4651
|
* Internal function to create a new SDK client instance. The client is
|
|
4576
4652
|
* installed and then bound to the current scope.
|
|
@@ -4593,7 +4669,61 @@ var Sentry = (function (exports) {
|
|
|
4593
4669
|
hub.bindClient(client);
|
|
4594
4670
|
}
|
|
4595
4671
|
|
|
4596
|
-
var
|
|
4672
|
+
var DEFAULT_TRANSPORT_BUFFER_SIZE = 30;
|
|
4673
|
+
/**
|
|
4674
|
+
* Creates a `NewTransport`
|
|
4675
|
+
*
|
|
4676
|
+
* @param options
|
|
4677
|
+
* @param makeRequest
|
|
4678
|
+
*/
|
|
4679
|
+
function createTransport(options, makeRequest, buffer) {
|
|
4680
|
+
if (buffer === void 0) { buffer = makePromiseBuffer(options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE); }
|
|
4681
|
+
var rateLimits = {};
|
|
4682
|
+
var flush = function (timeout) { return buffer.drain(timeout); };
|
|
4683
|
+
function send(envelope) {
|
|
4684
|
+
var envCategory = getEnvelopeType(envelope);
|
|
4685
|
+
var category = envCategory === 'event' ? 'error' : envCategory;
|
|
4686
|
+
var request = {
|
|
4687
|
+
category: category,
|
|
4688
|
+
body: serializeEnvelope(envelope),
|
|
4689
|
+
};
|
|
4690
|
+
// Don't add to buffer if transport is already rate-limited
|
|
4691
|
+
if (isRateLimited(rateLimits, category)) {
|
|
4692
|
+
return rejectedSyncPromise({
|
|
4693
|
+
status: 'rate_limit',
|
|
4694
|
+
reason: getRateLimitReason(rateLimits, category),
|
|
4695
|
+
});
|
|
4696
|
+
}
|
|
4697
|
+
var requestTask = function () {
|
|
4698
|
+
return makeRequest(request).then(function (_a) {
|
|
4699
|
+
var body = _a.body, headers = _a.headers, reason = _a.reason, statusCode = _a.statusCode;
|
|
4700
|
+
var status = eventStatusFromHttpCode(statusCode);
|
|
4701
|
+
if (headers) {
|
|
4702
|
+
rateLimits = updateRateLimits(rateLimits, headers);
|
|
4703
|
+
}
|
|
4704
|
+
if (status === 'success') {
|
|
4705
|
+
return resolvedSyncPromise({ status: status, reason: reason });
|
|
4706
|
+
}
|
|
4707
|
+
return rejectedSyncPromise({
|
|
4708
|
+
status: status,
|
|
4709
|
+
reason: reason ||
|
|
4710
|
+
body ||
|
|
4711
|
+
(status === 'rate_limit' ? getRateLimitReason(rateLimits, category) : 'Unknown transport error'),
|
|
4712
|
+
});
|
|
4713
|
+
});
|
|
4714
|
+
};
|
|
4715
|
+
return buffer.add(requestTask);
|
|
4716
|
+
}
|
|
4717
|
+
return {
|
|
4718
|
+
send: send,
|
|
4719
|
+
flush: flush,
|
|
4720
|
+
};
|
|
4721
|
+
}
|
|
4722
|
+
function getRateLimitReason(rateLimits, category) {
|
|
4723
|
+
return "Too many " + category + " requests, backing off until: " + new Date(disabledUntil(rateLimits, category)).toISOString();
|
|
4724
|
+
}
|
|
4725
|
+
|
|
4726
|
+
var SDK_VERSION = '6.19.3';
|
|
4597
4727
|
|
|
4598
4728
|
var originalFunctionToString;
|
|
4599
4729
|
/** Patch toString calls to return proper name for wrapped functions */
|
|
@@ -4643,158 +4773,139 @@ var Sentry = (function (exports) {
|
|
|
4643
4773
|
/**
|
|
4644
4774
|
* @inheritDoc
|
|
4645
4775
|
*/
|
|
4646
|
-
InboundFilters.prototype.setupOnce = function () {
|
|
4776
|
+
InboundFilters.prototype.setupOnce = function (addGlobalEventProcessor, getCurrentHub) {
|
|
4647
4777
|
addGlobalEventProcessor(function (event) {
|
|
4648
4778
|
var hub = getCurrentHub();
|
|
4649
|
-
if (
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
// This checks prevents most of the occurrences of the bug linked below:
|
|
4657
|
-
// https://github.com/getsentry/sentry-javascript/issues/2622
|
|
4658
|
-
// The bug is caused by multiple SDK instances, where one is minified and one is using non-mangled code.
|
|
4659
|
-
// Unfortunatelly we cannot fix it reliably (thus reserved property in rollup's terser config),
|
|
4660
|
-
// as we cannot force people using multiple instances in their apps to sync SDK versions.
|
|
4661
|
-
var options = typeof self._mergeOptions === 'function' ? self._mergeOptions(clientOptions) : {};
|
|
4662
|
-
if (typeof self._shouldDropEvent !== 'function') {
|
|
4663
|
-
return event;
|
|
4779
|
+
if (hub) {
|
|
4780
|
+
var self_1 = hub.getIntegration(InboundFilters);
|
|
4781
|
+
if (self_1) {
|
|
4782
|
+
var client = hub.getClient();
|
|
4783
|
+
var clientOptions = client ? client.getOptions() : {};
|
|
4784
|
+
var options = _mergeOptions(self_1._options, clientOptions);
|
|
4785
|
+
return _shouldDropEvent$1(event, options) ? null : event;
|
|
4664
4786
|
}
|
|
4665
|
-
return self._shouldDropEvent(event, options) ? null : event;
|
|
4666
4787
|
}
|
|
4667
4788
|
return event;
|
|
4668
4789
|
});
|
|
4669
4790
|
};
|
|
4670
|
-
/**
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4791
|
+
/**
|
|
4792
|
+
* @inheritDoc
|
|
4793
|
+
*/
|
|
4794
|
+
InboundFilters.id = 'InboundFilters';
|
|
4795
|
+
return InboundFilters;
|
|
4796
|
+
}());
|
|
4797
|
+
/** JSDoc */
|
|
4798
|
+
function _mergeOptions(internalOptions, clientOptions) {
|
|
4799
|
+
if (internalOptions === void 0) { internalOptions = {}; }
|
|
4800
|
+
if (clientOptions === void 0) { clientOptions = {}; }
|
|
4801
|
+
return {
|
|
4802
|
+
allowUrls: __spread((internalOptions.whitelistUrls || []), (internalOptions.allowUrls || []), (clientOptions.whitelistUrls || []), (clientOptions.allowUrls || [])),
|
|
4803
|
+
denyUrls: __spread((internalOptions.blacklistUrls || []), (internalOptions.denyUrls || []), (clientOptions.blacklistUrls || []), (clientOptions.denyUrls || [])),
|
|
4804
|
+
ignoreErrors: __spread((internalOptions.ignoreErrors || []), (clientOptions.ignoreErrors || []), DEFAULT_IGNORE_ERRORS),
|
|
4805
|
+
ignoreInternal: internalOptions.ignoreInternal !== undefined ? internalOptions.ignoreInternal : true,
|
|
4806
|
+
};
|
|
4807
|
+
}
|
|
4808
|
+
/** JSDoc */
|
|
4809
|
+
function _shouldDropEvent$1(event, options) {
|
|
4810
|
+
if (options.ignoreInternal && _isSentryError(event)) {
|
|
4811
|
+
logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + getEventDescription(event));
|
|
4812
|
+
return true;
|
|
4813
|
+
}
|
|
4814
|
+
if (_isIgnoredError(event, options.ignoreErrors)) {
|
|
4815
|
+
logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + getEventDescription(event));
|
|
4816
|
+
return true;
|
|
4817
|
+
}
|
|
4818
|
+
if (_isDeniedUrl(event, options.denyUrls)) {
|
|
4819
|
+
logger.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + _getEventFilterUrl(event));
|
|
4820
|
+
return true;
|
|
4821
|
+
}
|
|
4822
|
+
if (!_isAllowedUrl(event, options.allowUrls)) {
|
|
4823
|
+
logger.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + _getEventFilterUrl(event));
|
|
4824
|
+
return true;
|
|
4825
|
+
}
|
|
4826
|
+
return false;
|
|
4827
|
+
}
|
|
4828
|
+
function _isIgnoredError(event, ignoreErrors) {
|
|
4829
|
+
if (!ignoreErrors || !ignoreErrors.length) {
|
|
4830
|
+
return false;
|
|
4831
|
+
}
|
|
4832
|
+
return _getPossibleEventMessages(event).some(function (message) {
|
|
4833
|
+
return ignoreErrors.some(function (pattern) { return isMatchingPattern(message, pattern); });
|
|
4834
|
+
});
|
|
4835
|
+
}
|
|
4836
|
+
function _isDeniedUrl(event, denyUrls) {
|
|
4837
|
+
// TODO: Use Glob instead?
|
|
4838
|
+
if (!denyUrls || !denyUrls.length) {
|
|
4839
|
+
return false;
|
|
4840
|
+
}
|
|
4841
|
+
var url = _getEventFilterUrl(event);
|
|
4842
|
+
return !url ? false : denyUrls.some(function (pattern) { return isMatchingPattern(url, pattern); });
|
|
4843
|
+
}
|
|
4844
|
+
function _isAllowedUrl(event, allowUrls) {
|
|
4845
|
+
// TODO: Use Glob instead?
|
|
4846
|
+
if (!allowUrls || !allowUrls.length) {
|
|
4847
|
+
return true;
|
|
4848
|
+
}
|
|
4849
|
+
var url = _getEventFilterUrl(event);
|
|
4850
|
+
return !url ? true : allowUrls.some(function (pattern) { return isMatchingPattern(url, pattern); });
|
|
4851
|
+
}
|
|
4852
|
+
function _getPossibleEventMessages(event) {
|
|
4853
|
+
if (event.message) {
|
|
4854
|
+
return [event.message];
|
|
4855
|
+
}
|
|
4856
|
+
if (event.exception) {
|
|
4857
|
+
try {
|
|
4858
|
+
var _a = (event.exception.values && event.exception.values[0]) || {}, _b = _a.type, type = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c;
|
|
4859
|
+
return ["" + value, type + ": " + value];
|
|
4679
4860
|
}
|
|
4680
|
-
|
|
4681
|
-
logger.
|
|
4682
|
-
return
|
|
4861
|
+
catch (oO) {
|
|
4862
|
+
logger.error("Cannot extract message for event " + getEventDescription(event));
|
|
4863
|
+
return [];
|
|
4683
4864
|
}
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4865
|
+
}
|
|
4866
|
+
return [];
|
|
4867
|
+
}
|
|
4868
|
+
function _isSentryError(event) {
|
|
4869
|
+
try {
|
|
4870
|
+
// @ts-ignore can't be a sentry error if undefined
|
|
4871
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
4872
|
+
return event.exception.values[0].type === 'SentryError';
|
|
4873
|
+
}
|
|
4874
|
+
catch (e) {
|
|
4875
|
+
// ignore
|
|
4876
|
+
}
|
|
4877
|
+
return false;
|
|
4878
|
+
}
|
|
4879
|
+
function _getLastValidUrl(frames) {
|
|
4880
|
+
if (frames === void 0) { frames = []; }
|
|
4881
|
+
for (var i = frames.length - 1; i >= 0; i--) {
|
|
4882
|
+
var frame = frames[i];
|
|
4883
|
+
if (frame && frame.filename !== '<anonymous>' && frame.filename !== '[native code]') {
|
|
4884
|
+
return frame.filename || null;
|
|
4687
4885
|
}
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4886
|
+
}
|
|
4887
|
+
return null;
|
|
4888
|
+
}
|
|
4889
|
+
function _getEventFilterUrl(event) {
|
|
4890
|
+
try {
|
|
4891
|
+
if (event.stacktrace) {
|
|
4892
|
+
return _getLastValidUrl(event.stacktrace.frames);
|
|
4694
4893
|
}
|
|
4894
|
+
var frames_1;
|
|
4695
4895
|
try {
|
|
4696
|
-
// @ts-ignore
|
|
4697
|
-
|
|
4698
|
-
return event.exception.values[0].type === 'SentryError';
|
|
4896
|
+
// @ts-ignore we only care about frames if the whole thing here is defined
|
|
4897
|
+
frames_1 = event.exception.values[0].stacktrace.frames;
|
|
4699
4898
|
}
|
|
4700
4899
|
catch (e) {
|
|
4701
4900
|
// ignore
|
|
4702
4901
|
}
|
|
4703
|
-
return
|
|
4704
|
-
}
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
if (!options.ignoreErrors || !options.ignoreErrors.length) {
|
|
4708
|
-
return false;
|
|
4709
|
-
}
|
|
4710
|
-
return this._getPossibleEventMessages(event).some(function (message) {
|
|
4711
|
-
// Not sure why TypeScript complains here...
|
|
4712
|
-
return options.ignoreErrors.some(function (pattern) { return isMatchingPattern(message, pattern); });
|
|
4713
|
-
});
|
|
4714
|
-
};
|
|
4715
|
-
/** JSDoc */
|
|
4716
|
-
InboundFilters.prototype._isDeniedUrl = function (event, options) {
|
|
4717
|
-
// TODO: Use Glob instead?
|
|
4718
|
-
if (!options.denyUrls || !options.denyUrls.length) {
|
|
4719
|
-
return false;
|
|
4720
|
-
}
|
|
4721
|
-
var url = this._getEventFilterUrl(event);
|
|
4722
|
-
return !url ? false : options.denyUrls.some(function (pattern) { return isMatchingPattern(url, pattern); });
|
|
4723
|
-
};
|
|
4724
|
-
/** JSDoc */
|
|
4725
|
-
InboundFilters.prototype._isAllowedUrl = function (event, options) {
|
|
4726
|
-
// TODO: Use Glob instead?
|
|
4727
|
-
if (!options.allowUrls || !options.allowUrls.length) {
|
|
4728
|
-
return true;
|
|
4729
|
-
}
|
|
4730
|
-
var url = this._getEventFilterUrl(event);
|
|
4731
|
-
return !url ? true : options.allowUrls.some(function (pattern) { return isMatchingPattern(url, pattern); });
|
|
4732
|
-
};
|
|
4733
|
-
/** JSDoc */
|
|
4734
|
-
InboundFilters.prototype._mergeOptions = function (clientOptions) {
|
|
4735
|
-
if (clientOptions === void 0) { clientOptions = {}; }
|
|
4736
|
-
return {
|
|
4737
|
-
allowUrls: __spread((this._options.whitelistUrls || []), (this._options.allowUrls || []), (clientOptions.whitelistUrls || []), (clientOptions.allowUrls || [])),
|
|
4738
|
-
denyUrls: __spread((this._options.blacklistUrls || []), (this._options.denyUrls || []), (clientOptions.blacklistUrls || []), (clientOptions.denyUrls || [])),
|
|
4739
|
-
ignoreErrors: __spread((this._options.ignoreErrors || []), (clientOptions.ignoreErrors || []), DEFAULT_IGNORE_ERRORS),
|
|
4740
|
-
ignoreInternal: typeof this._options.ignoreInternal !== 'undefined' ? this._options.ignoreInternal : true,
|
|
4741
|
-
};
|
|
4742
|
-
};
|
|
4743
|
-
/** JSDoc */
|
|
4744
|
-
InboundFilters.prototype._getPossibleEventMessages = function (event) {
|
|
4745
|
-
if (event.message) {
|
|
4746
|
-
return [event.message];
|
|
4747
|
-
}
|
|
4748
|
-
if (event.exception) {
|
|
4749
|
-
try {
|
|
4750
|
-
var _a = (event.exception.values && event.exception.values[0]) || {}, _b = _a.type, type = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c;
|
|
4751
|
-
return ["" + value, type + ": " + value];
|
|
4752
|
-
}
|
|
4753
|
-
catch (oO) {
|
|
4754
|
-
logger.error("Cannot extract message for event " + getEventDescription(event));
|
|
4755
|
-
return [];
|
|
4756
|
-
}
|
|
4757
|
-
}
|
|
4758
|
-
return [];
|
|
4759
|
-
};
|
|
4760
|
-
/** JSDoc */
|
|
4761
|
-
InboundFilters.prototype._getLastValidUrl = function (frames) {
|
|
4762
|
-
if (frames === void 0) { frames = []; }
|
|
4763
|
-
for (var i = frames.length - 1; i >= 0; i--) {
|
|
4764
|
-
var frame = frames[i];
|
|
4765
|
-
if (frame && frame.filename !== '<anonymous>' && frame.filename !== '[native code]') {
|
|
4766
|
-
return frame.filename || null;
|
|
4767
|
-
}
|
|
4768
|
-
}
|
|
4902
|
+
return frames_1 ? _getLastValidUrl(frames_1) : null;
|
|
4903
|
+
}
|
|
4904
|
+
catch (oO) {
|
|
4905
|
+
logger.error("Cannot extract url for event " + getEventDescription(event));
|
|
4769
4906
|
return null;
|
|
4770
|
-
}
|
|
4771
|
-
|
|
4772
|
-
InboundFilters.prototype._getEventFilterUrl = function (event) {
|
|
4773
|
-
try {
|
|
4774
|
-
if (event.stacktrace) {
|
|
4775
|
-
return this._getLastValidUrl(event.stacktrace.frames);
|
|
4776
|
-
}
|
|
4777
|
-
var frames_1;
|
|
4778
|
-
try {
|
|
4779
|
-
// @ts-ignore we only care about frames if the whole thing here is defined
|
|
4780
|
-
frames_1 = event.exception.values[0].stacktrace.frames;
|
|
4781
|
-
}
|
|
4782
|
-
catch (e) {
|
|
4783
|
-
// ignore
|
|
4784
|
-
}
|
|
4785
|
-
return frames_1 ? this._getLastValidUrl(frames_1) : null;
|
|
4786
|
-
}
|
|
4787
|
-
catch (oO) {
|
|
4788
|
-
logger.error("Cannot extract url for event " + getEventDescription(event));
|
|
4789
|
-
return null;
|
|
4790
|
-
}
|
|
4791
|
-
};
|
|
4792
|
-
/**
|
|
4793
|
-
* @inheritDoc
|
|
4794
|
-
*/
|
|
4795
|
-
InboundFilters.id = 'InboundFilters';
|
|
4796
|
-
return InboundFilters;
|
|
4797
|
-
}());
|
|
4907
|
+
}
|
|
4908
|
+
}
|
|
4798
4909
|
|
|
4799
4910
|
var CoreIntegrations = /*#__PURE__*/Object.freeze({
|
|
4800
4911
|
__proto__: null,
|
|
@@ -5495,11 +5606,77 @@ var Sentry = (function (exports) {
|
|
|
5495
5606
|
return XHRTransport;
|
|
5496
5607
|
}(BaseTransport));
|
|
5497
5608
|
|
|
5609
|
+
/**
|
|
5610
|
+
* Creates a Transport that uses the Fetch API to send events to Sentry.
|
|
5611
|
+
*/
|
|
5612
|
+
function makeNewFetchTransport(options, nativeFetch) {
|
|
5613
|
+
if (nativeFetch === void 0) { nativeFetch = getNativeFetchImplementation(); }
|
|
5614
|
+
function makeRequest(request) {
|
|
5615
|
+
var requestOptions = __assign({ body: request.body, method: 'POST', referrerPolicy: 'origin' }, options.requestOptions);
|
|
5616
|
+
return nativeFetch(options.url, requestOptions).then(function (response) {
|
|
5617
|
+
return response.text().then(function (body) { return ({
|
|
5618
|
+
body: body,
|
|
5619
|
+
headers: {
|
|
5620
|
+
'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),
|
|
5621
|
+
'retry-after': response.headers.get('Retry-After'),
|
|
5622
|
+
},
|
|
5623
|
+
reason: response.statusText,
|
|
5624
|
+
statusCode: response.status,
|
|
5625
|
+
}); });
|
|
5626
|
+
});
|
|
5627
|
+
}
|
|
5628
|
+
return createTransport({ bufferSize: options.bufferSize }, makeRequest);
|
|
5629
|
+
}
|
|
5630
|
+
|
|
5631
|
+
/**
|
|
5632
|
+
* The DONE ready state for XmlHttpRequest
|
|
5633
|
+
*
|
|
5634
|
+
* Defining it here as a constant b/c XMLHttpRequest.DONE is not always defined
|
|
5635
|
+
* (e.g. during testing, it is `undefined`)
|
|
5636
|
+
*
|
|
5637
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState}
|
|
5638
|
+
*/
|
|
5639
|
+
var XHR_READYSTATE_DONE = 4;
|
|
5640
|
+
/**
|
|
5641
|
+
* Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.
|
|
5642
|
+
*/
|
|
5643
|
+
function makeNewXHRTransport(options) {
|
|
5644
|
+
function makeRequest(request) {
|
|
5645
|
+
return new SyncPromise(function (resolve, _reject) {
|
|
5646
|
+
var xhr = new XMLHttpRequest();
|
|
5647
|
+
xhr.onreadystatechange = function () {
|
|
5648
|
+
if (xhr.readyState === XHR_READYSTATE_DONE) {
|
|
5649
|
+
var response = {
|
|
5650
|
+
body: xhr.response,
|
|
5651
|
+
headers: {
|
|
5652
|
+
'x-sentry-rate-limits': xhr.getResponseHeader('X-Sentry-Rate-Limits'),
|
|
5653
|
+
'retry-after': xhr.getResponseHeader('Retry-After'),
|
|
5654
|
+
},
|
|
5655
|
+
reason: xhr.statusText,
|
|
5656
|
+
statusCode: xhr.status,
|
|
5657
|
+
};
|
|
5658
|
+
resolve(response);
|
|
5659
|
+
}
|
|
5660
|
+
};
|
|
5661
|
+
xhr.open('POST', options.url);
|
|
5662
|
+
for (var header in options.headers) {
|
|
5663
|
+
if (Object.prototype.hasOwnProperty.call(options.headers, header)) {
|
|
5664
|
+
xhr.setRequestHeader(header, options.headers[header]);
|
|
5665
|
+
}
|
|
5666
|
+
}
|
|
5667
|
+
xhr.send(request.body);
|
|
5668
|
+
});
|
|
5669
|
+
}
|
|
5670
|
+
return createTransport({ bufferSize: options.bufferSize }, makeRequest);
|
|
5671
|
+
}
|
|
5672
|
+
|
|
5498
5673
|
var index = /*#__PURE__*/Object.freeze({
|
|
5499
5674
|
__proto__: null,
|
|
5500
5675
|
BaseTransport: BaseTransport,
|
|
5501
5676
|
FetchTransport: FetchTransport,
|
|
5502
|
-
XHRTransport: XHRTransport
|
|
5677
|
+
XHRTransport: XHRTransport,
|
|
5678
|
+
makeNewFetchTransport: makeNewFetchTransport,
|
|
5679
|
+
makeNewXHRTransport: makeNewXHRTransport
|
|
5503
5680
|
});
|
|
5504
5681
|
|
|
5505
5682
|
/**
|
|
@@ -5533,12 +5710,20 @@ var Sentry = (function (exports) {
|
|
|
5533
5710
|
return _super.prototype._setupTransport.call(this);
|
|
5534
5711
|
}
|
|
5535
5712
|
var transportOptions = __assign(__assign({}, this._options.transportOptions), { dsn: this._options.dsn, tunnel: this._options.tunnel, sendClientReports: this._options.sendClientReports, _metadata: this._options._metadata });
|
|
5713
|
+
var api = initAPIDetails(transportOptions.dsn, transportOptions._metadata, transportOptions.tunnel);
|
|
5714
|
+
var url = getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel);
|
|
5536
5715
|
if (this._options.transport) {
|
|
5537
5716
|
return new this._options.transport(transportOptions);
|
|
5538
5717
|
}
|
|
5539
5718
|
if (supportsFetch()) {
|
|
5719
|
+
var requestOptions = __assign({}, transportOptions.fetchParameters);
|
|
5720
|
+
this._newTransport = makeNewFetchTransport({ requestOptions: requestOptions, url: url });
|
|
5540
5721
|
return new FetchTransport(transportOptions);
|
|
5541
5722
|
}
|
|
5723
|
+
this._newTransport = makeNewXHRTransport({
|
|
5724
|
+
url: url,
|
|
5725
|
+
headers: transportOptions.headers,
|
|
5726
|
+
});
|
|
5542
5727
|
return new XHRTransport(transportOptions);
|
|
5543
5728
|
};
|
|
5544
5729
|
return BrowserBackend;
|