vviinn-widgets 0.9.10 → 0.9.11
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/dist/cjs/{app-globals-eea7941d.js → app-globals-023ba3b4.js} +63 -2677
- package/dist/cjs/cropper-handler_28.cjs.entry.js +3 -3
- package/dist/cjs/{imageSearch.store-9badba6d.js → imageSearch.store-69466bb8.js} +1 -1
- package/dist/cjs/{index-fe4d4ff2.js → index-22940984.js} +1 -1
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{products.worker-053e042f.js → products.worker-1766003a.js} +2 -2
- package/dist/cjs/{vpr-slider-65d574c0.js → vpr-slider-a71da246.js} +2 -2
- package/dist/cjs/vpr-slider.cjs.entry.js +2 -2
- package/dist/cjs/vviinn-vpr-widget.cjs.entry.js +2 -2
- package/dist/cjs/vviinn-widgets.cjs.js +3 -3
- package/dist/collection/components/vviinn-vps-button/vviinn-vps-button.js +21 -1
- package/dist/collection/global.js +1 -3
- package/dist/esm/{app-globals-330036ec.js → app-globals-146b2ea2.js} +63 -2677
- package/dist/esm/cropper-handler_28.entry.js +3 -3
- package/dist/esm/{imageSearch.store-b6fbd866.js → imageSearch.store-0d49a9fc.js} +1 -1
- package/dist/esm/{index-d6f8815f.js → index-7fb78e77.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{products.worker-d8ebf5fc.js → products.worker-1d333a4c.js} +2 -2
- package/dist/esm/{vpr-slider-c5a7e0f6.js → vpr-slider-59c13ed8.js} +2 -2
- package/dist/esm/vpr-slider.entry.js +2 -2
- package/dist/esm/vviinn-vpr-widget.entry.js +2 -2
- package/dist/esm/vviinn-widgets.js +3 -3
- package/dist/types/components/vviinn-vps-button/vviinn-vps-button.d.ts +2 -0
- package/dist/types/components.d.ts +1 -0
- package/dist/vviinn-widgets/{p-ab707f1d.entry.js → p-20eb83f4.entry.js} +1 -1
- package/dist/vviinn-widgets/p-491df676.entry.js +1 -0
- package/dist/vviinn-widgets/p-b0eaac75.js +1 -0
- package/{www/build/p-35281467.js → dist/vviinn-widgets/p-c2578e4e.js} +1 -1
- package/dist/vviinn-widgets/{p-0d4aeff5.entry.js → p-c80ab12b.entry.js} +1 -1
- package/dist/vviinn-widgets/p-da6ea0b0.js +15 -0
- package/dist/vviinn-widgets/{p-8dd2b524.js → p-e46ad709.js} +1 -1
- package/dist/vviinn-widgets/p-f12092db.js +1 -0
- package/dist/vviinn-widgets/vviinn-widgets.esm.js +1 -1
- package/package.json +1 -1
- package/www/build/{p-ab707f1d.entry.js → p-20eb83f4.entry.js} +1 -1
- package/www/build/p-491df676.entry.js +1 -0
- package/www/build/p-a1878b2c.js +1 -0
- package/www/build/p-b0eaac75.js +1 -0
- package/{dist/vviinn-widgets/p-35281467.js → www/build/p-c2578e4e.js} +1 -1
- package/www/build/{p-0d4aeff5.entry.js → p-c80ab12b.entry.js} +1 -1
- package/www/build/p-da6ea0b0.js +15 -0
- package/www/build/{p-8dd2b524.js → p-e46ad709.js} +1 -1
- package/www/build/p-f12092db.js +1 -0
- package/www/build/vviinn-widgets.esm.js +1 -1
- package/www/index.html +1 -1
- package/dist/vviinn-widgets/p-11901002.js +0 -1
- package/dist/vviinn-widgets/p-a18c9fd0.js +0 -15
- package/dist/vviinn-widgets/p-b712167e.js +0 -1
- package/dist/vviinn-widgets/p-c290a38a.entry.js +0 -1
- package/www/build/p-11901002.js +0 -1
- package/www/build/p-a18c9fd0.js +0 -15
- package/www/build/p-b712167e.js +0 -1
- package/www/build/p-c0a19108.js +0 -1
- package/www/build/p-c290a38a.entry.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const index = require('./index-
|
|
3
|
+
const index = require('./index-22940984.js');
|
|
4
4
|
|
|
5
5
|
/*! *****************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -206,14 +206,6 @@ var Status;
|
|
|
206
206
|
Status.fromHttpCode = fromHttpCode;
|
|
207
207
|
})(Status || (Status = {}));
|
|
208
208
|
|
|
209
|
-
var TransactionSamplingMethod;
|
|
210
|
-
(function (TransactionSamplingMethod) {
|
|
211
|
-
TransactionSamplingMethod["Explicit"] = "explicitly_set";
|
|
212
|
-
TransactionSamplingMethod["Sampler"] = "client_sampler";
|
|
213
|
-
TransactionSamplingMethod["Rate"] = "client_rate";
|
|
214
|
-
TransactionSamplingMethod["Inheritance"] = "inheritance";
|
|
215
|
-
})(TransactionSamplingMethod || (TransactionSamplingMethod = {}));
|
|
216
|
-
|
|
217
209
|
var Outcome;
|
|
218
210
|
(function (Outcome) {
|
|
219
211
|
Outcome["BeforeSend"] = "before_send";
|
|
@@ -259,36 +251,6 @@ function dynamicRequire(mod, request) {
|
|
|
259
251
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
260
252
|
return mod.require(request);
|
|
261
253
|
}
|
|
262
|
-
/**
|
|
263
|
-
* Helper for dynamically loading module that should work with linked dependencies.
|
|
264
|
-
* The problem is that we _should_ be using `require(require.resolve(moduleName, { paths: [cwd()] }))`
|
|
265
|
-
* However it's _not possible_ to do that with Webpack, as it has to know all the dependencies during
|
|
266
|
-
* build time. `require.resolve` is also not available in any other way, so we cannot create,
|
|
267
|
-
* a fake helper like we do with `dynamicRequire`.
|
|
268
|
-
*
|
|
269
|
-
* We always prefer to use local package, thus the value is not returned early from each `try/catch` block.
|
|
270
|
-
* That is to mimic the behavior of `require.resolve` exactly.
|
|
271
|
-
*
|
|
272
|
-
* @param moduleName module name to require
|
|
273
|
-
* @returns possibly required module
|
|
274
|
-
*/
|
|
275
|
-
function loadModule(moduleName) {
|
|
276
|
-
var mod;
|
|
277
|
-
try {
|
|
278
|
-
mod = dynamicRequire(module, moduleName);
|
|
279
|
-
}
|
|
280
|
-
catch (e) {
|
|
281
|
-
// no-empty
|
|
282
|
-
}
|
|
283
|
-
try {
|
|
284
|
-
var cwd = dynamicRequire(module, 'process').cwd;
|
|
285
|
-
mod = dynamicRequire(module, cwd() + "/node_modules/" + moduleName);
|
|
286
|
-
}
|
|
287
|
-
catch (e) {
|
|
288
|
-
// no-empty
|
|
289
|
-
}
|
|
290
|
-
return mod;
|
|
291
|
-
}
|
|
292
254
|
|
|
293
255
|
/**
|
|
294
256
|
* NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
|
|
@@ -687,7 +649,7 @@ var Dsn = /** @class */ (function () {
|
|
|
687
649
|
}());
|
|
688
650
|
|
|
689
651
|
// TODO: Implement different loggers for different environments
|
|
690
|
-
var global$
|
|
652
|
+
var global$6 = getGlobalObject();
|
|
691
653
|
/** Prefix for logging strings */
|
|
692
654
|
var PREFIX = 'Sentry Logger ';
|
|
693
655
|
/**
|
|
@@ -746,7 +708,7 @@ var Logger = /** @class */ (function () {
|
|
|
746
708
|
return;
|
|
747
709
|
}
|
|
748
710
|
consoleSandbox(function () {
|
|
749
|
-
global$
|
|
711
|
+
global$6.console.log(PREFIX + "[Log]: " + args.join(' '));
|
|
750
712
|
});
|
|
751
713
|
};
|
|
752
714
|
/** JSDoc */
|
|
@@ -759,7 +721,7 @@ var Logger = /** @class */ (function () {
|
|
|
759
721
|
return;
|
|
760
722
|
}
|
|
761
723
|
consoleSandbox(function () {
|
|
762
|
-
global$
|
|
724
|
+
global$6.console.warn(PREFIX + "[Warn]: " + args.join(' '));
|
|
763
725
|
});
|
|
764
726
|
};
|
|
765
727
|
/** JSDoc */
|
|
@@ -772,14 +734,14 @@ var Logger = /** @class */ (function () {
|
|
|
772
734
|
return;
|
|
773
735
|
}
|
|
774
736
|
consoleSandbox(function () {
|
|
775
|
-
global$
|
|
737
|
+
global$6.console.error(PREFIX + "[Error]: " + args.join(' '));
|
|
776
738
|
});
|
|
777
739
|
};
|
|
778
740
|
return Logger;
|
|
779
741
|
}());
|
|
780
742
|
// Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
|
|
781
|
-
global$
|
|
782
|
-
var logger = global$
|
|
743
|
+
global$6.__SENTRY__ = global$6.__SENTRY__ || {};
|
|
744
|
+
var logger = global$6.__SENTRY__.logger || (global$6.__SENTRY__.logger = new Logger());
|
|
783
745
|
|
|
784
746
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
785
747
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -1348,7 +1310,7 @@ function supportsHistory() {
|
|
|
1348
1310
|
return !isChromePackagedApp && hasHistoryApi;
|
|
1349
1311
|
}
|
|
1350
1312
|
|
|
1351
|
-
var global$
|
|
1313
|
+
var global$5 = getGlobalObject();
|
|
1352
1314
|
/**
|
|
1353
1315
|
* Instrument native APIs to call handlers that can be used to create breadcrumbs, APM spans etc.
|
|
1354
1316
|
* - Console API
|
|
@@ -1433,14 +1395,14 @@ function triggerHandlers(type, data) {
|
|
|
1433
1395
|
}
|
|
1434
1396
|
/** JSDoc */
|
|
1435
1397
|
function instrumentConsole() {
|
|
1436
|
-
if (!('console' in global$
|
|
1398
|
+
if (!('console' in global$5)) {
|
|
1437
1399
|
return;
|
|
1438
1400
|
}
|
|
1439
1401
|
['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) {
|
|
1440
|
-
if (!(level in global$
|
|
1402
|
+
if (!(level in global$5.console)) {
|
|
1441
1403
|
return;
|
|
1442
1404
|
}
|
|
1443
|
-
fill(global$
|
|
1405
|
+
fill(global$5.console, level, function (originalConsoleLevel) {
|
|
1444
1406
|
return function () {
|
|
1445
1407
|
var args = [];
|
|
1446
1408
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -1449,7 +1411,7 @@ function instrumentConsole() {
|
|
|
1449
1411
|
triggerHandlers('console', { args: args, level: level });
|
|
1450
1412
|
// this fails for some browsers. :(
|
|
1451
1413
|
if (originalConsoleLevel) {
|
|
1452
|
-
Function.prototype.apply.call(originalConsoleLevel, global$
|
|
1414
|
+
Function.prototype.apply.call(originalConsoleLevel, global$5.console, args);
|
|
1453
1415
|
}
|
|
1454
1416
|
};
|
|
1455
1417
|
});
|
|
@@ -1460,7 +1422,7 @@ function instrumentFetch() {
|
|
|
1460
1422
|
if (!supportsNativeFetch()) {
|
|
1461
1423
|
return;
|
|
1462
1424
|
}
|
|
1463
|
-
fill(global$
|
|
1425
|
+
fill(global$5, 'fetch', function (originalFetch) {
|
|
1464
1426
|
return function () {
|
|
1465
1427
|
var args = [];
|
|
1466
1428
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -1476,7 +1438,7 @@ function instrumentFetch() {
|
|
|
1476
1438
|
};
|
|
1477
1439
|
triggerHandlers('fetch', __assign({}, handlerData));
|
|
1478
1440
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1479
|
-
return originalFetch.apply(global$
|
|
1441
|
+
return originalFetch.apply(global$5, args).then(function (response) {
|
|
1480
1442
|
triggerHandlers('fetch', __assign(__assign({}, handlerData), { endTimestamp: Date.now(), response: response }));
|
|
1481
1443
|
return response;
|
|
1482
1444
|
}, function (error) {
|
|
@@ -1493,7 +1455,7 @@ function instrumentFetch() {
|
|
|
1493
1455
|
/** Extract `method` from fetch call arguments */
|
|
1494
1456
|
function getFetchMethod(fetchArgs) {
|
|
1495
1457
|
if (fetchArgs === void 0) { fetchArgs = []; }
|
|
1496
|
-
if ('Request' in global$
|
|
1458
|
+
if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request) && fetchArgs[0].method) {
|
|
1497
1459
|
return String(fetchArgs[0].method).toUpperCase();
|
|
1498
1460
|
}
|
|
1499
1461
|
if (fetchArgs[1] && fetchArgs[1].method) {
|
|
@@ -1507,7 +1469,7 @@ function getFetchUrl(fetchArgs) {
|
|
|
1507
1469
|
if (typeof fetchArgs[0] === 'string') {
|
|
1508
1470
|
return fetchArgs[0];
|
|
1509
1471
|
}
|
|
1510
|
-
if ('Request' in global$
|
|
1472
|
+
if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request)) {
|
|
1511
1473
|
return fetchArgs[0].url;
|
|
1512
1474
|
}
|
|
1513
1475
|
return String(fetchArgs[0]);
|
|
@@ -1515,7 +1477,7 @@ function getFetchUrl(fetchArgs) {
|
|
|
1515
1477
|
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
|
|
1516
1478
|
/** JSDoc */
|
|
1517
1479
|
function instrumentXHR() {
|
|
1518
|
-
if (!('XMLHttpRequest' in global$
|
|
1480
|
+
if (!('XMLHttpRequest' in global$5)) {
|
|
1519
1481
|
return;
|
|
1520
1482
|
}
|
|
1521
1483
|
// Poor man's implementation of ES6 `Map`, tracking and keeping in sync key and value separately.
|
|
@@ -1616,13 +1578,13 @@ function instrumentHistory() {
|
|
|
1616
1578
|
if (!supportsHistory()) {
|
|
1617
1579
|
return;
|
|
1618
1580
|
}
|
|
1619
|
-
var oldOnPopState = global$
|
|
1620
|
-
global$
|
|
1581
|
+
var oldOnPopState = global$5.onpopstate;
|
|
1582
|
+
global$5.onpopstate = function () {
|
|
1621
1583
|
var args = [];
|
|
1622
1584
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1623
1585
|
args[_i] = arguments[_i];
|
|
1624
1586
|
}
|
|
1625
|
-
var to = global$
|
|
1587
|
+
var to = global$5.location.href;
|
|
1626
1588
|
// keep track of the current URL state, as we always receive only the updated state
|
|
1627
1589
|
var from = lastHref;
|
|
1628
1590
|
lastHref = to;
|
|
@@ -1664,8 +1626,8 @@ function instrumentHistory() {
|
|
|
1664
1626
|
return originalHistoryFunction.apply(this, args);
|
|
1665
1627
|
};
|
|
1666
1628
|
}
|
|
1667
|
-
fill(global$
|
|
1668
|
-
fill(global$
|
|
1629
|
+
fill(global$5.history, 'pushState', historyReplacementFunction);
|
|
1630
|
+
fill(global$5.history, 'replaceState', historyReplacementFunction);
|
|
1669
1631
|
}
|
|
1670
1632
|
var debounceDuration = 1000;
|
|
1671
1633
|
var debounceTimerID;
|
|
@@ -1768,14 +1730,14 @@ function makeDOMEventHandler(handler, globalListener) {
|
|
|
1768
1730
|
}
|
|
1769
1731
|
// Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together.
|
|
1770
1732
|
clearTimeout(debounceTimerID);
|
|
1771
|
-
debounceTimerID = global$
|
|
1733
|
+
debounceTimerID = global$5.setTimeout(function () {
|
|
1772
1734
|
debounceTimerID = undefined;
|
|
1773
1735
|
}, debounceDuration);
|
|
1774
1736
|
};
|
|
1775
1737
|
}
|
|
1776
1738
|
/** JSDoc */
|
|
1777
1739
|
function instrumentDOM() {
|
|
1778
|
-
if (!('document' in global$
|
|
1740
|
+
if (!('document' in global$5)) {
|
|
1779
1741
|
return;
|
|
1780
1742
|
}
|
|
1781
1743
|
// Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom
|
|
@@ -1783,8 +1745,8 @@ function instrumentDOM() {
|
|
|
1783
1745
|
// we instrument `addEventListener` so that we don't end up attaching this handler twice.
|
|
1784
1746
|
var triggerDOMHandler = triggerHandlers.bind(null, 'dom');
|
|
1785
1747
|
var globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true);
|
|
1786
|
-
global$
|
|
1787
|
-
global$
|
|
1748
|
+
global$5.document.addEventListener('click', globalDOMEventHandler, false);
|
|
1749
|
+
global$5.document.addEventListener('keypress', globalDOMEventHandler, false);
|
|
1788
1750
|
// After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled
|
|
1789
1751
|
// clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That
|
|
1790
1752
|
// way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler
|
|
@@ -1792,7 +1754,7 @@ function instrumentDOM() {
|
|
|
1792
1754
|
// guaranteed to fire at least once.)
|
|
1793
1755
|
['EventTarget', 'Node'].forEach(function (target) {
|
|
1794
1756
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1795
|
-
var proto = global$
|
|
1757
|
+
var proto = global$5[target] && global$5[target].prototype;
|
|
1796
1758
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
|
|
1797
1759
|
if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
|
|
1798
1760
|
return;
|
|
@@ -1853,8 +1815,8 @@ function instrumentDOM() {
|
|
|
1853
1815
|
var _oldOnErrorHandler = null;
|
|
1854
1816
|
/** JSDoc */
|
|
1855
1817
|
function instrumentError() {
|
|
1856
|
-
_oldOnErrorHandler = global$
|
|
1857
|
-
global$
|
|
1818
|
+
_oldOnErrorHandler = global$5.onerror;
|
|
1819
|
+
global$5.onerror = function (msg, url, line, column, error) {
|
|
1858
1820
|
triggerHandlers('error', {
|
|
1859
1821
|
column: column,
|
|
1860
1822
|
error: error,
|
|
@@ -1872,8 +1834,8 @@ function instrumentError() {
|
|
|
1872
1834
|
var _oldOnUnhandledRejectionHandler = null;
|
|
1873
1835
|
/** JSDoc */
|
|
1874
1836
|
function instrumentUnhandledRejection() {
|
|
1875
|
-
_oldOnUnhandledRejectionHandler = global$
|
|
1876
|
-
global$
|
|
1837
|
+
_oldOnUnhandledRejectionHandler = global$5.onunhandledrejection;
|
|
1838
|
+
global$5.onunhandledrejection = function (e) {
|
|
1877
1839
|
triggerHandlers('unhandledrejection', e);
|
|
1878
1840
|
if (_oldOnUnhandledRejectionHandler) {
|
|
1879
1841
|
// eslint-disable-next-line prefer-rest-params
|
|
@@ -2430,13 +2392,11 @@ var dateTimestampInSeconds = dateTimestampSource.nowSeconds.bind(dateTimestampSo
|
|
|
2430
2392
|
* See https://github.com/getsentry/sentry-javascript/issues/2590.
|
|
2431
2393
|
*/
|
|
2432
2394
|
var timestampInSeconds = timestampSource.nowSeconds.bind(timestampSource);
|
|
2433
|
-
// Re-exported with an old name for backwards-compatibility.
|
|
2434
|
-
var timestampWithMs = timestampInSeconds;
|
|
2435
2395
|
/**
|
|
2436
2396
|
* The number of milliseconds since the UNIX epoch. This value is only usable in a browser, and only when the
|
|
2437
2397
|
* performance API is available.
|
|
2438
2398
|
*/
|
|
2439
|
-
|
|
2399
|
+
((function () {
|
|
2440
2400
|
// Unfortunately browsers may report an inaccurate time origin data, through either performance.timeOrigin or
|
|
2441
2401
|
// performance.timing.navigationStart, which results in poor results in performance data. We only treat time origin
|
|
2442
2402
|
// data as reliable if they are within a reasonable threshold of the current time.
|
|
@@ -2473,7 +2433,7 @@ var browserPerformanceTimeOrigin = (function () {
|
|
|
2473
2433
|
}
|
|
2474
2434
|
}
|
|
2475
2435
|
return dateNow;
|
|
2476
|
-
})();
|
|
2436
|
+
}))();
|
|
2477
2437
|
|
|
2478
2438
|
/**
|
|
2479
2439
|
* Absolute maximum number of breadcrumbs added to an event.
|
|
@@ -5134,7 +5094,7 @@ function eventFromString(input, syntheticException, options) {
|
|
|
5134
5094
|
return event;
|
|
5135
5095
|
}
|
|
5136
5096
|
|
|
5137
|
-
var global$
|
|
5097
|
+
var global$4 = getGlobalObject();
|
|
5138
5098
|
var cachedFetchImpl;
|
|
5139
5099
|
/**
|
|
5140
5100
|
* A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
|
|
@@ -5181,11 +5141,11 @@ function getNativeFetchImplementation() {
|
|
|
5181
5141
|
}
|
|
5182
5142
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
5183
5143
|
// Fast path to avoid DOM I/O
|
|
5184
|
-
if (isNativeFetch(global$
|
|
5185
|
-
return (cachedFetchImpl = global$
|
|
5144
|
+
if (isNativeFetch(global$4.fetch)) {
|
|
5145
|
+
return (cachedFetchImpl = global$4.fetch.bind(global$4));
|
|
5186
5146
|
}
|
|
5187
|
-
var document = global$
|
|
5188
|
-
var fetchImpl = global$
|
|
5147
|
+
var document = global$4.document;
|
|
5148
|
+
var fetchImpl = global$4.fetch;
|
|
5189
5149
|
// eslint-disable-next-line deprecation/deprecation
|
|
5190
5150
|
if (typeof ((_a = document) === null || _a === void 0 ? void 0 : _a.createElement) === "function") {
|
|
5191
5151
|
try {
|
|
@@ -5201,7 +5161,7 @@ function getNativeFetchImplementation() {
|
|
|
5201
5161
|
logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);
|
|
5202
5162
|
}
|
|
5203
5163
|
}
|
|
5204
|
-
return (cachedFetchImpl = fetchImpl.bind(global$
|
|
5164
|
+
return (cachedFetchImpl = fetchImpl.bind(global$4));
|
|
5205
5165
|
/* eslint-enable @typescript-eslint/unbound-method */
|
|
5206
5166
|
}
|
|
5207
5167
|
/**
|
|
@@ -5211,11 +5171,11 @@ function getNativeFetchImplementation() {
|
|
|
5211
5171
|
* @param body report payload
|
|
5212
5172
|
*/
|
|
5213
5173
|
function sendReport(url, body) {
|
|
5214
|
-
var isRealNavigator = Object.prototype.toString.call(global$
|
|
5215
|
-
var hasSendBeacon = isRealNavigator && typeof global$
|
|
5174
|
+
var isRealNavigator = Object.prototype.toString.call(global$4 && global$4.navigator) === '[object Navigator]';
|
|
5175
|
+
var hasSendBeacon = isRealNavigator && typeof global$4.navigator.sendBeacon === 'function';
|
|
5216
5176
|
if (hasSendBeacon) {
|
|
5217
5177
|
// Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
|
|
5218
|
-
var sendBeacon = global$
|
|
5178
|
+
var sendBeacon = global$4.navigator.sendBeacon.bind(global$4.navigator);
|
|
5219
5179
|
return sendBeacon(url, body);
|
|
5220
5180
|
}
|
|
5221
5181
|
if (supportsFetch()) {
|
|
@@ -5235,7 +5195,7 @@ var CATEGORY_MAPPING = {
|
|
|
5235
5195
|
session: 'session',
|
|
5236
5196
|
attachment: 'attachment',
|
|
5237
5197
|
};
|
|
5238
|
-
var global$
|
|
5198
|
+
var global$3 = getGlobalObject();
|
|
5239
5199
|
/** Base Transport class implementation */
|
|
5240
5200
|
var BaseTransport = /** @class */ (function () {
|
|
5241
5201
|
function BaseTransport(options) {
|
|
@@ -5249,9 +5209,9 @@ var BaseTransport = /** @class */ (function () {
|
|
|
5249
5209
|
this._api = new API(options.dsn, options._metadata, options.tunnel);
|
|
5250
5210
|
// eslint-disable-next-line deprecation/deprecation
|
|
5251
5211
|
this.url = this._api.getStoreEndpointWithUrlEncodedAuth();
|
|
5252
|
-
if (this.options.sendClientReports && global$
|
|
5253
|
-
global$
|
|
5254
|
-
if (global$
|
|
5212
|
+
if (this.options.sendClientReports && global$3.document) {
|
|
5213
|
+
global$3.document.addEventListener('visibilitychange', function () {
|
|
5214
|
+
if (global$3.document.visibilityState === 'hidden') {
|
|
5255
5215
|
_this._flushOutcomes();
|
|
5256
5216
|
}
|
|
5257
5217
|
});
|
|
@@ -5612,7 +5572,7 @@ var BrowserBackend = /** @class */ (function (_super) {
|
|
|
5612
5572
|
return BrowserBackend;
|
|
5613
5573
|
}(BaseBackend));
|
|
5614
5574
|
|
|
5615
|
-
var global$
|
|
5575
|
+
var global$2 = getGlobalObject();
|
|
5616
5576
|
var ignoreOnError = 0;
|
|
5617
5577
|
/**
|
|
5618
5578
|
* @hidden
|
|
@@ -5638,7 +5598,7 @@ function ignoreNextOnError() {
|
|
|
5638
5598
|
* @returns The wrapped function.
|
|
5639
5599
|
* @hidden
|
|
5640
5600
|
*/
|
|
5641
|
-
function wrap
|
|
5601
|
+
function wrap(fn, options, before) {
|
|
5642
5602
|
if (options === void 0) { options = {}; }
|
|
5643
5603
|
if (typeof fn !== 'function') {
|
|
5644
5604
|
return fn;
|
|
@@ -5668,7 +5628,7 @@ function wrap$1(fn, options, before) {
|
|
|
5668
5628
|
before.apply(this, arguments);
|
|
5669
5629
|
}
|
|
5670
5630
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
5671
|
-
var wrappedArguments = args.map(function (arg) { return wrap
|
|
5631
|
+
var wrappedArguments = args.map(function (arg) { return wrap(arg, options); });
|
|
5672
5632
|
if (fn.handleEvent) {
|
|
5673
5633
|
// Attempt to invoke user-land function
|
|
5674
5634
|
// NOTE: If you are a Sentry user, and you are seeing this stack frame, it
|
|
@@ -5750,7 +5710,7 @@ function wrap$1(fn, options, before) {
|
|
|
5750
5710
|
*/
|
|
5751
5711
|
function injectReportDialog(options) {
|
|
5752
5712
|
if (options === void 0) { options = {}; }
|
|
5753
|
-
if (!global$
|
|
5713
|
+
if (!global$2.document) {
|
|
5754
5714
|
return;
|
|
5755
5715
|
}
|
|
5756
5716
|
if (!options.eventId) {
|
|
@@ -5761,14 +5721,14 @@ function injectReportDialog(options) {
|
|
|
5761
5721
|
logger.error("Missing dsn option in showReportDialog call");
|
|
5762
5722
|
return;
|
|
5763
5723
|
}
|
|
5764
|
-
var script = global$
|
|
5724
|
+
var script = global$2.document.createElement('script');
|
|
5765
5725
|
script.async = true;
|
|
5766
5726
|
script.src = new API(options.dsn).getReportDialogEndpoint(options);
|
|
5767
5727
|
if (options.onLoad) {
|
|
5768
5728
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
5769
5729
|
script.onload = options.onLoad;
|
|
5770
5730
|
}
|
|
5771
|
-
var injectionPoint = global$
|
|
5731
|
+
var injectionPoint = global$2.document.head || global$2.document.body;
|
|
5772
5732
|
if (injectionPoint) {
|
|
5773
5733
|
injectionPoint.appendChild(script);
|
|
5774
5734
|
}
|
|
@@ -6042,7 +6002,7 @@ var TryCatch = /** @class */ (function () {
|
|
|
6042
6002
|
args[_i] = arguments[_i];
|
|
6043
6003
|
}
|
|
6044
6004
|
var originalCallback = args[0];
|
|
6045
|
-
args[0] = wrap
|
|
6005
|
+
args[0] = wrap(originalCallback, {
|
|
6046
6006
|
mechanism: {
|
|
6047
6007
|
data: { function: getFunctionName(original) },
|
|
6048
6008
|
handled: true,
|
|
@@ -6058,7 +6018,7 @@ var TryCatch = /** @class */ (function () {
|
|
|
6058
6018
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6059
6019
|
return function (callback) {
|
|
6060
6020
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
6061
|
-
return original.call(this, wrap
|
|
6021
|
+
return original.call(this, wrap(callback, {
|
|
6062
6022
|
mechanism: {
|
|
6063
6023
|
data: {
|
|
6064
6024
|
function: 'requestAnimationFrame',
|
|
@@ -6084,7 +6044,7 @@ var TryCatch = /** @class */ (function () {
|
|
|
6084
6044
|
return function (eventName, fn, options) {
|
|
6085
6045
|
try {
|
|
6086
6046
|
if (typeof fn.handleEvent === 'function') {
|
|
6087
|
-
fn.handleEvent = wrap
|
|
6047
|
+
fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
|
|
6088
6048
|
mechanism: {
|
|
6089
6049
|
data: {
|
|
6090
6050
|
function: 'handleEvent',
|
|
@@ -6102,7 +6062,7 @@ var TryCatch = /** @class */ (function () {
|
|
|
6102
6062
|
}
|
|
6103
6063
|
return original.call(this, eventName,
|
|
6104
6064
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6105
|
-
wrap
|
|
6065
|
+
wrap(fn, {
|
|
6106
6066
|
mechanism: {
|
|
6107
6067
|
data: {
|
|
6108
6068
|
function: 'addEventListener',
|
|
@@ -6179,7 +6139,7 @@ var TryCatch = /** @class */ (function () {
|
|
|
6179
6139
|
wrapOptions.mechanism.data.handler = getFunctionName(original.__sentry_original__);
|
|
6180
6140
|
}
|
|
6181
6141
|
// Otherwise wrap directly
|
|
6182
|
-
return wrap
|
|
6142
|
+
return wrap(original, wrapOptions);
|
|
6183
6143
|
});
|
|
6184
6144
|
}
|
|
6185
6145
|
});
|
|
@@ -6513,7 +6473,7 @@ var LinkedErrors = /** @class */ (function () {
|
|
|
6513
6473
|
return LinkedErrors;
|
|
6514
6474
|
}());
|
|
6515
6475
|
|
|
6516
|
-
var global$
|
|
6476
|
+
var global$1 = getGlobalObject();
|
|
6517
6477
|
/** UserAgent */
|
|
6518
6478
|
var UserAgent = /** @class */ (function () {
|
|
6519
6479
|
function UserAgent() {
|
|
@@ -6530,13 +6490,13 @@ var UserAgent = /** @class */ (function () {
|
|
|
6530
6490
|
var _a, _b, _c;
|
|
6531
6491
|
if (getCurrentHub().getIntegration(UserAgent)) {
|
|
6532
6492
|
// if none of the information we want exists, don't bother
|
|
6533
|
-
if (!global$
|
|
6493
|
+
if (!global$1.navigator && !global$1.location && !global$1.document) {
|
|
6534
6494
|
return event;
|
|
6535
6495
|
}
|
|
6536
6496
|
// grab as much info as exists and add it to the event
|
|
6537
|
-
var url = ((_a = event.request) === null || _a === void 0 ? void 0 : _a.url) || ((_b = global$
|
|
6538
|
-
var referrer = (global$
|
|
6539
|
-
var userAgent = (global$
|
|
6497
|
+
var url = ((_a = event.request) === null || _a === void 0 ? void 0 : _a.url) || ((_b = global$1.location) === null || _b === void 0 ? void 0 : _b.href);
|
|
6498
|
+
var referrer = (global$1.document || {}).referrer;
|
|
6499
|
+
var userAgent = (global$1.navigator || {}).userAgent;
|
|
6540
6500
|
var headers = __assign(__assign(__assign({}, (_c = event.request) === null || _c === void 0 ? void 0 : _c.headers), (referrer && { Referer: referrer })), (userAgent && { 'User-Agent': userAgent }));
|
|
6541
6501
|
var request = __assign(__assign({}, (url && { url: url })), { headers: headers });
|
|
6542
6502
|
return __assign(__assign({}, event), { request: request });
|
|
@@ -6915,2587 +6875,13 @@ function startSessionTracking() {
|
|
|
6915
6875
|
});
|
|
6916
6876
|
}
|
|
6917
6877
|
|
|
6918
|
-
/** The status of an Span. */
|
|
6919
|
-
// eslint-disable-next-line import/export
|
|
6920
|
-
var SpanStatus;
|
|
6921
|
-
(function (SpanStatus) {
|
|
6922
|
-
/** The operation completed successfully. */
|
|
6923
|
-
SpanStatus["Ok"] = "ok";
|
|
6924
|
-
/** Deadline expired before operation could complete. */
|
|
6925
|
-
SpanStatus["DeadlineExceeded"] = "deadline_exceeded";
|
|
6926
|
-
/** 401 Unauthorized (actually does mean unauthenticated according to RFC 7235) */
|
|
6927
|
-
SpanStatus["Unauthenticated"] = "unauthenticated";
|
|
6928
|
-
/** 403 Forbidden */
|
|
6929
|
-
SpanStatus["PermissionDenied"] = "permission_denied";
|
|
6930
|
-
/** 404 Not Found. Some requested entity (file or directory) was not found. */
|
|
6931
|
-
SpanStatus["NotFound"] = "not_found";
|
|
6932
|
-
/** 429 Too Many Requests */
|
|
6933
|
-
SpanStatus["ResourceExhausted"] = "resource_exhausted";
|
|
6934
|
-
/** Client specified an invalid argument. 4xx. */
|
|
6935
|
-
SpanStatus["InvalidArgument"] = "invalid_argument";
|
|
6936
|
-
/** 501 Not Implemented */
|
|
6937
|
-
SpanStatus["Unimplemented"] = "unimplemented";
|
|
6938
|
-
/** 503 Service Unavailable */
|
|
6939
|
-
SpanStatus["Unavailable"] = "unavailable";
|
|
6940
|
-
/** Other/generic 5xx. */
|
|
6941
|
-
SpanStatus["InternalError"] = "internal_error";
|
|
6942
|
-
/** Unknown. Any non-standard HTTP status code. */
|
|
6943
|
-
SpanStatus["UnknownError"] = "unknown_error";
|
|
6944
|
-
/** The operation was cancelled (typically by the user). */
|
|
6945
|
-
SpanStatus["Cancelled"] = "cancelled";
|
|
6946
|
-
/** Already exists (409) */
|
|
6947
|
-
SpanStatus["AlreadyExists"] = "already_exists";
|
|
6948
|
-
/** Operation was rejected because the system is not in a state required for the operation's */
|
|
6949
|
-
SpanStatus["FailedPrecondition"] = "failed_precondition";
|
|
6950
|
-
/** The operation was aborted, typically due to a concurrency issue. */
|
|
6951
|
-
SpanStatus["Aborted"] = "aborted";
|
|
6952
|
-
/** Operation was attempted past the valid range. */
|
|
6953
|
-
SpanStatus["OutOfRange"] = "out_of_range";
|
|
6954
|
-
/** Unrecoverable data loss or corruption */
|
|
6955
|
-
SpanStatus["DataLoss"] = "data_loss";
|
|
6956
|
-
})(SpanStatus || (SpanStatus = {}));
|
|
6957
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace, import/export
|
|
6958
|
-
(function (SpanStatus) {
|
|
6959
|
-
/**
|
|
6960
|
-
* Converts a HTTP status code into a {@link SpanStatus}.
|
|
6961
|
-
*
|
|
6962
|
-
* @param httpStatus The HTTP response status code.
|
|
6963
|
-
* @returns The span status or {@link SpanStatus.UnknownError}.
|
|
6964
|
-
*/
|
|
6965
|
-
function fromHttpCode(httpStatus) {
|
|
6966
|
-
if (httpStatus < 400) {
|
|
6967
|
-
return SpanStatus.Ok;
|
|
6968
|
-
}
|
|
6969
|
-
if (httpStatus >= 400 && httpStatus < 500) {
|
|
6970
|
-
switch (httpStatus) {
|
|
6971
|
-
case 401:
|
|
6972
|
-
return SpanStatus.Unauthenticated;
|
|
6973
|
-
case 403:
|
|
6974
|
-
return SpanStatus.PermissionDenied;
|
|
6975
|
-
case 404:
|
|
6976
|
-
return SpanStatus.NotFound;
|
|
6977
|
-
case 409:
|
|
6978
|
-
return SpanStatus.AlreadyExists;
|
|
6979
|
-
case 413:
|
|
6980
|
-
return SpanStatus.FailedPrecondition;
|
|
6981
|
-
case 429:
|
|
6982
|
-
return SpanStatus.ResourceExhausted;
|
|
6983
|
-
default:
|
|
6984
|
-
return SpanStatus.InvalidArgument;
|
|
6985
|
-
}
|
|
6986
|
-
}
|
|
6987
|
-
if (httpStatus >= 500 && httpStatus < 600) {
|
|
6988
|
-
switch (httpStatus) {
|
|
6989
|
-
case 501:
|
|
6990
|
-
return SpanStatus.Unimplemented;
|
|
6991
|
-
case 503:
|
|
6992
|
-
return SpanStatus.Unavailable;
|
|
6993
|
-
case 504:
|
|
6994
|
-
return SpanStatus.DeadlineExceeded;
|
|
6995
|
-
default:
|
|
6996
|
-
return SpanStatus.InternalError;
|
|
6997
|
-
}
|
|
6998
|
-
}
|
|
6999
|
-
return SpanStatus.UnknownError;
|
|
7000
|
-
}
|
|
7001
|
-
SpanStatus.fromHttpCode = fromHttpCode;
|
|
7002
|
-
})(SpanStatus || (SpanStatus = {}));
|
|
7003
|
-
|
|
7004
|
-
var TRACEPARENT_REGEXP = new RegExp('^[ \\t]*' + // whitespace
|
|
7005
|
-
'([0-9a-f]{32})?' + // trace_id
|
|
7006
|
-
'-?([0-9a-f]{16})?' + // span_id
|
|
7007
|
-
'-?([01])?' + // sampled
|
|
7008
|
-
'[ \\t]*$');
|
|
7009
|
-
/**
|
|
7010
|
-
* Determines if tracing is currently enabled.
|
|
7011
|
-
*
|
|
7012
|
-
* Tracing is enabled when at least one of `tracesSampleRate` and `tracesSampler` is defined in the SDK config.
|
|
7013
|
-
*/
|
|
7014
|
-
function hasTracingEnabled(options) {
|
|
7015
|
-
if (options === void 0) { options = (_a = getCurrentHub()
|
|
7016
|
-
.getClient()) === null || _a === void 0 ? void 0 : _a.getOptions(); }
|
|
7017
|
-
var _a;
|
|
7018
|
-
if (!options) {
|
|
7019
|
-
return false;
|
|
7020
|
-
}
|
|
7021
|
-
return 'tracesSampleRate' in options || 'tracesSampler' in options;
|
|
7022
|
-
}
|
|
7023
|
-
/**
|
|
7024
|
-
* Extract transaction context data from a `sentry-trace` header.
|
|
7025
|
-
*
|
|
7026
|
-
* @param traceparent Traceparent string
|
|
7027
|
-
*
|
|
7028
|
-
* @returns Object containing data from the header, or undefined if traceparent string is malformed
|
|
7029
|
-
*/
|
|
7030
|
-
function extractTraceparentData(traceparent) {
|
|
7031
|
-
var matches = traceparent.match(TRACEPARENT_REGEXP);
|
|
7032
|
-
if (matches) {
|
|
7033
|
-
var parentSampled = void 0;
|
|
7034
|
-
if (matches[3] === '1') {
|
|
7035
|
-
parentSampled = true;
|
|
7036
|
-
}
|
|
7037
|
-
else if (matches[3] === '0') {
|
|
7038
|
-
parentSampled = false;
|
|
7039
|
-
}
|
|
7040
|
-
return {
|
|
7041
|
-
traceId: matches[1],
|
|
7042
|
-
parentSampled: parentSampled,
|
|
7043
|
-
parentSpanId: matches[2],
|
|
7044
|
-
};
|
|
7045
|
-
}
|
|
7046
|
-
return undefined;
|
|
7047
|
-
}
|
|
7048
|
-
/** Grabs active transaction off scope, if any */
|
|
7049
|
-
function getActiveTransaction(hub) {
|
|
7050
|
-
if (hub === void 0) { hub = getCurrentHub(); }
|
|
7051
|
-
var _a, _b;
|
|
7052
|
-
return (_b = (_a = hub) === null || _a === void 0 ? void 0 : _a.getScope()) === null || _b === void 0 ? void 0 : _b.getTransaction();
|
|
7053
|
-
}
|
|
7054
|
-
/**
|
|
7055
|
-
* Converts from milliseconds to seconds
|
|
7056
|
-
* @param time time in ms
|
|
7057
|
-
*/
|
|
7058
|
-
function msToSec(time) {
|
|
7059
|
-
return time / 1000;
|
|
7060
|
-
}
|
|
7061
|
-
/**
|
|
7062
|
-
* Converts from seconds to milliseconds
|
|
7063
|
-
* @param time time in seconds
|
|
7064
|
-
*/
|
|
7065
|
-
function secToMs(time) {
|
|
7066
|
-
return time * 1000;
|
|
7067
|
-
}
|
|
7068
|
-
|
|
7069
|
-
/**
|
|
7070
|
-
* Configures global error listeners
|
|
7071
|
-
*/
|
|
7072
|
-
function registerErrorInstrumentation() {
|
|
7073
|
-
addInstrumentationHandler({
|
|
7074
|
-
callback: errorCallback,
|
|
7075
|
-
type: 'error',
|
|
7076
|
-
});
|
|
7077
|
-
addInstrumentationHandler({
|
|
7078
|
-
callback: errorCallback,
|
|
7079
|
-
type: 'unhandledrejection',
|
|
7080
|
-
});
|
|
7081
|
-
}
|
|
7082
|
-
/**
|
|
7083
|
-
* If an error or unhandled promise occurs, we mark the active transaction as failed
|
|
7084
|
-
*/
|
|
7085
|
-
function errorCallback() {
|
|
7086
|
-
var activeTransaction = getActiveTransaction();
|
|
7087
|
-
if (activeTransaction) {
|
|
7088
|
-
logger.log("[Tracing] Transaction: " + SpanStatus.InternalError + " -> Global error occured");
|
|
7089
|
-
activeTransaction.setStatus(SpanStatus.InternalError);
|
|
7090
|
-
}
|
|
7091
|
-
}
|
|
7092
|
-
|
|
7093
|
-
/**
|
|
7094
|
-
* Keeps track of finished spans for a given transaction
|
|
7095
|
-
* @internal
|
|
7096
|
-
* @hideconstructor
|
|
7097
|
-
* @hidden
|
|
7098
|
-
*/
|
|
7099
|
-
var SpanRecorder = /** @class */ (function () {
|
|
7100
|
-
function SpanRecorder(maxlen) {
|
|
7101
|
-
if (maxlen === void 0) { maxlen = 1000; }
|
|
7102
|
-
this.spans = [];
|
|
7103
|
-
this._maxlen = maxlen;
|
|
7104
|
-
}
|
|
7105
|
-
/**
|
|
7106
|
-
* This is just so that we don't run out of memory while recording a lot
|
|
7107
|
-
* of spans. At some point we just stop and flush out the start of the
|
|
7108
|
-
* trace tree (i.e.the first n spans with the smallest
|
|
7109
|
-
* start_timestamp).
|
|
7110
|
-
*/
|
|
7111
|
-
SpanRecorder.prototype.add = function (span) {
|
|
7112
|
-
if (this.spans.length > this._maxlen) {
|
|
7113
|
-
span.spanRecorder = undefined;
|
|
7114
|
-
}
|
|
7115
|
-
else {
|
|
7116
|
-
this.spans.push(span);
|
|
7117
|
-
}
|
|
7118
|
-
};
|
|
7119
|
-
return SpanRecorder;
|
|
7120
|
-
}());
|
|
7121
|
-
/**
|
|
7122
|
-
* Span contains all data about a span
|
|
7123
|
-
*/
|
|
7124
|
-
var Span = /** @class */ (function () {
|
|
7125
|
-
/**
|
|
7126
|
-
* You should never call the constructor manually, always use `Sentry.startTransaction()`
|
|
7127
|
-
* or call `startChild()` on an existing span.
|
|
7128
|
-
* @internal
|
|
7129
|
-
* @hideconstructor
|
|
7130
|
-
* @hidden
|
|
7131
|
-
*/
|
|
7132
|
-
function Span(spanContext) {
|
|
7133
|
-
/**
|
|
7134
|
-
* @inheritDoc
|
|
7135
|
-
*/
|
|
7136
|
-
this.traceId = uuid4();
|
|
7137
|
-
/**
|
|
7138
|
-
* @inheritDoc
|
|
7139
|
-
*/
|
|
7140
|
-
this.spanId = uuid4().substring(16);
|
|
7141
|
-
/**
|
|
7142
|
-
* Timestamp in seconds when the span was created.
|
|
7143
|
-
*/
|
|
7144
|
-
this.startTimestamp = timestampWithMs();
|
|
7145
|
-
/**
|
|
7146
|
-
* @inheritDoc
|
|
7147
|
-
*/
|
|
7148
|
-
this.tags = {};
|
|
7149
|
-
/**
|
|
7150
|
-
* @inheritDoc
|
|
7151
|
-
*/
|
|
7152
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7153
|
-
this.data = {};
|
|
7154
|
-
if (!spanContext) {
|
|
7155
|
-
return this;
|
|
7156
|
-
}
|
|
7157
|
-
if (spanContext.traceId) {
|
|
7158
|
-
this.traceId = spanContext.traceId;
|
|
7159
|
-
}
|
|
7160
|
-
if (spanContext.spanId) {
|
|
7161
|
-
this.spanId = spanContext.spanId;
|
|
7162
|
-
}
|
|
7163
|
-
if (spanContext.parentSpanId) {
|
|
7164
|
-
this.parentSpanId = spanContext.parentSpanId;
|
|
7165
|
-
}
|
|
7166
|
-
// We want to include booleans as well here
|
|
7167
|
-
if ('sampled' in spanContext) {
|
|
7168
|
-
this.sampled = spanContext.sampled;
|
|
7169
|
-
}
|
|
7170
|
-
if (spanContext.op) {
|
|
7171
|
-
this.op = spanContext.op;
|
|
7172
|
-
}
|
|
7173
|
-
if (spanContext.description) {
|
|
7174
|
-
this.description = spanContext.description;
|
|
7175
|
-
}
|
|
7176
|
-
if (spanContext.data) {
|
|
7177
|
-
this.data = spanContext.data;
|
|
7178
|
-
}
|
|
7179
|
-
if (spanContext.tags) {
|
|
7180
|
-
this.tags = spanContext.tags;
|
|
7181
|
-
}
|
|
7182
|
-
if (spanContext.status) {
|
|
7183
|
-
this.status = spanContext.status;
|
|
7184
|
-
}
|
|
7185
|
-
if (spanContext.startTimestamp) {
|
|
7186
|
-
this.startTimestamp = spanContext.startTimestamp;
|
|
7187
|
-
}
|
|
7188
|
-
if (spanContext.endTimestamp) {
|
|
7189
|
-
this.endTimestamp = spanContext.endTimestamp;
|
|
7190
|
-
}
|
|
7191
|
-
}
|
|
7192
|
-
/**
|
|
7193
|
-
* @inheritDoc
|
|
7194
|
-
* @deprecated
|
|
7195
|
-
*/
|
|
7196
|
-
Span.prototype.child = function (spanContext) {
|
|
7197
|
-
return this.startChild(spanContext);
|
|
7198
|
-
};
|
|
7199
|
-
/**
|
|
7200
|
-
* @inheritDoc
|
|
7201
|
-
*/
|
|
7202
|
-
Span.prototype.startChild = function (spanContext) {
|
|
7203
|
-
var childSpan = new Span(__assign(__assign({}, spanContext), { parentSpanId: this.spanId, sampled: this.sampled, traceId: this.traceId }));
|
|
7204
|
-
childSpan.spanRecorder = this.spanRecorder;
|
|
7205
|
-
if (childSpan.spanRecorder) {
|
|
7206
|
-
childSpan.spanRecorder.add(childSpan);
|
|
7207
|
-
}
|
|
7208
|
-
childSpan.transaction = this.transaction;
|
|
7209
|
-
return childSpan;
|
|
7210
|
-
};
|
|
7211
|
-
/**
|
|
7212
|
-
* @inheritDoc
|
|
7213
|
-
*/
|
|
7214
|
-
Span.prototype.setTag = function (key, value) {
|
|
7215
|
-
var _a;
|
|
7216
|
-
this.tags = __assign(__assign({}, this.tags), (_a = {}, _a[key] = value, _a));
|
|
7217
|
-
return this;
|
|
7218
|
-
};
|
|
7219
|
-
/**
|
|
7220
|
-
* @inheritDoc
|
|
7221
|
-
*/
|
|
7222
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
7223
|
-
Span.prototype.setData = function (key, value) {
|
|
7224
|
-
var _a;
|
|
7225
|
-
this.data = __assign(__assign({}, this.data), (_a = {}, _a[key] = value, _a));
|
|
7226
|
-
return this;
|
|
7227
|
-
};
|
|
7228
|
-
/**
|
|
7229
|
-
* @inheritDoc
|
|
7230
|
-
*/
|
|
7231
|
-
Span.prototype.setStatus = function (value) {
|
|
7232
|
-
this.status = value;
|
|
7233
|
-
return this;
|
|
7234
|
-
};
|
|
7235
|
-
/**
|
|
7236
|
-
* @inheritDoc
|
|
7237
|
-
*/
|
|
7238
|
-
Span.prototype.setHttpStatus = function (httpStatus) {
|
|
7239
|
-
this.setTag('http.status_code', String(httpStatus));
|
|
7240
|
-
var spanStatus = SpanStatus.fromHttpCode(httpStatus);
|
|
7241
|
-
if (spanStatus !== SpanStatus.UnknownError) {
|
|
7242
|
-
this.setStatus(spanStatus);
|
|
7243
|
-
}
|
|
7244
|
-
return this;
|
|
7245
|
-
};
|
|
7246
|
-
/**
|
|
7247
|
-
* @inheritDoc
|
|
7248
|
-
*/
|
|
7249
|
-
Span.prototype.isSuccess = function () {
|
|
7250
|
-
return this.status === SpanStatus.Ok;
|
|
7251
|
-
};
|
|
7252
|
-
/**
|
|
7253
|
-
* @inheritDoc
|
|
7254
|
-
*/
|
|
7255
|
-
Span.prototype.finish = function (endTimestamp) {
|
|
7256
|
-
this.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : timestampWithMs();
|
|
7257
|
-
};
|
|
7258
|
-
/**
|
|
7259
|
-
* @inheritDoc
|
|
7260
|
-
*/
|
|
7261
|
-
Span.prototype.toTraceparent = function () {
|
|
7262
|
-
var sampledString = '';
|
|
7263
|
-
if (this.sampled !== undefined) {
|
|
7264
|
-
sampledString = this.sampled ? '-1' : '-0';
|
|
7265
|
-
}
|
|
7266
|
-
return this.traceId + "-" + this.spanId + sampledString;
|
|
7267
|
-
};
|
|
7268
|
-
/**
|
|
7269
|
-
* @inheritDoc
|
|
7270
|
-
*/
|
|
7271
|
-
Span.prototype.toContext = function () {
|
|
7272
|
-
return dropUndefinedKeys({
|
|
7273
|
-
data: this.data,
|
|
7274
|
-
description: this.description,
|
|
7275
|
-
endTimestamp: this.endTimestamp,
|
|
7276
|
-
op: this.op,
|
|
7277
|
-
parentSpanId: this.parentSpanId,
|
|
7278
|
-
sampled: this.sampled,
|
|
7279
|
-
spanId: this.spanId,
|
|
7280
|
-
startTimestamp: this.startTimestamp,
|
|
7281
|
-
status: this.status,
|
|
7282
|
-
tags: this.tags,
|
|
7283
|
-
traceId: this.traceId,
|
|
7284
|
-
});
|
|
7285
|
-
};
|
|
7286
|
-
/**
|
|
7287
|
-
* @inheritDoc
|
|
7288
|
-
*/
|
|
7289
|
-
Span.prototype.updateWithContext = function (spanContext) {
|
|
7290
|
-
var _a, _b, _c, _d, _e;
|
|
7291
|
-
this.data = (_a = spanContext.data, (_a !== null && _a !== void 0 ? _a : {}));
|
|
7292
|
-
this.description = spanContext.description;
|
|
7293
|
-
this.endTimestamp = spanContext.endTimestamp;
|
|
7294
|
-
this.op = spanContext.op;
|
|
7295
|
-
this.parentSpanId = spanContext.parentSpanId;
|
|
7296
|
-
this.sampled = spanContext.sampled;
|
|
7297
|
-
this.spanId = (_b = spanContext.spanId, (_b !== null && _b !== void 0 ? _b : this.spanId));
|
|
7298
|
-
this.startTimestamp = (_c = spanContext.startTimestamp, (_c !== null && _c !== void 0 ? _c : this.startTimestamp));
|
|
7299
|
-
this.status = spanContext.status;
|
|
7300
|
-
this.tags = (_d = spanContext.tags, (_d !== null && _d !== void 0 ? _d : {}));
|
|
7301
|
-
this.traceId = (_e = spanContext.traceId, (_e !== null && _e !== void 0 ? _e : this.traceId));
|
|
7302
|
-
return this;
|
|
7303
|
-
};
|
|
7304
|
-
/**
|
|
7305
|
-
* @inheritDoc
|
|
7306
|
-
*/
|
|
7307
|
-
Span.prototype.getTraceContext = function () {
|
|
7308
|
-
return dropUndefinedKeys({
|
|
7309
|
-
data: Object.keys(this.data).length > 0 ? this.data : undefined,
|
|
7310
|
-
description: this.description,
|
|
7311
|
-
op: this.op,
|
|
7312
|
-
parent_span_id: this.parentSpanId,
|
|
7313
|
-
span_id: this.spanId,
|
|
7314
|
-
status: this.status,
|
|
7315
|
-
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
|
|
7316
|
-
trace_id: this.traceId,
|
|
7317
|
-
});
|
|
7318
|
-
};
|
|
7319
|
-
/**
|
|
7320
|
-
* @inheritDoc
|
|
7321
|
-
*/
|
|
7322
|
-
Span.prototype.toJSON = function () {
|
|
7323
|
-
return dropUndefinedKeys({
|
|
7324
|
-
data: Object.keys(this.data).length > 0 ? this.data : undefined,
|
|
7325
|
-
description: this.description,
|
|
7326
|
-
op: this.op,
|
|
7327
|
-
parent_span_id: this.parentSpanId,
|
|
7328
|
-
span_id: this.spanId,
|
|
7329
|
-
start_timestamp: this.startTimestamp,
|
|
7330
|
-
status: this.status,
|
|
7331
|
-
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
|
|
7332
|
-
timestamp: this.endTimestamp,
|
|
7333
|
-
trace_id: this.traceId,
|
|
7334
|
-
});
|
|
7335
|
-
};
|
|
7336
|
-
return Span;
|
|
7337
|
-
}());
|
|
7338
|
-
|
|
7339
|
-
/** JSDoc */
|
|
7340
|
-
var Transaction = /** @class */ (function (_super) {
|
|
7341
|
-
__extends(Transaction, _super);
|
|
7342
|
-
/**
|
|
7343
|
-
* This constructor should never be called manually. Those instrumenting tracing should use
|
|
7344
|
-
* `Sentry.startTransaction()`, and internal methods should use `hub.startTransaction()`.
|
|
7345
|
-
* @internal
|
|
7346
|
-
* @hideconstructor
|
|
7347
|
-
* @hidden
|
|
7348
|
-
*/
|
|
7349
|
-
function Transaction(transactionContext, hub) {
|
|
7350
|
-
var _this = _super.call(this, transactionContext) || this;
|
|
7351
|
-
_this._measurements = {};
|
|
7352
|
-
/**
|
|
7353
|
-
* The reference to the current hub.
|
|
7354
|
-
*/
|
|
7355
|
-
_this._hub = getCurrentHub();
|
|
7356
|
-
if (isInstanceOf(hub, Hub)) {
|
|
7357
|
-
_this._hub = hub;
|
|
7358
|
-
}
|
|
7359
|
-
_this.name = transactionContext.name || '';
|
|
7360
|
-
_this.metadata = transactionContext.metadata || {};
|
|
7361
|
-
_this._trimEnd = transactionContext.trimEnd;
|
|
7362
|
-
// this is because transactions are also spans, and spans have a transaction pointer
|
|
7363
|
-
_this.transaction = _this;
|
|
7364
|
-
return _this;
|
|
7365
|
-
}
|
|
7366
|
-
/**
|
|
7367
|
-
* JSDoc
|
|
7368
|
-
*/
|
|
7369
|
-
Transaction.prototype.setName = function (name) {
|
|
7370
|
-
this.name = name;
|
|
7371
|
-
};
|
|
7372
|
-
/**
|
|
7373
|
-
* Attaches SpanRecorder to the span itself
|
|
7374
|
-
* @param maxlen maximum number of spans that can be recorded
|
|
7375
|
-
*/
|
|
7376
|
-
Transaction.prototype.initSpanRecorder = function (maxlen) {
|
|
7377
|
-
if (maxlen === void 0) { maxlen = 1000; }
|
|
7378
|
-
if (!this.spanRecorder) {
|
|
7379
|
-
this.spanRecorder = new SpanRecorder(maxlen);
|
|
7380
|
-
}
|
|
7381
|
-
this.spanRecorder.add(this);
|
|
7382
|
-
};
|
|
7383
|
-
/**
|
|
7384
|
-
* Set observed measurements for this transaction.
|
|
7385
|
-
* @hidden
|
|
7386
|
-
*/
|
|
7387
|
-
Transaction.prototype.setMeasurements = function (measurements) {
|
|
7388
|
-
this._measurements = __assign({}, measurements);
|
|
7389
|
-
};
|
|
7390
|
-
/**
|
|
7391
|
-
* Set metadata for this transaction.
|
|
7392
|
-
* @hidden
|
|
7393
|
-
*/
|
|
7394
|
-
Transaction.prototype.setMetadata = function (newMetadata) {
|
|
7395
|
-
this.metadata = __assign(__assign({}, this.metadata), newMetadata);
|
|
7396
|
-
};
|
|
7397
|
-
/**
|
|
7398
|
-
* @inheritDoc
|
|
7399
|
-
*/
|
|
7400
|
-
Transaction.prototype.finish = function (endTimestamp) {
|
|
7401
|
-
var _this = this;
|
|
7402
|
-
var _a, _b, _c, _d, _e;
|
|
7403
|
-
// This transaction is already finished, so we should not flush it again.
|
|
7404
|
-
if (this.endTimestamp !== undefined) {
|
|
7405
|
-
return undefined;
|
|
7406
|
-
}
|
|
7407
|
-
if (!this.name) {
|
|
7408
|
-
logger.warn('Transaction has no name, falling back to `<unlabeled transaction>`.');
|
|
7409
|
-
this.name = '<unlabeled transaction>';
|
|
7410
|
-
}
|
|
7411
|
-
// just sets the end timestamp
|
|
7412
|
-
_super.prototype.finish.call(this, endTimestamp);
|
|
7413
|
-
if (this.sampled !== true) {
|
|
7414
|
-
// At this point if `sampled !== true` we want to discard the transaction.
|
|
7415
|
-
logger.log('[Tracing] Discarding transaction because its trace was not chosen to be sampled.');
|
|
7416
|
-
(_e = (_c = (_a = this._hub
|
|
7417
|
-
.getClient()) === null || _a === void 0 ? void 0 : (_b = _a).getTransport) === null || _c === void 0 ? void 0 : (_d = _c.call(_b)).recordLostEvent) === null || _e === void 0 ? void 0 : _e.call(_d, Outcome.SampleRate, 'transaction');
|
|
7418
|
-
return undefined;
|
|
7419
|
-
}
|
|
7420
|
-
var finishedSpans = this.spanRecorder ? this.spanRecorder.spans.filter(function (s) { return s !== _this && s.endTimestamp; }) : [];
|
|
7421
|
-
if (this._trimEnd && finishedSpans.length > 0) {
|
|
7422
|
-
this.endTimestamp = finishedSpans.reduce(function (prev, current) {
|
|
7423
|
-
if (prev.endTimestamp && current.endTimestamp) {
|
|
7424
|
-
return prev.endTimestamp > current.endTimestamp ? prev : current;
|
|
7425
|
-
}
|
|
7426
|
-
return prev;
|
|
7427
|
-
}).endTimestamp;
|
|
7428
|
-
}
|
|
7429
|
-
var transaction = {
|
|
7430
|
-
contexts: {
|
|
7431
|
-
trace: this.getTraceContext(),
|
|
7432
|
-
},
|
|
7433
|
-
spans: finishedSpans,
|
|
7434
|
-
start_timestamp: this.startTimestamp,
|
|
7435
|
-
tags: this.tags,
|
|
7436
|
-
timestamp: this.endTimestamp,
|
|
7437
|
-
transaction: this.name,
|
|
7438
|
-
type: 'transaction',
|
|
7439
|
-
debug_meta: this.metadata,
|
|
7440
|
-
};
|
|
7441
|
-
var hasMeasurements = Object.keys(this._measurements).length > 0;
|
|
7442
|
-
if (hasMeasurements) {
|
|
7443
|
-
logger.log('[Measurements] Adding measurements to transaction', JSON.stringify(this._measurements, undefined, 2));
|
|
7444
|
-
transaction.measurements = this._measurements;
|
|
7445
|
-
}
|
|
7446
|
-
logger.log("[Tracing] Finishing " + this.op + " transaction: " + this.name + ".");
|
|
7447
|
-
return this._hub.captureEvent(transaction);
|
|
7448
|
-
};
|
|
7449
|
-
/**
|
|
7450
|
-
* @inheritDoc
|
|
7451
|
-
*/
|
|
7452
|
-
Transaction.prototype.toContext = function () {
|
|
7453
|
-
var spanContext = _super.prototype.toContext.call(this);
|
|
7454
|
-
return dropUndefinedKeys(__assign(__assign({}, spanContext), { name: this.name, trimEnd: this._trimEnd }));
|
|
7455
|
-
};
|
|
7456
|
-
/**
|
|
7457
|
-
* @inheritDoc
|
|
7458
|
-
*/
|
|
7459
|
-
Transaction.prototype.updateWithContext = function (transactionContext) {
|
|
7460
|
-
var _a;
|
|
7461
|
-
_super.prototype.updateWithContext.call(this, transactionContext);
|
|
7462
|
-
this.name = (_a = transactionContext.name, (_a !== null && _a !== void 0 ? _a : ''));
|
|
7463
|
-
this._trimEnd = transactionContext.trimEnd;
|
|
7464
|
-
return this;
|
|
7465
|
-
};
|
|
7466
|
-
return Transaction;
|
|
7467
|
-
}(Span));
|
|
7468
|
-
|
|
7469
|
-
var DEFAULT_IDLE_TIMEOUT = 1000;
|
|
7470
|
-
var HEARTBEAT_INTERVAL = 5000;
|
|
7471
|
-
/**
|
|
7472
|
-
* @inheritDoc
|
|
7473
|
-
*/
|
|
7474
|
-
var IdleTransactionSpanRecorder = /** @class */ (function (_super) {
|
|
7475
|
-
__extends(IdleTransactionSpanRecorder, _super);
|
|
7476
|
-
function IdleTransactionSpanRecorder(_pushActivity, _popActivity, transactionSpanId, maxlen) {
|
|
7477
|
-
if (transactionSpanId === void 0) { transactionSpanId = ''; }
|
|
7478
|
-
var _this = _super.call(this, maxlen) || this;
|
|
7479
|
-
_this._pushActivity = _pushActivity;
|
|
7480
|
-
_this._popActivity = _popActivity;
|
|
7481
|
-
_this.transactionSpanId = transactionSpanId;
|
|
7482
|
-
return _this;
|
|
7483
|
-
}
|
|
7484
|
-
/**
|
|
7485
|
-
* @inheritDoc
|
|
7486
|
-
*/
|
|
7487
|
-
IdleTransactionSpanRecorder.prototype.add = function (span) {
|
|
7488
|
-
var _this = this;
|
|
7489
|
-
// We should make sure we do not push and pop activities for
|
|
7490
|
-
// the transaction that this span recorder belongs to.
|
|
7491
|
-
if (span.spanId !== this.transactionSpanId) {
|
|
7492
|
-
// We patch span.finish() to pop an activity after setting an endTimestamp.
|
|
7493
|
-
span.finish = function (endTimestamp) {
|
|
7494
|
-
span.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : timestampWithMs();
|
|
7495
|
-
_this._popActivity(span.spanId);
|
|
7496
|
-
};
|
|
7497
|
-
// We should only push new activities if the span does not have an end timestamp.
|
|
7498
|
-
if (span.endTimestamp === undefined) {
|
|
7499
|
-
this._pushActivity(span.spanId);
|
|
7500
|
-
}
|
|
7501
|
-
}
|
|
7502
|
-
_super.prototype.add.call(this, span);
|
|
7503
|
-
};
|
|
7504
|
-
return IdleTransactionSpanRecorder;
|
|
7505
|
-
}(SpanRecorder));
|
|
7506
|
-
/**
|
|
7507
|
-
* An IdleTransaction is a transaction that automatically finishes. It does this by tracking child spans as activities.
|
|
7508
|
-
* You can have multiple IdleTransactions active, but if the `onScope` option is specified, the idle transaction will
|
|
7509
|
-
* put itself on the scope on creation.
|
|
7510
|
-
*/
|
|
7511
|
-
var IdleTransaction = /** @class */ (function (_super) {
|
|
7512
|
-
__extends(IdleTransaction, _super);
|
|
7513
|
-
function IdleTransaction(transactionContext, _idleHub,
|
|
7514
|
-
/**
|
|
7515
|
-
* The time to wait in ms until the idle transaction will be finished.
|
|
7516
|
-
* @default 1000
|
|
7517
|
-
*/
|
|
7518
|
-
_idleTimeout,
|
|
7519
|
-
// If an idle transaction should be put itself on and off the scope automatically.
|
|
7520
|
-
_onScope) {
|
|
7521
|
-
if (_idleTimeout === void 0) { _idleTimeout = DEFAULT_IDLE_TIMEOUT; }
|
|
7522
|
-
if (_onScope === void 0) { _onScope = false; }
|
|
7523
|
-
var _this = _super.call(this, transactionContext, _idleHub) || this;
|
|
7524
|
-
_this._idleHub = _idleHub;
|
|
7525
|
-
_this._idleTimeout = _idleTimeout;
|
|
7526
|
-
_this._onScope = _onScope;
|
|
7527
|
-
// Activities store a list of active spans
|
|
7528
|
-
_this.activities = {};
|
|
7529
|
-
// Amount of times heartbeat has counted. Will cause transaction to finish after 3 beats.
|
|
7530
|
-
_this._heartbeatCounter = 0;
|
|
7531
|
-
// We should not use heartbeat if we finished a transaction
|
|
7532
|
-
_this._finished = false;
|
|
7533
|
-
_this._beforeFinishCallbacks = [];
|
|
7534
|
-
if (_idleHub && _onScope) {
|
|
7535
|
-
// There should only be one active transaction on the scope
|
|
7536
|
-
clearActiveTransaction(_idleHub);
|
|
7537
|
-
// We set the transaction here on the scope so error events pick up the trace
|
|
7538
|
-
// context and attach it to the error.
|
|
7539
|
-
logger.log("Setting idle transaction on scope. Span ID: " + _this.spanId);
|
|
7540
|
-
_idleHub.configureScope(function (scope) { return scope.setSpan(_this); });
|
|
7541
|
-
}
|
|
7542
|
-
_this._initTimeout = setTimeout(function () {
|
|
7543
|
-
if (!_this._finished) {
|
|
7544
|
-
_this.finish();
|
|
7545
|
-
}
|
|
7546
|
-
}, _this._idleTimeout);
|
|
7547
|
-
return _this;
|
|
7548
|
-
}
|
|
7549
|
-
/** {@inheritDoc} */
|
|
7550
|
-
IdleTransaction.prototype.finish = function (endTimestamp) {
|
|
7551
|
-
var e_1, _a;
|
|
7552
|
-
var _this = this;
|
|
7553
|
-
if (endTimestamp === void 0) { endTimestamp = timestampWithMs(); }
|
|
7554
|
-
this._finished = true;
|
|
7555
|
-
this.activities = {};
|
|
7556
|
-
if (this.spanRecorder) {
|
|
7557
|
-
logger.log('[Tracing] finishing IdleTransaction', new Date(endTimestamp * 1000).toISOString(), this.op);
|
|
7558
|
-
try {
|
|
7559
|
-
for (var _b = __values(this._beforeFinishCallbacks), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7560
|
-
var callback = _c.value;
|
|
7561
|
-
callback(this, endTimestamp);
|
|
7562
|
-
}
|
|
7563
|
-
}
|
|
7564
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7565
|
-
finally {
|
|
7566
|
-
try {
|
|
7567
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7568
|
-
}
|
|
7569
|
-
finally { if (e_1) throw e_1.error; }
|
|
7570
|
-
}
|
|
7571
|
-
this.spanRecorder.spans = this.spanRecorder.spans.filter(function (span) {
|
|
7572
|
-
// If we are dealing with the transaction itself, we just return it
|
|
7573
|
-
if (span.spanId === _this.spanId) {
|
|
7574
|
-
return true;
|
|
7575
|
-
}
|
|
7576
|
-
// We cancel all pending spans with status "cancelled" to indicate the idle transaction was finished early
|
|
7577
|
-
if (!span.endTimestamp) {
|
|
7578
|
-
span.endTimestamp = endTimestamp;
|
|
7579
|
-
span.setStatus(SpanStatus.Cancelled);
|
|
7580
|
-
logger.log('[Tracing] cancelling span since transaction ended early', JSON.stringify(span, undefined, 2));
|
|
7581
|
-
}
|
|
7582
|
-
var keepSpan = span.startTimestamp < endTimestamp;
|
|
7583
|
-
if (!keepSpan) {
|
|
7584
|
-
logger.log('[Tracing] discarding Span since it happened after Transaction was finished', JSON.stringify(span, undefined, 2));
|
|
7585
|
-
}
|
|
7586
|
-
return keepSpan;
|
|
7587
|
-
});
|
|
7588
|
-
logger.log('[Tracing] flushing IdleTransaction');
|
|
7589
|
-
}
|
|
7590
|
-
else {
|
|
7591
|
-
logger.log('[Tracing] No active IdleTransaction');
|
|
7592
|
-
}
|
|
7593
|
-
// this._onScope is true if the transaction was previously on the scope.
|
|
7594
|
-
if (this._onScope) {
|
|
7595
|
-
clearActiveTransaction(this._idleHub);
|
|
7596
|
-
}
|
|
7597
|
-
return _super.prototype.finish.call(this, endTimestamp);
|
|
7598
|
-
};
|
|
7599
|
-
/**
|
|
7600
|
-
* Register a callback function that gets excecuted before the transaction finishes.
|
|
7601
|
-
* Useful for cleanup or if you want to add any additional spans based on current context.
|
|
7602
|
-
*
|
|
7603
|
-
* This is exposed because users have no other way of running something before an idle transaction
|
|
7604
|
-
* finishes.
|
|
7605
|
-
*/
|
|
7606
|
-
IdleTransaction.prototype.registerBeforeFinishCallback = function (callback) {
|
|
7607
|
-
this._beforeFinishCallbacks.push(callback);
|
|
7608
|
-
};
|
|
7609
|
-
/**
|
|
7610
|
-
* @inheritDoc
|
|
7611
|
-
*/
|
|
7612
|
-
IdleTransaction.prototype.initSpanRecorder = function (maxlen) {
|
|
7613
|
-
var _this = this;
|
|
7614
|
-
if (!this.spanRecorder) {
|
|
7615
|
-
var pushActivity = function (id) {
|
|
7616
|
-
if (_this._finished) {
|
|
7617
|
-
return;
|
|
7618
|
-
}
|
|
7619
|
-
_this._pushActivity(id);
|
|
7620
|
-
};
|
|
7621
|
-
var popActivity = function (id) {
|
|
7622
|
-
if (_this._finished) {
|
|
7623
|
-
return;
|
|
7624
|
-
}
|
|
7625
|
-
_this._popActivity(id);
|
|
7626
|
-
};
|
|
7627
|
-
this.spanRecorder = new IdleTransactionSpanRecorder(pushActivity, popActivity, this.spanId, maxlen);
|
|
7628
|
-
// Start heartbeat so that transactions do not run forever.
|
|
7629
|
-
logger.log('Starting heartbeat');
|
|
7630
|
-
this._pingHeartbeat();
|
|
7631
|
-
}
|
|
7632
|
-
this.spanRecorder.add(this);
|
|
7633
|
-
};
|
|
7634
|
-
/**
|
|
7635
|
-
* Start tracking a specific activity.
|
|
7636
|
-
* @param spanId The span id that represents the activity
|
|
7637
|
-
*/
|
|
7638
|
-
IdleTransaction.prototype._pushActivity = function (spanId) {
|
|
7639
|
-
if (this._initTimeout) {
|
|
7640
|
-
clearTimeout(this._initTimeout);
|
|
7641
|
-
this._initTimeout = undefined;
|
|
7642
|
-
}
|
|
7643
|
-
logger.log("[Tracing] pushActivity: " + spanId);
|
|
7644
|
-
this.activities[spanId] = true;
|
|
7645
|
-
logger.log('[Tracing] new activities count', Object.keys(this.activities).length);
|
|
7646
|
-
};
|
|
7647
|
-
/**
|
|
7648
|
-
* Remove an activity from usage
|
|
7649
|
-
* @param spanId The span id that represents the activity
|
|
7650
|
-
*/
|
|
7651
|
-
IdleTransaction.prototype._popActivity = function (spanId) {
|
|
7652
|
-
var _this = this;
|
|
7653
|
-
if (this.activities[spanId]) {
|
|
7654
|
-
logger.log("[Tracing] popActivity " + spanId);
|
|
7655
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
7656
|
-
delete this.activities[spanId];
|
|
7657
|
-
logger.log('[Tracing] new activities count', Object.keys(this.activities).length);
|
|
7658
|
-
}
|
|
7659
|
-
if (Object.keys(this.activities).length === 0) {
|
|
7660
|
-
var timeout = this._idleTimeout;
|
|
7661
|
-
// We need to add the timeout here to have the real endtimestamp of the transaction
|
|
7662
|
-
// Remember timestampWithMs is in seconds, timeout is in ms
|
|
7663
|
-
var end_1 = timestampWithMs() + timeout / 1000;
|
|
7664
|
-
setTimeout(function () {
|
|
7665
|
-
if (!_this._finished) {
|
|
7666
|
-
_this.finish(end_1);
|
|
7667
|
-
}
|
|
7668
|
-
}, timeout);
|
|
7669
|
-
}
|
|
7670
|
-
};
|
|
7671
|
-
/**
|
|
7672
|
-
* Checks when entries of this.activities are not changing for 3 beats.
|
|
7673
|
-
* If this occurs we finish the transaction.
|
|
7674
|
-
*/
|
|
7675
|
-
IdleTransaction.prototype._beat = function () {
|
|
7676
|
-
// We should not be running heartbeat if the idle transaction is finished.
|
|
7677
|
-
if (this._finished) {
|
|
7678
|
-
return;
|
|
7679
|
-
}
|
|
7680
|
-
var heartbeatString = Object.keys(this.activities).join('');
|
|
7681
|
-
if (heartbeatString === this._prevHeartbeatString) {
|
|
7682
|
-
this._heartbeatCounter += 1;
|
|
7683
|
-
}
|
|
7684
|
-
else {
|
|
7685
|
-
this._heartbeatCounter = 1;
|
|
7686
|
-
}
|
|
7687
|
-
this._prevHeartbeatString = heartbeatString;
|
|
7688
|
-
if (this._heartbeatCounter >= 3) {
|
|
7689
|
-
logger.log("[Tracing] Transaction finished because of no change for 3 heart beats");
|
|
7690
|
-
this.setStatus(SpanStatus.DeadlineExceeded);
|
|
7691
|
-
this.setTag('heartbeat', 'failed');
|
|
7692
|
-
this.finish();
|
|
7693
|
-
}
|
|
7694
|
-
else {
|
|
7695
|
-
this._pingHeartbeat();
|
|
7696
|
-
}
|
|
7697
|
-
};
|
|
7698
|
-
/**
|
|
7699
|
-
* Pings the heartbeat
|
|
7700
|
-
*/
|
|
7701
|
-
IdleTransaction.prototype._pingHeartbeat = function () {
|
|
7702
|
-
var _this = this;
|
|
7703
|
-
logger.log("pinging Heartbeat -> current counter: " + this._heartbeatCounter);
|
|
7704
|
-
setTimeout(function () {
|
|
7705
|
-
_this._beat();
|
|
7706
|
-
}, HEARTBEAT_INTERVAL);
|
|
7707
|
-
};
|
|
7708
|
-
return IdleTransaction;
|
|
7709
|
-
}(Transaction));
|
|
7710
|
-
/**
|
|
7711
|
-
* Reset active transaction on scope
|
|
7712
|
-
*/
|
|
7713
|
-
function clearActiveTransaction(hub) {
|
|
7714
|
-
if (hub) {
|
|
7715
|
-
var scope = hub.getScope();
|
|
7716
|
-
if (scope) {
|
|
7717
|
-
var transaction = scope.getTransaction();
|
|
7718
|
-
if (transaction) {
|
|
7719
|
-
scope.setSpan(undefined);
|
|
7720
|
-
}
|
|
7721
|
-
}
|
|
7722
|
-
}
|
|
7723
|
-
}
|
|
7724
|
-
|
|
7725
|
-
/** Returns all trace headers that are currently on the top scope. */
|
|
7726
|
-
function traceHeaders() {
|
|
7727
|
-
var scope = this.getScope();
|
|
7728
|
-
if (scope) {
|
|
7729
|
-
var span = scope.getSpan();
|
|
7730
|
-
if (span) {
|
|
7731
|
-
return {
|
|
7732
|
-
'sentry-trace': span.toTraceparent(),
|
|
7733
|
-
};
|
|
7734
|
-
}
|
|
7735
|
-
}
|
|
7736
|
-
return {};
|
|
7737
|
-
}
|
|
7738
|
-
/**
|
|
7739
|
-
* Makes a sampling decision for the given transaction and stores it on the transaction.
|
|
7740
|
-
*
|
|
7741
|
-
* Called every time a transaction is created. Only transactions which emerge with a `sampled` value of `true` will be
|
|
7742
|
-
* sent to Sentry.
|
|
7743
|
-
*
|
|
7744
|
-
* @param hub: The hub off of which to read config options
|
|
7745
|
-
* @param transaction: The transaction needing a sampling decision
|
|
7746
|
-
* @param samplingContext: Default and user-provided data which may be used to help make the decision
|
|
7747
|
-
*
|
|
7748
|
-
* @returns The given transaction with its `sampled` value set
|
|
7749
|
-
*/
|
|
7750
|
-
function sample(transaction, options, samplingContext) {
|
|
7751
|
-
// nothing to do if tracing is not enabled
|
|
7752
|
-
if (!hasTracingEnabled(options)) {
|
|
7753
|
-
transaction.sampled = false;
|
|
7754
|
-
return transaction;
|
|
7755
|
-
}
|
|
7756
|
-
// if the user has forced a sampling decision by passing a `sampled` value in their transaction context, go with that
|
|
7757
|
-
if (transaction.sampled !== undefined) {
|
|
7758
|
-
transaction.setMetadata({
|
|
7759
|
-
transactionSampling: { method: TransactionSamplingMethod.Explicit },
|
|
7760
|
-
});
|
|
7761
|
-
return transaction;
|
|
7762
|
-
}
|
|
7763
|
-
// we would have bailed already if neither `tracesSampler` nor `tracesSampleRate` were defined, so one of these should
|
|
7764
|
-
// work; prefer the hook if so
|
|
7765
|
-
var sampleRate;
|
|
7766
|
-
if (typeof options.tracesSampler === 'function') {
|
|
7767
|
-
sampleRate = options.tracesSampler(samplingContext);
|
|
7768
|
-
transaction.setMetadata({
|
|
7769
|
-
transactionSampling: {
|
|
7770
|
-
method: TransactionSamplingMethod.Sampler,
|
|
7771
|
-
// cast to number in case it's a boolean
|
|
7772
|
-
rate: Number(sampleRate),
|
|
7773
|
-
},
|
|
7774
|
-
});
|
|
7775
|
-
}
|
|
7776
|
-
else if (samplingContext.parentSampled !== undefined) {
|
|
7777
|
-
sampleRate = samplingContext.parentSampled;
|
|
7778
|
-
transaction.setMetadata({
|
|
7779
|
-
transactionSampling: { method: TransactionSamplingMethod.Inheritance },
|
|
7780
|
-
});
|
|
7781
|
-
}
|
|
7782
|
-
else {
|
|
7783
|
-
sampleRate = options.tracesSampleRate;
|
|
7784
|
-
transaction.setMetadata({
|
|
7785
|
-
transactionSampling: {
|
|
7786
|
-
method: TransactionSamplingMethod.Rate,
|
|
7787
|
-
// cast to number in case it's a boolean
|
|
7788
|
-
rate: Number(sampleRate),
|
|
7789
|
-
},
|
|
7790
|
-
});
|
|
7791
|
-
}
|
|
7792
|
-
// Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
|
|
7793
|
-
// only valid values are booleans or numbers between 0 and 1.)
|
|
7794
|
-
if (!isValidSampleRate(sampleRate)) {
|
|
7795
|
-
logger.warn("[Tracing] Discarding transaction because of invalid sample rate.");
|
|
7796
|
-
transaction.sampled = false;
|
|
7797
|
-
return transaction;
|
|
7798
|
-
}
|
|
7799
|
-
// if the function returned 0 (or false), or if `tracesSampleRate` is 0, it's a sign the transaction should be dropped
|
|
7800
|
-
if (!sampleRate) {
|
|
7801
|
-
logger.log("[Tracing] Discarding transaction because " + (typeof options.tracesSampler === 'function'
|
|
7802
|
-
? 'tracesSampler returned 0 or false'
|
|
7803
|
-
: 'a negative sampling decision was inherited or tracesSampleRate is set to 0'));
|
|
7804
|
-
transaction.sampled = false;
|
|
7805
|
-
return transaction;
|
|
7806
|
-
}
|
|
7807
|
-
// Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is
|
|
7808
|
-
// a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.
|
|
7809
|
-
transaction.sampled = Math.random() < sampleRate;
|
|
7810
|
-
// if we're not going to keep it, we're done
|
|
7811
|
-
if (!transaction.sampled) {
|
|
7812
|
-
logger.log("[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = " + Number(sampleRate) + ")");
|
|
7813
|
-
return transaction;
|
|
7814
|
-
}
|
|
7815
|
-
logger.log("[Tracing] starting " + transaction.op + " transaction - " + transaction.name);
|
|
7816
|
-
return transaction;
|
|
7817
|
-
}
|
|
7818
|
-
/**
|
|
7819
|
-
* Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).
|
|
7820
|
-
*/
|
|
7821
|
-
function isValidSampleRate(rate) {
|
|
7822
|
-
// we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck
|
|
7823
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7824
|
-
if (isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) {
|
|
7825
|
-
logger.warn("[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got " + JSON.stringify(rate) + " of type " + JSON.stringify(typeof rate) + ".");
|
|
7826
|
-
return false;
|
|
7827
|
-
}
|
|
7828
|
-
// in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false
|
|
7829
|
-
if (rate < 0 || rate > 1) {
|
|
7830
|
-
logger.warn("[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got " + rate + ".");
|
|
7831
|
-
return false;
|
|
7832
|
-
}
|
|
7833
|
-
return true;
|
|
7834
|
-
}
|
|
7835
|
-
/**
|
|
7836
|
-
* Creates a new transaction and adds a sampling decision if it doesn't yet have one.
|
|
7837
|
-
*
|
|
7838
|
-
* The Hub.startTransaction method delegates to this method to do its work, passing the Hub instance in as `this`, as if
|
|
7839
|
-
* it had been called on the hub directly. Exists as a separate function so that it can be injected into the class as an
|
|
7840
|
-
* "extension method."
|
|
7841
|
-
*
|
|
7842
|
-
* @param this: The Hub starting the transaction
|
|
7843
|
-
* @param transactionContext: Data used to configure the transaction
|
|
7844
|
-
* @param CustomSamplingContext: Optional data to be provided to the `tracesSampler` function (if any)
|
|
7845
|
-
*
|
|
7846
|
-
* @returns The new transaction
|
|
7847
|
-
*
|
|
7848
|
-
* @see {@link Hub.startTransaction}
|
|
7849
|
-
*/
|
|
7850
|
-
function _startTransaction(transactionContext, customSamplingContext) {
|
|
7851
|
-
var _a, _b;
|
|
7852
|
-
var options = ((_a = this.getClient()) === null || _a === void 0 ? void 0 : _a.getOptions()) || {};
|
|
7853
|
-
var transaction = new Transaction(transactionContext, this);
|
|
7854
|
-
transaction = sample(transaction, options, __assign({ parentSampled: transactionContext.parentSampled, transactionContext: transactionContext }, customSamplingContext));
|
|
7855
|
-
if (transaction.sampled) {
|
|
7856
|
-
transaction.initSpanRecorder((_b = options._experiments) === null || _b === void 0 ? void 0 : _b.maxSpans);
|
|
7857
|
-
}
|
|
7858
|
-
return transaction;
|
|
7859
|
-
}
|
|
7860
|
-
/**
|
|
7861
|
-
* Create new idle transaction.
|
|
7862
|
-
*/
|
|
7863
|
-
function startIdleTransaction(hub, transactionContext, idleTimeout, onScope, customSamplingContext) {
|
|
7864
|
-
var _a, _b;
|
|
7865
|
-
var options = ((_a = hub.getClient()) === null || _a === void 0 ? void 0 : _a.getOptions()) || {};
|
|
7866
|
-
var transaction = new IdleTransaction(transactionContext, hub, idleTimeout, onScope);
|
|
7867
|
-
transaction = sample(transaction, options, __assign({ parentSampled: transactionContext.parentSampled, transactionContext: transactionContext }, customSamplingContext));
|
|
7868
|
-
if (transaction.sampled) {
|
|
7869
|
-
transaction.initSpanRecorder((_b = options._experiments) === null || _b === void 0 ? void 0 : _b.maxSpans);
|
|
7870
|
-
}
|
|
7871
|
-
return transaction;
|
|
7872
|
-
}
|
|
7873
|
-
/**
|
|
7874
|
-
* @private
|
|
7875
|
-
*/
|
|
7876
|
-
function _addTracingExtensions() {
|
|
7877
|
-
var carrier = getMainCarrier();
|
|
7878
|
-
if (!carrier.__SENTRY__) {
|
|
7879
|
-
return;
|
|
7880
|
-
}
|
|
7881
|
-
carrier.__SENTRY__.extensions = carrier.__SENTRY__.extensions || {};
|
|
7882
|
-
if (!carrier.__SENTRY__.extensions.startTransaction) {
|
|
7883
|
-
carrier.__SENTRY__.extensions.startTransaction = _startTransaction;
|
|
7884
|
-
}
|
|
7885
|
-
if (!carrier.__SENTRY__.extensions.traceHeaders) {
|
|
7886
|
-
carrier.__SENTRY__.extensions.traceHeaders = traceHeaders;
|
|
7887
|
-
}
|
|
7888
|
-
}
|
|
7889
|
-
/**
|
|
7890
|
-
* @private
|
|
7891
|
-
*/
|
|
7892
|
-
function _autoloadDatabaseIntegrations() {
|
|
7893
|
-
var carrier = getMainCarrier();
|
|
7894
|
-
if (!carrier.__SENTRY__) {
|
|
7895
|
-
return;
|
|
7896
|
-
}
|
|
7897
|
-
var packageToIntegrationMapping = {
|
|
7898
|
-
mongodb: function () {
|
|
7899
|
-
var integration = dynamicRequire(module, './integrations/node/mongo');
|
|
7900
|
-
return new integration.Mongo();
|
|
7901
|
-
},
|
|
7902
|
-
mongoose: function () {
|
|
7903
|
-
var integration = dynamicRequire(module, './integrations/node/mongo');
|
|
7904
|
-
return new integration.Mongo({ mongoose: true });
|
|
7905
|
-
},
|
|
7906
|
-
mysql: function () {
|
|
7907
|
-
var integration = dynamicRequire(module, './integrations/node/mysql');
|
|
7908
|
-
return new integration.Mysql();
|
|
7909
|
-
},
|
|
7910
|
-
pg: function () {
|
|
7911
|
-
var integration = dynamicRequire(module, './integrations/node/postgres');
|
|
7912
|
-
return new integration.Postgres();
|
|
7913
|
-
},
|
|
7914
|
-
};
|
|
7915
|
-
var mappedPackages = Object.keys(packageToIntegrationMapping)
|
|
7916
|
-
.filter(function (moduleName) { return !!loadModule(moduleName); })
|
|
7917
|
-
.map(function (pkg) {
|
|
7918
|
-
try {
|
|
7919
|
-
return packageToIntegrationMapping[pkg]();
|
|
7920
|
-
}
|
|
7921
|
-
catch (e) {
|
|
7922
|
-
return undefined;
|
|
7923
|
-
}
|
|
7924
|
-
})
|
|
7925
|
-
.filter(function (p) { return p; });
|
|
7926
|
-
if (mappedPackages.length > 0) {
|
|
7927
|
-
carrier.__SENTRY__.integrations = __spread((carrier.__SENTRY__.integrations || []), mappedPackages);
|
|
7928
|
-
}
|
|
7929
|
-
}
|
|
7930
|
-
/**
|
|
7931
|
-
* This patches the global object and injects the Tracing extensions methods
|
|
7932
|
-
*/
|
|
7933
|
-
function addExtensionMethods() {
|
|
7934
|
-
_addTracingExtensions();
|
|
7935
|
-
// Detect and automatically load specified integrations.
|
|
7936
|
-
if (isNodeEnv()) {
|
|
7937
|
-
_autoloadDatabaseIntegrations();
|
|
7938
|
-
}
|
|
7939
|
-
// If an error happens globally, we should make sure transaction status is set to error.
|
|
7940
|
-
registerErrorInstrumentation();
|
|
7941
|
-
}
|
|
7942
|
-
|
|
7943
|
-
var global$3 = getGlobalObject();
|
|
7944
|
-
/**
|
|
7945
|
-
* Add a listener that cancels and finishes a transaction when the global
|
|
7946
|
-
* document is hidden.
|
|
7947
|
-
*/
|
|
7948
|
-
function registerBackgroundTabDetection() {
|
|
7949
|
-
if (global$3 && global$3.document) {
|
|
7950
|
-
global$3.document.addEventListener('visibilitychange', function () {
|
|
7951
|
-
var activeTransaction = getActiveTransaction();
|
|
7952
|
-
if (global$3.document.hidden && activeTransaction) {
|
|
7953
|
-
logger.log("[Tracing] Transaction: " + SpanStatus.Cancelled + " -> since tab moved to the background, op: " + activeTransaction.op);
|
|
7954
|
-
// We should not set status if it is already set, this prevent important statuses like
|
|
7955
|
-
// error or data loss from being overwritten on transaction.
|
|
7956
|
-
if (!activeTransaction.status) {
|
|
7957
|
-
activeTransaction.setStatus(SpanStatus.Cancelled);
|
|
7958
|
-
}
|
|
7959
|
-
activeTransaction.setTag('visibilitychange', 'document.hidden');
|
|
7960
|
-
activeTransaction.finish();
|
|
7961
|
-
}
|
|
7962
|
-
});
|
|
7963
|
-
}
|
|
7964
|
-
else {
|
|
7965
|
-
logger.warn('[Tracing] Could not set up background tab detection due to lack of global document');
|
|
7966
|
-
}
|
|
7967
|
-
}
|
|
7968
|
-
|
|
7969
|
-
/*
|
|
7970
|
-
* Copyright 2020 Google LLC
|
|
7971
|
-
*
|
|
7972
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7973
|
-
* you may not use this file except in compliance with the License.
|
|
7974
|
-
* You may obtain a copy of the License at
|
|
7975
|
-
*
|
|
7976
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
7977
|
-
*
|
|
7978
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7979
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
7980
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
7981
|
-
* See the License for the specific language governing permissions and
|
|
7982
|
-
* limitations under the License.
|
|
7983
|
-
*/
|
|
7984
|
-
var bindReporter = function (callback, metric, reportAllChanges) {
|
|
7985
|
-
var prevValue;
|
|
7986
|
-
return function (forceReport) {
|
|
7987
|
-
if (metric.value >= 0) {
|
|
7988
|
-
if (forceReport || reportAllChanges) {
|
|
7989
|
-
metric.delta = metric.value - (prevValue || 0);
|
|
7990
|
-
// Report the metric if there's a non-zero delta or if no previous
|
|
7991
|
-
// value exists (which can happen in the case of the document becoming
|
|
7992
|
-
// hidden when the metric value is 0).
|
|
7993
|
-
// See: https://github.com/GoogleChrome/web-vitals/issues/14
|
|
7994
|
-
if (metric.delta || prevValue === undefined) {
|
|
7995
|
-
prevValue = metric.value;
|
|
7996
|
-
callback(metric);
|
|
7997
|
-
}
|
|
7998
|
-
}
|
|
7999
|
-
}
|
|
8000
|
-
};
|
|
8001
|
-
};
|
|
8002
|
-
|
|
8003
|
-
/*
|
|
8004
|
-
* Copyright 2020 Google LLC
|
|
8005
|
-
*
|
|
8006
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8007
|
-
* you may not use this file except in compliance with the License.
|
|
8008
|
-
* You may obtain a copy of the License at
|
|
8009
|
-
*
|
|
8010
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8011
|
-
*
|
|
8012
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8013
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8014
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8015
|
-
* See the License for the specific language governing permissions and
|
|
8016
|
-
* limitations under the License.
|
|
8017
|
-
*/
|
|
8018
|
-
/**
|
|
8019
|
-
* Performantly generate a unique, 30-char string by combining a version
|
|
8020
|
-
* number, the current timestamp with a 13-digit number integer.
|
|
8021
|
-
* @return {string}
|
|
8022
|
-
*/
|
|
8023
|
-
var generateUniqueID = function () {
|
|
8024
|
-
return "v2-" + Date.now() + "-" + (Math.floor(Math.random() * (9e12 - 1)) + 1e12);
|
|
8025
|
-
};
|
|
8026
|
-
|
|
8027
|
-
/*
|
|
8028
|
-
* Copyright 2020 Google LLC
|
|
8029
|
-
*
|
|
8030
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8031
|
-
* you may not use this file except in compliance with the License.
|
|
8032
|
-
* You may obtain a copy of the License at
|
|
8033
|
-
*
|
|
8034
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8035
|
-
*
|
|
8036
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8037
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8038
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8039
|
-
* See the License for the specific language governing permissions and
|
|
8040
|
-
* limitations under the License.
|
|
8041
|
-
*/
|
|
8042
|
-
var initMetric = function (name, value) {
|
|
8043
|
-
return {
|
|
8044
|
-
name: name,
|
|
8045
|
-
value: (value !== null && value !== void 0 ? value : -1),
|
|
8046
|
-
delta: 0,
|
|
8047
|
-
entries: [],
|
|
8048
|
-
id: generateUniqueID(),
|
|
8049
|
-
};
|
|
8050
|
-
};
|
|
8051
|
-
|
|
8052
|
-
/*
|
|
8053
|
-
* Copyright 2020 Google LLC
|
|
8054
|
-
*
|
|
8055
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8056
|
-
* you may not use this file except in compliance with the License.
|
|
8057
|
-
* You may obtain a copy of the License at
|
|
8058
|
-
*
|
|
8059
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8060
|
-
*
|
|
8061
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8062
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8063
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8064
|
-
* See the License for the specific language governing permissions and
|
|
8065
|
-
* limitations under the License.
|
|
8066
|
-
*/
|
|
8067
|
-
/**
|
|
8068
|
-
* Takes a performance entry type and a callback function, and creates a
|
|
8069
|
-
* `PerformanceObserver` instance that will observe the specified entry type
|
|
8070
|
-
* with buffering enabled and call the callback _for each entry_.
|
|
8071
|
-
*
|
|
8072
|
-
* This function also feature-detects entry support and wraps the logic in a
|
|
8073
|
-
* try/catch to avoid errors in unsupporting browsers.
|
|
8074
|
-
*/
|
|
8075
|
-
var observe = function (type, callback) {
|
|
8076
|
-
try {
|
|
8077
|
-
if (PerformanceObserver.supportedEntryTypes.includes(type)) {
|
|
8078
|
-
// More extensive feature detect needed for Firefox due to:
|
|
8079
|
-
// https://github.com/GoogleChrome/web-vitals/issues/142
|
|
8080
|
-
if (type === 'first-input' && !('PerformanceEventTiming' in self)) {
|
|
8081
|
-
return;
|
|
8082
|
-
}
|
|
8083
|
-
var po = new PerformanceObserver(function (l) { return l.getEntries().map(callback); });
|
|
8084
|
-
po.observe({ type: type, buffered: true });
|
|
8085
|
-
return po;
|
|
8086
|
-
}
|
|
8087
|
-
}
|
|
8088
|
-
catch (e) {
|
|
8089
|
-
// Do nothing.
|
|
8090
|
-
}
|
|
8091
|
-
return;
|
|
8092
|
-
};
|
|
8093
|
-
|
|
8094
|
-
/*
|
|
8095
|
-
* Copyright 2020 Google LLC
|
|
8096
|
-
*
|
|
8097
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8098
|
-
* you may not use this file except in compliance with the License.
|
|
8099
|
-
* You may obtain a copy of the License at
|
|
8100
|
-
*
|
|
8101
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8102
|
-
*
|
|
8103
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8104
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8105
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8106
|
-
* See the License for the specific language governing permissions and
|
|
8107
|
-
* limitations under the License.
|
|
8108
|
-
*/
|
|
8109
|
-
var onHidden = function (cb, once) {
|
|
8110
|
-
var onHiddenOrPageHide = function (event) {
|
|
8111
|
-
if (event.type === 'pagehide' || getGlobalObject().document.visibilityState === 'hidden') {
|
|
8112
|
-
cb(event);
|
|
8113
|
-
if (once) {
|
|
8114
|
-
removeEventListener('visibilitychange', onHiddenOrPageHide, true);
|
|
8115
|
-
removeEventListener('pagehide', onHiddenOrPageHide, true);
|
|
8116
|
-
}
|
|
8117
|
-
}
|
|
8118
|
-
};
|
|
8119
|
-
addEventListener('visibilitychange', onHiddenOrPageHide, true);
|
|
8120
|
-
// Some browsers have buggy implementations of visibilitychange,
|
|
8121
|
-
// so we use pagehide in addition, just to be safe.
|
|
8122
|
-
addEventListener('pagehide', onHiddenOrPageHide, true);
|
|
8123
|
-
};
|
|
8124
|
-
|
|
8125
|
-
/*
|
|
8126
|
-
* Copyright 2020 Google LLC
|
|
8127
|
-
*
|
|
8128
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8129
|
-
* you may not use this file except in compliance with the License.
|
|
8130
|
-
* You may obtain a copy of the License at
|
|
8131
|
-
*
|
|
8132
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8133
|
-
*
|
|
8134
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8135
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8136
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8137
|
-
* See the License for the specific language governing permissions and
|
|
8138
|
-
* limitations under the License.
|
|
8139
|
-
*/
|
|
8140
|
-
var getCLS = function (onReport, reportAllChanges) {
|
|
8141
|
-
var metric = initMetric('CLS', 0);
|
|
8142
|
-
var report;
|
|
8143
|
-
var sessionValue = 0;
|
|
8144
|
-
var sessionEntries = [];
|
|
8145
|
-
var entryHandler = function (entry) {
|
|
8146
|
-
// Only count layout shifts without recent user input.
|
|
8147
|
-
// TODO: Figure out why entry can be undefined
|
|
8148
|
-
if (entry && !entry.hadRecentInput) {
|
|
8149
|
-
var firstSessionEntry = sessionEntries[0];
|
|
8150
|
-
var lastSessionEntry = sessionEntries[sessionEntries.length - 1];
|
|
8151
|
-
// If the entry occurred less than 1 second after the previous entry and
|
|
8152
|
-
// less than 5 seconds after the first entry in the session, include the
|
|
8153
|
-
// entry in the current session. Otherwise, start a new session.
|
|
8154
|
-
if (sessionValue &&
|
|
8155
|
-
sessionEntries.length !== 0 &&
|
|
8156
|
-
entry.startTime - lastSessionEntry.startTime < 1000 &&
|
|
8157
|
-
entry.startTime - firstSessionEntry.startTime < 5000) {
|
|
8158
|
-
sessionValue += entry.value;
|
|
8159
|
-
sessionEntries.push(entry);
|
|
8160
|
-
}
|
|
8161
|
-
else {
|
|
8162
|
-
sessionValue = entry.value;
|
|
8163
|
-
sessionEntries = [entry];
|
|
8164
|
-
}
|
|
8165
|
-
// If the current session value is larger than the current CLS value,
|
|
8166
|
-
// update CLS and the entries contributing to it.
|
|
8167
|
-
if (sessionValue > metric.value) {
|
|
8168
|
-
metric.value = sessionValue;
|
|
8169
|
-
metric.entries = sessionEntries;
|
|
8170
|
-
if (report) {
|
|
8171
|
-
report();
|
|
8172
|
-
}
|
|
8173
|
-
}
|
|
8174
|
-
}
|
|
8175
|
-
};
|
|
8176
|
-
var po = observe('layout-shift', entryHandler);
|
|
8177
|
-
if (po) {
|
|
8178
|
-
report = bindReporter(onReport, metric, reportAllChanges);
|
|
8179
|
-
onHidden(function () {
|
|
8180
|
-
po.takeRecords().map(entryHandler);
|
|
8181
|
-
report(true);
|
|
8182
|
-
});
|
|
8183
|
-
}
|
|
8184
|
-
};
|
|
8185
|
-
|
|
8186
|
-
/*
|
|
8187
|
-
* Copyright 2020 Google LLC
|
|
8188
|
-
*
|
|
8189
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8190
|
-
* you may not use this file except in compliance with the License.
|
|
8191
|
-
* You may obtain a copy of the License at
|
|
8192
|
-
*
|
|
8193
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8194
|
-
*
|
|
8195
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8196
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8197
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8198
|
-
* See the License for the specific language governing permissions and
|
|
8199
|
-
* limitations under the License.
|
|
8200
|
-
*/
|
|
8201
|
-
var firstHiddenTime = -1;
|
|
8202
|
-
var initHiddenTime = function () {
|
|
8203
|
-
return getGlobalObject().document.visibilityState === 'hidden' ? 0 : Infinity;
|
|
8204
|
-
};
|
|
8205
|
-
var trackChanges = function () {
|
|
8206
|
-
// Update the time if/when the document becomes hidden.
|
|
8207
|
-
onHidden(function (_a) {
|
|
8208
|
-
var timeStamp = _a.timeStamp;
|
|
8209
|
-
firstHiddenTime = timeStamp;
|
|
8210
|
-
}, true);
|
|
8211
|
-
};
|
|
8212
|
-
var getVisibilityWatcher = function () {
|
|
8213
|
-
if (firstHiddenTime < 0) {
|
|
8214
|
-
// If the document is hidden when this code runs, assume it was hidden
|
|
8215
|
-
// since navigation start. This isn't a perfect heuristic, but it's the
|
|
8216
|
-
// best we can do until an API is available to support querying past
|
|
8217
|
-
// visibilityState.
|
|
8218
|
-
firstHiddenTime = initHiddenTime();
|
|
8219
|
-
trackChanges();
|
|
8220
|
-
}
|
|
8221
|
-
return {
|
|
8222
|
-
get firstHiddenTime() {
|
|
8223
|
-
return firstHiddenTime;
|
|
8224
|
-
},
|
|
8225
|
-
};
|
|
8226
|
-
};
|
|
8227
|
-
|
|
8228
|
-
/*
|
|
8229
|
-
* Copyright 2020 Google LLC
|
|
8230
|
-
*
|
|
8231
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8232
|
-
* you may not use this file except in compliance with the License.
|
|
8233
|
-
* You may obtain a copy of the License at
|
|
8234
|
-
*
|
|
8235
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8236
|
-
*
|
|
8237
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8238
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8239
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8240
|
-
* See the License for the specific language governing permissions and
|
|
8241
|
-
* limitations under the License.
|
|
8242
|
-
*/
|
|
8243
|
-
var getFID = function (onReport, reportAllChanges) {
|
|
8244
|
-
var visibilityWatcher = getVisibilityWatcher();
|
|
8245
|
-
var metric = initMetric('FID');
|
|
8246
|
-
var report;
|
|
8247
|
-
var entryHandler = function (entry) {
|
|
8248
|
-
// Only report if the page wasn't hidden prior to the first input.
|
|
8249
|
-
if (report && entry.startTime < visibilityWatcher.firstHiddenTime) {
|
|
8250
|
-
metric.value = entry.processingStart - entry.startTime;
|
|
8251
|
-
metric.entries.push(entry);
|
|
8252
|
-
report(true);
|
|
8253
|
-
}
|
|
8254
|
-
};
|
|
8255
|
-
var po = observe('first-input', entryHandler);
|
|
8256
|
-
if (po) {
|
|
8257
|
-
report = bindReporter(onReport, metric, reportAllChanges);
|
|
8258
|
-
onHidden(function () {
|
|
8259
|
-
po.takeRecords().map(entryHandler);
|
|
8260
|
-
po.disconnect();
|
|
8261
|
-
}, true);
|
|
8262
|
-
}
|
|
8263
|
-
};
|
|
8264
|
-
|
|
8265
|
-
/*
|
|
8266
|
-
* Copyright 2020 Google LLC
|
|
8267
|
-
*
|
|
8268
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8269
|
-
* you may not use this file except in compliance with the License.
|
|
8270
|
-
* You may obtain a copy of the License at
|
|
8271
|
-
*
|
|
8272
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8273
|
-
*
|
|
8274
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8275
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8276
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8277
|
-
* See the License for the specific language governing permissions and
|
|
8278
|
-
* limitations under the License.
|
|
8279
|
-
*/
|
|
8280
|
-
var reportedMetricIDs = {};
|
|
8281
|
-
var getLCP = function (onReport, reportAllChanges) {
|
|
8282
|
-
var visibilityWatcher = getVisibilityWatcher();
|
|
8283
|
-
var metric = initMetric('LCP');
|
|
8284
|
-
var report;
|
|
8285
|
-
var entryHandler = function (entry) {
|
|
8286
|
-
// The startTime attribute returns the value of the renderTime if it is not 0,
|
|
8287
|
-
// and the value of the loadTime otherwise.
|
|
8288
|
-
var value = entry.startTime;
|
|
8289
|
-
// If the page was hidden prior to paint time of the entry,
|
|
8290
|
-
// ignore it and mark the metric as final, otherwise add the entry.
|
|
8291
|
-
if (value < visibilityWatcher.firstHiddenTime) {
|
|
8292
|
-
metric.value = value;
|
|
8293
|
-
metric.entries.push(entry);
|
|
8294
|
-
}
|
|
8295
|
-
if (report) {
|
|
8296
|
-
report();
|
|
8297
|
-
}
|
|
8298
|
-
};
|
|
8299
|
-
var po = observe('largest-contentful-paint', entryHandler);
|
|
8300
|
-
if (po) {
|
|
8301
|
-
report = bindReporter(onReport, metric, reportAllChanges);
|
|
8302
|
-
var stopListening_1 = function () {
|
|
8303
|
-
if (!reportedMetricIDs[metric.id]) {
|
|
8304
|
-
po.takeRecords().map(entryHandler);
|
|
8305
|
-
po.disconnect();
|
|
8306
|
-
reportedMetricIDs[metric.id] = true;
|
|
8307
|
-
report(true);
|
|
8308
|
-
}
|
|
8309
|
-
};
|
|
8310
|
-
// Stop listening after input. Note: while scrolling is an input that
|
|
8311
|
-
// stop LCP observation, it's unreliable since it can be programmatically
|
|
8312
|
-
// generated. See: https://github.com/GoogleChrome/web-vitals/issues/75
|
|
8313
|
-
['keydown', 'click'].forEach(function (type) {
|
|
8314
|
-
addEventListener(type, stopListening_1, { once: true, capture: true });
|
|
8315
|
-
});
|
|
8316
|
-
onHidden(stopListening_1, true);
|
|
8317
|
-
}
|
|
8318
|
-
};
|
|
8319
|
-
|
|
8320
|
-
var global$2 = getGlobalObject();
|
|
8321
|
-
var DEFAULT_METRICS_INSTR_OPTIONS = {
|
|
8322
|
-
_reportAllChanges: false,
|
|
8323
|
-
};
|
|
8324
|
-
/** Class tracking metrics */
|
|
8325
|
-
var MetricsInstrumentation = /** @class */ (function () {
|
|
8326
|
-
function MetricsInstrumentation(_options) {
|
|
8327
|
-
var _a, _b;
|
|
8328
|
-
this._measurements = {};
|
|
8329
|
-
this._performanceCursor = 0;
|
|
8330
|
-
if (!isNodeEnv() && ((_a = global$2) === null || _a === void 0 ? void 0 : _a.performance) && ((_b = global$2) === null || _b === void 0 ? void 0 : _b.document)) {
|
|
8331
|
-
if (global$2.performance.mark) {
|
|
8332
|
-
global$2.performance.mark('sentry-tracing-init');
|
|
8333
|
-
}
|
|
8334
|
-
this._trackCLS();
|
|
8335
|
-
this._trackLCP(_options._reportAllChanges);
|
|
8336
|
-
this._trackFID();
|
|
8337
|
-
}
|
|
8338
|
-
}
|
|
8339
|
-
/** Add performance related spans to a transaction */
|
|
8340
|
-
MetricsInstrumentation.prototype.addPerformanceEntries = function (transaction) {
|
|
8341
|
-
var _this = this;
|
|
8342
|
-
if (!global$2 || !global$2.performance || !global$2.performance.getEntries || !browserPerformanceTimeOrigin) {
|
|
8343
|
-
// Gatekeeper if performance API not available
|
|
8344
|
-
return;
|
|
8345
|
-
}
|
|
8346
|
-
logger.log('[Tracing] Adding & adjusting spans using Performance API');
|
|
8347
|
-
var timeOrigin = msToSec(browserPerformanceTimeOrigin);
|
|
8348
|
-
var entryScriptSrc;
|
|
8349
|
-
if (global$2.document && global$2.document.scripts) {
|
|
8350
|
-
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
8351
|
-
for (var i = 0; i < global$2.document.scripts.length; i++) {
|
|
8352
|
-
// We go through all scripts on the page and look for 'data-entry'
|
|
8353
|
-
// We remember the name and measure the time between this script finished loading and
|
|
8354
|
-
// our mark 'sentry-tracing-init'
|
|
8355
|
-
if (global$2.document.scripts[i].dataset.entry === 'true') {
|
|
8356
|
-
entryScriptSrc = global$2.document.scripts[i].src;
|
|
8357
|
-
break;
|
|
8358
|
-
}
|
|
8359
|
-
}
|
|
8360
|
-
}
|
|
8361
|
-
var entryScriptStartTimestamp;
|
|
8362
|
-
var tracingInitMarkStartTime;
|
|
8363
|
-
var responseStartTimestamp;
|
|
8364
|
-
var requestStartTimestamp;
|
|
8365
|
-
global$2.performance
|
|
8366
|
-
.getEntries()
|
|
8367
|
-
.slice(this._performanceCursor)
|
|
8368
|
-
.forEach(function (entry) {
|
|
8369
|
-
var startTime = msToSec(entry.startTime);
|
|
8370
|
-
var duration = msToSec(entry.duration);
|
|
8371
|
-
if (transaction.op === 'navigation' && timeOrigin + startTime < transaction.startTimestamp) {
|
|
8372
|
-
return;
|
|
8373
|
-
}
|
|
8374
|
-
switch (entry.entryType) {
|
|
8375
|
-
case 'navigation': {
|
|
8376
|
-
addNavigationSpans(transaction, entry, timeOrigin);
|
|
8377
|
-
responseStartTimestamp = timeOrigin + msToSec(entry.responseStart);
|
|
8378
|
-
requestStartTimestamp = timeOrigin + msToSec(entry.requestStart);
|
|
8379
|
-
break;
|
|
8380
|
-
}
|
|
8381
|
-
case 'mark':
|
|
8382
|
-
case 'paint':
|
|
8383
|
-
case 'measure': {
|
|
8384
|
-
var startTimestamp = addMeasureSpans(transaction, entry, startTime, duration, timeOrigin);
|
|
8385
|
-
if (tracingInitMarkStartTime === undefined && entry.name === 'sentry-tracing-init') {
|
|
8386
|
-
tracingInitMarkStartTime = startTimestamp;
|
|
8387
|
-
}
|
|
8388
|
-
// capture web vitals
|
|
8389
|
-
var firstHidden = getVisibilityWatcher();
|
|
8390
|
-
// Only report if the page wasn't hidden prior to the web vital.
|
|
8391
|
-
var shouldRecord = entry.startTime < firstHidden.firstHiddenTime;
|
|
8392
|
-
if (entry.name === 'first-paint' && shouldRecord) {
|
|
8393
|
-
logger.log('[Measurements] Adding FP');
|
|
8394
|
-
_this._measurements['fp'] = { value: entry.startTime };
|
|
8395
|
-
_this._measurements['mark.fp'] = { value: startTimestamp };
|
|
8396
|
-
}
|
|
8397
|
-
if (entry.name === 'first-contentful-paint' && shouldRecord) {
|
|
8398
|
-
logger.log('[Measurements] Adding FCP');
|
|
8399
|
-
_this._measurements['fcp'] = { value: entry.startTime };
|
|
8400
|
-
_this._measurements['mark.fcp'] = { value: startTimestamp };
|
|
8401
|
-
}
|
|
8402
|
-
break;
|
|
8403
|
-
}
|
|
8404
|
-
case 'resource': {
|
|
8405
|
-
var resourceName = entry.name.replace(global$2.location.origin, '');
|
|
8406
|
-
var endTimestamp = addResourceSpans(transaction, entry, resourceName, startTime, duration, timeOrigin);
|
|
8407
|
-
// We remember the entry script end time to calculate the difference to the first init mark
|
|
8408
|
-
if (entryScriptStartTimestamp === undefined && (entryScriptSrc || '').indexOf(resourceName) > -1) {
|
|
8409
|
-
entryScriptStartTimestamp = endTimestamp;
|
|
8410
|
-
}
|
|
8411
|
-
break;
|
|
8412
|
-
}
|
|
8413
|
-
// Ignore other entry types.
|
|
8414
|
-
}
|
|
8415
|
-
});
|
|
8416
|
-
if (entryScriptStartTimestamp !== undefined && tracingInitMarkStartTime !== undefined) {
|
|
8417
|
-
_startChild(transaction, {
|
|
8418
|
-
description: 'evaluation',
|
|
8419
|
-
endTimestamp: tracingInitMarkStartTime,
|
|
8420
|
-
op: 'script',
|
|
8421
|
-
startTimestamp: entryScriptStartTimestamp,
|
|
8422
|
-
});
|
|
8423
|
-
}
|
|
8424
|
-
this._performanceCursor = Math.max(performance.getEntries().length - 1, 0);
|
|
8425
|
-
this._trackNavigator(transaction);
|
|
8426
|
-
// Measurements are only available for pageload transactions
|
|
8427
|
-
if (transaction.op === 'pageload') {
|
|
8428
|
-
// normalize applicable web vital values to be relative to transaction.startTimestamp
|
|
8429
|
-
var timeOrigin_1 = msToSec(browserPerformanceTimeOrigin);
|
|
8430
|
-
// Generate TTFB (Time to First Byte), which measured as the time between the beginning of the transaction and the
|
|
8431
|
-
// start of the response in milliseconds
|
|
8432
|
-
if (typeof responseStartTimestamp === 'number') {
|
|
8433
|
-
logger.log('[Measurements] Adding TTFB');
|
|
8434
|
-
this._measurements['ttfb'] = { value: (responseStartTimestamp - transaction.startTimestamp) * 1000 };
|
|
8435
|
-
if (typeof requestStartTimestamp === 'number' && requestStartTimestamp <= responseStartTimestamp) {
|
|
8436
|
-
// Capture the time spent making the request and receiving the first byte of the response.
|
|
8437
|
-
// This is the time between the start of the request and the start of the response in milliseconds.
|
|
8438
|
-
this._measurements['ttfb.requestTime'] = { value: (responseStartTimestamp - requestStartTimestamp) * 1000 };
|
|
8439
|
-
}
|
|
8440
|
-
}
|
|
8441
|
-
['fcp', 'fp', 'lcp'].forEach(function (name) {
|
|
8442
|
-
if (!_this._measurements[name] || timeOrigin_1 >= transaction.startTimestamp) {
|
|
8443
|
-
return;
|
|
8444
|
-
}
|
|
8445
|
-
// The web vitals, fcp, fp, lcp, and ttfb, all measure relative to timeOrigin.
|
|
8446
|
-
// Unfortunately, timeOrigin is not captured within the transaction span data, so these web vitals will need
|
|
8447
|
-
// to be adjusted to be relative to transaction.startTimestamp.
|
|
8448
|
-
var oldValue = _this._measurements[name].value;
|
|
8449
|
-
var measurementTimestamp = timeOrigin_1 + msToSec(oldValue);
|
|
8450
|
-
// normalizedValue should be in milliseconds
|
|
8451
|
-
var normalizedValue = Math.abs((measurementTimestamp - transaction.startTimestamp) * 1000);
|
|
8452
|
-
var delta = normalizedValue - oldValue;
|
|
8453
|
-
logger.log("[Measurements] Normalized " + name + " from " + oldValue + " to " + normalizedValue + " (" + delta + ")");
|
|
8454
|
-
_this._measurements[name].value = normalizedValue;
|
|
8455
|
-
});
|
|
8456
|
-
if (this._measurements['mark.fid'] && this._measurements['fid']) {
|
|
8457
|
-
// create span for FID
|
|
8458
|
-
_startChild(transaction, {
|
|
8459
|
-
description: 'first input delay',
|
|
8460
|
-
endTimestamp: this._measurements['mark.fid'].value + msToSec(this._measurements['fid'].value),
|
|
8461
|
-
op: 'web.vitals',
|
|
8462
|
-
startTimestamp: this._measurements['mark.fid'].value,
|
|
8463
|
-
});
|
|
8464
|
-
}
|
|
8465
|
-
// If FCP is not recorded we should not record the cls value
|
|
8466
|
-
// according to the new definition of CLS.
|
|
8467
|
-
if (!('fcp' in this._measurements)) {
|
|
8468
|
-
delete this._measurements.cls;
|
|
8469
|
-
}
|
|
8470
|
-
transaction.setMeasurements(this._measurements);
|
|
8471
|
-
this._tagMetricInfo(transaction);
|
|
8472
|
-
}
|
|
8473
|
-
};
|
|
8474
|
-
/** Add LCP / CLS data to transaction to allow debugging */
|
|
8475
|
-
MetricsInstrumentation.prototype._tagMetricInfo = function (transaction) {
|
|
8476
|
-
if (this._lcpEntry) {
|
|
8477
|
-
logger.log('[Measurements] Adding LCP Data');
|
|
8478
|
-
// Capture Properties of the LCP element that contributes to the LCP.
|
|
8479
|
-
if (this._lcpEntry.element) {
|
|
8480
|
-
transaction.setTag('lcp.element', htmlTreeAsString(this._lcpEntry.element));
|
|
8481
|
-
}
|
|
8482
|
-
if (this._lcpEntry.id) {
|
|
8483
|
-
transaction.setTag('lcp.id', this._lcpEntry.id);
|
|
8484
|
-
}
|
|
8485
|
-
if (this._lcpEntry.url) {
|
|
8486
|
-
// Trim URL to the first 200 characters.
|
|
8487
|
-
transaction.setTag('lcp.url', this._lcpEntry.url.trim().slice(0, 200));
|
|
8488
|
-
}
|
|
8489
|
-
transaction.setTag('lcp.size', this._lcpEntry.size);
|
|
8490
|
-
}
|
|
8491
|
-
// See: https://developer.mozilla.org/en-US/docs/Web/API/LayoutShift
|
|
8492
|
-
if (this._clsEntry && this._clsEntry.sources) {
|
|
8493
|
-
logger.log('[Measurements] Adding CLS Data');
|
|
8494
|
-
this._clsEntry.sources.forEach(function (source, index) {
|
|
8495
|
-
return transaction.setTag("cls.source." + (index + 1), htmlTreeAsString(source.node));
|
|
8496
|
-
});
|
|
8497
|
-
}
|
|
8498
|
-
};
|
|
8499
|
-
/** Starts tracking the Cumulative Layout Shift on the current page. */
|
|
8500
|
-
MetricsInstrumentation.prototype._trackCLS = function () {
|
|
8501
|
-
var _this = this;
|
|
8502
|
-
// See:
|
|
8503
|
-
// https://web.dev/evolving-cls/
|
|
8504
|
-
// https://web.dev/cls-web-tooling/
|
|
8505
|
-
getCLS(function (metric) {
|
|
8506
|
-
var entry = metric.entries.pop();
|
|
8507
|
-
if (!entry) {
|
|
8508
|
-
return;
|
|
8509
|
-
}
|
|
8510
|
-
logger.log('[Measurements] Adding CLS');
|
|
8511
|
-
_this._measurements['cls'] = { value: metric.value };
|
|
8512
|
-
_this._clsEntry = entry;
|
|
8513
|
-
});
|
|
8514
|
-
};
|
|
8515
|
-
/**
|
|
8516
|
-
* Capture the information of the user agent.
|
|
8517
|
-
*/
|
|
8518
|
-
MetricsInstrumentation.prototype._trackNavigator = function (transaction) {
|
|
8519
|
-
var navigator = global$2.navigator;
|
|
8520
|
-
if (!navigator) {
|
|
8521
|
-
return;
|
|
8522
|
-
}
|
|
8523
|
-
// track network connectivity
|
|
8524
|
-
var connection = navigator.connection;
|
|
8525
|
-
if (connection) {
|
|
8526
|
-
if (connection.effectiveType) {
|
|
8527
|
-
transaction.setTag('effectiveConnectionType', connection.effectiveType);
|
|
8528
|
-
}
|
|
8529
|
-
if (connection.type) {
|
|
8530
|
-
transaction.setTag('connectionType', connection.type);
|
|
8531
|
-
}
|
|
8532
|
-
if (isMeasurementValue(connection.rtt)) {
|
|
8533
|
-
this._measurements['connection.rtt'] = { value: connection.rtt };
|
|
8534
|
-
}
|
|
8535
|
-
if (isMeasurementValue(connection.downlink)) {
|
|
8536
|
-
this._measurements['connection.downlink'] = { value: connection.downlink };
|
|
8537
|
-
}
|
|
8538
|
-
}
|
|
8539
|
-
if (isMeasurementValue(navigator.deviceMemory)) {
|
|
8540
|
-
transaction.setTag('deviceMemory', String(navigator.deviceMemory));
|
|
8541
|
-
}
|
|
8542
|
-
if (isMeasurementValue(navigator.hardwareConcurrency)) {
|
|
8543
|
-
transaction.setTag('hardwareConcurrency', String(navigator.hardwareConcurrency));
|
|
8544
|
-
}
|
|
8545
|
-
};
|
|
8546
|
-
/** Starts tracking the Largest Contentful Paint on the current page. */
|
|
8547
|
-
MetricsInstrumentation.prototype._trackLCP = function (reportAllChanges) {
|
|
8548
|
-
var _this = this;
|
|
8549
|
-
getLCP(function (metric) {
|
|
8550
|
-
var entry = metric.entries.pop();
|
|
8551
|
-
if (!entry) {
|
|
8552
|
-
return;
|
|
8553
|
-
}
|
|
8554
|
-
var timeOrigin = msToSec(browserPerformanceTimeOrigin);
|
|
8555
|
-
var startTime = msToSec(entry.startTime);
|
|
8556
|
-
logger.log('[Measurements] Adding LCP');
|
|
8557
|
-
_this._measurements['lcp'] = { value: metric.value };
|
|
8558
|
-
_this._measurements['mark.lcp'] = { value: timeOrigin + startTime };
|
|
8559
|
-
_this._lcpEntry = entry;
|
|
8560
|
-
}, reportAllChanges);
|
|
8561
|
-
};
|
|
8562
|
-
/** Starts tracking the First Input Delay on the current page. */
|
|
8563
|
-
MetricsInstrumentation.prototype._trackFID = function () {
|
|
8564
|
-
var _this = this;
|
|
8565
|
-
getFID(function (metric) {
|
|
8566
|
-
var entry = metric.entries.pop();
|
|
8567
|
-
if (!entry) {
|
|
8568
|
-
return;
|
|
8569
|
-
}
|
|
8570
|
-
var timeOrigin = msToSec(browserPerformanceTimeOrigin);
|
|
8571
|
-
var startTime = msToSec(entry.startTime);
|
|
8572
|
-
logger.log('[Measurements] Adding FID');
|
|
8573
|
-
_this._measurements['fid'] = { value: metric.value };
|
|
8574
|
-
_this._measurements['mark.fid'] = { value: timeOrigin + startTime };
|
|
8575
|
-
});
|
|
8576
|
-
};
|
|
8577
|
-
return MetricsInstrumentation;
|
|
8578
|
-
}());
|
|
8579
|
-
/** Instrument navigation entries */
|
|
8580
|
-
function addNavigationSpans(transaction, entry, timeOrigin) {
|
|
8581
|
-
addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'unloadEvent', timeOrigin: timeOrigin });
|
|
8582
|
-
addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'redirect', timeOrigin: timeOrigin });
|
|
8583
|
-
addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'domContentLoadedEvent', timeOrigin: timeOrigin });
|
|
8584
|
-
addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'loadEvent', timeOrigin: timeOrigin });
|
|
8585
|
-
addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'connect', timeOrigin: timeOrigin });
|
|
8586
|
-
addPerformanceNavigationTiming({
|
|
8587
|
-
transaction: transaction,
|
|
8588
|
-
entry: entry,
|
|
8589
|
-
event: 'secureConnection',
|
|
8590
|
-
timeOrigin: timeOrigin,
|
|
8591
|
-
eventEnd: 'connectEnd',
|
|
8592
|
-
description: 'TLS/SSL',
|
|
8593
|
-
});
|
|
8594
|
-
addPerformanceNavigationTiming({
|
|
8595
|
-
transaction: transaction,
|
|
8596
|
-
entry: entry,
|
|
8597
|
-
event: 'fetch',
|
|
8598
|
-
timeOrigin: timeOrigin,
|
|
8599
|
-
eventEnd: 'domainLookupStart',
|
|
8600
|
-
description: 'cache',
|
|
8601
|
-
});
|
|
8602
|
-
addPerformanceNavigationTiming({ transaction: transaction, entry: entry, event: 'domainLookup', timeOrigin: timeOrigin, description: 'DNS' });
|
|
8603
|
-
addRequest(transaction, entry, timeOrigin);
|
|
8604
|
-
}
|
|
8605
|
-
/** Create measure related spans */
|
|
8606
|
-
function addMeasureSpans(transaction, entry, startTime, duration, timeOrigin) {
|
|
8607
|
-
var measureStartTimestamp = timeOrigin + startTime;
|
|
8608
|
-
var measureEndTimestamp = measureStartTimestamp + duration;
|
|
8609
|
-
_startChild(transaction, {
|
|
8610
|
-
description: entry.name,
|
|
8611
|
-
endTimestamp: measureEndTimestamp,
|
|
8612
|
-
op: entry.entryType,
|
|
8613
|
-
startTimestamp: measureStartTimestamp,
|
|
8614
|
-
});
|
|
8615
|
-
return measureStartTimestamp;
|
|
8616
|
-
}
|
|
8617
|
-
/** Create resource-related spans */
|
|
8618
|
-
function addResourceSpans(transaction, entry, resourceName, startTime, duration, timeOrigin) {
|
|
8619
|
-
// we already instrument based on fetch and xhr, so we don't need to
|
|
8620
|
-
// duplicate spans here.
|
|
8621
|
-
if (entry.initiatorType === 'xmlhttprequest' || entry.initiatorType === 'fetch') {
|
|
8622
|
-
return undefined;
|
|
8623
|
-
}
|
|
8624
|
-
var data = {};
|
|
8625
|
-
if ('transferSize' in entry) {
|
|
8626
|
-
data['Transfer Size'] = entry.transferSize;
|
|
8627
|
-
}
|
|
8628
|
-
if ('encodedBodySize' in entry) {
|
|
8629
|
-
data['Encoded Body Size'] = entry.encodedBodySize;
|
|
8630
|
-
}
|
|
8631
|
-
if ('decodedBodySize' in entry) {
|
|
8632
|
-
data['Decoded Body Size'] = entry.decodedBodySize;
|
|
8633
|
-
}
|
|
8634
|
-
var startTimestamp = timeOrigin + startTime;
|
|
8635
|
-
var endTimestamp = startTimestamp + duration;
|
|
8636
|
-
_startChild(transaction, {
|
|
8637
|
-
description: resourceName,
|
|
8638
|
-
endTimestamp: endTimestamp,
|
|
8639
|
-
op: entry.initiatorType ? "resource." + entry.initiatorType : 'resource',
|
|
8640
|
-
startTimestamp: startTimestamp,
|
|
8641
|
-
data: data,
|
|
8642
|
-
});
|
|
8643
|
-
return endTimestamp;
|
|
8644
|
-
}
|
|
8645
|
-
/** Create performance navigation related spans */
|
|
8646
|
-
function addPerformanceNavigationTiming(props) {
|
|
8647
|
-
var transaction = props.transaction, entry = props.entry, event = props.event, timeOrigin = props.timeOrigin, eventEnd = props.eventEnd, description = props.description;
|
|
8648
|
-
var end = eventEnd ? entry[eventEnd] : entry[event + "End"];
|
|
8649
|
-
var start = entry[event + "Start"];
|
|
8650
|
-
if (!start || !end) {
|
|
8651
|
-
return;
|
|
8652
|
-
}
|
|
8653
|
-
_startChild(transaction, {
|
|
8654
|
-
op: 'browser',
|
|
8655
|
-
description: (description !== null && description !== void 0 ? description : event),
|
|
8656
|
-
startTimestamp: timeOrigin + msToSec(start),
|
|
8657
|
-
endTimestamp: timeOrigin + msToSec(end),
|
|
8658
|
-
});
|
|
8659
|
-
}
|
|
8660
|
-
/** Create request and response related spans */
|
|
8661
|
-
function addRequest(transaction, entry, timeOrigin) {
|
|
8662
|
-
_startChild(transaction, {
|
|
8663
|
-
op: 'browser',
|
|
8664
|
-
description: 'request',
|
|
8665
|
-
startTimestamp: timeOrigin + msToSec(entry.requestStart),
|
|
8666
|
-
endTimestamp: timeOrigin + msToSec(entry.responseEnd),
|
|
8667
|
-
});
|
|
8668
|
-
_startChild(transaction, {
|
|
8669
|
-
op: 'browser',
|
|
8670
|
-
description: 'response',
|
|
8671
|
-
startTimestamp: timeOrigin + msToSec(entry.responseStart),
|
|
8672
|
-
endTimestamp: timeOrigin + msToSec(entry.responseEnd),
|
|
8673
|
-
});
|
|
8674
|
-
}
|
|
8675
|
-
/**
|
|
8676
|
-
* Helper function to start child on transactions. This function will make sure that the transaction will
|
|
8677
|
-
* use the start timestamp of the created child span if it is earlier than the transactions actual
|
|
8678
|
-
* start timestamp.
|
|
8679
|
-
*/
|
|
8680
|
-
function _startChild(transaction, _a) {
|
|
8681
|
-
var startTimestamp = _a.startTimestamp, ctx = __rest(_a, ["startTimestamp"]);
|
|
8682
|
-
if (startTimestamp && transaction.startTimestamp > startTimestamp) {
|
|
8683
|
-
transaction.startTimestamp = startTimestamp;
|
|
8684
|
-
}
|
|
8685
|
-
return transaction.startChild(__assign({ startTimestamp: startTimestamp }, ctx));
|
|
8686
|
-
}
|
|
8687
|
-
/**
|
|
8688
|
-
* Checks if a given value is a valid measurement value.
|
|
8689
|
-
*/
|
|
8690
|
-
function isMeasurementValue(value) {
|
|
8691
|
-
return typeof value === 'number' && isFinite(value);
|
|
8692
|
-
}
|
|
8693
|
-
|
|
8694
|
-
var DEFAULT_TRACING_ORIGINS = ['localhost', /^\//];
|
|
8695
|
-
var defaultRequestInstrumentationOptions = {
|
|
8696
|
-
traceFetch: true,
|
|
8697
|
-
traceXHR: true,
|
|
8698
|
-
tracingOrigins: DEFAULT_TRACING_ORIGINS,
|
|
8699
|
-
};
|
|
8700
|
-
/** Registers span creators for xhr and fetch requests */
|
|
8701
|
-
function instrumentOutgoingRequests(_options) {
|
|
8702
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
8703
|
-
var _a = __assign(__assign({}, defaultRequestInstrumentationOptions), _options), traceFetch = _a.traceFetch, traceXHR = _a.traceXHR, tracingOrigins = _a.tracingOrigins, shouldCreateSpanForRequest = _a.shouldCreateSpanForRequest;
|
|
8704
|
-
// We should cache url -> decision so that we don't have to compute
|
|
8705
|
-
// regexp everytime we create a request.
|
|
8706
|
-
var urlMap = {};
|
|
8707
|
-
var defaultShouldCreateSpan = function (url) {
|
|
8708
|
-
if (urlMap[url]) {
|
|
8709
|
-
return urlMap[url];
|
|
8710
|
-
}
|
|
8711
|
-
var origins = tracingOrigins;
|
|
8712
|
-
urlMap[url] =
|
|
8713
|
-
origins.some(function (origin) { return isMatchingPattern(url, origin); }) &&
|
|
8714
|
-
!isMatchingPattern(url, 'sentry_key');
|
|
8715
|
-
return urlMap[url];
|
|
8716
|
-
};
|
|
8717
|
-
// We want that our users don't have to re-implement shouldCreateSpanForRequest themselves
|
|
8718
|
-
// That's why we filter out already unwanted Spans from tracingOrigins
|
|
8719
|
-
var shouldCreateSpan = defaultShouldCreateSpan;
|
|
8720
|
-
if (typeof shouldCreateSpanForRequest === 'function') {
|
|
8721
|
-
shouldCreateSpan = function (url) {
|
|
8722
|
-
return defaultShouldCreateSpan(url) && shouldCreateSpanForRequest(url);
|
|
8723
|
-
};
|
|
8724
|
-
}
|
|
8725
|
-
var spans = {};
|
|
8726
|
-
if (traceFetch) {
|
|
8727
|
-
addInstrumentationHandler({
|
|
8728
|
-
callback: function (handlerData) {
|
|
8729
|
-
fetchCallback(handlerData, shouldCreateSpan, spans);
|
|
8730
|
-
},
|
|
8731
|
-
type: 'fetch',
|
|
8732
|
-
});
|
|
8733
|
-
}
|
|
8734
|
-
if (traceXHR) {
|
|
8735
|
-
addInstrumentationHandler({
|
|
8736
|
-
callback: function (handlerData) {
|
|
8737
|
-
xhrCallback(handlerData, shouldCreateSpan, spans);
|
|
8738
|
-
},
|
|
8739
|
-
type: 'xhr',
|
|
8740
|
-
});
|
|
8741
|
-
}
|
|
8742
|
-
}
|
|
8743
|
-
/**
|
|
8744
|
-
* Create and track fetch request spans
|
|
8745
|
-
*/
|
|
8746
|
-
function fetchCallback(handlerData, shouldCreateSpan, spans) {
|
|
8747
|
-
if (!hasTracingEnabled() || !(handlerData.fetchData && shouldCreateSpan(handlerData.fetchData.url))) {
|
|
8748
|
-
return;
|
|
8749
|
-
}
|
|
8750
|
-
if (handlerData.endTimestamp && handlerData.fetchData.__span) {
|
|
8751
|
-
var span = spans[handlerData.fetchData.__span];
|
|
8752
|
-
if (span) {
|
|
8753
|
-
if (handlerData.response) {
|
|
8754
|
-
// TODO (kmclb) remove this once types PR goes through
|
|
8755
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
8756
|
-
span.setHttpStatus(handlerData.response.status);
|
|
8757
|
-
}
|
|
8758
|
-
else if (handlerData.error) {
|
|
8759
|
-
span.setStatus(SpanStatus.InternalError);
|
|
8760
|
-
}
|
|
8761
|
-
span.finish();
|
|
8762
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
8763
|
-
delete spans[handlerData.fetchData.__span];
|
|
8764
|
-
}
|
|
8765
|
-
return;
|
|
8766
|
-
}
|
|
8767
|
-
var activeTransaction = getActiveTransaction();
|
|
8768
|
-
if (activeTransaction) {
|
|
8769
|
-
var span = activeTransaction.startChild({
|
|
8770
|
-
data: __assign(__assign({}, handlerData.fetchData), { type: 'fetch' }),
|
|
8771
|
-
description: handlerData.fetchData.method + " " + handlerData.fetchData.url,
|
|
8772
|
-
op: 'http.client',
|
|
8773
|
-
});
|
|
8774
|
-
handlerData.fetchData.__span = span.spanId;
|
|
8775
|
-
spans[span.spanId] = span;
|
|
8776
|
-
var request = (handlerData.args[0] = handlerData.args[0]);
|
|
8777
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8778
|
-
var options = (handlerData.args[1] = handlerData.args[1] || {});
|
|
8779
|
-
var headers = options.headers;
|
|
8780
|
-
if (isInstanceOf(request, Request)) {
|
|
8781
|
-
headers = request.headers;
|
|
8782
|
-
}
|
|
8783
|
-
if (headers) {
|
|
8784
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
8785
|
-
if (typeof headers.append === 'function') {
|
|
8786
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
8787
|
-
headers.append('sentry-trace', span.toTraceparent());
|
|
8788
|
-
}
|
|
8789
|
-
else if (Array.isArray(headers)) {
|
|
8790
|
-
headers = __spread(headers, [['sentry-trace', span.toTraceparent()]]);
|
|
8791
|
-
}
|
|
8792
|
-
else {
|
|
8793
|
-
headers = __assign(__assign({}, headers), { 'sentry-trace': span.toTraceparent() });
|
|
8794
|
-
}
|
|
8795
|
-
}
|
|
8796
|
-
else {
|
|
8797
|
-
headers = { 'sentry-trace': span.toTraceparent() };
|
|
8798
|
-
}
|
|
8799
|
-
options.headers = headers;
|
|
8800
|
-
}
|
|
8801
|
-
}
|
|
8802
|
-
/**
|
|
8803
|
-
* Create and track xhr request spans
|
|
8804
|
-
*/
|
|
8805
|
-
function xhrCallback(handlerData, shouldCreateSpan, spans) {
|
|
8806
|
-
var _a, _b;
|
|
8807
|
-
if (!hasTracingEnabled() || ((_a = handlerData.xhr) === null || _a === void 0 ? void 0 : _a.__sentry_own_request__) ||
|
|
8808
|
-
!(((_b = handlerData.xhr) === null || _b === void 0 ? void 0 : _b.__sentry_xhr__) && shouldCreateSpan(handlerData.xhr.__sentry_xhr__.url))) {
|
|
8809
|
-
return;
|
|
8810
|
-
}
|
|
8811
|
-
var xhr = handlerData.xhr.__sentry_xhr__;
|
|
8812
|
-
// check first if the request has finished and is tracked by an existing span which should now end
|
|
8813
|
-
if (handlerData.endTimestamp && handlerData.xhr.__sentry_xhr_span_id__) {
|
|
8814
|
-
var span = spans[handlerData.xhr.__sentry_xhr_span_id__];
|
|
8815
|
-
if (span) {
|
|
8816
|
-
span.setHttpStatus(xhr.status_code);
|
|
8817
|
-
span.finish();
|
|
8818
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
8819
|
-
delete spans[handlerData.xhr.__sentry_xhr_span_id__];
|
|
8820
|
-
}
|
|
8821
|
-
return;
|
|
8822
|
-
}
|
|
8823
|
-
// if not, create a new span to track it
|
|
8824
|
-
var activeTransaction = getActiveTransaction();
|
|
8825
|
-
if (activeTransaction) {
|
|
8826
|
-
var span = activeTransaction.startChild({
|
|
8827
|
-
data: __assign(__assign({}, xhr.data), { type: 'xhr', method: xhr.method, url: xhr.url }),
|
|
8828
|
-
description: xhr.method + " " + xhr.url,
|
|
8829
|
-
op: 'http.client',
|
|
8830
|
-
});
|
|
8831
|
-
handlerData.xhr.__sentry_xhr_span_id__ = span.spanId;
|
|
8832
|
-
spans[handlerData.xhr.__sentry_xhr_span_id__] = span;
|
|
8833
|
-
if (handlerData.xhr.setRequestHeader) {
|
|
8834
|
-
try {
|
|
8835
|
-
handlerData.xhr.setRequestHeader('sentry-trace', span.toTraceparent());
|
|
8836
|
-
}
|
|
8837
|
-
catch (_) {
|
|
8838
|
-
// Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.
|
|
8839
|
-
}
|
|
8840
|
-
}
|
|
8841
|
-
}
|
|
8842
|
-
}
|
|
8843
|
-
|
|
8844
|
-
var global$1 = getGlobalObject();
|
|
8845
|
-
/**
|
|
8846
|
-
* Default function implementing pageload and navigation transactions
|
|
8847
|
-
*/
|
|
8848
|
-
function instrumentRoutingWithDefaults(customStartTransaction, startTransactionOnPageLoad, startTransactionOnLocationChange) {
|
|
8849
|
-
if (startTransactionOnPageLoad === void 0) { startTransactionOnPageLoad = true; }
|
|
8850
|
-
if (startTransactionOnLocationChange === void 0) { startTransactionOnLocationChange = true; }
|
|
8851
|
-
if (!global$1 || !global$1.location) {
|
|
8852
|
-
logger.warn('Could not initialize routing instrumentation due to invalid location');
|
|
8853
|
-
return;
|
|
8854
|
-
}
|
|
8855
|
-
var startingUrl = global$1.location.href;
|
|
8856
|
-
var activeTransaction;
|
|
8857
|
-
if (startTransactionOnPageLoad) {
|
|
8858
|
-
activeTransaction = customStartTransaction({ name: global$1.location.pathname, op: 'pageload' });
|
|
8859
|
-
}
|
|
8860
|
-
if (startTransactionOnLocationChange) {
|
|
8861
|
-
addInstrumentationHandler({
|
|
8862
|
-
callback: function (_a) {
|
|
8863
|
-
var to = _a.to, from = _a.from;
|
|
8864
|
-
/**
|
|
8865
|
-
* This early return is there to account for some cases where a navigation transaction starts right after
|
|
8866
|
-
* long-running pageload. We make sure that if `from` is undefined and a valid `startingURL` exists, we don't
|
|
8867
|
-
* create an uneccessary navigation transaction.
|
|
8868
|
-
*
|
|
8869
|
-
* This was hard to duplicate, but this behavior stopped as soon as this fix was applied. This issue might also
|
|
8870
|
-
* only be caused in certain development environments where the usage of a hot module reloader is causing
|
|
8871
|
-
* errors.
|
|
8872
|
-
*/
|
|
8873
|
-
if (from === undefined && startingUrl && startingUrl.indexOf(to) !== -1) {
|
|
8874
|
-
startingUrl = undefined;
|
|
8875
|
-
return;
|
|
8876
|
-
}
|
|
8877
|
-
if (from !== to) {
|
|
8878
|
-
startingUrl = undefined;
|
|
8879
|
-
if (activeTransaction) {
|
|
8880
|
-
logger.log("[Tracing] Finishing current transaction with op: " + activeTransaction.op);
|
|
8881
|
-
// If there's an open transaction on the scope, we need to finish it before creating an new one.
|
|
8882
|
-
activeTransaction.finish();
|
|
8883
|
-
}
|
|
8884
|
-
activeTransaction = customStartTransaction({ name: global$1.location.pathname, op: 'navigation' });
|
|
8885
|
-
}
|
|
8886
|
-
},
|
|
8887
|
-
type: 'history',
|
|
8888
|
-
});
|
|
8889
|
-
}
|
|
8890
|
-
}
|
|
8891
|
-
|
|
8892
|
-
var DEFAULT_MAX_TRANSACTION_DURATION_SECONDS = 600;
|
|
8893
|
-
var DEFAULT_BROWSER_TRACING_OPTIONS = __assign({ idleTimeout: DEFAULT_IDLE_TIMEOUT, markBackgroundTransactions: true, maxTransactionDuration: DEFAULT_MAX_TRANSACTION_DURATION_SECONDS, routingInstrumentation: instrumentRoutingWithDefaults, startTransactionOnLocationChange: true, startTransactionOnPageLoad: true }, defaultRequestInstrumentationOptions);
|
|
8894
|
-
/**
|
|
8895
|
-
* The Browser Tracing integration automatically instruments browser pageload/navigation
|
|
8896
|
-
* actions as transactions, and captures requests, metrics and errors as spans.
|
|
8897
|
-
*
|
|
8898
|
-
* The integration can be configured with a variety of options, and can be extended to use
|
|
8899
|
-
* any routing library. This integration uses {@see IdleTransaction} to create transactions.
|
|
8900
|
-
*/
|
|
8901
|
-
var BrowserTracing = /** @class */ (function () {
|
|
8902
|
-
function BrowserTracing(_options) {
|
|
8903
|
-
/**
|
|
8904
|
-
* @inheritDoc
|
|
8905
|
-
*/
|
|
8906
|
-
this.name = BrowserTracing.id;
|
|
8907
|
-
this._emitOptionsWarning = false;
|
|
8908
|
-
var tracingOrigins = defaultRequestInstrumentationOptions.tracingOrigins;
|
|
8909
|
-
// NOTE: Logger doesn't work in constructors, as it's initialized after integrations instances
|
|
8910
|
-
if (_options &&
|
|
8911
|
-
_options.tracingOrigins &&
|
|
8912
|
-
Array.isArray(_options.tracingOrigins) &&
|
|
8913
|
-
_options.tracingOrigins.length !== 0) {
|
|
8914
|
-
tracingOrigins = _options.tracingOrigins;
|
|
8915
|
-
}
|
|
8916
|
-
else {
|
|
8917
|
-
this._emitOptionsWarning = true;
|
|
8918
|
-
}
|
|
8919
|
-
this.options = __assign(__assign(__assign({}, DEFAULT_BROWSER_TRACING_OPTIONS), _options), { tracingOrigins: tracingOrigins });
|
|
8920
|
-
this._metrics = new MetricsInstrumentation(__assign(__assign({}, DEFAULT_METRICS_INSTR_OPTIONS), this.options._metricOptions));
|
|
8921
|
-
}
|
|
8922
|
-
/**
|
|
8923
|
-
* @inheritDoc
|
|
8924
|
-
*/
|
|
8925
|
-
BrowserTracing.prototype.setupOnce = function (_, getCurrentHub) {
|
|
8926
|
-
var _this = this;
|
|
8927
|
-
this._getCurrentHub = getCurrentHub;
|
|
8928
|
-
if (this._emitOptionsWarning) {
|
|
8929
|
-
logger.warn('[Tracing] You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace.');
|
|
8930
|
-
logger.warn("[Tracing] We added a reasonable default for you: " + defaultRequestInstrumentationOptions.tracingOrigins);
|
|
8931
|
-
}
|
|
8932
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
8933
|
-
var _a = this.options, instrumentRouting = _a.routingInstrumentation, startTransactionOnLocationChange = _a.startTransactionOnLocationChange, startTransactionOnPageLoad = _a.startTransactionOnPageLoad, markBackgroundTransactions = _a.markBackgroundTransactions, traceFetch = _a.traceFetch, traceXHR = _a.traceXHR, tracingOrigins = _a.tracingOrigins, shouldCreateSpanForRequest = _a.shouldCreateSpanForRequest;
|
|
8934
|
-
instrumentRouting(function (context) { return _this._createRouteTransaction(context); }, startTransactionOnPageLoad, startTransactionOnLocationChange);
|
|
8935
|
-
if (markBackgroundTransactions) {
|
|
8936
|
-
registerBackgroundTabDetection();
|
|
8937
|
-
}
|
|
8938
|
-
instrumentOutgoingRequests({ traceFetch: traceFetch, traceXHR: traceXHR, tracingOrigins: tracingOrigins, shouldCreateSpanForRequest: shouldCreateSpanForRequest });
|
|
8939
|
-
};
|
|
8940
|
-
/** Create routing idle transaction. */
|
|
8941
|
-
BrowserTracing.prototype._createRouteTransaction = function (context) {
|
|
8942
|
-
var _this = this;
|
|
8943
|
-
if (!this._getCurrentHub) {
|
|
8944
|
-
logger.warn("[Tracing] Did not create " + context.op + " transaction because _getCurrentHub is invalid.");
|
|
8945
|
-
return undefined;
|
|
8946
|
-
}
|
|
8947
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
8948
|
-
var _a = this.options, beforeNavigate = _a.beforeNavigate, idleTimeout = _a.idleTimeout, maxTransactionDuration = _a.maxTransactionDuration;
|
|
8949
|
-
var parentContextFromHeader = context.op === 'pageload' ? getHeaderContext() : undefined;
|
|
8950
|
-
var expandedContext = __assign(__assign(__assign({}, context), parentContextFromHeader), { trimEnd: true });
|
|
8951
|
-
var modifiedContext = typeof beforeNavigate === 'function' ? beforeNavigate(expandedContext) : expandedContext;
|
|
8952
|
-
// For backwards compatibility reasons, beforeNavigate can return undefined to "drop" the transaction (prevent it
|
|
8953
|
-
// from being sent to Sentry).
|
|
8954
|
-
var finalContext = modifiedContext === undefined ? __assign(__assign({}, expandedContext), { sampled: false }) : modifiedContext;
|
|
8955
|
-
if (finalContext.sampled === false) {
|
|
8956
|
-
logger.log("[Tracing] Will not send " + finalContext.op + " transaction because of beforeNavigate.");
|
|
8957
|
-
}
|
|
8958
|
-
logger.log("[Tracing] Starting " + finalContext.op + " transaction on scope");
|
|
8959
|
-
var hub = this._getCurrentHub();
|
|
8960
|
-
var location = getGlobalObject().location;
|
|
8961
|
-
var idleTransaction = startIdleTransaction(hub, finalContext, idleTimeout, true, { location: location });
|
|
8962
|
-
idleTransaction.registerBeforeFinishCallback(function (transaction, endTimestamp) {
|
|
8963
|
-
_this._metrics.addPerformanceEntries(transaction);
|
|
8964
|
-
adjustTransactionDuration(secToMs(maxTransactionDuration), transaction, endTimestamp);
|
|
8965
|
-
});
|
|
8966
|
-
return idleTransaction;
|
|
8967
|
-
};
|
|
8968
|
-
/**
|
|
8969
|
-
* @inheritDoc
|
|
8970
|
-
*/
|
|
8971
|
-
BrowserTracing.id = 'BrowserTracing';
|
|
8972
|
-
return BrowserTracing;
|
|
8973
|
-
}());
|
|
8974
|
-
/**
|
|
8975
|
-
* Gets transaction context from a sentry-trace meta.
|
|
8976
|
-
*
|
|
8977
|
-
* @returns Transaction context data from the header or undefined if there's no header or the header is malformed
|
|
8978
|
-
*/
|
|
8979
|
-
function getHeaderContext() {
|
|
8980
|
-
var header = getMetaContent('sentry-trace');
|
|
8981
|
-
if (header) {
|
|
8982
|
-
return extractTraceparentData(header);
|
|
8983
|
-
}
|
|
8984
|
-
return undefined;
|
|
8985
|
-
}
|
|
8986
|
-
/** Returns the value of a meta tag */
|
|
8987
|
-
function getMetaContent(metaName) {
|
|
8988
|
-
var el = getGlobalObject().document.querySelector("meta[name=" + metaName + "]");
|
|
8989
|
-
return el ? el.getAttribute('content') : null;
|
|
8990
|
-
}
|
|
8991
|
-
/** Adjusts transaction value based on max transaction duration */
|
|
8992
|
-
function adjustTransactionDuration(maxDuration, transaction, endTimestamp) {
|
|
8993
|
-
var diff = endTimestamp - transaction.startTimestamp;
|
|
8994
|
-
var isOutdatedTransaction = endTimestamp && (diff > maxDuration || diff < 0);
|
|
8995
|
-
if (isOutdatedTransaction) {
|
|
8996
|
-
transaction.setStatus(SpanStatus.DeadlineExceeded);
|
|
8997
|
-
transaction.setTag('maxTransactionDurationExceeded', 'true');
|
|
8998
|
-
}
|
|
8999
|
-
}
|
|
9000
|
-
|
|
9001
|
-
/**
|
|
9002
|
-
* Express integration
|
|
9003
|
-
*
|
|
9004
|
-
* Provides an request and error handler for Express framework as well as tracing capabilities
|
|
9005
|
-
*/
|
|
9006
|
-
var Express = /** @class */ (function () {
|
|
9007
|
-
/**
|
|
9008
|
-
* @inheritDoc
|
|
9009
|
-
*/
|
|
9010
|
-
function Express(options) {
|
|
9011
|
-
if (options === void 0) { options = {}; }
|
|
9012
|
-
/**
|
|
9013
|
-
* @inheritDoc
|
|
9014
|
-
*/
|
|
9015
|
-
this.name = Express.id;
|
|
9016
|
-
this._router = options.router || options.app;
|
|
9017
|
-
this._methods = (Array.isArray(options.methods) ? options.methods : []).concat('use');
|
|
9018
|
-
}
|
|
9019
|
-
/**
|
|
9020
|
-
* @inheritDoc
|
|
9021
|
-
*/
|
|
9022
|
-
Express.prototype.setupOnce = function () {
|
|
9023
|
-
if (!this._router) {
|
|
9024
|
-
logger.error('ExpressIntegration is missing an Express instance');
|
|
9025
|
-
return;
|
|
9026
|
-
}
|
|
9027
|
-
instrumentMiddlewares(this._router, this._methods);
|
|
9028
|
-
};
|
|
9029
|
-
/**
|
|
9030
|
-
* @inheritDoc
|
|
9031
|
-
*/
|
|
9032
|
-
Express.id = 'Express';
|
|
9033
|
-
return Express;
|
|
9034
|
-
}());
|
|
9035
|
-
/**
|
|
9036
|
-
* Wraps original middleware function in a tracing call, which stores the info about the call as a span,
|
|
9037
|
-
* and finishes it once the middleware is done invoking.
|
|
9038
|
-
*
|
|
9039
|
-
* Express middlewares have 3 various forms, thus we have to take care of all of them:
|
|
9040
|
-
* // sync
|
|
9041
|
-
* app.use(function (req, res) { ... })
|
|
9042
|
-
* // async
|
|
9043
|
-
* app.use(function (req, res, next) { ... })
|
|
9044
|
-
* // error handler
|
|
9045
|
-
* app.use(function (err, req, res, next) { ... })
|
|
9046
|
-
*
|
|
9047
|
-
* They all internally delegate to the `router[method]` of the given application instance.
|
|
9048
|
-
*/
|
|
9049
|
-
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any
|
|
9050
|
-
function wrap(fn, method) {
|
|
9051
|
-
var arity = fn.length;
|
|
9052
|
-
switch (arity) {
|
|
9053
|
-
case 2: {
|
|
9054
|
-
return function (req, res) {
|
|
9055
|
-
var transaction = res.__sentry_transaction;
|
|
9056
|
-
if (transaction) {
|
|
9057
|
-
var span_1 = transaction.startChild({
|
|
9058
|
-
description: fn.name,
|
|
9059
|
-
op: "middleware." + method,
|
|
9060
|
-
});
|
|
9061
|
-
res.once('finish', function () {
|
|
9062
|
-
span_1.finish();
|
|
9063
|
-
});
|
|
9064
|
-
}
|
|
9065
|
-
return fn.call(this, req, res);
|
|
9066
|
-
};
|
|
9067
|
-
}
|
|
9068
|
-
case 3: {
|
|
9069
|
-
return function (req, res, next) {
|
|
9070
|
-
var _a;
|
|
9071
|
-
var transaction = res.__sentry_transaction;
|
|
9072
|
-
var span = (_a = transaction) === null || _a === void 0 ? void 0 : _a.startChild({
|
|
9073
|
-
description: fn.name,
|
|
9074
|
-
op: "middleware." + method,
|
|
9075
|
-
});
|
|
9076
|
-
fn.call(this, req, res, function () {
|
|
9077
|
-
var args = [];
|
|
9078
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
9079
|
-
args[_i] = arguments[_i];
|
|
9080
|
-
}
|
|
9081
|
-
var _a;
|
|
9082
|
-
(_a = span) === null || _a === void 0 ? void 0 : _a.finish();
|
|
9083
|
-
next.call.apply(next, __spread([this], args));
|
|
9084
|
-
});
|
|
9085
|
-
};
|
|
9086
|
-
}
|
|
9087
|
-
case 4: {
|
|
9088
|
-
return function (err, req, res, next) {
|
|
9089
|
-
var _a;
|
|
9090
|
-
var transaction = res.__sentry_transaction;
|
|
9091
|
-
var span = (_a = transaction) === null || _a === void 0 ? void 0 : _a.startChild({
|
|
9092
|
-
description: fn.name,
|
|
9093
|
-
op: "middleware." + method,
|
|
9094
|
-
});
|
|
9095
|
-
fn.call(this, err, req, res, function () {
|
|
9096
|
-
var args = [];
|
|
9097
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
9098
|
-
args[_i] = arguments[_i];
|
|
9099
|
-
}
|
|
9100
|
-
var _a;
|
|
9101
|
-
(_a = span) === null || _a === void 0 ? void 0 : _a.finish();
|
|
9102
|
-
next.call.apply(next, __spread([this], args));
|
|
9103
|
-
});
|
|
9104
|
-
};
|
|
9105
|
-
}
|
|
9106
|
-
default: {
|
|
9107
|
-
throw new Error("Express middleware takes 2-4 arguments. Got: " + arity);
|
|
9108
|
-
}
|
|
9109
|
-
}
|
|
9110
|
-
}
|
|
9111
|
-
/**
|
|
9112
|
-
* Takes all the function arguments passed to the original `app` or `router` method, eg. `app.use` or `router.use`
|
|
9113
|
-
* and wraps every function, as well as array of functions with a call to our `wrap` method.
|
|
9114
|
-
* We have to take care of the arrays as well as iterate over all of the arguments,
|
|
9115
|
-
* as `app.use` can accept middlewares in few various forms.
|
|
9116
|
-
*
|
|
9117
|
-
* app.use([<path>], <fn>)
|
|
9118
|
-
* app.use([<path>], <fn>, ...<fn>)
|
|
9119
|
-
* app.use([<path>], ...<fn>[])
|
|
9120
|
-
*/
|
|
9121
|
-
function wrapMiddlewareArgs(args, method) {
|
|
9122
|
-
return args.map(function (arg) {
|
|
9123
|
-
if (typeof arg === 'function') {
|
|
9124
|
-
return wrap(arg, method);
|
|
9125
|
-
}
|
|
9126
|
-
if (Array.isArray(arg)) {
|
|
9127
|
-
return arg.map(function (a) {
|
|
9128
|
-
if (typeof a === 'function') {
|
|
9129
|
-
return wrap(a, method);
|
|
9130
|
-
}
|
|
9131
|
-
return a;
|
|
9132
|
-
});
|
|
9133
|
-
}
|
|
9134
|
-
return arg;
|
|
9135
|
-
});
|
|
9136
|
-
}
|
|
9137
|
-
/**
|
|
9138
|
-
* Patches original router to utilize our tracing functionality
|
|
9139
|
-
*/
|
|
9140
|
-
function patchMiddleware(router, method) {
|
|
9141
|
-
var originalCallback = router[method];
|
|
9142
|
-
router[method] = function () {
|
|
9143
|
-
var args = [];
|
|
9144
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
9145
|
-
args[_i] = arguments[_i];
|
|
9146
|
-
}
|
|
9147
|
-
return originalCallback.call.apply(originalCallback, __spread([this], wrapMiddlewareArgs(args, method)));
|
|
9148
|
-
};
|
|
9149
|
-
return router;
|
|
9150
|
-
}
|
|
9151
|
-
/**
|
|
9152
|
-
* Patches original router methods
|
|
9153
|
-
*/
|
|
9154
|
-
function instrumentMiddlewares(router, methods) {
|
|
9155
|
-
if (methods === void 0) { methods = []; }
|
|
9156
|
-
methods.forEach(function (method) { return patchMiddleware(router, method); });
|
|
9157
|
-
}
|
|
9158
|
-
|
|
9159
|
-
/** Tracing integration for node-postgres package */
|
|
9160
|
-
var Postgres = /** @class */ (function () {
|
|
9161
|
-
function Postgres(options) {
|
|
9162
|
-
if (options === void 0) { options = {}; }
|
|
9163
|
-
/**
|
|
9164
|
-
* @inheritDoc
|
|
9165
|
-
*/
|
|
9166
|
-
this.name = Postgres.id;
|
|
9167
|
-
this._usePgNative = !!options.usePgNative;
|
|
9168
|
-
}
|
|
9169
|
-
/**
|
|
9170
|
-
* @inheritDoc
|
|
9171
|
-
*/
|
|
9172
|
-
Postgres.prototype.setupOnce = function (_, getCurrentHub) {
|
|
9173
|
-
var _a;
|
|
9174
|
-
var pkg = loadModule('pg');
|
|
9175
|
-
if (!pkg) {
|
|
9176
|
-
logger.error('Postgres Integration was unable to require `pg` package.');
|
|
9177
|
-
return;
|
|
9178
|
-
}
|
|
9179
|
-
if (this._usePgNative && !((_a = pkg.native) === null || _a === void 0 ? void 0 : _a.Client)) {
|
|
9180
|
-
logger.error("Postgres Integration was unable to access 'pg-native' bindings.");
|
|
9181
|
-
return;
|
|
9182
|
-
}
|
|
9183
|
-
var Client = (this._usePgNative ? pkg.native : pkg).Client;
|
|
9184
|
-
/**
|
|
9185
|
-
* function (query, callback) => void
|
|
9186
|
-
* function (query, params, callback) => void
|
|
9187
|
-
* function (query) => Promise
|
|
9188
|
-
* function (query, params) => Promise
|
|
9189
|
-
* function (pg.Cursor) => pg.Cursor
|
|
9190
|
-
*/
|
|
9191
|
-
fill(Client.prototype, 'query', function (orig) {
|
|
9192
|
-
return function (config, values, callback) {
|
|
9193
|
-
var _a, _b, _c;
|
|
9194
|
-
var scope = getCurrentHub().getScope();
|
|
9195
|
-
var parentSpan = (_a = scope) === null || _a === void 0 ? void 0 : _a.getSpan();
|
|
9196
|
-
var span = (_b = parentSpan) === null || _b === void 0 ? void 0 : _b.startChild({
|
|
9197
|
-
description: typeof config === 'string' ? config : config.text,
|
|
9198
|
-
op: "db",
|
|
9199
|
-
});
|
|
9200
|
-
if (typeof callback === 'function') {
|
|
9201
|
-
return orig.call(this, config, values, function (err, result) {
|
|
9202
|
-
var _a;
|
|
9203
|
-
(_a = span) === null || _a === void 0 ? void 0 : _a.finish();
|
|
9204
|
-
callback(err, result);
|
|
9205
|
-
});
|
|
9206
|
-
}
|
|
9207
|
-
if (typeof values === 'function') {
|
|
9208
|
-
return orig.call(this, config, function (err, result) {
|
|
9209
|
-
var _a;
|
|
9210
|
-
(_a = span) === null || _a === void 0 ? void 0 : _a.finish();
|
|
9211
|
-
values(err, result);
|
|
9212
|
-
});
|
|
9213
|
-
}
|
|
9214
|
-
var rv = typeof values !== 'undefined' ? orig.call(this, config, values) : orig.call(this, config);
|
|
9215
|
-
if (isThenable(rv)) {
|
|
9216
|
-
return rv.then(function (res) {
|
|
9217
|
-
var _a;
|
|
9218
|
-
(_a = span) === null || _a === void 0 ? void 0 : _a.finish();
|
|
9219
|
-
return res;
|
|
9220
|
-
});
|
|
9221
|
-
}
|
|
9222
|
-
(_c = span) === null || _c === void 0 ? void 0 : _c.finish();
|
|
9223
|
-
return rv;
|
|
9224
|
-
};
|
|
9225
|
-
});
|
|
9226
|
-
};
|
|
9227
|
-
/**
|
|
9228
|
-
* @inheritDoc
|
|
9229
|
-
*/
|
|
9230
|
-
Postgres.id = 'Postgres';
|
|
9231
|
-
return Postgres;
|
|
9232
|
-
}());
|
|
9233
|
-
|
|
9234
|
-
/** Tracing integration for node-mysql package */
|
|
9235
|
-
var Mysql = /** @class */ (function () {
|
|
9236
|
-
function Mysql() {
|
|
9237
|
-
/**
|
|
9238
|
-
* @inheritDoc
|
|
9239
|
-
*/
|
|
9240
|
-
this.name = Mysql.id;
|
|
9241
|
-
}
|
|
9242
|
-
/**
|
|
9243
|
-
* @inheritDoc
|
|
9244
|
-
*/
|
|
9245
|
-
Mysql.prototype.setupOnce = function (_, getCurrentHub) {
|
|
9246
|
-
var pkg = loadModule('mysql/lib/Connection.js');
|
|
9247
|
-
if (!pkg) {
|
|
9248
|
-
logger.error('Mysql Integration was unable to require `mysql` package.');
|
|
9249
|
-
return;
|
|
9250
|
-
}
|
|
9251
|
-
// The original function will have one of these signatures:
|
|
9252
|
-
// function (callback) => void
|
|
9253
|
-
// function (options, callback) => void
|
|
9254
|
-
// function (options, values, callback) => void
|
|
9255
|
-
fill(pkg, 'createQuery', function (orig) {
|
|
9256
|
-
return function (options, values, callback) {
|
|
9257
|
-
var _a, _b;
|
|
9258
|
-
var scope = getCurrentHub().getScope();
|
|
9259
|
-
var parentSpan = (_a = scope) === null || _a === void 0 ? void 0 : _a.getSpan();
|
|
9260
|
-
var span = (_b = parentSpan) === null || _b === void 0 ? void 0 : _b.startChild({
|
|
9261
|
-
description: typeof options === 'string' ? options : options.sql,
|
|
9262
|
-
op: "db",
|
|
9263
|
-
});
|
|
9264
|
-
if (typeof callback === 'function') {
|
|
9265
|
-
return orig.call(this, options, values, function (err, result, fields) {
|
|
9266
|
-
var _a;
|
|
9267
|
-
(_a = span) === null || _a === void 0 ? void 0 : _a.finish();
|
|
9268
|
-
callback(err, result, fields);
|
|
9269
|
-
});
|
|
9270
|
-
}
|
|
9271
|
-
if (typeof values === 'function') {
|
|
9272
|
-
return orig.call(this, options, function (err, result, fields) {
|
|
9273
|
-
var _a;
|
|
9274
|
-
(_a = span) === null || _a === void 0 ? void 0 : _a.finish();
|
|
9275
|
-
values(err, result, fields);
|
|
9276
|
-
});
|
|
9277
|
-
}
|
|
9278
|
-
return orig.call(this, options, values, callback);
|
|
9279
|
-
};
|
|
9280
|
-
});
|
|
9281
|
-
};
|
|
9282
|
-
/**
|
|
9283
|
-
* @inheritDoc
|
|
9284
|
-
*/
|
|
9285
|
-
Mysql.id = 'Mysql';
|
|
9286
|
-
return Mysql;
|
|
9287
|
-
}());
|
|
9288
|
-
|
|
9289
|
-
var OPERATIONS = [
|
|
9290
|
-
'aggregate',
|
|
9291
|
-
'bulkWrite',
|
|
9292
|
-
'countDocuments',
|
|
9293
|
-
'createIndex',
|
|
9294
|
-
'createIndexes',
|
|
9295
|
-
'deleteMany',
|
|
9296
|
-
'deleteOne',
|
|
9297
|
-
'distinct',
|
|
9298
|
-
'drop',
|
|
9299
|
-
'dropIndex',
|
|
9300
|
-
'dropIndexes',
|
|
9301
|
-
'estimatedDocumentCount',
|
|
9302
|
-
'find',
|
|
9303
|
-
'findOne',
|
|
9304
|
-
'findOneAndDelete',
|
|
9305
|
-
'findOneAndReplace',
|
|
9306
|
-
'findOneAndUpdate',
|
|
9307
|
-
'indexes',
|
|
9308
|
-
'indexExists',
|
|
9309
|
-
'indexInformation',
|
|
9310
|
-
'initializeOrderedBulkOp',
|
|
9311
|
-
'insertMany',
|
|
9312
|
-
'insertOne',
|
|
9313
|
-
'isCapped',
|
|
9314
|
-
'mapReduce',
|
|
9315
|
-
'options',
|
|
9316
|
-
'parallelCollectionScan',
|
|
9317
|
-
'rename',
|
|
9318
|
-
'replaceOne',
|
|
9319
|
-
'stats',
|
|
9320
|
-
'updateMany',
|
|
9321
|
-
'updateOne',
|
|
9322
|
-
];
|
|
9323
|
-
// All of the operations above take `options` and `callback` as their final parameters, but some of them
|
|
9324
|
-
// take additional parameters as well. For those operations, this is a map of
|
|
9325
|
-
// { <operation name>: [<names of additional parameters>] }, as a way to know what to call the operation's
|
|
9326
|
-
// positional arguments when we add them to the span's `data` object later
|
|
9327
|
-
var OPERATION_SIGNATURES = {
|
|
9328
|
-
// aggregate intentionally not included because `pipeline` arguments are too complex to serialize well
|
|
9329
|
-
// see https://github.com/getsentry/sentry-javascript/pull/3102
|
|
9330
|
-
bulkWrite: ['operations'],
|
|
9331
|
-
countDocuments: ['query'],
|
|
9332
|
-
createIndex: ['fieldOrSpec'],
|
|
9333
|
-
createIndexes: ['indexSpecs'],
|
|
9334
|
-
deleteMany: ['filter'],
|
|
9335
|
-
deleteOne: ['filter'],
|
|
9336
|
-
distinct: ['key', 'query'],
|
|
9337
|
-
dropIndex: ['indexName'],
|
|
9338
|
-
find: ['query'],
|
|
9339
|
-
findOne: ['query'],
|
|
9340
|
-
findOneAndDelete: ['filter'],
|
|
9341
|
-
findOneAndReplace: ['filter', 'replacement'],
|
|
9342
|
-
findOneAndUpdate: ['filter', 'update'],
|
|
9343
|
-
indexExists: ['indexes'],
|
|
9344
|
-
insertMany: ['docs'],
|
|
9345
|
-
insertOne: ['doc'],
|
|
9346
|
-
mapReduce: ['map', 'reduce'],
|
|
9347
|
-
rename: ['newName'],
|
|
9348
|
-
replaceOne: ['filter', 'doc'],
|
|
9349
|
-
updateMany: ['filter', 'update'],
|
|
9350
|
-
updateOne: ['filter', 'update'],
|
|
9351
|
-
};
|
|
9352
|
-
/** Tracing integration for mongo package */
|
|
9353
|
-
var Mongo = /** @class */ (function () {
|
|
9354
|
-
/**
|
|
9355
|
-
* @inheritDoc
|
|
9356
|
-
*/
|
|
9357
|
-
function Mongo(options) {
|
|
9358
|
-
if (options === void 0) { options = {}; }
|
|
9359
|
-
/**
|
|
9360
|
-
* @inheritDoc
|
|
9361
|
-
*/
|
|
9362
|
-
this.name = Mongo.id;
|
|
9363
|
-
this._operations = Array.isArray(options.operations)
|
|
9364
|
-
? options.operations
|
|
9365
|
-
: OPERATIONS;
|
|
9366
|
-
this._describeOperations = 'describeOperations' in options ? options.describeOperations : true;
|
|
9367
|
-
this._useMongoose = !!options.useMongoose;
|
|
9368
|
-
}
|
|
9369
|
-
/**
|
|
9370
|
-
* @inheritDoc
|
|
9371
|
-
*/
|
|
9372
|
-
Mongo.prototype.setupOnce = function (_, getCurrentHub) {
|
|
9373
|
-
var moduleName = this._useMongoose ? 'mongoose' : 'mongodb';
|
|
9374
|
-
var pkg = loadModule(moduleName);
|
|
9375
|
-
if (!pkg) {
|
|
9376
|
-
logger.error("Mongo Integration was unable to require `" + moduleName + "` package.");
|
|
9377
|
-
return;
|
|
9378
|
-
}
|
|
9379
|
-
this._instrumentOperations(pkg.Collection, this._operations, getCurrentHub);
|
|
9380
|
-
};
|
|
9381
|
-
/**
|
|
9382
|
-
* Patches original collection methods
|
|
9383
|
-
*/
|
|
9384
|
-
Mongo.prototype._instrumentOperations = function (collection, operations, getCurrentHub) {
|
|
9385
|
-
var _this = this;
|
|
9386
|
-
operations.forEach(function (operation) { return _this._patchOperation(collection, operation, getCurrentHub); });
|
|
9387
|
-
};
|
|
9388
|
-
/**
|
|
9389
|
-
* Patches original collection to utilize our tracing functionality
|
|
9390
|
-
*/
|
|
9391
|
-
Mongo.prototype._patchOperation = function (collection, operation, getCurrentHub) {
|
|
9392
|
-
if (!(operation in collection.prototype))
|
|
9393
|
-
return;
|
|
9394
|
-
var getSpanContext = this._getSpanContextFromOperationArguments.bind(this);
|
|
9395
|
-
fill(collection.prototype, operation, function (orig) {
|
|
9396
|
-
return function () {
|
|
9397
|
-
var args = [];
|
|
9398
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
9399
|
-
args[_i] = arguments[_i];
|
|
9400
|
-
}
|
|
9401
|
-
var _a, _b, _c, _d;
|
|
9402
|
-
var lastArg = args[args.length - 1];
|
|
9403
|
-
var scope = getCurrentHub().getScope();
|
|
9404
|
-
var parentSpan = (_a = scope) === null || _a === void 0 ? void 0 : _a.getSpan();
|
|
9405
|
-
// Check if the operation was passed a callback. (mapReduce requires a different check, as
|
|
9406
|
-
// its (non-callback) arguments can also be functions.)
|
|
9407
|
-
if (typeof lastArg !== 'function' || (operation === 'mapReduce' && args.length === 2)) {
|
|
9408
|
-
var span_1 = (_b = parentSpan) === null || _b === void 0 ? void 0 : _b.startChild(getSpanContext(this, operation, args));
|
|
9409
|
-
var maybePromise = orig.call.apply(orig, __spread([this], args));
|
|
9410
|
-
if (isThenable(maybePromise)) {
|
|
9411
|
-
return maybePromise.then(function (res) {
|
|
9412
|
-
var _a;
|
|
9413
|
-
(_a = span_1) === null || _a === void 0 ? void 0 : _a.finish();
|
|
9414
|
-
return res;
|
|
9415
|
-
});
|
|
9416
|
-
}
|
|
9417
|
-
else {
|
|
9418
|
-
(_c = span_1) === null || _c === void 0 ? void 0 : _c.finish();
|
|
9419
|
-
return maybePromise;
|
|
9420
|
-
}
|
|
9421
|
-
}
|
|
9422
|
-
var span = (_d = parentSpan) === null || _d === void 0 ? void 0 : _d.startChild(getSpanContext(this, operation, args.slice(0, -1)));
|
|
9423
|
-
return orig.call.apply(orig, __spread([this], args.slice(0, -1), [function (err, result) {
|
|
9424
|
-
var _a;
|
|
9425
|
-
(_a = span) === null || _a === void 0 ? void 0 : _a.finish();
|
|
9426
|
-
lastArg(err, result);
|
|
9427
|
-
}]));
|
|
9428
|
-
};
|
|
9429
|
-
});
|
|
9430
|
-
};
|
|
9431
|
-
/**
|
|
9432
|
-
* Form a SpanContext based on the user input to a given operation.
|
|
9433
|
-
*/
|
|
9434
|
-
Mongo.prototype._getSpanContextFromOperationArguments = function (collection, operation, args) {
|
|
9435
|
-
var data = {
|
|
9436
|
-
collectionName: collection.collectionName,
|
|
9437
|
-
dbName: collection.dbName,
|
|
9438
|
-
namespace: collection.namespace,
|
|
9439
|
-
};
|
|
9440
|
-
var spanContext = {
|
|
9441
|
-
op: "db",
|
|
9442
|
-
description: operation,
|
|
9443
|
-
data: data,
|
|
9444
|
-
};
|
|
9445
|
-
// If the operation takes no arguments besides `options` and `callback`, or if argument
|
|
9446
|
-
// collection is disabled for this operation, just return early.
|
|
9447
|
-
var signature = OPERATION_SIGNATURES[operation];
|
|
9448
|
-
var shouldDescribe = Array.isArray(this._describeOperations)
|
|
9449
|
-
? this._describeOperations.includes(operation)
|
|
9450
|
-
: this._describeOperations;
|
|
9451
|
-
if (!signature || !shouldDescribe) {
|
|
9452
|
-
return spanContext;
|
|
9453
|
-
}
|
|
9454
|
-
try {
|
|
9455
|
-
// Special case for `mapReduce`, as the only one accepting functions as arguments.
|
|
9456
|
-
if (operation === 'mapReduce') {
|
|
9457
|
-
var _a = __read(args, 2), map = _a[0], reduce = _a[1];
|
|
9458
|
-
data[signature[0]] = typeof map === 'string' ? map : map.name || '<anonymous>';
|
|
9459
|
-
data[signature[1]] = typeof reduce === 'string' ? reduce : reduce.name || '<anonymous>';
|
|
9460
|
-
}
|
|
9461
|
-
else {
|
|
9462
|
-
for (var i = 0; i < signature.length; i++) {
|
|
9463
|
-
data[signature[i]] = JSON.stringify(args[i]);
|
|
9464
|
-
}
|
|
9465
|
-
}
|
|
9466
|
-
}
|
|
9467
|
-
catch (_oO) {
|
|
9468
|
-
// no-empty
|
|
9469
|
-
}
|
|
9470
|
-
return spanContext;
|
|
9471
|
-
};
|
|
9472
|
-
/**
|
|
9473
|
-
* @inheritDoc
|
|
9474
|
-
*/
|
|
9475
|
-
Mongo.id = 'Mongo';
|
|
9476
|
-
return Mongo;
|
|
9477
|
-
}());
|
|
9478
|
-
|
|
9479
|
-
const TracingIntegrations = /*#__PURE__*/Object.freeze({
|
|
9480
|
-
__proto__: null,
|
|
9481
|
-
Express: Express,
|
|
9482
|
-
Postgres: Postgres,
|
|
9483
|
-
Mysql: Mysql,
|
|
9484
|
-
Mongo: Mongo
|
|
9485
|
-
});
|
|
9486
|
-
|
|
9487
|
-
var Integrations = __assign(__assign({}, TracingIntegrations), { BrowserTracing: BrowserTracing });
|
|
9488
|
-
// We are patching the global object with our hub extension methods
|
|
9489
|
-
addExtensionMethods();
|
|
9490
|
-
|
|
9491
6878
|
const setupSentry = () => {
|
|
9492
6879
|
init({
|
|
9493
6880
|
dsn: "https://70bcf561598b44148bd3cabc7c142a6c@o1015876.ingest.sentry.io/5983034",
|
|
9494
|
-
integrations: [new Integrations.BrowserTracing()],
|
|
9495
6881
|
release: `${index.Env.packageName}@${index.Env.packageVersion}`,
|
|
6882
|
+
environment: index.Env.environment,
|
|
9496
6883
|
tracesSampleRate: 1.0,
|
|
9497
6884
|
maxBreadcrumbs: 4,
|
|
9498
|
-
allowUrls: [/https?:\/\/.+vviinn-widgets.+.js/],
|
|
9499
6885
|
});
|
|
9500
6886
|
};
|
|
9501
6887
|
function appGlobalScript () {
|