@sentry/browser 6.19.1 → 6.19.4
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 +748 -586
- 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 +777 -608
- 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/base.js +1 -1
- package/dist/transports/base.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/base.js +1 -1
- package/esm/transports/base.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 +8 -8
- 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.4 (261f2e4) | https://github.com/getsentry/sentry-javascript */
|
|
2
2
|
var Sentry = (function (exports) {
|
|
3
3
|
|
|
4
4
|
/*! *****************************************************************************
|
|
@@ -113,22 +113,6 @@ var Sentry = (function (exports) {
|
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
/**
|
|
117
|
-
* This module exists for optimizations in the build process through rollup and terser. We define some global
|
|
118
|
-
* constants, which can be overridden during build. By guarding certain pieces of code with functions that return these
|
|
119
|
-
* constants, we can control whether or not they appear in the final bundle. (Any code guarded by a false condition will
|
|
120
|
-
* never run, and will hence be dropped during treeshaking.) The two primary uses for this are stripping out calls to
|
|
121
|
-
* `logger` and preventing node-related code from appearing in browser bundles.
|
|
122
|
-
*/
|
|
123
|
-
/**
|
|
124
|
-
* Figures out if we're building with debug functionality.
|
|
125
|
-
*
|
|
126
|
-
* @returns true if this is a debug build
|
|
127
|
-
*/
|
|
128
|
-
function isDebugBuild() {
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
116
|
/**
|
|
133
117
|
* NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
|
|
134
118
|
* you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
|
|
@@ -279,6 +263,16 @@ var Sentry = (function (exports) {
|
|
|
279
263
|
function isSyntheticEvent(wat) {
|
|
280
264
|
return isPlainObject(wat) && 'nativeEvent' in wat && 'preventDefault' in wat && 'stopPropagation' in wat;
|
|
281
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Checks whether given value is NaN
|
|
268
|
+
* {@link isNaN}.
|
|
269
|
+
*
|
|
270
|
+
* @param wat A value to be checked.
|
|
271
|
+
* @returns A boolean representing the result.
|
|
272
|
+
*/
|
|
273
|
+
function isNaN$1(wat) {
|
|
274
|
+
return typeof wat === 'number' && wat !== wat;
|
|
275
|
+
}
|
|
282
276
|
/**
|
|
283
277
|
* Checks whether given value's type is an instance of provided constructor.
|
|
284
278
|
* {@link isInstanceOf}.
|
|
@@ -624,140 +618,6 @@ var Sentry = (function (exports) {
|
|
|
624
618
|
global$6.__SENTRY__ = sentryGlobal;
|
|
625
619
|
}
|
|
626
620
|
|
|
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
621
|
/**
|
|
762
622
|
* Truncates given string to the maximum characters count
|
|
763
623
|
*
|
|
@@ -898,242 +758,38 @@ var Sentry = (function (exports) {
|
|
|
898
758
|
*
|
|
899
759
|
* @param value Initial source that we have to transform in order for it to be usable by the serializer
|
|
900
760
|
*/
|
|
901
|
-
function
|
|
761
|
+
function convertToPlainObject(value) {
|
|
762
|
+
var newObj = value;
|
|
902
763
|
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;
|
|
764
|
+
newObj = __assign({ message: value.message, name: value.name, stack: value.stack }, getOwnProperties(value));
|
|
915
765
|
}
|
|
916
|
-
if (isEvent(value)) {
|
|
766
|
+
else if (isEvent(value)) {
|
|
917
767
|
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
|
-
}
|
|
768
|
+
newObj = __assign({ type: event_1.type, target: serializeEventTarget(event_1.target), currentTarget: serializeEventTarget(event_1.currentTarget) }, getOwnProperties(event_1));
|
|
939
769
|
if (typeof CustomEvent !== 'undefined' && isInstanceOf(value, CustomEvent)) {
|
|
940
|
-
|
|
770
|
+
newObj.detail = event_1.detail;
|
|
941
771
|
}
|
|
942
|
-
for (var attr in event_1) {
|
|
943
|
-
if (Object.prototype.hasOwnProperty.call(event_1, attr)) {
|
|
944
|
-
source[attr] = event_1[attr];
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
return source;
|
|
948
772
|
}
|
|
949
|
-
return
|
|
773
|
+
return newObj;
|
|
950
774
|
}
|
|
951
|
-
/**
|
|
952
|
-
function
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
}
|
|
956
|
-
/** Calculates bytes size of input object */
|
|
957
|
-
function jsonSize(value) {
|
|
958
|
-
return utf8Length(JSON.stringify(value));
|
|
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) + "]";
|
|
775
|
+
/** Creates a string representation of the target of an `Event` object */
|
|
776
|
+
function serializeEventTarget(target) {
|
|
777
|
+
try {
|
|
778
|
+
return isElement(target) ? htmlTreeAsString(target) : Object.prototype.toString.call(target);
|
|
1043
779
|
}
|
|
1044
|
-
|
|
1045
|
-
return
|
|
780
|
+
catch (_oO) {
|
|
781
|
+
return '<unknown>';
|
|
1046
782
|
}
|
|
1047
|
-
return value;
|
|
1048
783
|
}
|
|
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;
|
|
784
|
+
/** Filters out all but an object's own properties */
|
|
785
|
+
function getOwnProperties(obj) {
|
|
786
|
+
var extractedProps = {};
|
|
787
|
+
for (var property in obj) {
|
|
788
|
+
if (Object.prototype.hasOwnProperty.call(obj, property)) {
|
|
789
|
+
extractedProps[property] = obj[property];
|
|
1093
790
|
}
|
|
1094
|
-
if (propertyCount >= maxProperties) {
|
|
1095
|
-
acc[innerKey] = '[MaxProperties ~]';
|
|
1096
|
-
break;
|
|
1097
|
-
}
|
|
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
791
|
}
|
|
792
|
+
return extractedProps;
|
|
1137
793
|
}
|
|
1138
794
|
/**
|
|
1139
795
|
* Given any captured exception, extract its keys and create a sorted
|
|
@@ -1143,7 +799,7 @@ var Sentry = (function (exports) {
|
|
|
1143
799
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1144
800
|
function extractExceptionKeysForMessage(exception, maxLength) {
|
|
1145
801
|
if (maxLength === void 0) { maxLength = 40; }
|
|
1146
|
-
var keys = Object.keys(
|
|
802
|
+
var keys = Object.keys(convertToPlainObject(exception));
|
|
1147
803
|
keys.sort();
|
|
1148
804
|
if (!keys.length) {
|
|
1149
805
|
return '[object has no keys]';
|
|
@@ -1170,13 +826,12 @@ var Sentry = (function (exports) {
|
|
|
1170
826
|
function dropUndefinedKeys(val) {
|
|
1171
827
|
var e_1, _a;
|
|
1172
828
|
if (isPlainObject(val)) {
|
|
1173
|
-
var obj = val;
|
|
1174
829
|
var rv = {};
|
|
1175
830
|
try {
|
|
1176
|
-
for (var _b = __values(Object.keys(
|
|
831
|
+
for (var _b = __values(Object.keys(val)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1177
832
|
var key = _c.value;
|
|
1178
|
-
if (typeof
|
|
1179
|
-
rv[key] = dropUndefinedKeys(
|
|
833
|
+
if (typeof val[key] !== 'undefined') {
|
|
834
|
+
rv[key] = dropUndefinedKeys(val[key]);
|
|
1180
835
|
}
|
|
1181
836
|
}
|
|
1182
837
|
}
|
|
@@ -1187,12 +842,104 @@ var Sentry = (function (exports) {
|
|
|
1187
842
|
}
|
|
1188
843
|
finally { if (e_1) throw e_1.error; }
|
|
1189
844
|
}
|
|
1190
|
-
return rv;
|
|
845
|
+
return rv;
|
|
846
|
+
}
|
|
847
|
+
if (Array.isArray(val)) {
|
|
848
|
+
return val.map(dropUndefinedKeys);
|
|
849
|
+
}
|
|
850
|
+
return val;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
var STACKTRACE_LIMIT = 50;
|
|
854
|
+
/**
|
|
855
|
+
* Creates a stack parser with the supplied line parsers
|
|
856
|
+
*
|
|
857
|
+
* StackFrames are returned in the correct order for Sentry Exception
|
|
858
|
+
* frames and with Sentry SDK internal frames removed from the top and bottom
|
|
859
|
+
*
|
|
860
|
+
*/
|
|
861
|
+
function createStackParser() {
|
|
862
|
+
var parsers = [];
|
|
863
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
864
|
+
parsers[_i] = arguments[_i];
|
|
865
|
+
}
|
|
866
|
+
var sortedParsers = parsers.sort(function (a, b) { return a[0] - b[0]; }).map(function (p) { return p[1]; });
|
|
867
|
+
return function (stack, skipFirst) {
|
|
868
|
+
var e_1, _a, e_2, _b;
|
|
869
|
+
if (skipFirst === void 0) { skipFirst = 0; }
|
|
870
|
+
var frames = [];
|
|
871
|
+
try {
|
|
872
|
+
for (var _c = __values(stack.split('\n').slice(skipFirst)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
873
|
+
var line = _d.value;
|
|
874
|
+
try {
|
|
875
|
+
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()) {
|
|
876
|
+
var parser = sortedParsers_1_1.value;
|
|
877
|
+
var frame = parser(line);
|
|
878
|
+
if (frame) {
|
|
879
|
+
frames.push(frame);
|
|
880
|
+
break;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
885
|
+
finally {
|
|
886
|
+
try {
|
|
887
|
+
if (sortedParsers_1_1 && !sortedParsers_1_1.done && (_b = sortedParsers_1.return)) _b.call(sortedParsers_1);
|
|
888
|
+
}
|
|
889
|
+
finally { if (e_2) throw e_2.error; }
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
894
|
+
finally {
|
|
895
|
+
try {
|
|
896
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
897
|
+
}
|
|
898
|
+
finally { if (e_1) throw e_1.error; }
|
|
899
|
+
}
|
|
900
|
+
return stripSentryFramesAndReverse(frames);
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* @hidden
|
|
905
|
+
*/
|
|
906
|
+
function stripSentryFramesAndReverse(stack) {
|
|
907
|
+
if (!stack.length) {
|
|
908
|
+
return [];
|
|
909
|
+
}
|
|
910
|
+
var localStack = stack;
|
|
911
|
+
var firstFrameFunction = localStack[0].function || '';
|
|
912
|
+
var lastFrameFunction = localStack[localStack.length - 1].function || '';
|
|
913
|
+
// If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
|
|
914
|
+
if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
|
|
915
|
+
localStack = localStack.slice(1);
|
|
916
|
+
}
|
|
917
|
+
// 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)
|
|
918
|
+
if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
|
|
919
|
+
localStack = localStack.slice(0, -1);
|
|
920
|
+
}
|
|
921
|
+
// The frame where the crash happened, should be the last entry in the array
|
|
922
|
+
return localStack
|
|
923
|
+
.slice(0, STACKTRACE_LIMIT)
|
|
924
|
+
.map(function (frame) { return (__assign(__assign({}, frame), { filename: frame.filename || localStack[0].filename, function: frame.function || '?' })); })
|
|
925
|
+
.reverse();
|
|
926
|
+
}
|
|
927
|
+
var defaultFunctionName = '<anonymous>';
|
|
928
|
+
/**
|
|
929
|
+
* Safely extract function name from itself
|
|
930
|
+
*/
|
|
931
|
+
function getFunctionName(fn) {
|
|
932
|
+
try {
|
|
933
|
+
if (!fn || typeof fn !== 'function') {
|
|
934
|
+
return defaultFunctionName;
|
|
935
|
+
}
|
|
936
|
+
return fn.name || defaultFunctionName;
|
|
1191
937
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
938
|
+
catch (e) {
|
|
939
|
+
// Just accessing custom props in some Selenium environments
|
|
940
|
+
// can cause a "Permission denied" exception (see raven-js#495).
|
|
941
|
+
return defaultFunctionName;
|
|
1194
942
|
}
|
|
1195
|
-
return val;
|
|
1196
943
|
}
|
|
1197
944
|
|
|
1198
945
|
/**
|
|
@@ -1819,6 +1566,48 @@ var Sentry = (function (exports) {
|
|
|
1819
1566
|
};
|
|
1820
1567
|
}
|
|
1821
1568
|
|
|
1569
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
1570
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1571
|
+
/**
|
|
1572
|
+
* Helper to decycle json objects
|
|
1573
|
+
*/
|
|
1574
|
+
function memoBuilder() {
|
|
1575
|
+
var hasWeakSet = typeof WeakSet === 'function';
|
|
1576
|
+
var inner = hasWeakSet ? new WeakSet() : [];
|
|
1577
|
+
function memoize(obj) {
|
|
1578
|
+
if (hasWeakSet) {
|
|
1579
|
+
if (inner.has(obj)) {
|
|
1580
|
+
return true;
|
|
1581
|
+
}
|
|
1582
|
+
inner.add(obj);
|
|
1583
|
+
return false;
|
|
1584
|
+
}
|
|
1585
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
1586
|
+
for (var i = 0; i < inner.length; i++) {
|
|
1587
|
+
var value = inner[i];
|
|
1588
|
+
if (value === obj) {
|
|
1589
|
+
return true;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
inner.push(obj);
|
|
1593
|
+
return false;
|
|
1594
|
+
}
|
|
1595
|
+
function unmemoize(obj) {
|
|
1596
|
+
if (hasWeakSet) {
|
|
1597
|
+
inner.delete(obj);
|
|
1598
|
+
}
|
|
1599
|
+
else {
|
|
1600
|
+
for (var i = 0; i < inner.length; i++) {
|
|
1601
|
+
if (inner[i] === obj) {
|
|
1602
|
+
inner.splice(i, 1);
|
|
1603
|
+
break;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
return [memoize, unmemoize];
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1822
1611
|
/**
|
|
1823
1612
|
* UUID4 generator
|
|
1824
1613
|
*
|
|
@@ -1976,6 +1765,194 @@ var Sentry = (function (exports) {
|
|
|
1976
1765
|
return false;
|
|
1977
1766
|
}
|
|
1978
1767
|
|
|
1768
|
+
/**
|
|
1769
|
+
* Recursively normalizes the given object.
|
|
1770
|
+
*
|
|
1771
|
+
* - Creates a copy to prevent original input mutation
|
|
1772
|
+
* - Skips non-enumerable properties
|
|
1773
|
+
* - When stringifying, calls `toJSON` if implemented
|
|
1774
|
+
* - Removes circular references
|
|
1775
|
+
* - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format
|
|
1776
|
+
* - Translates known global objects/classes to a string representations
|
|
1777
|
+
* - Takes care of `Error` object serialization
|
|
1778
|
+
* - Optionally limits depth of final output
|
|
1779
|
+
* - Optionally limits number of properties/elements included in any single object/array
|
|
1780
|
+
*
|
|
1781
|
+
* @param input The object to be normalized.
|
|
1782
|
+
* @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)
|
|
1783
|
+
* @param maxProperties The max number of elements or properties to be included in any single array or
|
|
1784
|
+
* object in the normallized output..
|
|
1785
|
+
* @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
|
|
1786
|
+
*/
|
|
1787
|
+
function normalize(input, depth, maxProperties) {
|
|
1788
|
+
if (depth === void 0) { depth = +Infinity; }
|
|
1789
|
+
if (maxProperties === void 0) { maxProperties = +Infinity; }
|
|
1790
|
+
try {
|
|
1791
|
+
// since we're at the outermost level, there is no key
|
|
1792
|
+
return visit('', input, depth, maxProperties);
|
|
1793
|
+
}
|
|
1794
|
+
catch (err) {
|
|
1795
|
+
return { ERROR: "**non-serializable** (" + err + ")" };
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
/** JSDoc */
|
|
1799
|
+
function normalizeToSize(object,
|
|
1800
|
+
// Default Node.js REPL depth
|
|
1801
|
+
depth,
|
|
1802
|
+
// 100kB, as 200kB is max payload size, so half sounds reasonable
|
|
1803
|
+
maxSize) {
|
|
1804
|
+
if (depth === void 0) { depth = 3; }
|
|
1805
|
+
if (maxSize === void 0) { maxSize = 100 * 1024; }
|
|
1806
|
+
var normalized = normalize(object, depth);
|
|
1807
|
+
if (jsonSize(normalized) > maxSize) {
|
|
1808
|
+
return normalizeToSize(object, depth - 1, maxSize);
|
|
1809
|
+
}
|
|
1810
|
+
return normalized;
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Visits a node to perform normalization on it
|
|
1814
|
+
*
|
|
1815
|
+
* @param key The key corresponding to the given node
|
|
1816
|
+
* @param value The node to be visited
|
|
1817
|
+
* @param depth Optional number indicating the maximum recursion depth
|
|
1818
|
+
* @param maxProperties Optional maximum number of properties/elements included in any single object/array
|
|
1819
|
+
* @param memo Optional Memo class handling decycling
|
|
1820
|
+
*/
|
|
1821
|
+
function visit(key, value, depth, maxProperties, memo) {
|
|
1822
|
+
if (depth === void 0) { depth = +Infinity; }
|
|
1823
|
+
if (maxProperties === void 0) { maxProperties = +Infinity; }
|
|
1824
|
+
if (memo === void 0) { memo = memoBuilder(); }
|
|
1825
|
+
var _a = __read(memo, 2), memoize = _a[0], unmemoize = _a[1];
|
|
1826
|
+
// If the value has a `toJSON` method, see if we can bail and let it do the work
|
|
1827
|
+
var valueWithToJSON = value;
|
|
1828
|
+
if (valueWithToJSON && typeof valueWithToJSON.toJSON === 'function') {
|
|
1829
|
+
try {
|
|
1830
|
+
return valueWithToJSON.toJSON();
|
|
1831
|
+
}
|
|
1832
|
+
catch (err) {
|
|
1833
|
+
// pass (The built-in `toJSON` failed, but we can still try to do it ourselves)
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
// Get the simple cases out of the way first
|
|
1837
|
+
if (value === null || (['number', 'boolean', 'string'].includes(typeof value) && !isNaN$1(value))) {
|
|
1838
|
+
return value;
|
|
1839
|
+
}
|
|
1840
|
+
var stringified = stringifyValue(key, value);
|
|
1841
|
+
// Anything we could potentially dig into more (objects or arrays) will have come back as `"[object XXXX]"`.
|
|
1842
|
+
// Everything else will have already been serialized, so if we don't see that pattern, we're done.
|
|
1843
|
+
if (!stringified.startsWith('[object ')) {
|
|
1844
|
+
return stringified;
|
|
1845
|
+
}
|
|
1846
|
+
// We're also done if we've reached the max depth
|
|
1847
|
+
if (depth === 0) {
|
|
1848
|
+
// At this point we know `serialized` is a string of the form `"[object XXXX]"`. Clean it up so it's just `"[XXXX]"`.
|
|
1849
|
+
return stringified.replace('object ', '');
|
|
1850
|
+
}
|
|
1851
|
+
// If we've already visited this branch, bail out, as it's circular reference. If not, note that we're seeing it now.
|
|
1852
|
+
if (memoize(value)) {
|
|
1853
|
+
return '[Circular ~]';
|
|
1854
|
+
}
|
|
1855
|
+
// 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
|
|
1856
|
+
// because we haven't yet reached the max depth. Create an accumulator to hold the results of visiting each
|
|
1857
|
+
// property/entry, and keep track of the number of items we add to it.
|
|
1858
|
+
var normalized = (Array.isArray(value) ? [] : {});
|
|
1859
|
+
var numAdded = 0;
|
|
1860
|
+
// Before we begin, convert`Error` and`Event` instances into plain objects, since some of each of their relevant
|
|
1861
|
+
// properties are non-enumerable and otherwise would get missed.
|
|
1862
|
+
var visitable = (isError(value) || isEvent(value) ? convertToPlainObject(value) : value);
|
|
1863
|
+
for (var visitKey in visitable) {
|
|
1864
|
+
// Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
|
|
1865
|
+
if (!Object.prototype.hasOwnProperty.call(visitable, visitKey)) {
|
|
1866
|
+
continue;
|
|
1867
|
+
}
|
|
1868
|
+
if (numAdded >= maxProperties) {
|
|
1869
|
+
normalized[visitKey] = '[MaxProperties ~]';
|
|
1870
|
+
break;
|
|
1871
|
+
}
|
|
1872
|
+
// Recursively visit all the child nodes
|
|
1873
|
+
var visitValue = visitable[visitKey];
|
|
1874
|
+
normalized[visitKey] = visit(visitKey, visitValue, depth - 1, maxProperties, memo);
|
|
1875
|
+
numAdded += 1;
|
|
1876
|
+
}
|
|
1877
|
+
// Once we've visited all the branches, remove the parent from memo storage
|
|
1878
|
+
unmemoize(value);
|
|
1879
|
+
// Return accumulated values
|
|
1880
|
+
return normalized;
|
|
1881
|
+
}
|
|
1882
|
+
/**
|
|
1883
|
+
* Stringify the given value. Handles various known special values and types.
|
|
1884
|
+
*
|
|
1885
|
+
* Not meant to be used on simple primitives which already have a string representation, as it will, for example, turn
|
|
1886
|
+
* the number 1231 into "[Object Number]", nor on `null`, as it will throw.
|
|
1887
|
+
*
|
|
1888
|
+
* @param value The value to stringify
|
|
1889
|
+
* @returns A stringified representation of the given value
|
|
1890
|
+
*/
|
|
1891
|
+
function stringifyValue(key,
|
|
1892
|
+
// this type is a tiny bit of a cheat, since this function does handle NaN (which is technically a number), but for
|
|
1893
|
+
// our internal use, it'll do
|
|
1894
|
+
value) {
|
|
1895
|
+
try {
|
|
1896
|
+
if (key === 'domain' && value && typeof value === 'object' && value._events) {
|
|
1897
|
+
return '[Domain]';
|
|
1898
|
+
}
|
|
1899
|
+
if (key === 'domainEmitter') {
|
|
1900
|
+
return '[DomainEmitter]';
|
|
1901
|
+
}
|
|
1902
|
+
// It's safe to use `global`, `window`, and `document` here in this manner, as we are asserting using `typeof` first
|
|
1903
|
+
// which won't throw if they are not present.
|
|
1904
|
+
if (typeof global !== 'undefined' && value === global) {
|
|
1905
|
+
return '[Global]';
|
|
1906
|
+
}
|
|
1907
|
+
// eslint-disable-next-line no-restricted-globals
|
|
1908
|
+
if (typeof window !== 'undefined' && value === window) {
|
|
1909
|
+
return '[Window]';
|
|
1910
|
+
}
|
|
1911
|
+
// eslint-disable-next-line no-restricted-globals
|
|
1912
|
+
if (typeof document !== 'undefined' && value === document) {
|
|
1913
|
+
return '[Document]';
|
|
1914
|
+
}
|
|
1915
|
+
// React's SyntheticEvent thingy
|
|
1916
|
+
if (isSyntheticEvent(value)) {
|
|
1917
|
+
return '[SyntheticEvent]';
|
|
1918
|
+
}
|
|
1919
|
+
if (typeof value === 'number' && value !== value) {
|
|
1920
|
+
return '[NaN]';
|
|
1921
|
+
}
|
|
1922
|
+
// this catches `undefined` (but not `null`, which is a primitive and can be serialized on its own)
|
|
1923
|
+
if (value === void 0) {
|
|
1924
|
+
return '[undefined]';
|
|
1925
|
+
}
|
|
1926
|
+
if (typeof value === 'function') {
|
|
1927
|
+
return "[Function: " + getFunctionName(value) + "]";
|
|
1928
|
+
}
|
|
1929
|
+
if (typeof value === 'symbol') {
|
|
1930
|
+
return "[" + String(value) + "]";
|
|
1931
|
+
}
|
|
1932
|
+
// stringified BigInts are indistinguishable from regular numbers, so we need to label them to avoid confusion
|
|
1933
|
+
if (typeof value === 'bigint') {
|
|
1934
|
+
return "[BigInt: " + String(value) + "]";
|
|
1935
|
+
}
|
|
1936
|
+
// Now that we've knocked out all the special cases and the primitives, all we have left are objects. Simply casting
|
|
1937
|
+
// them to strings means that instances of classes which haven't defined their `toStringTag` will just come out as
|
|
1938
|
+
// `"[object Object]"`. If we instead look at the constructor's name (which is the same as the name of the class),
|
|
1939
|
+
// we can make sure that only plain objects come out that way.
|
|
1940
|
+
return "[object " + Object.getPrototypeOf(value).constructor.name + "]";
|
|
1941
|
+
}
|
|
1942
|
+
catch (err) {
|
|
1943
|
+
return "**non-serializable** (" + err + ")";
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
/** Calculates bytes size of input string */
|
|
1947
|
+
function utf8Length(value) {
|
|
1948
|
+
// eslint-disable-next-line no-bitwise
|
|
1949
|
+
return ~-encodeURI(value).split(/%..|./).length;
|
|
1950
|
+
}
|
|
1951
|
+
/** Calculates bytes size of input object */
|
|
1952
|
+
function jsonSize(value) {
|
|
1953
|
+
return utf8Length(JSON.stringify(value));
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1979
1956
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1980
1957
|
/**
|
|
1981
1958
|
* Creates a resolved sync promise.
|
|
@@ -2383,6 +2360,13 @@ var Sentry = (function (exports) {
|
|
|
2383
2360
|
if (items === void 0) { items = []; }
|
|
2384
2361
|
return [headers, items];
|
|
2385
2362
|
}
|
|
2363
|
+
/**
|
|
2364
|
+
* Get the type of the envelope. Grabs the type from the first envelope item.
|
|
2365
|
+
*/
|
|
2366
|
+
function getEnvelopeType(envelope) {
|
|
2367
|
+
var _a = __read(envelope, 2), _b = __read(_a[1], 1), _c = __read(_b[0], 1), firstItemHeader = _c[0];
|
|
2368
|
+
return firstItemHeader.type;
|
|
2369
|
+
}
|
|
2386
2370
|
/**
|
|
2387
2371
|
* Serializes an envelope into a string.
|
|
2388
2372
|
*/
|
|
@@ -4189,7 +4173,7 @@ var Sentry = (function (exports) {
|
|
|
4189
4173
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
4190
4174
|
normalized.contexts.trace = event.contexts.trace;
|
|
4191
4175
|
}
|
|
4192
|
-
|
|
4176
|
+
normalized.sdkProcessingMetadata = __assign(__assign({}, normalized.sdkProcessingMetadata), { baseClientNormalized: true });
|
|
4193
4177
|
return normalized;
|
|
4194
4178
|
};
|
|
4195
4179
|
/**
|
|
@@ -4363,89 +4347,6 @@ var Sentry = (function (exports) {
|
|
|
4363
4347
|
return rv;
|
|
4364
4348
|
}
|
|
4365
4349
|
|
|
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
4350
|
/** Extract sdk info from from the API metadata */
|
|
4450
4351
|
function getSdkMetadataForEnvelopeHeader(api) {
|
|
4451
4352
|
if (!api.metadata || !api.metadata.sdk) {
|
|
@@ -4469,8 +4370,8 @@ var Sentry = (function (exports) {
|
|
|
4469
4370
|
event.sdk.packages = __spread((event.sdk.packages || []), (sdkInfo.packages || []));
|
|
4470
4371
|
return event;
|
|
4471
4372
|
}
|
|
4472
|
-
/** Creates
|
|
4473
|
-
function
|
|
4373
|
+
/** Creates an envelope from a Session */
|
|
4374
|
+
function createSessionEnvelope(session, api) {
|
|
4474
4375
|
var sdkInfo = getSdkMetadataForEnvelopeHeader(api);
|
|
4475
4376
|
var envelopeHeaders = __assign(__assign({ sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
|
|
4476
4377
|
// I know this is hacky but we don't want to add `sessions` to request type since it's never rate limited
|
|
@@ -4478,12 +4379,62 @@ var Sentry = (function (exports) {
|
|
|
4478
4379
|
// TODO (v7) Have to cast type because envelope items do not accept a `SentryRequestType`
|
|
4479
4380
|
var envelopeItem = [{ type: type }, session];
|
|
4480
4381
|
var envelope = createEnvelope(envelopeHeaders, [envelopeItem]);
|
|
4382
|
+
return [envelope, type];
|
|
4383
|
+
}
|
|
4384
|
+
/** Creates a SentryRequest from a Session. */
|
|
4385
|
+
function sessionToSentryRequest(session, api) {
|
|
4386
|
+
var _a = __read(createSessionEnvelope(session, api), 2), envelope = _a[0], type = _a[1];
|
|
4481
4387
|
return {
|
|
4482
4388
|
body: serializeEnvelope(envelope),
|
|
4483
4389
|
type: type,
|
|
4484
4390
|
url: getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel),
|
|
4485
4391
|
};
|
|
4486
4392
|
}
|
|
4393
|
+
/**
|
|
4394
|
+
* Create an Envelope from an event. Note that this is duplicated from below,
|
|
4395
|
+
* but on purpose as this will be refactored in v7.
|
|
4396
|
+
*/
|
|
4397
|
+
function createEventEnvelope(event, api) {
|
|
4398
|
+
var sdkInfo = getSdkMetadataForEnvelopeHeader(api);
|
|
4399
|
+
var eventType = event.type || 'event';
|
|
4400
|
+
var transactionSampling = (event.sdkProcessingMetadata || {}).transactionSampling;
|
|
4401
|
+
var _a = transactionSampling || {}, samplingMethod = _a.method, sampleRate = _a.rate;
|
|
4402
|
+
// TODO: Below is a temporary hack in order to debug a serialization error - see
|
|
4403
|
+
// https://github.com/getsentry/sentry-javascript/issues/2809,
|
|
4404
|
+
// https://github.com/getsentry/sentry-javascript/pull/4425, and
|
|
4405
|
+
// https://github.com/getsentry/sentry-javascript/pull/4574.
|
|
4406
|
+
//
|
|
4407
|
+
// TL; DR: even though we normalize all events (which should prevent this), something is causing `JSON.stringify` to
|
|
4408
|
+
// throw a circular reference error.
|
|
4409
|
+
//
|
|
4410
|
+
// When it's time to remove it:
|
|
4411
|
+
// 1. Delete everything between here and where the request object `req` is created, EXCEPT the line deleting
|
|
4412
|
+
// `sdkProcessingMetadata`
|
|
4413
|
+
// 2. Restore the original version of the request body, which is commented out
|
|
4414
|
+
// 3. Search for either of the PR URLs above and pull out the companion hacks in the browser playwright tests and the
|
|
4415
|
+
// baseClient tests in this package
|
|
4416
|
+
enhanceEventWithSdkInfo(event, api.metadata.sdk);
|
|
4417
|
+
event.tags = event.tags || {};
|
|
4418
|
+
event.extra = event.extra || {};
|
|
4419
|
+
// In theory, all events should be marked as having gone through normalization and so
|
|
4420
|
+
// we should never set this tag/extra data
|
|
4421
|
+
if (!(event.sdkProcessingMetadata && event.sdkProcessingMetadata.baseClientNormalized)) {
|
|
4422
|
+
event.tags.skippedNormalization = true;
|
|
4423
|
+
event.extra.normalizeDepth = event.sdkProcessingMetadata ? event.sdkProcessingMetadata.normalizeDepth : 'unset';
|
|
4424
|
+
}
|
|
4425
|
+
// prevent this data from being sent to sentry
|
|
4426
|
+
// TODO: This is NOT part of the hack - DO NOT DELETE
|
|
4427
|
+
delete event.sdkProcessingMetadata;
|
|
4428
|
+
var envelopeHeaders = __assign(__assign({ event_id: event.event_id, sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
|
|
4429
|
+
var eventItem = [
|
|
4430
|
+
{
|
|
4431
|
+
type: eventType,
|
|
4432
|
+
sample_rates: [{ id: samplingMethod, rate: sampleRate }],
|
|
4433
|
+
},
|
|
4434
|
+
event,
|
|
4435
|
+
];
|
|
4436
|
+
return createEnvelope(envelopeHeaders, [eventItem]);
|
|
4437
|
+
}
|
|
4487
4438
|
/** Creates a SentryRequest from an event. */
|
|
4488
4439
|
function eventToSentryRequest(event, api) {
|
|
4489
4440
|
var sdkInfo = getSdkMetadataForEnvelopeHeader(api);
|
|
@@ -4571,6 +4522,115 @@ var Sentry = (function (exports) {
|
|
|
4571
4522
|
return req;
|
|
4572
4523
|
}
|
|
4573
4524
|
|
|
4525
|
+
/** Noop transport */
|
|
4526
|
+
var NoopTransport = /** @class */ (function () {
|
|
4527
|
+
function NoopTransport() {
|
|
4528
|
+
}
|
|
4529
|
+
/**
|
|
4530
|
+
* @inheritDoc
|
|
4531
|
+
*/
|
|
4532
|
+
NoopTransport.prototype.sendEvent = function (_) {
|
|
4533
|
+
return resolvedSyncPromise({
|
|
4534
|
+
reason: 'NoopTransport: Event has been skipped because no Dsn is configured.',
|
|
4535
|
+
status: 'skipped',
|
|
4536
|
+
});
|
|
4537
|
+
};
|
|
4538
|
+
/**
|
|
4539
|
+
* @inheritDoc
|
|
4540
|
+
*/
|
|
4541
|
+
NoopTransport.prototype.close = function (_) {
|
|
4542
|
+
return resolvedSyncPromise(true);
|
|
4543
|
+
};
|
|
4544
|
+
return NoopTransport;
|
|
4545
|
+
}());
|
|
4546
|
+
|
|
4547
|
+
/**
|
|
4548
|
+
* This is the base implemention of a Backend.
|
|
4549
|
+
* @hidden
|
|
4550
|
+
*/
|
|
4551
|
+
var BaseBackend = /** @class */ (function () {
|
|
4552
|
+
/** Creates a new backend instance. */
|
|
4553
|
+
function BaseBackend(options) {
|
|
4554
|
+
this._options = options;
|
|
4555
|
+
if (!this._options.dsn) {
|
|
4556
|
+
logger.warn('No DSN provided, backend will not do anything.');
|
|
4557
|
+
}
|
|
4558
|
+
this._transport = this._setupTransport();
|
|
4559
|
+
}
|
|
4560
|
+
/**
|
|
4561
|
+
* @inheritDoc
|
|
4562
|
+
*/
|
|
4563
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
4564
|
+
BaseBackend.prototype.eventFromException = function (_exception, _hint) {
|
|
4565
|
+
throw new SentryError('Backend has to implement `eventFromException` method');
|
|
4566
|
+
};
|
|
4567
|
+
/**
|
|
4568
|
+
* @inheritDoc
|
|
4569
|
+
*/
|
|
4570
|
+
BaseBackend.prototype.eventFromMessage = function (_message, _level, _hint) {
|
|
4571
|
+
throw new SentryError('Backend has to implement `eventFromMessage` method');
|
|
4572
|
+
};
|
|
4573
|
+
/**
|
|
4574
|
+
* @inheritDoc
|
|
4575
|
+
*/
|
|
4576
|
+
BaseBackend.prototype.sendEvent = function (event) {
|
|
4577
|
+
// TODO(v7): Remove the if-else
|
|
4578
|
+
if (this._newTransport &&
|
|
4579
|
+
this._options.dsn &&
|
|
4580
|
+
this._options._experiments &&
|
|
4581
|
+
this._options._experiments.newTransport) {
|
|
4582
|
+
var api = initAPIDetails(this._options.dsn, this._options._metadata, this._options.tunnel);
|
|
4583
|
+
var env = createEventEnvelope(event, api);
|
|
4584
|
+
void this._newTransport.send(env).then(null, function (reason) {
|
|
4585
|
+
logger.error('Error while sending event:', reason);
|
|
4586
|
+
});
|
|
4587
|
+
}
|
|
4588
|
+
else {
|
|
4589
|
+
void this._transport.sendEvent(event).then(null, function (reason) {
|
|
4590
|
+
logger.error('Error while sending event:', reason);
|
|
4591
|
+
});
|
|
4592
|
+
}
|
|
4593
|
+
};
|
|
4594
|
+
/**
|
|
4595
|
+
* @inheritDoc
|
|
4596
|
+
*/
|
|
4597
|
+
BaseBackend.prototype.sendSession = function (session) {
|
|
4598
|
+
if (!this._transport.sendSession) {
|
|
4599
|
+
logger.warn("Dropping session because custom transport doesn't implement sendSession");
|
|
4600
|
+
return;
|
|
4601
|
+
}
|
|
4602
|
+
// TODO(v7): Remove the if-else
|
|
4603
|
+
if (this._newTransport &&
|
|
4604
|
+
this._options.dsn &&
|
|
4605
|
+
this._options._experiments &&
|
|
4606
|
+
this._options._experiments.newTransport) {
|
|
4607
|
+
var api = initAPIDetails(this._options.dsn, this._options._metadata, this._options.tunnel);
|
|
4608
|
+
var _a = __read(createSessionEnvelope(session, api), 1), env = _a[0];
|
|
4609
|
+
void this._newTransport.send(env).then(null, function (reason) {
|
|
4610
|
+
logger.error('Error while sending session:', reason);
|
|
4611
|
+
});
|
|
4612
|
+
}
|
|
4613
|
+
else {
|
|
4614
|
+
void this._transport.sendSession(session).then(null, function (reason) {
|
|
4615
|
+
logger.error('Error while sending session:', reason);
|
|
4616
|
+
});
|
|
4617
|
+
}
|
|
4618
|
+
};
|
|
4619
|
+
/**
|
|
4620
|
+
* @inheritDoc
|
|
4621
|
+
*/
|
|
4622
|
+
BaseBackend.prototype.getTransport = function () {
|
|
4623
|
+
return this._transport;
|
|
4624
|
+
};
|
|
4625
|
+
/**
|
|
4626
|
+
* Sets up the transport so it can be used later to send requests.
|
|
4627
|
+
*/
|
|
4628
|
+
BaseBackend.prototype._setupTransport = function () {
|
|
4629
|
+
return new NoopTransport();
|
|
4630
|
+
};
|
|
4631
|
+
return BaseBackend;
|
|
4632
|
+
}());
|
|
4633
|
+
|
|
4574
4634
|
/**
|
|
4575
4635
|
* Internal function to create a new SDK client instance. The client is
|
|
4576
4636
|
* installed and then bound to the current scope.
|
|
@@ -4593,7 +4653,61 @@ var Sentry = (function (exports) {
|
|
|
4593
4653
|
hub.bindClient(client);
|
|
4594
4654
|
}
|
|
4595
4655
|
|
|
4596
|
-
var
|
|
4656
|
+
var DEFAULT_TRANSPORT_BUFFER_SIZE = 30;
|
|
4657
|
+
/**
|
|
4658
|
+
* Creates a `NewTransport`
|
|
4659
|
+
*
|
|
4660
|
+
* @param options
|
|
4661
|
+
* @param makeRequest
|
|
4662
|
+
*/
|
|
4663
|
+
function createTransport(options, makeRequest, buffer) {
|
|
4664
|
+
if (buffer === void 0) { buffer = makePromiseBuffer(options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE); }
|
|
4665
|
+
var rateLimits = {};
|
|
4666
|
+
var flush = function (timeout) { return buffer.drain(timeout); };
|
|
4667
|
+
function send(envelope) {
|
|
4668
|
+
var envCategory = getEnvelopeType(envelope);
|
|
4669
|
+
var category = envCategory === 'event' ? 'error' : envCategory;
|
|
4670
|
+
var request = {
|
|
4671
|
+
category: category,
|
|
4672
|
+
body: serializeEnvelope(envelope),
|
|
4673
|
+
};
|
|
4674
|
+
// Don't add to buffer if transport is already rate-limited
|
|
4675
|
+
if (isRateLimited(rateLimits, category)) {
|
|
4676
|
+
return rejectedSyncPromise({
|
|
4677
|
+
status: 'rate_limit',
|
|
4678
|
+
reason: getRateLimitReason(rateLimits, category),
|
|
4679
|
+
});
|
|
4680
|
+
}
|
|
4681
|
+
var requestTask = function () {
|
|
4682
|
+
return makeRequest(request).then(function (_a) {
|
|
4683
|
+
var body = _a.body, headers = _a.headers, reason = _a.reason, statusCode = _a.statusCode;
|
|
4684
|
+
var status = eventStatusFromHttpCode(statusCode);
|
|
4685
|
+
if (headers) {
|
|
4686
|
+
rateLimits = updateRateLimits(rateLimits, headers);
|
|
4687
|
+
}
|
|
4688
|
+
if (status === 'success') {
|
|
4689
|
+
return resolvedSyncPromise({ status: status, reason: reason });
|
|
4690
|
+
}
|
|
4691
|
+
return rejectedSyncPromise({
|
|
4692
|
+
status: status,
|
|
4693
|
+
reason: reason ||
|
|
4694
|
+
body ||
|
|
4695
|
+
(status === 'rate_limit' ? getRateLimitReason(rateLimits, category) : 'Unknown transport error'),
|
|
4696
|
+
});
|
|
4697
|
+
});
|
|
4698
|
+
};
|
|
4699
|
+
return buffer.add(requestTask);
|
|
4700
|
+
}
|
|
4701
|
+
return {
|
|
4702
|
+
send: send,
|
|
4703
|
+
flush: flush,
|
|
4704
|
+
};
|
|
4705
|
+
}
|
|
4706
|
+
function getRateLimitReason(rateLimits, category) {
|
|
4707
|
+
return "Too many " + category + " requests, backing off until: " + new Date(disabledUntil(rateLimits, category)).toISOString();
|
|
4708
|
+
}
|
|
4709
|
+
|
|
4710
|
+
var SDK_VERSION = '6.19.4';
|
|
4597
4711
|
|
|
4598
4712
|
var originalFunctionToString;
|
|
4599
4713
|
/** Patch toString calls to return proper name for wrapped functions */
|
|
@@ -4643,158 +4757,139 @@ var Sentry = (function (exports) {
|
|
|
4643
4757
|
/**
|
|
4644
4758
|
* @inheritDoc
|
|
4645
4759
|
*/
|
|
4646
|
-
InboundFilters.prototype.setupOnce = function () {
|
|
4760
|
+
InboundFilters.prototype.setupOnce = function (addGlobalEventProcessor, getCurrentHub) {
|
|
4647
4761
|
addGlobalEventProcessor(function (event) {
|
|
4648
4762
|
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;
|
|
4763
|
+
if (hub) {
|
|
4764
|
+
var self_1 = hub.getIntegration(InboundFilters);
|
|
4765
|
+
if (self_1) {
|
|
4766
|
+
var client = hub.getClient();
|
|
4767
|
+
var clientOptions = client ? client.getOptions() : {};
|
|
4768
|
+
var options = _mergeOptions(self_1._options, clientOptions);
|
|
4769
|
+
return _shouldDropEvent$1(event, options) ? null : event;
|
|
4664
4770
|
}
|
|
4665
|
-
return self._shouldDropEvent(event, options) ? null : event;
|
|
4666
4771
|
}
|
|
4667
4772
|
return event;
|
|
4668
4773
|
});
|
|
4669
4774
|
};
|
|
4670
|
-
/**
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4775
|
+
/**
|
|
4776
|
+
* @inheritDoc
|
|
4777
|
+
*/
|
|
4778
|
+
InboundFilters.id = 'InboundFilters';
|
|
4779
|
+
return InboundFilters;
|
|
4780
|
+
}());
|
|
4781
|
+
/** JSDoc */
|
|
4782
|
+
function _mergeOptions(internalOptions, clientOptions) {
|
|
4783
|
+
if (internalOptions === void 0) { internalOptions = {}; }
|
|
4784
|
+
if (clientOptions === void 0) { clientOptions = {}; }
|
|
4785
|
+
return {
|
|
4786
|
+
allowUrls: __spread((internalOptions.whitelistUrls || []), (internalOptions.allowUrls || []), (clientOptions.whitelistUrls || []), (clientOptions.allowUrls || [])),
|
|
4787
|
+
denyUrls: __spread((internalOptions.blacklistUrls || []), (internalOptions.denyUrls || []), (clientOptions.blacklistUrls || []), (clientOptions.denyUrls || [])),
|
|
4788
|
+
ignoreErrors: __spread((internalOptions.ignoreErrors || []), (clientOptions.ignoreErrors || []), DEFAULT_IGNORE_ERRORS),
|
|
4789
|
+
ignoreInternal: internalOptions.ignoreInternal !== undefined ? internalOptions.ignoreInternal : true,
|
|
4790
|
+
};
|
|
4791
|
+
}
|
|
4792
|
+
/** JSDoc */
|
|
4793
|
+
function _shouldDropEvent$1(event, options) {
|
|
4794
|
+
if (options.ignoreInternal && _isSentryError(event)) {
|
|
4795
|
+
logger.warn("Event dropped due to being internal Sentry Error.\nEvent: " + getEventDescription(event));
|
|
4796
|
+
return true;
|
|
4797
|
+
}
|
|
4798
|
+
if (_isIgnoredError(event, options.ignoreErrors)) {
|
|
4799
|
+
logger.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: " + getEventDescription(event));
|
|
4800
|
+
return true;
|
|
4801
|
+
}
|
|
4802
|
+
if (_isDeniedUrl(event, options.denyUrls)) {
|
|
4803
|
+
logger.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + _getEventFilterUrl(event));
|
|
4804
|
+
return true;
|
|
4805
|
+
}
|
|
4806
|
+
if (!_isAllowedUrl(event, options.allowUrls)) {
|
|
4807
|
+
logger.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: " + getEventDescription(event) + ".\nUrl: " + _getEventFilterUrl(event));
|
|
4808
|
+
return true;
|
|
4809
|
+
}
|
|
4810
|
+
return false;
|
|
4811
|
+
}
|
|
4812
|
+
function _isIgnoredError(event, ignoreErrors) {
|
|
4813
|
+
if (!ignoreErrors || !ignoreErrors.length) {
|
|
4814
|
+
return false;
|
|
4815
|
+
}
|
|
4816
|
+
return _getPossibleEventMessages(event).some(function (message) {
|
|
4817
|
+
return ignoreErrors.some(function (pattern) { return isMatchingPattern(message, pattern); });
|
|
4818
|
+
});
|
|
4819
|
+
}
|
|
4820
|
+
function _isDeniedUrl(event, denyUrls) {
|
|
4821
|
+
// TODO: Use Glob instead?
|
|
4822
|
+
if (!denyUrls || !denyUrls.length) {
|
|
4823
|
+
return false;
|
|
4824
|
+
}
|
|
4825
|
+
var url = _getEventFilterUrl(event);
|
|
4826
|
+
return !url ? false : denyUrls.some(function (pattern) { return isMatchingPattern(url, pattern); });
|
|
4827
|
+
}
|
|
4828
|
+
function _isAllowedUrl(event, allowUrls) {
|
|
4829
|
+
// TODO: Use Glob instead?
|
|
4830
|
+
if (!allowUrls || !allowUrls.length) {
|
|
4831
|
+
return true;
|
|
4832
|
+
}
|
|
4833
|
+
var url = _getEventFilterUrl(event);
|
|
4834
|
+
return !url ? true : allowUrls.some(function (pattern) { return isMatchingPattern(url, pattern); });
|
|
4835
|
+
}
|
|
4836
|
+
function _getPossibleEventMessages(event) {
|
|
4837
|
+
if (event.message) {
|
|
4838
|
+
return [event.message];
|
|
4839
|
+
}
|
|
4840
|
+
if (event.exception) {
|
|
4841
|
+
try {
|
|
4842
|
+
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;
|
|
4843
|
+
return ["" + value, type + ": " + value];
|
|
4679
4844
|
}
|
|
4680
|
-
|
|
4681
|
-
logger.
|
|
4682
|
-
return
|
|
4845
|
+
catch (oO) {
|
|
4846
|
+
logger.error("Cannot extract message for event " + getEventDescription(event));
|
|
4847
|
+
return [];
|
|
4683
4848
|
}
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4849
|
+
}
|
|
4850
|
+
return [];
|
|
4851
|
+
}
|
|
4852
|
+
function _isSentryError(event) {
|
|
4853
|
+
try {
|
|
4854
|
+
// @ts-ignore can't be a sentry error if undefined
|
|
4855
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
4856
|
+
return event.exception.values[0].type === 'SentryError';
|
|
4857
|
+
}
|
|
4858
|
+
catch (e) {
|
|
4859
|
+
// ignore
|
|
4860
|
+
}
|
|
4861
|
+
return false;
|
|
4862
|
+
}
|
|
4863
|
+
function _getLastValidUrl(frames) {
|
|
4864
|
+
if (frames === void 0) { frames = []; }
|
|
4865
|
+
for (var i = frames.length - 1; i >= 0; i--) {
|
|
4866
|
+
var frame = frames[i];
|
|
4867
|
+
if (frame && frame.filename !== '<anonymous>' && frame.filename !== '[native code]') {
|
|
4868
|
+
return frame.filename || null;
|
|
4687
4869
|
}
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4870
|
+
}
|
|
4871
|
+
return null;
|
|
4872
|
+
}
|
|
4873
|
+
function _getEventFilterUrl(event) {
|
|
4874
|
+
try {
|
|
4875
|
+
if (event.stacktrace) {
|
|
4876
|
+
return _getLastValidUrl(event.stacktrace.frames);
|
|
4694
4877
|
}
|
|
4878
|
+
var frames_1;
|
|
4695
4879
|
try {
|
|
4696
|
-
// @ts-ignore
|
|
4697
|
-
|
|
4698
|
-
return event.exception.values[0].type === 'SentryError';
|
|
4880
|
+
// @ts-ignore we only care about frames if the whole thing here is defined
|
|
4881
|
+
frames_1 = event.exception.values[0].stacktrace.frames;
|
|
4699
4882
|
}
|
|
4700
4883
|
catch (e) {
|
|
4701
4884
|
// ignore
|
|
4702
4885
|
}
|
|
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
|
-
}
|
|
4886
|
+
return frames_1 ? _getLastValidUrl(frames_1) : null;
|
|
4887
|
+
}
|
|
4888
|
+
catch (oO) {
|
|
4889
|
+
logger.error("Cannot extract url for event " + getEventDescription(event));
|
|
4769
4890
|
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
|
-
}());
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4798
4893
|
|
|
4799
4894
|
var CoreIntegrations = /*#__PURE__*/Object.freeze({
|
|
4800
4895
|
__proto__: null,
|
|
@@ -5330,7 +5425,7 @@ var Sentry = (function (exports) {
|
|
|
5330
5425
|
var status = eventStatusFromHttpCode(response.status);
|
|
5331
5426
|
this._rateLimits = updateRateLimits(this._rateLimits, headers);
|
|
5332
5427
|
// eslint-disable-next-line deprecation/deprecation
|
|
5333
|
-
if (this._isRateLimited(requestType)
|
|
5428
|
+
if (this._isRateLimited(requestType)) {
|
|
5334
5429
|
// eslint-disable-next-line deprecation/deprecation
|
|
5335
5430
|
logger.warn("Too many " + requestType + " requests, backing off until: " + this._disabledUntil(requestType));
|
|
5336
5431
|
}
|
|
@@ -5495,11 +5590,77 @@ var Sentry = (function (exports) {
|
|
|
5495
5590
|
return XHRTransport;
|
|
5496
5591
|
}(BaseTransport));
|
|
5497
5592
|
|
|
5593
|
+
/**
|
|
5594
|
+
* Creates a Transport that uses the Fetch API to send events to Sentry.
|
|
5595
|
+
*/
|
|
5596
|
+
function makeNewFetchTransport(options, nativeFetch) {
|
|
5597
|
+
if (nativeFetch === void 0) { nativeFetch = getNativeFetchImplementation(); }
|
|
5598
|
+
function makeRequest(request) {
|
|
5599
|
+
var requestOptions = __assign({ body: request.body, method: 'POST', referrerPolicy: 'origin' }, options.requestOptions);
|
|
5600
|
+
return nativeFetch(options.url, requestOptions).then(function (response) {
|
|
5601
|
+
return response.text().then(function (body) { return ({
|
|
5602
|
+
body: body,
|
|
5603
|
+
headers: {
|
|
5604
|
+
'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),
|
|
5605
|
+
'retry-after': response.headers.get('Retry-After'),
|
|
5606
|
+
},
|
|
5607
|
+
reason: response.statusText,
|
|
5608
|
+
statusCode: response.status,
|
|
5609
|
+
}); });
|
|
5610
|
+
});
|
|
5611
|
+
}
|
|
5612
|
+
return createTransport({ bufferSize: options.bufferSize }, makeRequest);
|
|
5613
|
+
}
|
|
5614
|
+
|
|
5615
|
+
/**
|
|
5616
|
+
* The DONE ready state for XmlHttpRequest
|
|
5617
|
+
*
|
|
5618
|
+
* Defining it here as a constant b/c XMLHttpRequest.DONE is not always defined
|
|
5619
|
+
* (e.g. during testing, it is `undefined`)
|
|
5620
|
+
*
|
|
5621
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState}
|
|
5622
|
+
*/
|
|
5623
|
+
var XHR_READYSTATE_DONE = 4;
|
|
5624
|
+
/**
|
|
5625
|
+
* Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.
|
|
5626
|
+
*/
|
|
5627
|
+
function makeNewXHRTransport(options) {
|
|
5628
|
+
function makeRequest(request) {
|
|
5629
|
+
return new SyncPromise(function (resolve, _reject) {
|
|
5630
|
+
var xhr = new XMLHttpRequest();
|
|
5631
|
+
xhr.onreadystatechange = function () {
|
|
5632
|
+
if (xhr.readyState === XHR_READYSTATE_DONE) {
|
|
5633
|
+
var response = {
|
|
5634
|
+
body: xhr.response,
|
|
5635
|
+
headers: {
|
|
5636
|
+
'x-sentry-rate-limits': xhr.getResponseHeader('X-Sentry-Rate-Limits'),
|
|
5637
|
+
'retry-after': xhr.getResponseHeader('Retry-After'),
|
|
5638
|
+
},
|
|
5639
|
+
reason: xhr.statusText,
|
|
5640
|
+
statusCode: xhr.status,
|
|
5641
|
+
};
|
|
5642
|
+
resolve(response);
|
|
5643
|
+
}
|
|
5644
|
+
};
|
|
5645
|
+
xhr.open('POST', options.url);
|
|
5646
|
+
for (var header in options.headers) {
|
|
5647
|
+
if (Object.prototype.hasOwnProperty.call(options.headers, header)) {
|
|
5648
|
+
xhr.setRequestHeader(header, options.headers[header]);
|
|
5649
|
+
}
|
|
5650
|
+
}
|
|
5651
|
+
xhr.send(request.body);
|
|
5652
|
+
});
|
|
5653
|
+
}
|
|
5654
|
+
return createTransport({ bufferSize: options.bufferSize }, makeRequest);
|
|
5655
|
+
}
|
|
5656
|
+
|
|
5498
5657
|
var index = /*#__PURE__*/Object.freeze({
|
|
5499
5658
|
__proto__: null,
|
|
5500
5659
|
BaseTransport: BaseTransport,
|
|
5501
5660
|
FetchTransport: FetchTransport,
|
|
5502
|
-
XHRTransport: XHRTransport
|
|
5661
|
+
XHRTransport: XHRTransport,
|
|
5662
|
+
makeNewFetchTransport: makeNewFetchTransport,
|
|
5663
|
+
makeNewXHRTransport: makeNewXHRTransport
|
|
5503
5664
|
});
|
|
5504
5665
|
|
|
5505
5666
|
/**
|
|
@@ -5533,12 +5694,20 @@ var Sentry = (function (exports) {
|
|
|
5533
5694
|
return _super.prototype._setupTransport.call(this);
|
|
5534
5695
|
}
|
|
5535
5696
|
var transportOptions = __assign(__assign({}, this._options.transportOptions), { dsn: this._options.dsn, tunnel: this._options.tunnel, sendClientReports: this._options.sendClientReports, _metadata: this._options._metadata });
|
|
5697
|
+
var api = initAPIDetails(transportOptions.dsn, transportOptions._metadata, transportOptions.tunnel);
|
|
5698
|
+
var url = getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel);
|
|
5536
5699
|
if (this._options.transport) {
|
|
5537
5700
|
return new this._options.transport(transportOptions);
|
|
5538
5701
|
}
|
|
5539
5702
|
if (supportsFetch()) {
|
|
5703
|
+
var requestOptions = __assign({}, transportOptions.fetchParameters);
|
|
5704
|
+
this._newTransport = makeNewFetchTransport({ requestOptions: requestOptions, url: url });
|
|
5540
5705
|
return new FetchTransport(transportOptions);
|
|
5541
5706
|
}
|
|
5707
|
+
this._newTransport = makeNewXHRTransport({
|
|
5708
|
+
url: url,
|
|
5709
|
+
headers: transportOptions.headers,
|
|
5710
|
+
});
|
|
5542
5711
|
return new XHRTransport(transportOptions);
|
|
5543
5712
|
};
|
|
5544
5713
|
return BrowserBackend;
|