@sentry/react-native 5.29.0 → 6.0.0-alpha.0
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/CHANGELOG.md +90 -0
- package/dist/js/client.d.ts +5 -9
- package/dist/js/client.d.ts.map +1 -1
- package/dist/js/client.js +11 -42
- package/dist/js/client.js.map +1 -1
- package/dist/js/index.d.ts +5 -10
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +4 -21
- package/dist/js/index.js.map +1 -1
- package/dist/js/integrations/debugsymbolicator.d.ts +2 -8
- package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
- package/dist/js/integrations/debugsymbolicator.js +1 -9
- package/dist/js/integrations/debugsymbolicator.js.map +1 -1
- package/dist/js/integrations/default.d.ts.map +1 -1
- package/dist/js/integrations/default.js +18 -7
- package/dist/js/integrations/default.js.map +1 -1
- package/dist/js/integrations/devicecontext.d.ts +2 -8
- package/dist/js/integrations/devicecontext.d.ts.map +1 -1
- package/dist/js/integrations/devicecontext.js +0 -9
- package/dist/js/integrations/devicecontext.js.map +1 -1
- package/dist/js/integrations/eventorigin.d.ts +2 -8
- package/dist/js/integrations/eventorigin.d.ts.map +1 -1
- package/dist/js/integrations/eventorigin.js +0 -8
- package/dist/js/integrations/eventorigin.js.map +1 -1
- package/dist/js/integrations/expocontext.d.ts +2 -8
- package/dist/js/integrations/expocontext.d.ts.map +1 -1
- package/dist/js/integrations/expocontext.js +0 -8
- package/dist/js/integrations/expocontext.js.map +1 -1
- package/dist/js/integrations/exports.d.ts +4 -0
- package/dist/js/integrations/exports.d.ts.map +1 -1
- package/dist/js/integrations/exports.js +4 -0
- package/dist/js/integrations/exports.js.map +1 -1
- package/dist/js/integrations/modulesloader.d.ts +2 -8
- package/dist/js/integrations/modulesloader.d.ts.map +1 -1
- package/dist/js/integrations/modulesloader.js +0 -8
- package/dist/js/integrations/modulesloader.js.map +1 -1
- package/dist/js/integrations/nativelinkederrors.d.ts +2 -8
- package/dist/js/integrations/nativelinkederrors.d.ts.map +1 -1
- package/dist/js/integrations/nativelinkederrors.js +0 -8
- package/dist/js/integrations/nativelinkederrors.js.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.d.ts +2 -8
- package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.js +1 -8
- package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
- package/dist/js/integrations/reactnativeinfo.d.ts +2 -8
- package/dist/js/integrations/reactnativeinfo.d.ts.map +1 -1
- package/dist/js/integrations/reactnativeinfo.js +0 -8
- package/dist/js/integrations/reactnativeinfo.js.map +1 -1
- package/dist/js/integrations/release.d.ts +2 -8
- package/dist/js/integrations/release.d.ts.map +1 -1
- package/dist/js/integrations/release.js +0 -8
- package/dist/js/integrations/release.js.map +1 -1
- package/dist/js/integrations/rewriteframes.js +1 -1
- package/dist/js/integrations/rewriteframes.js.map +1 -1
- package/dist/js/integrations/screenshot.d.ts +2 -8
- package/dist/js/integrations/screenshot.d.ts.map +1 -1
- package/dist/js/integrations/screenshot.js +2 -11
- package/dist/js/integrations/screenshot.js.map +1 -1
- package/dist/js/integrations/sdkinfo.d.ts +2 -8
- package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
- package/dist/js/integrations/sdkinfo.js +0 -8
- package/dist/js/integrations/sdkinfo.js.map +1 -1
- package/dist/js/integrations/spotlight.d.ts +2 -10
- package/dist/js/integrations/spotlight.d.ts.map +1 -1
- package/dist/js/integrations/spotlight.js +1 -10
- package/dist/js/integrations/spotlight.js.map +1 -1
- package/dist/js/integrations/viewhierarchy.d.ts +2 -8
- package/dist/js/integrations/viewhierarchy.d.ts.map +1 -1
- package/dist/js/integrations/viewhierarchy.js +0 -8
- package/dist/js/integrations/viewhierarchy.js.map +1 -1
- package/dist/js/options.d.ts +43 -0
- package/dist/js/options.d.ts.map +1 -1
- package/dist/js/options.js.map +1 -1
- package/dist/js/profiling/cache.d.ts +1 -1
- package/dist/js/profiling/hermes.d.ts +1 -1
- package/dist/js/profiling/hermes.d.ts.map +1 -1
- package/dist/js/profiling/integration.d.ts +1 -7
- package/dist/js/profiling/integration.d.ts.map +1 -1
- package/dist/js/profiling/integration.js +39 -25
- package/dist/js/profiling/integration.js.map +1 -1
- package/dist/js/profiling/utils.js +2 -1
- package/dist/js/profiling/utils.js.map +1 -1
- package/dist/js/replay/mobilereplay.d.ts +2 -2
- package/dist/js/replay/mobilereplay.d.ts.map +1 -1
- package/dist/js/replay/mobilereplay.js.map +1 -1
- package/dist/js/scopeSync.d.ts +6 -0
- package/dist/js/scopeSync.d.ts.map +1 -0
- package/dist/js/scopeSync.js +60 -0
- package/dist/js/scopeSync.js.map +1 -0
- package/dist/js/sdk.d.ts +1 -20
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +20 -53
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
- package/dist/js/touchevents.d.ts +0 -1
- package/dist/js/touchevents.d.ts.map +1 -1
- package/dist/js/touchevents.js +5 -9
- package/dist/js/touchevents.js.map +1 -1
- package/dist/js/tracing/gesturetracing.d.ts +1 -6
- package/dist/js/tracing/gesturetracing.d.ts.map +1 -1
- package/dist/js/tracing/gesturetracing.js +8 -12
- package/dist/js/tracing/gesturetracing.js.map +1 -1
- package/dist/js/tracing/index.d.ts +6 -7
- package/dist/js/tracing/index.d.ts.map +1 -1
- package/dist/js/tracing/index.js +4 -7
- package/dist/js/tracing/index.js.map +1 -1
- package/dist/js/tracing/integrations/appStart.d.ts +39 -0
- package/dist/js/tracing/integrations/appStart.d.ts.map +1 -0
- package/dist/js/tracing/integrations/appStart.js +301 -0
- package/dist/js/tracing/integrations/appStart.js.map +1 -0
- package/dist/js/tracing/integrations/nativeFrames.d.ts +20 -0
- package/dist/js/tracing/integrations/nativeFrames.d.ts.map +1 -0
- package/dist/js/tracing/integrations/nativeFrames.js +256 -0
- package/dist/js/tracing/integrations/nativeFrames.js.map +1 -0
- package/dist/js/tracing/integrations/stalltracking.d.ts +31 -0
- package/dist/js/tracing/integrations/stalltracking.d.ts.map +1 -0
- package/dist/js/tracing/integrations/stalltracking.js +236 -0
- package/dist/js/tracing/integrations/stalltracking.js.map +1 -0
- package/dist/js/tracing/integrations/userInteraction.d.ts +11 -0
- package/dist/js/tracing/integrations/userInteraction.d.ts.map +1 -0
- package/dist/js/tracing/integrations/userInteraction.js +70 -0
- package/dist/js/tracing/integrations/userInteraction.js.map +1 -0
- package/dist/js/tracing/onSpanEndUtils.d.ts +17 -0
- package/dist/js/tracing/onSpanEndUtils.d.ts.map +1 -0
- package/dist/js/tracing/onSpanEndUtils.js +112 -0
- package/dist/js/tracing/onSpanEndUtils.js.map +1 -0
- package/dist/js/tracing/origin.d.ts +2 -0
- package/dist/js/tracing/origin.d.ts.map +1 -0
- package/dist/js/tracing/origin.js +2 -0
- package/dist/js/tracing/origin.js.map +1 -0
- package/dist/js/tracing/reactnativenavigation.d.ts +21 -39
- package/dist/js/tracing/reactnativenavigation.d.ts.map +1 -1
- package/dist/js/tracing/reactnativenavigation.js +98 -87
- package/dist/js/tracing/reactnativenavigation.js.map +1 -1
- package/dist/js/tracing/reactnativeprofiler.d.ts.map +1 -1
- package/dist/js/tracing/reactnativeprofiler.js +6 -13
- package/dist/js/tracing/reactnativeprofiler.js.map +1 -1
- package/dist/js/tracing/reactnativetracing.d.ts +44 -160
- package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
- package/dist/js/tracing/reactnativetracing.js +51 -481
- package/dist/js/tracing/reactnativetracing.js.map +1 -1
- package/dist/js/tracing/reactnavigation.d.ts +18 -63
- package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
- package/dist/js/tracing/reactnavigation.js +200 -205
- package/dist/js/tracing/reactnavigation.js.map +1 -1
- package/dist/js/tracing/semanticAttributes.d.ts +12 -0
- package/dist/js/tracing/semanticAttributes.d.ts.map +1 -0
- package/dist/js/tracing/semanticAttributes.js +12 -0
- package/dist/js/tracing/semanticAttributes.js.map +1 -0
- package/dist/js/tracing/span.d.ts +52 -0
- package/dist/js/tracing/span.d.ts.map +1 -0
- package/dist/js/tracing/span.js +82 -0
- package/dist/js/tracing/span.js.map +1 -0
- package/dist/js/tracing/timetodisplay.d.ts.map +1 -1
- package/dist/js/tracing/timetodisplay.js +14 -29
- package/dist/js/tracing/timetodisplay.js.map +1 -1
- package/dist/js/tracing/types.d.ts +2 -9
- package/dist/js/tracing/types.d.ts.map +1 -1
- package/dist/js/tracing/types.js.map +1 -1
- package/dist/js/tracing/utils.d.ts +19 -14
- package/dist/js/tracing/utils.d.ts.map +1 -1
- package/dist/js/tracing/utils.js +38 -52
- package/dist/js/tracing/utils.js.map +1 -1
- package/dist/js/transports/encodePolyfill.d.ts +3 -0
- package/dist/js/transports/encodePolyfill.d.ts.map +1 -0
- package/dist/js/transports/encodePolyfill.js +13 -0
- package/dist/js/transports/encodePolyfill.js.map +1 -0
- package/dist/js/transports/native.d.ts +2 -2
- package/dist/js/transports/native.d.ts.map +1 -1
- package/dist/js/transports/native.js +2 -1
- package/dist/js/transports/native.js.map +1 -1
- package/dist/js/utils/fill.d.ts +7 -0
- package/dist/js/utils/fill.d.ts.map +1 -0
- package/dist/js/utils/fill.js +9 -0
- package/dist/js/utils/fill.js.map +1 -0
- package/dist/js/utils/span.d.ts +19 -0
- package/dist/js/utils/span.d.ts.map +1 -0
- package/dist/js/utils/span.js +29 -0
- package/dist/js/utils/span.js.map +1 -0
- package/dist/js/vendor/react-native/index.d.ts +1 -1
- package/dist/js/vendor/react-native/index.d.ts.map +1 -1
- package/dist/js/vendor/react-native/index.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.d.ts.map +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js +1 -0
- package/dist/js/wrapper.js.map +1 -1
- package/package.json +10 -12
- package/ts3.8/dist/js/client.d.ts +5 -9
- package/ts3.8/dist/js/index.d.ts +5 -10
- package/ts3.8/dist/js/integrations/debugsymbolicator.d.ts +2 -8
- package/ts3.8/dist/js/integrations/devicecontext.d.ts +2 -8
- package/ts3.8/dist/js/integrations/eventorigin.d.ts +2 -8
- package/ts3.8/dist/js/integrations/expocontext.d.ts +2 -8
- package/ts3.8/dist/js/integrations/exports.d.ts +4 -0
- package/ts3.8/dist/js/integrations/modulesloader.d.ts +2 -8
- package/ts3.8/dist/js/integrations/nativelinkederrors.d.ts +2 -8
- package/ts3.8/dist/js/integrations/reactnativeerrorhandlers.d.ts +2 -8
- package/ts3.8/dist/js/integrations/reactnativeinfo.d.ts +2 -8
- package/ts3.8/dist/js/integrations/release.d.ts +2 -8
- package/ts3.8/dist/js/integrations/screenshot.d.ts +2 -8
- package/ts3.8/dist/js/integrations/sdkinfo.d.ts +2 -8
- package/ts3.8/dist/js/integrations/spotlight.d.ts +2 -10
- package/ts3.8/dist/js/integrations/viewhierarchy.d.ts +2 -8
- package/ts3.8/dist/js/options.d.ts +43 -0
- package/ts3.8/dist/js/profiling/cache.d.ts +1 -1
- package/ts3.8/dist/js/profiling/hermes.d.ts +1 -1
- package/ts3.8/dist/js/profiling/integration.d.ts +1 -7
- package/ts3.8/dist/js/replay/mobilereplay.d.ts +2 -2
- package/ts3.8/dist/js/scopeSync.d.ts +6 -0
- package/ts3.8/dist/js/sdk.d.ts +1 -20
- package/ts3.8/dist/js/touchevents.d.ts +0 -1
- package/ts3.8/dist/js/tracing/gesturetracing.d.ts +1 -6
- package/ts3.8/dist/js/tracing/index.d.ts +6 -7
- package/ts3.8/dist/js/tracing/integrations/appStart.d.ts +39 -0
- package/ts3.8/dist/js/tracing/integrations/nativeFrames.d.ts +20 -0
- package/ts3.8/dist/js/tracing/integrations/stalltracking.d.ts +31 -0
- package/ts3.8/dist/js/tracing/integrations/userInteraction.d.ts +11 -0
- package/ts3.8/dist/js/tracing/onSpanEndUtils.d.ts +17 -0
- package/ts3.8/dist/js/tracing/origin.d.ts +2 -0
- package/ts3.8/dist/js/tracing/reactnativenavigation.d.ts +21 -39
- package/ts3.8/dist/js/tracing/reactnativetracing.d.ts +44 -160
- package/ts3.8/dist/js/tracing/reactnavigation.d.ts +18 -63
- package/ts3.8/dist/js/tracing/semanticAttributes.d.ts +12 -0
- package/ts3.8/dist/js/tracing/span.d.ts +52 -0
- package/ts3.8/dist/js/tracing/types.d.ts +2 -9
- package/ts3.8/dist/js/tracing/utils.d.ts +19 -14
- package/ts3.8/dist/js/transports/encodePolyfill.d.ts +3 -0
- package/ts3.8/dist/js/transports/native.d.ts +2 -2
- package/ts3.8/dist/js/utils/fill.d.ts +7 -0
- package/ts3.8/dist/js/utils/span.d.ts +19 -0
- package/ts3.8/dist/js/vendor/react-native/index.d.ts +1 -1
- package/ts3.8/dist/js/version.d.ts +1 -1
- package/dist/js/integrations/index.d.ts +0 -16
- package/dist/js/integrations/index.d.ts.map +0 -1
- package/dist/js/integrations/index.js +0 -17
- package/dist/js/integrations/index.js.map +0 -1
- package/dist/js/scope.d.ts +0 -54
- package/dist/js/scope.d.ts.map +0 -1
- package/dist/js/scope.js +0 -89
- package/dist/js/scope.js.map +0 -1
- package/dist/js/tracing/addTracingExtensions.d.ts +0 -8
- package/dist/js/tracing/addTracingExtensions.d.ts.map +0 -1
- package/dist/js/tracing/addTracingExtensions.js +0 -66
- package/dist/js/tracing/addTracingExtensions.js.map +0 -1
- package/dist/js/tracing/nativeframes.d.ts +0 -60
- package/dist/js/tracing/nativeframes.d.ts.map +0 -1
- package/dist/js/tracing/nativeframes.js +0 -210
- package/dist/js/tracing/nativeframes.js.map +0 -1
- package/dist/js/tracing/reactnavigationv4.d.ts +0 -92
- package/dist/js/tracing/reactnavigationv4.d.ts.map +0 -1
- package/dist/js/tracing/reactnavigationv4.js +0 -229
- package/dist/js/tracing/reactnavigationv4.js.map +0 -1
- package/dist/js/tracing/routingInstrumentation.d.ts +0 -52
- package/dist/js/tracing/routingInstrumentation.d.ts.map +0 -1
- package/dist/js/tracing/routingInstrumentation.js +0 -36
- package/dist/js/tracing/routingInstrumentation.js.map +0 -1
- package/dist/js/tracing/stalltracking.d.ts +0 -99
- package/dist/js/tracing/stalltracking.d.ts.map +0 -1
- package/dist/js/tracing/stalltracking.js +0 -286
- package/dist/js/tracing/stalltracking.js.map +0 -1
- package/dist/js/tracing/transaction.d.ts +0 -11
- package/dist/js/tracing/transaction.d.ts.map +0 -1
- package/dist/js/tracing/transaction.js +0 -37
- package/dist/js/tracing/transaction.js.map +0 -1
- package/dist/js/transports/TextEncoder.d.ts +0 -3
- package/dist/js/transports/TextEncoder.d.ts.map +0 -1
- package/dist/js/transports/TextEncoder.js +0 -12
- package/dist/js/transports/TextEncoder.js.map +0 -1
- package/ts3.8/dist/js/integrations/index.d.ts +0 -16
- package/ts3.8/dist/js/scope.d.ts +0 -54
- package/ts3.8/dist/js/tracing/addTracingExtensions.d.ts +0 -8
- package/ts3.8/dist/js/tracing/nativeframes.d.ts +0 -60
- package/ts3.8/dist/js/tracing/reactnavigationv4.d.ts +0 -92
- package/ts3.8/dist/js/tracing/routingInstrumentation.d.ts +0 -52
- package/ts3.8/dist/js/tracing/stalltracking.d.ts +0 -99
- package/ts3.8/dist/js/tracing/transaction.d.ts +0 -11
- package/ts3.8/dist/js/transports/TextEncoder.d.ts +0 -3
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { logger, timestampInSeconds } from '@sentry/utils';
|
|
2
|
-
import { AppState } from 'react-native';
|
|
3
|
-
import { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../measurements';
|
|
4
|
-
/** Margin of error of 20ms */
|
|
5
|
-
const MARGIN_OF_ERROR_SECONDS = 0.02;
|
|
6
|
-
/** How long between each iteration in the event loop tracker timeout */
|
|
7
|
-
const LOOP_TIMEOUT_INTERVAL_MS = 50;
|
|
8
|
-
/** Limit for how many transactions the stall tracker will track at a time to prevent leaks due to transactions not being finished */
|
|
9
|
-
const MAX_RUNNING_TRANSACTIONS = 10;
|
|
10
|
-
/**
|
|
11
|
-
* Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:
|
|
12
|
-
* https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js
|
|
13
|
-
*
|
|
14
|
-
* However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.
|
|
15
|
-
* We then would consider that iteration a stall when the total time for that interval to run is greater than `LOOP_TIMEOUT_INTERVAL_MS + minimumStallThreshold`
|
|
16
|
-
*/
|
|
17
|
-
export class StallTrackingInstrumentation {
|
|
18
|
-
constructor(options = { minimumStallThreshold: 50 }) {
|
|
19
|
-
this.isTracking = false;
|
|
20
|
-
/** Total amount of time of all stalls that occurred during the current tracking session */
|
|
21
|
-
this._totalStallTime = 0;
|
|
22
|
-
/** Total number of stalls that occurred during the current tracking session */
|
|
23
|
-
this._stallCount = 0;
|
|
24
|
-
/** The last timestamp the iteration ran in milliseconds */
|
|
25
|
-
this._lastIntervalMs = 0;
|
|
26
|
-
this._timeout = null;
|
|
27
|
-
this._isBackground = false;
|
|
28
|
-
this._statsByTransaction = new Map();
|
|
29
|
-
this._minimumStallThreshold = options.minimumStallThreshold;
|
|
30
|
-
this._backgroundEventListener = this._backgroundEventListener.bind(this);
|
|
31
|
-
// Avoids throwing any error if using React Native on a environment that doesn't implement AppState.
|
|
32
|
-
if (AppState === null || AppState === void 0 ? void 0 : AppState.isAvailable) {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
34
|
-
AppState.addEventListener('change', this._backgroundEventListener);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @inheritDoc
|
|
39
|
-
* Not used for this integration. Instead call `registerTransactionStart` to start tracking.
|
|
40
|
-
*/
|
|
41
|
-
setupOnce() {
|
|
42
|
-
// Do nothing.
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Register a transaction as started. Starts stall tracking if not already running.
|
|
46
|
-
* @returns A finish method that returns the stall measurements.
|
|
47
|
-
*/
|
|
48
|
-
onTransactionStart(transaction) {
|
|
49
|
-
if (this._statsByTransaction.has(transaction)) {
|
|
50
|
-
logger.error('[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.');
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
this._startTracking();
|
|
54
|
-
this._statsByTransaction.set(transaction, {
|
|
55
|
-
longestStallTime: 0,
|
|
56
|
-
atTimestamp: null,
|
|
57
|
-
atStart: this._getCurrentStats(transaction),
|
|
58
|
-
});
|
|
59
|
-
this._flushLeakedTransactions();
|
|
60
|
-
if (transaction.spanRecorder) {
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
62
|
-
const originalAdd = transaction.spanRecorder.add;
|
|
63
|
-
transaction.spanRecorder.add = (span) => {
|
|
64
|
-
originalAdd.apply(transaction.spanRecorder, [span]);
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
66
|
-
const originalSpanFinish = span.finish;
|
|
67
|
-
span.finish = (endTimestamp) => {
|
|
68
|
-
// We let the span determine its own end timestamp as well in case anything gets changed upstream
|
|
69
|
-
originalSpanFinish.apply(span, [endTimestamp]);
|
|
70
|
-
// The span should set a timestamp, so this would be defined.
|
|
71
|
-
if (span.endTimestamp) {
|
|
72
|
-
this._markSpanFinish(transaction, span.endTimestamp);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
76
|
-
const originalSpanEnd = span.end;
|
|
77
|
-
span.end = (endTimestamp) => {
|
|
78
|
-
// We let the span determine its own end timestamp as well in case anything gets changed upstream
|
|
79
|
-
originalSpanEnd.apply(span, [endTimestamp]);
|
|
80
|
-
// The span should set a timestamp, so this would be defined.
|
|
81
|
-
if (span.endTimestamp) {
|
|
82
|
-
this._markSpanFinish(transaction, span.endTimestamp);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Logs a transaction as finished.
|
|
90
|
-
* Stops stall tracking if no more transactions are running.
|
|
91
|
-
* @returns The stall measurements
|
|
92
|
-
*/
|
|
93
|
-
onTransactionFinish(transaction, passedEndTimestamp) {
|
|
94
|
-
const transactionStats = this._statsByTransaction.get(transaction);
|
|
95
|
-
if (!transactionStats) {
|
|
96
|
-
// Transaction has been flushed out somehow, we return null.
|
|
97
|
-
logger.log('[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.');
|
|
98
|
-
this._statsByTransaction.delete(transaction);
|
|
99
|
-
this._shouldStopTracking();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const endTimestamp = passedEndTimestamp !== null && passedEndTimestamp !== void 0 ? passedEndTimestamp : transaction.endTimestamp;
|
|
103
|
-
const spans = transaction.spanRecorder ? transaction.spanRecorder.spans : [];
|
|
104
|
-
const finishedSpanCount = spans.reduce((count, s) => (s !== transaction && s.endTimestamp ? count + 1 : count), 0);
|
|
105
|
-
const trimEnd = transaction.toContext().trimEnd;
|
|
106
|
-
const endWillBeTrimmed = trimEnd && finishedSpanCount > 0;
|
|
107
|
-
/*
|
|
108
|
-
This is not safe in the case that something changes upstream, but if we're planning to move this over to @sentry/javascript anyways,
|
|
109
|
-
we can have this temporarily for now.
|
|
110
|
-
*/
|
|
111
|
-
const isIdleTransaction = 'activities' in transaction;
|
|
112
|
-
let statsOnFinish;
|
|
113
|
-
if (endTimestamp && isIdleTransaction) {
|
|
114
|
-
/*
|
|
115
|
-
There is different behavior regarding child spans in a normal transaction and an idle transaction. In normal transactions,
|
|
116
|
-
the child spans that aren't finished will be dumped, while in an idle transaction they're cancelled and finished.
|
|
117
|
-
|
|
118
|
-
Note: `endTimestamp` will always be defined if this is called on an idle transaction finish. This is because we only instrument
|
|
119
|
-
idle transactions inside `ReactNativeTracing`, which will pass an `endTimestamp`.
|
|
120
|
-
*/
|
|
121
|
-
// There will be cancelled spans, which means that the end won't be trimmed
|
|
122
|
-
const spansWillBeCancelled = spans.some(s => s !== transaction && s.startTimestamp < endTimestamp && !s.endTimestamp);
|
|
123
|
-
if (endWillBeTrimmed && !spansWillBeCancelled) {
|
|
124
|
-
// the last span's timestamp will be used.
|
|
125
|
-
if (transactionStats.atTimestamp) {
|
|
126
|
-
statsOnFinish = transactionStats.atTimestamp.stats;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
// this endTimestamp will be used.
|
|
131
|
-
statsOnFinish = this._getCurrentStats(transaction);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
else if (endWillBeTrimmed) {
|
|
135
|
-
// If `trimEnd` is used, and there is a span to trim to. If there isn't, then the transaction should use `endTimestamp` or generate one.
|
|
136
|
-
if (transactionStats.atTimestamp) {
|
|
137
|
-
statsOnFinish = transactionStats.atTimestamp.stats;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
else if (!endTimestamp) {
|
|
141
|
-
statsOnFinish = this._getCurrentStats(transaction);
|
|
142
|
-
}
|
|
143
|
-
this._statsByTransaction.delete(transaction);
|
|
144
|
-
this._shouldStopTracking();
|
|
145
|
-
if (!statsOnFinish) {
|
|
146
|
-
if (typeof endTimestamp !== 'undefined') {
|
|
147
|
-
logger.log('[StallTracking] Stall measurements not added due to `endTimestamp` being set.');
|
|
148
|
-
}
|
|
149
|
-
else if (trimEnd) {
|
|
150
|
-
logger.log('[StallTracking] Stall measurements not added due to `trimEnd` being set but we could not determine the stall measurements at that time.');
|
|
151
|
-
}
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
transaction.setMeasurement(STALL_COUNT, statsOnFinish.stall_count.value - transactionStats.atStart.stall_count.value, transactionStats.atStart.stall_count.unit);
|
|
155
|
-
transaction.setMeasurement(STALL_TOTAL_TIME, statsOnFinish.stall_total_time.value - transactionStats.atStart.stall_total_time.value, transactionStats.atStart.stall_total_time.unit);
|
|
156
|
-
transaction.setMeasurement(STALL_LONGEST_TIME, statsOnFinish.stall_longest_time.value, statsOnFinish.stall_longest_time.unit);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Switch that enables the iteraction once app moves from background to foreground.
|
|
160
|
-
*/
|
|
161
|
-
_backgroundEventListener(state) {
|
|
162
|
-
if (state === 'active') {
|
|
163
|
-
this._isBackground = false;
|
|
164
|
-
if (this._timeout != null) {
|
|
165
|
-
this._lastIntervalMs = timestampInSeconds() * 1000;
|
|
166
|
-
this._iteration();
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
this._isBackground = true;
|
|
171
|
-
this._timeout !== null && clearTimeout(this._timeout);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Logs the finish time of the span for use in `trimEnd: true` transactions.
|
|
176
|
-
*/
|
|
177
|
-
_markSpanFinish(transaction, spanEndTimestamp) {
|
|
178
|
-
const previousStats = this._statsByTransaction.get(transaction);
|
|
179
|
-
if (previousStats) {
|
|
180
|
-
if (Math.abs(timestampInSeconds() - spanEndTimestamp) > MARGIN_OF_ERROR_SECONDS) {
|
|
181
|
-
logger.log('[StallTracking] Span end not logged due to end timestamp being outside the margin of error from now.');
|
|
182
|
-
if (previousStats.atTimestamp && previousStats.atTimestamp.timestamp < spanEndTimestamp) {
|
|
183
|
-
// We also need to delete the stat for the last span, as the transaction would be trimmed to this span not the last one.
|
|
184
|
-
this._statsByTransaction.set(transaction, Object.assign(Object.assign({}, previousStats), { atTimestamp: null }));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
this._statsByTransaction.set(transaction, Object.assign(Object.assign({}, previousStats), { atTimestamp: {
|
|
189
|
-
timestamp: spanEndTimestamp,
|
|
190
|
-
stats: this._getCurrentStats(transaction),
|
|
191
|
-
} }));
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Get the current stats for a transaction at a given time.
|
|
197
|
-
*/
|
|
198
|
-
_getCurrentStats(transaction) {
|
|
199
|
-
var _a, _b;
|
|
200
|
-
return {
|
|
201
|
-
stall_count: { value: this._stallCount, unit: 'none' },
|
|
202
|
-
stall_total_time: { value: this._totalStallTime, unit: 'millisecond' },
|
|
203
|
-
stall_longest_time: {
|
|
204
|
-
value: (_b = (_a = this._statsByTransaction.get(transaction)) === null || _a === void 0 ? void 0 : _a.longestStallTime) !== null && _b !== void 0 ? _b : 0,
|
|
205
|
-
unit: 'millisecond',
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Start tracking stalls
|
|
211
|
-
*/
|
|
212
|
-
_startTracking() {
|
|
213
|
-
if (!this.isTracking) {
|
|
214
|
-
this.isTracking = true;
|
|
215
|
-
this._lastIntervalMs = Math.floor(timestampInSeconds() * 1000);
|
|
216
|
-
this._iteration();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Stops the stall tracking interval and calls reset().
|
|
221
|
-
*/
|
|
222
|
-
_stopTracking() {
|
|
223
|
-
this.isTracking = false;
|
|
224
|
-
if (this._timeout !== null) {
|
|
225
|
-
clearTimeout(this._timeout);
|
|
226
|
-
this._timeout = null;
|
|
227
|
-
}
|
|
228
|
-
this._reset();
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Will stop tracking if there are no more transactions.
|
|
232
|
-
*/
|
|
233
|
-
_shouldStopTracking() {
|
|
234
|
-
if (this._statsByTransaction.size === 0) {
|
|
235
|
-
this._stopTracking();
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Clears all the collected stats
|
|
240
|
-
*/
|
|
241
|
-
_reset() {
|
|
242
|
-
this._stallCount = 0;
|
|
243
|
-
this._totalStallTime = 0;
|
|
244
|
-
this._lastIntervalMs = 0;
|
|
245
|
-
this._statsByTransaction.clear();
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how
|
|
249
|
-
* long the stall is for.
|
|
250
|
-
*/
|
|
251
|
-
_iteration() {
|
|
252
|
-
var _a;
|
|
253
|
-
const now = timestampInSeconds() * 1000;
|
|
254
|
-
const totalTimeTaken = now - this._lastIntervalMs;
|
|
255
|
-
if (totalTimeTaken >= LOOP_TIMEOUT_INTERVAL_MS + this._minimumStallThreshold) {
|
|
256
|
-
const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;
|
|
257
|
-
this._stallCount += 1;
|
|
258
|
-
this._totalStallTime += stallTime;
|
|
259
|
-
for (const [transaction, value] of this._statsByTransaction.entries()) {
|
|
260
|
-
const longestStallTime = Math.max((_a = value.longestStallTime) !== null && _a !== void 0 ? _a : 0, stallTime);
|
|
261
|
-
this._statsByTransaction.set(transaction, Object.assign(Object.assign({}, value), { longestStallTime }));
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
this._lastIntervalMs = now;
|
|
265
|
-
if (this.isTracking && !this._isBackground) {
|
|
266
|
-
this._timeout = setTimeout(this._iteration.bind(this), LOOP_TIMEOUT_INTERVAL_MS);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)
|
|
271
|
-
*/
|
|
272
|
-
_flushLeakedTransactions() {
|
|
273
|
-
if (this._statsByTransaction.size > MAX_RUNNING_TRANSACTIONS) {
|
|
274
|
-
let counter = 0;
|
|
275
|
-
const len = this._statsByTransaction.size - MAX_RUNNING_TRANSACTIONS;
|
|
276
|
-
const transactions = this._statsByTransaction.keys();
|
|
277
|
-
for (const t of transactions) {
|
|
278
|
-
if (counter >= len)
|
|
279
|
-
break;
|
|
280
|
-
counter += 1;
|
|
281
|
-
this._statsByTransaction.delete(t);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
//# sourceMappingURL=stalltracking.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stalltracking.js","sourceRoot":"","sources":["../../../src/js/tracing/stalltracking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAgBpF,8BAA8B;AAC9B,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,wEAAwE;AACxE,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,qIAAqI;AACrI,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,OAAO,4BAA4B;IA4BvC,YAAmB,UAAgC,EAAE,qBAAqB,EAAE,EAAE,EAAE;QA3BzE,eAAU,GAAY,KAAK,CAAC;QAInC,2FAA2F;QACnF,oBAAe,GAAW,CAAC,CAAC;QACpC,+EAA+E;QACvE,gBAAW,GAAW,CAAC,CAAC;QAEhC,2DAA2D;QACnD,oBAAe,GAAW,CAAC,CAAC;QAC5B,aAAQ,GAAyC,IAAI,CAAC;QAEtD,kBAAa,GAAY,KAAK,CAAC;QAE/B,wBAAmB,GAUvB,IAAI,GAAG,EAAE,CAAC;QAGZ,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC;QAE5D,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzE,oGAAoG;QACpG,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,EAAE;YACzB,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GAAG,GAAG,CAAC;QAE3B,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YAC1C,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,wBAAwB,CAAC,CAAC;SAClF;IACH,CAAC;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,wBAAwB,EAAE;YAC5D,IAAI,OAAO,GAAG,CAAC,CAAC;YAChB,MAAM,GAAG,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,wBAAwB,CAAC;YACrE,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;YACrD,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;gBAC5B,IAAI,OAAO,IAAI,GAAG;oBAAE,MAAM;gBAC1B,OAAO,IAAI,CAAC,CAAC;gBACb,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aACpC;SACF;IACH,CAAC;CACF","sourcesContent":["/* eslint-disable max-lines */\nimport type { IdleTransaction, Span, Transaction } from '@sentry/core';\nimport type { Measurements, MeasurementUnit } from '@sentry/types';\nimport { logger, timestampInSeconds } from '@sentry/utils';\nimport type { AppStateStatus } from 'react-native';\nimport { AppState } from 'react-native';\n\nimport { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../measurements';\n\nexport interface StallMeasurements extends Measurements {\n [STALL_COUNT]: { value: number; unit: MeasurementUnit };\n [STALL_TOTAL_TIME]: { value: number; unit: MeasurementUnit };\n [STALL_LONGEST_TIME]: { value: number; unit: MeasurementUnit };\n}\n\nexport type StallTrackingOptions = {\n /**\n * How long in milliseconds an event loop iteration can be delayed for before being considered a \"stall.\"\n * @default 100\n */\n minimumStallThreshold: number;\n};\n\n/** Margin of error of 20ms */\nconst MARGIN_OF_ERROR_SECONDS = 0.02;\n/** How long between each iteration in the event loop tracker timeout */\nconst LOOP_TIMEOUT_INTERVAL_MS = 50;\n/** Limit for how many transactions the stall tracker will track at a time to prevent leaks due to transactions not being finished */\nconst MAX_RUNNING_TRANSACTIONS = 10;\n\n/**\n * Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:\n * https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js\n *\n * However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.\n * We then would consider that iteration a stall when the total time for that interval to run is greater than `LOOP_TIMEOUT_INTERVAL_MS + minimumStallThreshold`\n */\nexport class StallTrackingInstrumentation {\n public isTracking: boolean = false;\n\n private _minimumStallThreshold: number;\n\n /** Total amount of time of all stalls that occurred during the current tracking session */\n private _totalStallTime: number = 0;\n /** Total number of stalls that occurred during the current tracking session */\n private _stallCount: number = 0;\n\n /** The last timestamp the iteration ran in milliseconds */\n private _lastIntervalMs: number = 0;\n private _timeout: ReturnType<typeof setTimeout> | null = null;\n\n private _isBackground: boolean = false;\n\n private _statsByTransaction: Map<\n Transaction,\n {\n longestStallTime: number;\n atStart: StallMeasurements;\n atTimestamp: {\n timestamp: number;\n stats: StallMeasurements;\n } | null;\n }\n > = new Map();\n\n public constructor(options: StallTrackingOptions = { minimumStallThreshold: 50 }) {\n this._minimumStallThreshold = options.minimumStallThreshold;\n\n this._backgroundEventListener = this._backgroundEventListener.bind(this);\n // Avoids throwing any error if using React Native on a environment that doesn't implement AppState.\n if (AppState?.isAvailable) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n AppState.addEventListener('change', this._backgroundEventListener);\n }\n }\n\n /**\n * @inheritDoc\n * Not used for this integration. Instead call `registerTransactionStart` to start tracking.\n */\n public setupOnce(): void {\n // Do nothing.\n }\n\n /**\n * Register a transaction as started. Starts stall tracking if not already running.\n * @returns A finish method that returns the stall measurements.\n */\n public onTransactionStart(transaction: Transaction): void {\n if (this._statsByTransaction.has(transaction)) {\n logger.error(\n '[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.',\n );\n\n return;\n }\n\n this._startTracking();\n this._statsByTransaction.set(transaction, {\n longestStallTime: 0,\n atTimestamp: null,\n atStart: this._getCurrentStats(transaction),\n });\n this._flushLeakedTransactions();\n\n if (transaction.spanRecorder) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalAdd = transaction.spanRecorder.add;\n\n transaction.spanRecorder.add = (span: Span): void => {\n originalAdd.apply(transaction.spanRecorder, [span]);\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalSpanFinish = span.finish;\n\n span.finish = (endTimestamp?: number) => {\n // We let the span determine its own end timestamp as well in case anything gets changed upstream\n originalSpanFinish.apply(span, [endTimestamp]);\n\n // The span should set a timestamp, so this would be defined.\n if (span.endTimestamp) {\n this._markSpanFinish(transaction, span.endTimestamp);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalSpanEnd = span.end;\n\n span.end = (endTimestamp?: number) => {\n // We let the span determine its own end timestamp as well in case anything gets changed upstream\n originalSpanEnd.apply(span, [endTimestamp]);\n\n // The span should set a timestamp, so this would be defined.\n if (span.endTimestamp) {\n this._markSpanFinish(transaction, span.endTimestamp);\n }\n };\n };\n }\n }\n\n /**\n * Logs a transaction as finished.\n * Stops stall tracking if no more transactions are running.\n * @returns The stall measurements\n */\n public onTransactionFinish(transaction: Transaction | IdleTransaction, passedEndTimestamp?: number): void {\n const transactionStats = this._statsByTransaction.get(transaction);\n\n if (!transactionStats) {\n // Transaction has been flushed out somehow, we return null.\n logger.log('[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.');\n\n this._statsByTransaction.delete(transaction);\n this._shouldStopTracking();\n\n return;\n }\n\n const endTimestamp = passedEndTimestamp ?? transaction.endTimestamp;\n\n const spans = transaction.spanRecorder ? transaction.spanRecorder.spans : [];\n const finishedSpanCount = spans.reduce((count, s) => (s !== transaction && s.endTimestamp ? count + 1 : count), 0);\n\n const trimEnd = transaction.toContext().trimEnd;\n const endWillBeTrimmed = trimEnd && finishedSpanCount > 0;\n\n /*\n This is not safe in the case that something changes upstream, but if we're planning to move this over to @sentry/javascript anyways,\n we can have this temporarily for now.\n */\n const isIdleTransaction = 'activities' in transaction;\n\n let statsOnFinish: StallMeasurements | undefined;\n if (endTimestamp && isIdleTransaction) {\n /*\n There is different behavior regarding child spans in a normal transaction and an idle transaction. In normal transactions,\n the child spans that aren't finished will be dumped, while in an idle transaction they're cancelled and finished.\n\n Note: `endTimestamp` will always be defined if this is called on an idle transaction finish. This is because we only instrument\n idle transactions inside `ReactNativeTracing`, which will pass an `endTimestamp`.\n */\n\n // There will be cancelled spans, which means that the end won't be trimmed\n const spansWillBeCancelled = spans.some(\n s => s !== transaction && s.startTimestamp < endTimestamp && !s.endTimestamp,\n );\n\n if (endWillBeTrimmed && !spansWillBeCancelled) {\n // the last span's timestamp will be used.\n\n if (transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n } else {\n // this endTimestamp will be used.\n statsOnFinish = this._getCurrentStats(transaction);\n }\n } else if (endWillBeTrimmed) {\n // If `trimEnd` is used, and there is a span to trim to. If there isn't, then the transaction should use `endTimestamp` or generate one.\n if (transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n } else if (!endTimestamp) {\n statsOnFinish = this._getCurrentStats(transaction);\n }\n\n this._statsByTransaction.delete(transaction);\n this._shouldStopTracking();\n\n if (!statsOnFinish) {\n if (typeof endTimestamp !== 'undefined') {\n logger.log('[StallTracking] Stall measurements not added due to `endTimestamp` being set.');\n } else if (trimEnd) {\n logger.log(\n '[StallTracking] Stall measurements not added due to `trimEnd` being set but we could not determine the stall measurements at that time.',\n );\n }\n\n return;\n }\n\n transaction.setMeasurement(\n STALL_COUNT,\n statsOnFinish.stall_count.value - transactionStats.atStart.stall_count.value,\n transactionStats.atStart.stall_count.unit,\n );\n\n transaction.setMeasurement(\n STALL_TOTAL_TIME,\n statsOnFinish.stall_total_time.value - transactionStats.atStart.stall_total_time.value,\n transactionStats.atStart.stall_total_time.unit,\n );\n\n transaction.setMeasurement(\n STALL_LONGEST_TIME,\n statsOnFinish.stall_longest_time.value,\n statsOnFinish.stall_longest_time.unit,\n );\n }\n\n /**\n * Switch that enables the iteraction once app moves from background to foreground.\n */\n private _backgroundEventListener(state: AppStateStatus): void {\n if (state === ('active' as AppStateStatus)) {\n this._isBackground = false;\n if (this._timeout != null) {\n this._lastIntervalMs = timestampInSeconds() * 1000;\n this._iteration();\n }\n } else {\n this._isBackground = true;\n this._timeout !== null && clearTimeout(this._timeout);\n }\n }\n\n /**\n * Logs the finish time of the span for use in `trimEnd: true` transactions.\n */\n private _markSpanFinish(transaction: Transaction, spanEndTimestamp: number): void {\n const previousStats = this._statsByTransaction.get(transaction);\n if (previousStats) {\n if (Math.abs(timestampInSeconds() - spanEndTimestamp) > MARGIN_OF_ERROR_SECONDS) {\n logger.log(\n '[StallTracking] Span end not logged due to end timestamp being outside the margin of error from now.',\n );\n\n if (previousStats.atTimestamp && previousStats.atTimestamp.timestamp < spanEndTimestamp) {\n // We also need to delete the stat for the last span, as the transaction would be trimmed to this span not the last one.\n this._statsByTransaction.set(transaction, {\n ...previousStats,\n atTimestamp: null,\n });\n }\n } else {\n this._statsByTransaction.set(transaction, {\n ...previousStats,\n atTimestamp: {\n timestamp: spanEndTimestamp,\n stats: this._getCurrentStats(transaction),\n },\n });\n }\n }\n }\n\n /**\n * Get the current stats for a transaction at a given time.\n */\n private _getCurrentStats(transaction: Transaction): StallMeasurements {\n return {\n stall_count: { value: this._stallCount, unit: 'none' },\n stall_total_time: { value: this._totalStallTime, unit: 'millisecond' },\n stall_longest_time: {\n value: this._statsByTransaction.get(transaction)?.longestStallTime ?? 0,\n unit: 'millisecond',\n },\n };\n }\n\n /**\n * Start tracking stalls\n */\n private _startTracking(): void {\n if (!this.isTracking) {\n this.isTracking = true;\n this._lastIntervalMs = Math.floor(timestampInSeconds() * 1000);\n\n this._iteration();\n }\n }\n\n /**\n * Stops the stall tracking interval and calls reset().\n */\n private _stopTracking(): void {\n this.isTracking = false;\n\n if (this._timeout !== null) {\n clearTimeout(this._timeout);\n this._timeout = null;\n }\n\n this._reset();\n }\n\n /**\n * Will stop tracking if there are no more transactions.\n */\n private _shouldStopTracking(): void {\n if (this._statsByTransaction.size === 0) {\n this._stopTracking();\n }\n }\n\n /**\n * Clears all the collected stats\n */\n private _reset(): void {\n this._stallCount = 0;\n this._totalStallTime = 0;\n this._lastIntervalMs = 0;\n this._statsByTransaction.clear();\n }\n\n /**\n * Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how\n * long the stall is for.\n */\n private _iteration(): void {\n const now = timestampInSeconds() * 1000;\n const totalTimeTaken = now - this._lastIntervalMs;\n\n if (totalTimeTaken >= LOOP_TIMEOUT_INTERVAL_MS + this._minimumStallThreshold) {\n const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;\n this._stallCount += 1;\n this._totalStallTime += stallTime;\n\n for (const [transaction, value] of this._statsByTransaction.entries()) {\n const longestStallTime = Math.max(value.longestStallTime ?? 0, stallTime);\n\n this._statsByTransaction.set(transaction, {\n ...value,\n longestStallTime,\n });\n }\n }\n\n this._lastIntervalMs = now;\n\n if (this.isTracking && !this._isBackground) {\n this._timeout = setTimeout(this._iteration.bind(this), LOOP_TIMEOUT_INTERVAL_MS);\n }\n }\n\n /**\n * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)\n */\n private _flushLeakedTransactions(): void {\n if (this._statsByTransaction.size > MAX_RUNNING_TRANSACTIONS) {\n let counter = 0;\n const len = this._statsByTransaction.size - MAX_RUNNING_TRANSACTIONS;\n const transactions = this._statsByTransaction.keys();\n for (const t of transactions) {\n if (counter >= len) break;\n counter += 1;\n this._statsByTransaction.delete(t);\n }\n }\n }\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type BeforeFinishCallback, type IdleTransaction } from '@sentry/core';
|
|
2
|
-
/**
|
|
3
|
-
* Idle Transaction callback to only sample transactions with child spans.
|
|
4
|
-
* To avoid side effects of other callbacks this should be hooked as the last callback.
|
|
5
|
-
*/
|
|
6
|
-
export declare const onlySampleIfChildSpans: BeforeFinishCallback;
|
|
7
|
-
/**
|
|
8
|
-
* Hooks on AppState change to cancel the transaction if the app goes background.
|
|
9
|
-
*/
|
|
10
|
-
export declare const cancelInBackground: (transaction: IdleTransaction) => void;
|
|
11
|
-
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/E;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,oBASpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,gBAAiB,eAAe,KAAG,IAsBjE,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { logger } from '@sentry/utils';
|
|
2
|
-
import { AppState } from 'react-native';
|
|
3
|
-
/**
|
|
4
|
-
* Idle Transaction callback to only sample transactions with child spans.
|
|
5
|
-
* To avoid side effects of other callbacks this should be hooked as the last callback.
|
|
6
|
-
*/
|
|
7
|
-
export const onlySampleIfChildSpans = (transaction) => {
|
|
8
|
-
const spansCount = transaction.spanRecorder &&
|
|
9
|
-
transaction.spanRecorder.spans.filter(span => span.spanId !== transaction.spanId).length;
|
|
10
|
-
if (!spansCount || spansCount <= 0) {
|
|
11
|
-
logger.log(`Not sampling as ${transaction.op} transaction has no child spans.`);
|
|
12
|
-
transaction.sampled = false;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Hooks on AppState change to cancel the transaction if the app goes background.
|
|
17
|
-
*/
|
|
18
|
-
export const cancelInBackground = (transaction) => {
|
|
19
|
-
if (!AppState || !AppState.isAvailable) {
|
|
20
|
-
logger.warn('AppState is not available, spans will not be canceled in background.');
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
// RN Web can return undefined, https://github.com/necolas/react-native-web/blob/8cf720f0e57c74a254bfa7bed0313e33a4b29c11/packages/react-native-web/src/exports/AppState/index.js#L55
|
|
24
|
-
const subscription = AppState.addEventListener('change', (newState) => {
|
|
25
|
-
if (newState === 'background') {
|
|
26
|
-
logger.debug(`Setting ${transaction.op} transaction to cancelled because the app is in the background.`);
|
|
27
|
-
transaction.setStatus('cancelled');
|
|
28
|
-
transaction.finish();
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
subscription &&
|
|
32
|
-
transaction.registerBeforeFinishCallback(() => {
|
|
33
|
-
logger.debug(`Removing AppState listener for ${transaction.op} transaction.`);
|
|
34
|
-
subscription && subscription.remove && subscription.remove();
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=transaction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/js/tracing/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAyB,CAAC,WAA4B,EAAQ,EAAE;IACjG,MAAM,UAAU,GACd,WAAW,CAAC,YAAY;QACxB,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IAE3F,IAAI,CAAC,UAAU,IAAI,UAAU,IAAI,CAAC,EAAE;QAClC,MAAM,CAAC,GAAG,CAAC,mBAAmB,WAAW,CAAC,EAAE,kCAAkC,CAAC,CAAC;QAChF,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;KAC7B;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAA4B,EAAQ,EAAE;IACvE,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;QACtC,MAAM,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;QACpF,OAAO;KACR;IAED,qLAAqL;IACrL,MAAM,YAAY,GAAwC,QAAQ,CAAC,gBAAgB,CACjF,QAAQ,EACR,CAAC,QAAwB,EAAE,EAAE;QAC3B,IAAI,QAAQ,KAAK,YAAY,EAAE;YAC7B,MAAM,CAAC,KAAK,CAAC,WAAW,WAAW,CAAC,EAAE,iEAAiE,CAAC,CAAC;YACzG,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YACnC,WAAW,CAAC,MAAM,EAAE,CAAC;SACtB;IACH,CAAC,CACF,CAAC;IACF,YAAY;QACV,WAAW,CAAC,4BAA4B,CAAC,GAAG,EAAE;YAC5C,MAAM,CAAC,KAAK,CAAC,kCAAkC,WAAW,CAAC,EAAE,eAAe,CAAC,CAAC;YAC9E,YAAY,IAAI,YAAY,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;QAC/D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import { type BeforeFinishCallback, type IdleTransaction } from '@sentry/core';\nimport { logger } from '@sentry/utils';\nimport type { AppStateStatus, NativeEventSubscription } from 'react-native';\nimport { AppState } from 'react-native';\n\n/**\n * Idle Transaction callback to only sample transactions with child spans.\n * To avoid side effects of other callbacks this should be hooked as the last callback.\n */\nexport const onlySampleIfChildSpans: BeforeFinishCallback = (transaction: IdleTransaction): void => {\n const spansCount =\n transaction.spanRecorder &&\n transaction.spanRecorder.spans.filter(span => span.spanId !== transaction.spanId).length;\n\n if (!spansCount || spansCount <= 0) {\n logger.log(`Not sampling as ${transaction.op} transaction has no child spans.`);\n transaction.sampled = false;\n }\n};\n\n/**\n * Hooks on AppState change to cancel the transaction if the app goes background.\n */\nexport const cancelInBackground = (transaction: IdleTransaction): void => {\n if (!AppState || !AppState.isAvailable) {\n logger.warn('AppState is not available, spans will not be canceled in background.');\n return;\n }\n\n // RN Web can return undefined, https://github.com/necolas/react-native-web/blob/8cf720f0e57c74a254bfa7bed0313e33a4b29c11/packages/react-native-web/src/exports/AppState/index.js#L55\n const subscription: NativeEventSubscription | undefined = AppState.addEventListener(\n 'change',\n (newState: AppStateStatus) => {\n if (newState === 'background') {\n logger.debug(`Setting ${transaction.op} transaction to cancelled because the app is in the background.`);\n transaction.setStatus('cancelled');\n transaction.finish();\n }\n },\n );\n subscription &&\n transaction.registerBeforeFinishCallback(() => {\n logger.debug(`Removing AppState listener for ${transaction.op} transaction.`);\n subscription && subscription.remove && subscription.remove();\n });\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TextEncoder.d.ts","sourceRoot":"","sources":["../../../src/js/transports/TextEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIzD,eAAO,MAAM,mBAAmB,QAAO,mBAStC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { utf8ToBytes } from '../vendor';
|
|
2
|
-
export const makeUtf8TextEncoder = () => {
|
|
3
|
-
const textEncoder = {
|
|
4
|
-
encode: (text) => {
|
|
5
|
-
const bytes = new Uint8Array(utf8ToBytes(text));
|
|
6
|
-
return bytes;
|
|
7
|
-
},
|
|
8
|
-
encoding: 'utf-8',
|
|
9
|
-
};
|
|
10
|
-
return textEncoder;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=TextEncoder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TextEncoder.js","sourceRoot":"","sources":["../../../src/js/transports/TextEncoder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAwB,EAAE;IAC3D,MAAM,WAAW,GAAG;QAClB,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;YACvB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,QAAQ,EAAE,OAAO;KAClB,CAAC;IACF,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC","sourcesContent":["import type { TextEncoderInternal } from '@sentry/types';\n\nimport { utf8ToBytes } from '../vendor';\n\nexport const makeUtf8TextEncoder = (): TextEncoderInternal => {\n const textEncoder = {\n encode: (text: string) => {\n const bytes = new Uint8Array(utf8ToBytes(text));\n return bytes;\n },\n encoding: 'utf-8',\n };\n return textEncoder;\n};\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { DebugSymbolicator } from './debugsymbolicator';
|
|
2
|
-
export { DeviceContext } from './devicecontext';
|
|
3
|
-
export { ReactNativeErrorHandlers } from './reactnativeerrorhandlers';
|
|
4
|
-
export { NativeLinkedErrors } from './nativelinkederrors';
|
|
5
|
-
export { Release } from './release';
|
|
6
|
-
export { EventOrigin } from './eventorigin';
|
|
7
|
-
export { SdkInfo } from './sdkinfo';
|
|
8
|
-
export { ReactNativeInfo } from './reactnativeinfo';
|
|
9
|
-
export { ModulesLoader } from './modulesloader';
|
|
10
|
-
export { HermesProfiling } from '../profiling/integration';
|
|
11
|
-
export { Screenshot } from './screenshot';
|
|
12
|
-
export { ViewHierarchy } from './viewhierarchy';
|
|
13
|
-
export { ExpoContext } from './expocontext';
|
|
14
|
-
export { Spotlight } from './spotlight';
|
|
15
|
-
export { mobileReplayIntegration } from '../replay/mobilereplay';
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
package/ts3.8/dist/js/scope.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Scope } from '@sentry/core';
|
|
2
|
-
import type { Attachment, Breadcrumb, User } from '@sentry/types';
|
|
3
|
-
/**
|
|
4
|
-
* Extends the scope methods to set scope on the Native SDKs
|
|
5
|
-
*/
|
|
6
|
-
export declare class ReactNativeScope extends Scope {
|
|
7
|
-
/**
|
|
8
|
-
* @inheritDoc
|
|
9
|
-
*/
|
|
10
|
-
setUser(user: User | null): this;
|
|
11
|
-
/**
|
|
12
|
-
* @inheritDoc
|
|
13
|
-
*/
|
|
14
|
-
setTag(key: string, value: string): this;
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
setTags(tags: {
|
|
19
|
-
[key: string]: string;
|
|
20
|
-
}): this;
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
setExtras(extras: {
|
|
25
|
-
[key: string]: any;
|
|
26
|
-
}): this;
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
setExtra(key: string, extra: any): this;
|
|
31
|
-
/**
|
|
32
|
-
* @inheritDoc
|
|
33
|
-
*/
|
|
34
|
-
addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this;
|
|
35
|
-
/**
|
|
36
|
-
* @inheritDoc
|
|
37
|
-
*/
|
|
38
|
-
clearBreadcrumbs(): this;
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
setContext(key: string, context: {
|
|
43
|
-
[key: string]: any;
|
|
44
|
-
} | null): this;
|
|
45
|
-
/**
|
|
46
|
-
* @inheritDoc
|
|
47
|
-
*/
|
|
48
|
-
addAttachment(attachment: Attachment): this;
|
|
49
|
-
/**
|
|
50
|
-
* @inheritDoc
|
|
51
|
-
*/
|
|
52
|
-
clearAttachments(): this;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Hub, Transaction } from '@sentry/core';
|
|
2
|
-
import type { CustomSamplingContext, TransactionContext } from '@sentry/types';
|
|
3
|
-
/**
|
|
4
|
-
* Adds React Native's extensions. Needs to be called before any transactions are created.
|
|
5
|
-
*/
|
|
6
|
-
export declare function _addTracingExtensions(): void;
|
|
7
|
-
export type StartTransactionFunction = (this: Hub, transactionContext: TransactionContext, customSamplingContext?: CustomSamplingContext) => Transaction;
|
|
8
|
-
//# sourceMappingURL=addTracingExtensions.d.ts.map
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { Transaction } from '@sentry/core';
|
|
2
|
-
import type { EventProcessor, Measurements, MeasurementUnit } from '@sentry/types';
|
|
3
|
-
export interface FramesMeasurements extends Measurements {
|
|
4
|
-
frames_total: {
|
|
5
|
-
value: number;
|
|
6
|
-
unit: MeasurementUnit;
|
|
7
|
-
};
|
|
8
|
-
frames_slow: {
|
|
9
|
-
value: number;
|
|
10
|
-
unit: MeasurementUnit;
|
|
11
|
-
};
|
|
12
|
-
frames_frozen: {
|
|
13
|
-
value: number;
|
|
14
|
-
unit: MeasurementUnit;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Instrumentation to add native slow/frozen frames measurements onto transactions.
|
|
19
|
-
*/
|
|
20
|
-
export declare class NativeFramesInstrumentation {
|
|
21
|
-
/** The native frames at the finish time of the most recent span. */
|
|
22
|
-
private _lastSpanFinishFrames?;
|
|
23
|
-
constructor(addGlobalEventProcessor: (e: EventProcessor) => void, doesExist: () => boolean);
|
|
24
|
-
/**
|
|
25
|
-
* To be called when a transaction is started.
|
|
26
|
-
* Logs the native frames at this start point and instruments child span finishes.
|
|
27
|
-
*/
|
|
28
|
-
onTransactionStart(transaction: Transaction): void;
|
|
29
|
-
/**
|
|
30
|
-
* To be called when a transaction is finished
|
|
31
|
-
*/
|
|
32
|
-
onTransactionFinish(transaction: Transaction): void;
|
|
33
|
-
/**
|
|
34
|
-
* Called on a span finish to fetch native frames to support transactions with trimEnd.
|
|
35
|
-
* Only to be called when a span does not have an end timestamp.
|
|
36
|
-
*/
|
|
37
|
-
private _onSpanFinish;
|
|
38
|
-
/**
|
|
39
|
-
* Returns the computed frames measurements and awaits for them if they are not ready yet.
|
|
40
|
-
*/
|
|
41
|
-
private _getFramesMeasurements;
|
|
42
|
-
/**
|
|
43
|
-
* Returns the computed frames measurements given ready data
|
|
44
|
-
*/
|
|
45
|
-
private _prepareMeasurements;
|
|
46
|
-
/**
|
|
47
|
-
* Fetch finish frames for a transaction at the current time. Calls any awaiting listeners.
|
|
48
|
-
*/
|
|
49
|
-
private _fetchEndFramesForTransaction;
|
|
50
|
-
/**
|
|
51
|
-
* On a finish frames failure, we cancel the await.
|
|
52
|
-
*/
|
|
53
|
-
private _cancelEndFrames;
|
|
54
|
-
/**
|
|
55
|
-
* Adds frames measurements to an event. Called from a valid event processor.
|
|
56
|
-
* Awaits for finish frames if needed.
|
|
57
|
-
*/
|
|
58
|
-
private _processEvent;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=nativeframes.d.ts.map
|