@sentry/browser 6.19.2 → 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 +311 -163
- 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 +316 -163
- 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 +4 -4
- 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}.
|
|
@@ -764,55 +774,38 @@ var Sentry = (function (exports) {
|
|
|
764
774
|
*
|
|
765
775
|
* @param value Initial source that we have to transform in order for it to be usable by the serializer
|
|
766
776
|
*/
|
|
767
|
-
function
|
|
777
|
+
function convertToPlainObject(value) {
|
|
778
|
+
var newObj = value;
|
|
768
779
|
if (isError(value)) {
|
|
769
|
-
|
|
770
|
-
var err = {
|
|
771
|
-
message: error.message,
|
|
772
|
-
name: error.name,
|
|
773
|
-
stack: error.stack,
|
|
774
|
-
};
|
|
775
|
-
for (var i in error) {
|
|
776
|
-
if (Object.prototype.hasOwnProperty.call(error, i)) {
|
|
777
|
-
err[i] = error[i];
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
return err;
|
|
780
|
+
newObj = __assign({ message: value.message, name: value.name, stack: value.stack }, getOwnProperties(value));
|
|
781
781
|
}
|
|
782
|
-
if (isEvent(value)) {
|
|
782
|
+
else if (isEvent(value)) {
|
|
783
783
|
var event_1 = value;
|
|
784
|
-
|
|
785
|
-
// Accessing event attributes can throw (see https://github.com/getsentry/sentry-javascript/issues/768 and
|
|
786
|
-
// https://github.com/getsentry/sentry-javascript/issues/838), but accessing `type` hasn't been wrapped in a
|
|
787
|
-
// try-catch in at least two years and no one's complained, so that's likely not an issue anymore
|
|
788
|
-
source.type = event_1.type;
|
|
789
|
-
try {
|
|
790
|
-
source.target = isElement(event_1.target)
|
|
791
|
-
? htmlTreeAsString(event_1.target)
|
|
792
|
-
: Object.prototype.toString.call(event_1.target);
|
|
793
|
-
}
|
|
794
|
-
catch (_oO) {
|
|
795
|
-
source.target = '<unknown>';
|
|
796
|
-
}
|
|
797
|
-
try {
|
|
798
|
-
source.currentTarget = isElement(event_1.currentTarget)
|
|
799
|
-
? htmlTreeAsString(event_1.currentTarget)
|
|
800
|
-
: Object.prototype.toString.call(event_1.currentTarget);
|
|
801
|
-
}
|
|
802
|
-
catch (_oO) {
|
|
803
|
-
source.currentTarget = '<unknown>';
|
|
804
|
-
}
|
|
784
|
+
newObj = __assign({ type: event_1.type, target: serializeEventTarget(event_1.target), currentTarget: serializeEventTarget(event_1.currentTarget) }, getOwnProperties(event_1));
|
|
805
785
|
if (typeof CustomEvent !== 'undefined' && isInstanceOf(value, CustomEvent)) {
|
|
806
|
-
|
|
786
|
+
newObj.detail = event_1.detail;
|
|
807
787
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
788
|
+
}
|
|
789
|
+
return newObj;
|
|
790
|
+
}
|
|
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);
|
|
795
|
+
}
|
|
796
|
+
catch (_oO) {
|
|
797
|
+
return '<unknown>';
|
|
798
|
+
}
|
|
799
|
+
}
|
|
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];
|
|
812
806
|
}
|
|
813
|
-
return source;
|
|
814
807
|
}
|
|
815
|
-
return
|
|
808
|
+
return extractedProps;
|
|
816
809
|
}
|
|
817
810
|
/**
|
|
818
811
|
* Given any captured exception, extract its keys and create a sorted
|
|
@@ -822,7 +815,7 @@ var Sentry = (function (exports) {
|
|
|
822
815
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
823
816
|
function extractExceptionKeysForMessage(exception, maxLength) {
|
|
824
817
|
if (maxLength === void 0) { maxLength = 40; }
|
|
825
|
-
var keys = Object.keys(
|
|
818
|
+
var keys = Object.keys(convertToPlainObject(exception));
|
|
826
819
|
keys.sort();
|
|
827
820
|
if (!keys.length) {
|
|
828
821
|
return '[object has no keys]';
|
|
@@ -849,13 +842,12 @@ var Sentry = (function (exports) {
|
|
|
849
842
|
function dropUndefinedKeys(val) {
|
|
850
843
|
var e_1, _a;
|
|
851
844
|
if (isPlainObject(val)) {
|
|
852
|
-
var obj = val;
|
|
853
845
|
var rv = {};
|
|
854
846
|
try {
|
|
855
|
-
for (var _b = __values(Object.keys(
|
|
847
|
+
for (var _b = __values(Object.keys(val)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
856
848
|
var key = _c.value;
|
|
857
|
-
if (typeof
|
|
858
|
-
rv[key] = dropUndefinedKeys(
|
|
849
|
+
if (typeof val[key] !== 'undefined') {
|
|
850
|
+
rv[key] = dropUndefinedKeys(val[key]);
|
|
859
851
|
}
|
|
860
852
|
}
|
|
861
853
|
}
|
|
@@ -1813,10 +1805,10 @@ var Sentry = (function (exports) {
|
|
|
1813
1805
|
if (maxProperties === void 0) { maxProperties = +Infinity; }
|
|
1814
1806
|
try {
|
|
1815
1807
|
// since we're at the outermost level, there is no key
|
|
1816
|
-
return
|
|
1808
|
+
return visit('', input, depth, maxProperties);
|
|
1817
1809
|
}
|
|
1818
|
-
catch (
|
|
1819
|
-
return
|
|
1810
|
+
catch (err) {
|
|
1811
|
+
return { ERROR: "**non-serializable** (" + err + ")" };
|
|
1820
1812
|
}
|
|
1821
1813
|
}
|
|
1822
1814
|
/** JSDoc */
|
|
@@ -1827,145 +1819,145 @@ var Sentry = (function (exports) {
|
|
|
1827
1819
|
maxSize) {
|
|
1828
1820
|
if (depth === void 0) { depth = 3; }
|
|
1829
1821
|
if (maxSize === void 0) { maxSize = 100 * 1024; }
|
|
1830
|
-
var
|
|
1831
|
-
if (jsonSize(
|
|
1822
|
+
var normalized = normalize(object, depth);
|
|
1823
|
+
if (jsonSize(normalized) > maxSize) {
|
|
1832
1824
|
return normalizeToSize(object, depth - 1, maxSize);
|
|
1833
1825
|
}
|
|
1834
|
-
return
|
|
1826
|
+
return normalized;
|
|
1835
1827
|
}
|
|
1836
1828
|
/**
|
|
1837
|
-
*
|
|
1829
|
+
* Visits a node to perform normalization on it
|
|
1838
1830
|
*
|
|
1839
|
-
* @param key
|
|
1840
|
-
* @param value
|
|
1841
|
-
* @param depth Optional number indicating
|
|
1842
|
-
* @param maxProperties Optional maximum
|
|
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
|
|
1843
1835
|
* @param memo Optional Memo class handling decycling
|
|
1844
1836
|
*/
|
|
1845
|
-
function
|
|
1837
|
+
function visit(key, value, depth, maxProperties, memo) {
|
|
1846
1838
|
if (depth === void 0) { depth = +Infinity; }
|
|
1847
1839
|
if (maxProperties === void 0) { maxProperties = +Infinity; }
|
|
1848
1840
|
if (memo === void 0) { memo = memoBuilder(); }
|
|
1849
1841
|
var _a = __read(memo, 2), memoize = _a[0], unmemoize = _a[1];
|
|
1850
|
-
// If
|
|
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
|
|
1851
1863
|
if (depth === 0) {
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
return value.toJSON();
|
|
1857
|
-
}
|
|
1858
|
-
// `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
|
|
1859
|
-
// pass-through. If what comes back is a primitive (either because it's been stringified or because it was primitive
|
|
1860
|
-
// all along), we're done.
|
|
1861
|
-
var serializable = makeSerializable(value, key);
|
|
1862
|
-
if (isPrimitive(serializable)) {
|
|
1863
|
-
return serializable;
|
|
1864
|
-
}
|
|
1865
|
-
// Create source that we will use for the next iteration. It will either be an objectified error object (`Error` type
|
|
1866
|
-
// with extracted key:value pairs) or the input itself.
|
|
1867
|
-
var source = getWalkSource(value);
|
|
1868
|
-
// Create an accumulator that will act as a parent for all future itterations of that branch
|
|
1869
|
-
var acc = Array.isArray(value) ? [] : {};
|
|
1870
|
-
// If we already walked that branch, bail out, as it's circular reference
|
|
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.
|
|
1871
1868
|
if (memoize(value)) {
|
|
1872
1869
|
return '[Circular ~]';
|
|
1873
1870
|
}
|
|
1874
|
-
|
|
1875
|
-
//
|
|
1876
|
-
|
|
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) {
|
|
1877
1880
|
// Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
|
|
1878
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
1881
|
+
if (!Object.prototype.hasOwnProperty.call(visitable, visitKey)) {
|
|
1879
1882
|
continue;
|
|
1880
1883
|
}
|
|
1881
|
-
if (
|
|
1882
|
-
|
|
1884
|
+
if (numAdded >= maxProperties) {
|
|
1885
|
+
normalized[visitKey] = '[MaxProperties ~]';
|
|
1883
1886
|
break;
|
|
1884
1887
|
}
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
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;
|
|
1889
1892
|
}
|
|
1890
|
-
// Once
|
|
1893
|
+
// Once we've visited all the branches, remove the parent from memo storage
|
|
1891
1894
|
unmemoize(value);
|
|
1892
1895
|
// Return accumulated values
|
|
1893
|
-
return
|
|
1896
|
+
return normalized;
|
|
1894
1897
|
}
|
|
1895
1898
|
/**
|
|
1896
|
-
*
|
|
1897
|
-
* booleans, null, and undefined.
|
|
1899
|
+
* Stringify the given value. Handles various known special values and types.
|
|
1898
1900
|
*
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
1901
|
-
* type and `description` property, respectively. For non-BigInt, non-Symbol primitives, returns the original value,
|
|
1902
|
-
* unchanged.
|
|
1903
|
-
*/
|
|
1904
|
-
function serializeValue(value) {
|
|
1905
|
-
// Node.js REPL notation
|
|
1906
|
-
if (typeof value === 'string') {
|
|
1907
|
-
return value;
|
|
1908
|
-
}
|
|
1909
|
-
var type = Object.prototype.toString.call(value);
|
|
1910
|
-
if (type === '[object Object]') {
|
|
1911
|
-
return '[Object]';
|
|
1912
|
-
}
|
|
1913
|
-
if (type === '[object Array]') {
|
|
1914
|
-
return '[Array]';
|
|
1915
|
-
}
|
|
1916
|
-
// `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
|
|
1917
|
-
// pass-through.
|
|
1918
|
-
var serializable = makeSerializable(value);
|
|
1919
|
-
return isPrimitive(serializable) ? serializable : type;
|
|
1920
|
-
}
|
|
1921
|
-
/**
|
|
1922
|
-
* makeSerializable()
|
|
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.
|
|
1923
1903
|
*
|
|
1924
|
-
*
|
|
1925
|
-
*
|
|
1926
|
-
* Handles globals, functions, `undefined`, `NaN`, and other non-serializable values.
|
|
1904
|
+
* @param value The value to stringify
|
|
1905
|
+
* @returns A stringified representation of the given value
|
|
1927
1906
|
*/
|
|
1928
|
-
function
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
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 + "]";
|
|
1964
1957
|
}
|
|
1965
|
-
|
|
1966
|
-
return "
|
|
1958
|
+
catch (err) {
|
|
1959
|
+
return "**non-serializable** (" + err + ")";
|
|
1967
1960
|
}
|
|
1968
|
-
return value;
|
|
1969
1961
|
}
|
|
1970
1962
|
/** Calculates bytes size of input string */
|
|
1971
1963
|
function utf8Length(value) {
|
|
@@ -2384,6 +2376,13 @@ var Sentry = (function (exports) {
|
|
|
2384
2376
|
if (items === void 0) { items = []; }
|
|
2385
2377
|
return [headers, items];
|
|
2386
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
|
+
}
|
|
2387
2386
|
/**
|
|
2388
2387
|
* Serializes an envelope into a string.
|
|
2389
2388
|
*/
|
|
@@ -4190,7 +4189,7 @@ var Sentry = (function (exports) {
|
|
|
4190
4189
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
4191
4190
|
normalized.contexts.trace = event.contexts.trace;
|
|
4192
4191
|
}
|
|
4193
|
-
|
|
4192
|
+
normalized.sdkProcessingMetadata = __assign(__assign({}, normalized.sdkProcessingMetadata), { baseClientNormalized: true });
|
|
4194
4193
|
return normalized;
|
|
4195
4194
|
};
|
|
4196
4195
|
/**
|
|
@@ -4416,6 +4415,32 @@ var Sentry = (function (exports) {
|
|
|
4416
4415
|
var eventType = event.type || 'event';
|
|
4417
4416
|
var transactionSampling = (event.sdkProcessingMetadata || {}).transactionSampling;
|
|
4418
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;
|
|
4419
4444
|
var envelopeHeaders = __assign(__assign({ event_id: event.event_id, sent_at: new Date().toISOString() }, (sdkInfo && { sdk: sdkInfo })), (!!api.tunnel && { dsn: dsnToString(api.dsn) }));
|
|
4420
4445
|
var eventItem = [
|
|
4421
4446
|
{
|
|
@@ -4644,7 +4669,61 @@ var Sentry = (function (exports) {
|
|
|
4644
4669
|
hub.bindClient(client);
|
|
4645
4670
|
}
|
|
4646
4671
|
|
|
4647
|
-
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';
|
|
4648
4727
|
|
|
4649
4728
|
var originalFunctionToString;
|
|
4650
4729
|
/** Patch toString calls to return proper name for wrapped functions */
|
|
@@ -5527,11 +5606,77 @@ var Sentry = (function (exports) {
|
|
|
5527
5606
|
return XHRTransport;
|
|
5528
5607
|
}(BaseTransport));
|
|
5529
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
|
+
|
|
5530
5673
|
var index = /*#__PURE__*/Object.freeze({
|
|
5531
5674
|
__proto__: null,
|
|
5532
5675
|
BaseTransport: BaseTransport,
|
|
5533
5676
|
FetchTransport: FetchTransport,
|
|
5534
|
-
XHRTransport: XHRTransport
|
|
5677
|
+
XHRTransport: XHRTransport,
|
|
5678
|
+
makeNewFetchTransport: makeNewFetchTransport,
|
|
5679
|
+
makeNewXHRTransport: makeNewXHRTransport
|
|
5535
5680
|
});
|
|
5536
5681
|
|
|
5537
5682
|
/**
|
|
@@ -5565,12 +5710,20 @@ var Sentry = (function (exports) {
|
|
|
5565
5710
|
return _super.prototype._setupTransport.call(this);
|
|
5566
5711
|
}
|
|
5567
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);
|
|
5568
5715
|
if (this._options.transport) {
|
|
5569
5716
|
return new this._options.transport(transportOptions);
|
|
5570
5717
|
}
|
|
5571
5718
|
if (supportsFetch()) {
|
|
5719
|
+
var requestOptions = __assign({}, transportOptions.fetchParameters);
|
|
5720
|
+
this._newTransport = makeNewFetchTransport({ requestOptions: requestOptions, url: url });
|
|
5572
5721
|
return new FetchTransport(transportOptions);
|
|
5573
5722
|
}
|
|
5723
|
+
this._newTransport = makeNewXHRTransport({
|
|
5724
|
+
url: url,
|
|
5725
|
+
headers: transportOptions.headers,
|
|
5726
|
+
});
|
|
5574
5727
|
return new XHRTransport(transportOptions);
|
|
5575
5728
|
};
|
|
5576
5729
|
return BrowserBackend;
|