@sentry/react-native 5.31.1 → 6.0.0-alpha.1
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 +102 -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 +16 -4
- 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 +5 -0
- package/dist/js/integrations/exports.d.ts.map +1 -1
- package/dist/js/integrations/exports.js +5 -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 +34 -2
- 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/replay/networkUtils.d.ts +0 -1
- package/dist/js/replay/networkUtils.d.ts.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/metroconfig.d.ts +1 -1
- package/dist/js/tools/metroconfig.d.ts.map +1 -1
- package/dist/js/tools/metroconfig.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 +21 -0
- package/dist/js/tracing/integrations/nativeFrames.d.ts.map +1 -0
- package/dist/js/tracing/integrations/nativeFrames.js +195 -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/timetodisplaynative.types.d.ts +0 -1
- package/dist/js/tracing/timetodisplaynative.types.d.ts.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/AsyncExpiringMap.d.ts +56 -0
- package/dist/js/utils/AsyncExpiringMap.d.ts.map +1 -0
- package/dist/js/utils/AsyncExpiringMap.js +130 -0
- package/dist/js/utils/AsyncExpiringMap.js.map +1 -0
- 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 -2
- 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 +11 -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 +5 -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 +34 -2
- 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/replay/networkUtils.d.ts +0 -1
- 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 +21 -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/timetodisplaynative.types.d.ts +0 -1
- 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/AsyncExpiringMap.d.ts +56 -0
- 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 -2
- 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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Client, Scope, Span, StartSpanOptions } from '@sentry/types';
|
|
2
|
+
export declare const DEFAULT_NAVIGATION_SPAN_NAME = "Route Change";
|
|
3
|
+
export declare const defaultIdleOptions: {
|
|
4
|
+
/**
|
|
5
|
+
* The time that has to pass without any span being created.
|
|
6
|
+
* If this time is exceeded, the idle span will finish.
|
|
7
|
+
*
|
|
8
|
+
* @default 1_000 (ms)
|
|
9
|
+
*/
|
|
10
|
+
finalTimeout: number;
|
|
11
|
+
/**
|
|
12
|
+
* The max. time an idle span may run.
|
|
13
|
+
* If this time is exceeded, the idle span will finish no matter what.
|
|
14
|
+
*
|
|
15
|
+
* @default 60_0000 (ms)
|
|
16
|
+
*/
|
|
17
|
+
idleTimeout: number;
|
|
18
|
+
};
|
|
19
|
+
export declare const startIdleNavigationSpan: (startSpanOption: StartSpanOptions, { finalTimeout, idleTimeout, }?: Partial<typeof defaultIdleOptions>) => Span | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Starts an idle span from `@sentry/core` with React Native application
|
|
22
|
+
* context awareness.
|
|
23
|
+
*
|
|
24
|
+
* - Span will be started with new propagation context.
|
|
25
|
+
* - Span will be canceled if the app goes to background.
|
|
26
|
+
*/
|
|
27
|
+
export declare const startIdleSpan: (startSpanOption: StartSpanOptions, { finalTimeout, idleTimeout }: {
|
|
28
|
+
finalTimeout: number | undefined;
|
|
29
|
+
idleTimeout: number | undefined;
|
|
30
|
+
}) => Span;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the default options for the idle navigation span.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getDefaultIdleNavigationSpanOptions(): StartSpanOptions;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if the span is a Sentry User Interaction span.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isSentryInteractionSpan(span: Span): boolean;
|
|
39
|
+
declare const SCOPE_SPAN_FIELD = "_sentrySpan";
|
|
40
|
+
type ScopeWithMaybeSpan = Scope & {
|
|
41
|
+
[SCOPE_SPAN_FIELD]?: Span;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Removes the active span from the scope.
|
|
45
|
+
*/
|
|
46
|
+
export declare function clearActiveSpanFromScope(scope: ScopeWithMaybeSpan): void;
|
|
47
|
+
/**
|
|
48
|
+
* Ensures that all created spans have an operation name.
|
|
49
|
+
*/
|
|
50
|
+
export declare function addDefaultOpForSpanFrom(client: Client): void;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=span.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/span.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAO3E,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAE3D,eAAO,MAAM,kBAAkB,EAAE;IAC/B;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;CAIrB,CAAC;AAEF,eAAO,MAAM,uBAAuB,oBACjB,gBAAgB,mCAI9B,QAAQ,yBAAyB,CAAC,KACpC,IAAI,GAAG,SAgCT,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,oBACP,gBAAgB;kBACc,MAAM,GAAG,SAAS;iBAAe,MAAM,GAAG,SAAS;MACjG,IAYF,CAAC;AAEF;;GAEG;AACH,wBAAgB,mCAAmC,IAAI,gBAAgB,CAOtE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAE3D;AAED,QAAA,MAAM,gBAAgB,gBAAgB,CAAC;AAEvC,KAAK,kBAAkB,GAAG,KAAK,GAAG;IAChC,CAAC,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAGxE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAM5D"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { getActiveSpan, getClient, getCurrentScope, SEMANTIC_ATTRIBUTE_SENTRY_OP, SentryNonRecordingSpan, SPAN_STATUS_ERROR, spanToJSON, startIdleSpan as coreStartIdleSpan, } from '@sentry/core';
|
|
2
|
+
import { generatePropagationContext, logger } from '@sentry/utils';
|
|
3
|
+
import { isRootSpan } from '../utils/span';
|
|
4
|
+
import { adjustTransactionDuration, cancelInBackground } from './onSpanEndUtils';
|
|
5
|
+
import { SPAN_ORIGIN_AUTO_INTERACTION } from './origin';
|
|
6
|
+
export const DEFAULT_NAVIGATION_SPAN_NAME = 'Route Change';
|
|
7
|
+
export const defaultIdleOptions = {
|
|
8
|
+
idleTimeout: 1000,
|
|
9
|
+
finalTimeout: 600000,
|
|
10
|
+
};
|
|
11
|
+
export const startIdleNavigationSpan = (startSpanOption, { finalTimeout = defaultIdleOptions.finalTimeout, idleTimeout = defaultIdleOptions.idleTimeout, } = {}) => {
|
|
12
|
+
const client = getClient();
|
|
13
|
+
if (!client) {
|
|
14
|
+
logger.warn(`[startIdleNavigationSpan] Can't create route change span, missing client.`);
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const activeSpan = getActiveSpan();
|
|
18
|
+
if (activeSpan && isRootSpan(activeSpan) && isSentryInteractionSpan(activeSpan)) {
|
|
19
|
+
logger.log(`[startIdleNavigationSpan] Canceling ${spanToJSON(activeSpan).op} transaction because of a new navigation root span.`);
|
|
20
|
+
activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'cancelled' });
|
|
21
|
+
activeSpan.end();
|
|
22
|
+
}
|
|
23
|
+
const finalStartStapOptions = Object.assign(Object.assign({}, getDefaultIdleNavigationSpanOptions()), startSpanOption);
|
|
24
|
+
const idleSpan = startIdleSpan(finalStartStapOptions, { finalTimeout, idleTimeout });
|
|
25
|
+
logger.log(`[startIdleNavigationSpan] Starting ${finalStartStapOptions.op || 'unknown op'} transaction "${finalStartStapOptions.name}" on scope`);
|
|
26
|
+
adjustTransactionDuration(client, idleSpan, finalTimeout);
|
|
27
|
+
return idleSpan;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Starts an idle span from `@sentry/core` with React Native application
|
|
31
|
+
* context awareness.
|
|
32
|
+
*
|
|
33
|
+
* - Span will be started with new propagation context.
|
|
34
|
+
* - Span will be canceled if the app goes to background.
|
|
35
|
+
*/
|
|
36
|
+
export const startIdleSpan = (startSpanOption, { finalTimeout, idleTimeout }) => {
|
|
37
|
+
const client = getClient();
|
|
38
|
+
if (!client) {
|
|
39
|
+
logger.warn(`[startIdleSpan] Can't create idle span, missing client.`);
|
|
40
|
+
return new SentryNonRecordingSpan();
|
|
41
|
+
}
|
|
42
|
+
getCurrentScope().setPropagationContext(generatePropagationContext());
|
|
43
|
+
const span = coreStartIdleSpan(startSpanOption, { finalTimeout, idleTimeout });
|
|
44
|
+
cancelInBackground(client, span);
|
|
45
|
+
return span;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Returns the default options for the idle navigation span.
|
|
49
|
+
*/
|
|
50
|
+
export function getDefaultIdleNavigationSpanOptions() {
|
|
51
|
+
return {
|
|
52
|
+
name: DEFAULT_NAVIGATION_SPAN_NAME,
|
|
53
|
+
op: 'navigation',
|
|
54
|
+
forceTransaction: true,
|
|
55
|
+
scope: getCurrentScope(),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Checks if the span is a Sentry User Interaction span.
|
|
60
|
+
*/
|
|
61
|
+
export function isSentryInteractionSpan(span) {
|
|
62
|
+
return spanToJSON(span).origin === SPAN_ORIGIN_AUTO_INTERACTION;
|
|
63
|
+
}
|
|
64
|
+
const SCOPE_SPAN_FIELD = '_sentrySpan';
|
|
65
|
+
/**
|
|
66
|
+
* Removes the active span from the scope.
|
|
67
|
+
*/
|
|
68
|
+
export function clearActiveSpanFromScope(scope) {
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
70
|
+
delete scope[SCOPE_SPAN_FIELD];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Ensures that all created spans have an operation name.
|
|
74
|
+
*/
|
|
75
|
+
export function addDefaultOpForSpanFrom(client) {
|
|
76
|
+
client.on('spanStart', (span) => {
|
|
77
|
+
if (!spanToJSON(span).op) {
|
|
78
|
+
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'default');
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=span.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span.js","sourceRoot":"","sources":["../../../src/js/tracing/span.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,SAAS,EACT,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,EACV,aAAa,IAAI,iBAAiB,GACnC,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,MAAM,CAAC,MAAM,4BAA4B,GAAG,cAAc,CAAC;AAE3D,MAAM,CAAC,MAAM,kBAAkB,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RIBUTE_SENTRY_OP,\n SentryNonRecordingSpan,\n SPAN_STATUS_ERROR,\n spanToJSON,\n startIdleSpan as coreStartIdleSpan,\n} from '@sentry/core';\nimport type { Client, Scope, Span, StartSpanOptions } from '@sentry/types';\nimport { generatePropagationContext, logger } from '@sentry/utils';\n\nimport { isRootSpan } from '../utils/span';\nimport { adjustTransactionDuration, cancelInBackground } from './onSpanEndUtils';\nimport { SPAN_ORIGIN_AUTO_INTERACTION } from './origin';\n\nexport const DEFAULT_NAVIGATION_SPAN_NAME = 'Route Change';\n\nexport const defaultIdleOptions: {\n /**\n * The time that has to pass without any span being created.\n * If this time is exceeded, the idle span will finish.\n *\n * @default 1_000 (ms)\n */\n finalTimeout: number;\n\n /**\n * The max. time an idle span may run.\n * If this time is exceeded, the idle span will finish no matter what.\n *\n * @default 60_0000 (ms)\n */\n idleTimeout: number;\n} = {\n idleTimeout: 1_000,\n finalTimeout: 60_0000,\n};\n\nexport const startIdleNavigationSpan = (\n startSpanOption: StartSpanOptions,\n {\n finalTimeout = defaultIdleOptions.finalTimeout,\n idleTimeout = defaultIdleOptions.idleTimeout,\n }: Partial<typeof defaultIdleOptions> = {},\n): Span | undefined => {\n const client = getClient();\n if (!client) {\n logger.warn(`[startIdleNavigationSpan] Can't create route change span, missing client.`);\n return undefined;\n }\n\n const activeSpan = getActiveSpan();\n if (activeSpan && isRootSpan(activeSpan) && isSentryInteractionSpan(activeSpan)) {\n logger.log(\n `[startIdleNavigationSpan] Canceling ${\n spanToJSON(activeSpan).op\n } transaction because of a new navigation root span.`,\n );\n activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'cancelled' });\n activeSpan.end();\n }\n\n const finalStartStapOptions = {\n ...getDefaultIdleNavigationSpanOptions(),\n ...startSpanOption,\n };\n\n const idleSpan = startIdleSpan(finalStartStapOptions, { finalTimeout, idleTimeout });\n logger.log(\n `[startIdleNavigationSpan] Starting ${finalStartStapOptions.op || 'unknown op'} transaction \"${\n finalStartStapOptions.name\n }\" on scope`,\n );\n\n adjustTransactionDuration(client, idleSpan, finalTimeout);\n return idleSpan;\n};\n\n/**\n * Starts an idle span from `@sentry/core` with React Native application\n * context awareness.\n *\n * - Span will be started with new propagation context.\n * - Span will be canceled if the app goes to background.\n */\nexport const startIdleSpan = (\n startSpanOption: StartSpanOptions,\n { finalTimeout, idleTimeout }: { finalTimeout: number | undefined; idleTimeout: number | undefined },\n): Span => {\n const client = getClient();\n if (!client) {\n logger.warn(`[startIdleSpan] Can't create idle span, missing client.`);\n return new SentryNonRecordingSpan();\n }\n\n getCurrentScope().setPropagationContext(generatePropagationContext());\n\n const span = coreStartIdleSpan(startSpanOption, { finalTimeout, idleTimeout });\n cancelInBackground(client, span);\n return span;\n};\n\n/**\n * Returns the default options for the idle navigation span.\n */\nexport function getDefaultIdleNavigationSpanOptions(): StartSpanOptions {\n return {\n name: DEFAULT_NAVIGATION_SPAN_NAME,\n op: 'navigation',\n forceTransaction: true,\n scope: getCurrentScope(),\n };\n}\n\n/**\n * Checks if the span is a Sentry User Interaction span.\n */\nexport function isSentryInteractionSpan(span: Span): boolean {\n return spanToJSON(span).origin === SPAN_ORIGIN_AUTO_INTERACTION;\n}\n\nconst SCOPE_SPAN_FIELD = '_sentrySpan';\n\ntype ScopeWithMaybeSpan = Scope & {\n [SCOPE_SPAN_FIELD]?: Span;\n};\n\n/**\n * Removes the active span from the scope.\n */\nexport function clearActiveSpanFromScope(scope: ScopeWithMaybeSpan): void {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete scope[SCOPE_SPAN_FIELD];\n}\n\n/**\n * Ensures that all created spans have an operation name.\n */\nexport function addDefaultOpForSpanFrom(client: Client): void {\n client.on('spanStart', (span: Span) => {\n if (!spanToJSON(span).op) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'default');\n }\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timetodisplay.d.ts","sourceRoot":"","sources":["../../../src/js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;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAQlF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAG/E;AA8BD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,MAAM,CAAC,GAAG;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,GACA,IAAI,GAAG,SAAS,CA4BlB;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,MAAM,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAEnF,GACA,IAAI,GAAG,SAAS,CA+ClB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getActiveSpan,
|
|
1
|
+
import { getActiveSpan, getSpanDescendants, SPAN_STATUS_ERROR, SPAN_STATUS_OK, spanToJSON, startInactiveSpan } from '@sentry/core';
|
|
2
2
|
import { fill, logger } from '@sentry/utils';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { getRNSentryOnDrawReporter, nativeComponentExists } from './timetodisplaynative';
|
|
@@ -58,24 +58,19 @@ function TimeToDisplay(props) {
|
|
|
58
58
|
* Returns current span if already exists in the currently active span.
|
|
59
59
|
*/
|
|
60
60
|
export function startTimeToInitialDisplaySpan(options) {
|
|
61
|
-
var _a;
|
|
62
61
|
const activeSpan = getActiveSpan();
|
|
63
62
|
if (!activeSpan) {
|
|
64
63
|
logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (!(activeSpan instanceof SpanClass)) {
|
|
68
|
-
logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);
|
|
69
|
-
return;
|
|
64
|
+
return undefined;
|
|
70
65
|
}
|
|
71
|
-
const existingSpan = (
|
|
66
|
+
const existingSpan = getSpanDescendants(activeSpan).find((span) => spanToJSON(span).op === 'ui.load.initial_display');
|
|
72
67
|
if (existingSpan) {
|
|
73
68
|
logger.debug(`[TimeToDisplay] Found existing ui.load.initial_display span.`);
|
|
74
69
|
return existingSpan;
|
|
75
70
|
}
|
|
76
|
-
const initialDisplaySpan = startInactiveSpan(Object.assign({ op: 'ui.load.initial_display', name: 'Time To Initial Display',
|
|
71
|
+
const initialDisplaySpan = startInactiveSpan(Object.assign({ op: 'ui.load.initial_display', name: 'Time To Initial Display', startTime: spanToJSON(activeSpan).start_timestamp }, options));
|
|
77
72
|
if (!initialDisplaySpan) {
|
|
78
|
-
return;
|
|
73
|
+
return undefined;
|
|
79
74
|
}
|
|
80
75
|
if (!(options === null || options === void 0 ? void 0 : options.isAutoInstrumented)) {
|
|
81
76
|
manualInitialDisplaySpans.set(activeSpan, true);
|
|
@@ -90,36 +85,31 @@ export function startTimeToInitialDisplaySpan(options) {
|
|
|
90
85
|
export function startTimeToFullDisplaySpan(options = {
|
|
91
86
|
timeoutMs: 30000,
|
|
92
87
|
}) {
|
|
93
|
-
var _a;
|
|
94
88
|
const activeSpan = getActiveSpan();
|
|
95
89
|
if (!activeSpan) {
|
|
96
90
|
logger.warn(`[TimeToDisplay] No active span found to attach ui.load.full_display to.`);
|
|
97
|
-
return;
|
|
91
|
+
return undefined;
|
|
98
92
|
}
|
|
99
|
-
|
|
100
|
-
logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const descendantSpans = ((_a = activeSpan.spanRecorder) === null || _a === void 0 ? void 0 : _a.spans) || [];
|
|
93
|
+
const descendantSpans = getSpanDescendants(activeSpan);
|
|
104
94
|
const initialDisplaySpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');
|
|
105
95
|
if (!initialDisplaySpan) {
|
|
106
96
|
logger.warn(`[TimeToDisplay] No initial display span found to attach ui.load.full_display to.`);
|
|
107
|
-
return;
|
|
97
|
+
return undefined;
|
|
108
98
|
}
|
|
109
99
|
const existingSpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.full_display');
|
|
110
100
|
if (existingSpan) {
|
|
111
101
|
logger.debug(`[TimeToDisplay] Found existing ui.load.full_display span.`);
|
|
112
102
|
return existingSpan;
|
|
113
103
|
}
|
|
114
|
-
const fullDisplaySpan = startInactiveSpan(Object.assign({ op: 'ui.load.full_display', name: 'Time To Full Display',
|
|
104
|
+
const fullDisplaySpan = startInactiveSpan(Object.assign({ op: 'ui.load.full_display', name: 'Time To Full Display', startTime: spanToJSON(initialDisplaySpan).start_timestamp }, options));
|
|
115
105
|
if (!fullDisplaySpan) {
|
|
116
|
-
return;
|
|
106
|
+
return undefined;
|
|
117
107
|
}
|
|
118
108
|
const timeout = setTimeout(() => {
|
|
119
109
|
if (spanToJSON(fullDisplaySpan).timestamp) {
|
|
120
110
|
return;
|
|
121
111
|
}
|
|
122
|
-
fullDisplaySpan.setStatus('deadline_exceeded');
|
|
112
|
+
fullDisplaySpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'deadline_exceeded' });
|
|
123
113
|
fullDisplaySpan.end(spanToJSON(initialDisplaySpan).timestamp);
|
|
124
114
|
setSpanDurationAsMeasurement('time_to_full_display', fullDisplaySpan);
|
|
125
115
|
logger.warn(`[TimeToDisplay] Full display span deadline_exceeded.`);
|
|
@@ -159,7 +149,7 @@ function updateInitialDisplaySpan(frameTimestampSeconds) {
|
|
|
159
149
|
return;
|
|
160
150
|
}
|
|
161
151
|
span.end(frameTimestampSeconds);
|
|
162
|
-
span.setStatus(
|
|
152
|
+
span.setStatus({ code: SPAN_STATUS_OK });
|
|
163
153
|
logger.debug(`[TimeToDisplay] ${spanToJSON(span).description} span updated with end timestamp.`);
|
|
164
154
|
if (fullDisplayBeforeInitialDisplay.has(activeSpan)) {
|
|
165
155
|
fullDisplayBeforeInitialDisplay.delete(activeSpan);
|
|
@@ -169,18 +159,13 @@ function updateInitialDisplaySpan(frameTimestampSeconds) {
|
|
|
169
159
|
setSpanDurationAsMeasurement('time_to_initial_display', span);
|
|
170
160
|
}
|
|
171
161
|
function updateFullDisplaySpan(frameTimestampSeconds, passedInitialDisplaySpan) {
|
|
172
|
-
var _a;
|
|
173
162
|
const activeSpan = getActiveSpan();
|
|
174
163
|
if (!activeSpan) {
|
|
175
164
|
logger.warn(`[TimeToDisplay] No active span found to update ui.load.full_display in.`);
|
|
176
165
|
return;
|
|
177
166
|
}
|
|
178
|
-
if (!(activeSpan instanceof SpanClass)) {
|
|
179
|
-
logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
167
|
const existingInitialDisplaySpan = passedInitialDisplaySpan
|
|
183
|
-
|| (
|
|
168
|
+
|| getSpanDescendants(activeSpan).find((span) => spanToJSON(span).op === 'ui.load.initial_display');
|
|
184
169
|
const initialDisplayEndTimestamp = existingInitialDisplaySpan && spanToJSON(existingInitialDisplaySpan).timestamp;
|
|
185
170
|
if (!initialDisplayEndTimestamp) {
|
|
186
171
|
fullDisplayBeforeInitialDisplay.set(activeSpan, true);
|
|
@@ -204,7 +189,7 @@ function updateFullDisplaySpan(frameTimestampSeconds, passedInitialDisplaySpan)
|
|
|
204
189
|
else {
|
|
205
190
|
span.end(frameTimestampSeconds);
|
|
206
191
|
}
|
|
207
|
-
span.setStatus(
|
|
192
|
+
span.setStatus({ code: SPAN_STATUS_OK });
|
|
208
193
|
logger.debug(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span updated with end timestamp.`);
|
|
209
194
|
setSpanDurationAsMeasurement('time_to_full_display', span);
|
|
210
195
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timetodis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BAAqB,CAAC,CAAC;KACjC;IAED,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrB,MAAM,CAAC,KAAK,CAAC,mBAAmB,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC,OAAO,oCAAoC,CAAC,CAAC;IAE/G,4BAA4B,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { getActiveSpan, Span as SpanClass, spanToJSON, startInactiveSpan } from '@sentry/core';\nimport type { Span,StartSpanOptions } from '@sentry/types';\nimport { fill, logger } from '@sentry/utils';\nimport * as React from 'react';\n\nimport { getRNSentryOnDrawReporter, nativeComponentExists } from './timetodisplaynative';\nimport type {RNSentryOnDrawNextFrameEvent } from './timetodisplaynative.types';\nimport { setSpanDurationAsMeasurement } from './utils';\n\nlet nativeComponentMissingLogged = false;\n\n/**\n * Flags of active spans with manual initial display.\n */\nexport const manualInitialDisplaySpans = new WeakMap<Span, true>();\n\n/**\n * Flag full display called before initial display for an active span.\n */\nconst fullDisplayBeforeInitialDisplay = new WeakMap<Span, true>();\n\nexport type TimeToDisplayProps = {\n children?: React.ReactNode;\n spanName?: string;\n record?: boolean;\n};\n\n/**\n * Component to measure time to initial display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToInitialDisplay(props: TimeToDisplayProps): React.ReactElement {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n manualInitialDisplaySpans.set(activeSpan, true);\n startTimeToInitialDisplaySpan();\n }\n\n return <TimeToDisplay initialDisplay={props.record}>{props.children}</TimeToDisplay>;\n}\n\n/**\n * Component to measure time to full display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToFullDisplay(props: TimeToDisplayProps): React.ReactElement {\n startTimeToFullDisplaySpan();\n return <TimeToDisplay fullDisplay={props.record}>{props.children}</TimeToDisplay>;\n}\n\nfunction TimeToDisplay(props: {\n children?: React.ReactNode;\n initialDisplay?: boolean;\n fullDisplay?: boolean;\n}): React.ReactElement {\n const RNSentryOnDrawReporter = getRNSentryOnDrawReporter();\n\n if (__DEV__ && !nativeComponentMissingLogged && !nativeComponentExists) {\n nativeComponentMissingLogged = true;\n // Using setTimeout with a delay of 0 milliseconds to defer execution and avoid printing the React stack trace.\n setTimeout(() => {\n logger.warn('TimeToInitialDisplay and TimeToFullDisplay are not supported on the web, Expo Go and New Architecture. Run native build or report an issue at https://github.com/getsentry/sentry-react-native');\n }, 0);\n }\n\n const onDraw = (event: { nativeEvent: RNSentryOnDrawNextFrameEvent }): void => onDrawNextFrame(event);\n\n return (\n <>\n <RNSentryOnDrawReporter\n onDrawNextFrame={onDraw}\n initialDisplay={props.initialDisplay}\n fullDisplay={props.fullDisplay} />\n {props.children}\n </>\n );\n}\n\n/**\n * Starts a new span for the initial display.\n *\n * Returns current span if already exists in the currently active span.\n */\nexport function startTimeToInitialDisplaySpan(\n options?: Omit<StartSpanOptions, 'op' | 'name'> & {\n name?: string;\n isAutoInstrumented?: boolean\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return;\n }\n\n if (!(activeSpan instanceof SpanClass)) {\n logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);\n return;\n }\n\n const existingSpan = activeSpan.spanRecorder?.spans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.initial_display span.`);\n return existingSpan\n }\n\n const initialDisplaySpan = startInactiveSpan({\n op: 'ui.load.initial_display',\n name: 'Time To Initial Display',\n startTimestamp: spanToJSON(activeSpan).start_timestamp,\n ...options,\n });\n\n if (!initialDisplaySpan) {\n return;\n }\n\n if (!options?.isAutoInstrumented) {\n manualInitialDisplaySpans.set(activeSpan, true);\n }\n return initialDisplaySpan;\n}\n\n/**\n * Starts a new span for the full display.\n *\n * Returns current span if already exists in the currently active span.\n */\nexport function startTimeToFullDisplaySpan(\n options: Omit<StartSpanOptions, 'op' | 'name'> & { name?: string, timeoutMs?: number } = {\n timeoutMs: 30_000,\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.full_display to.`);\n return;\n }\n\n if (!(activeSpan instanceof SpanClass)) {\n logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);\n return;\n }\n\n const descendantSpans = activeSpan.spanRecorder?.spans || [];\n\n const initialDisplaySpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (!initialDisplaySpan) {\n logger.warn(`[TimeToDisplay] No initial display span found to attach ui.load.full_display to.`);\n return;\n }\n\n const existingSpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.full_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.full_display span.`);\n return existingSpan;\n }\n\n const fullDisplaySpan = startInactiveSpan({\n op: 'ui.load.full_display',\n name: 'Time To Full Display',\n startTimestamp: spanToJSON(initialDisplaySpan).start_timestamp,\n ...options,\n });\n if (!fullDisplaySpan) {\n return;\n }\n\n const timeout = setTimeout(() => {\n if (spanToJSON(fullDisplaySpan).timestamp) {\n return;\n }\n fullDisplaySpan.setStatus('deadline_exceeded');\n fullDisplaySpan.end(spanToJSON(initialDisplaySpan).timestamp);\n setSpanDurationAsMeasurement('time_to_full_display', fullDisplaySpan);\n logger.warn(`[TimeToDisplay] Full display span deadline_exceeded.`);\n }, options.timeoutMs);\n\n fill(fullDisplaySpan, 'end', (originalEnd: SpanClass['end']) => (endTimestamp?: Parameters<SpanClass['end']>[0]) => {\n clearTimeout(timeout);\n originalEnd.call(fullDisplaySpan, endTimestamp);\n });\n\n return fullDisplaySpan;\n}\n\nfunction onDrawNextFrame(event: { nativeEvent: RNSentryOnDrawNextFrameEvent }): void {\n logger.debug(`[TimeToDisplay] onDrawNextFrame: ${JSON.stringify(event.nativeEvent)}`);\n if (event.nativeEvent.type === 'fullDisplay') {\n return updateFullDisplaySpan(event.nativeEvent.newFrameTimestampInSeconds);\n }\n if (event.nativeEvent.type === 'initialDisplay') {\n return updateInitialDisplaySpan(event.nativeEvent.newFrameTimestampInSeconds);\n }\n}\n\nfunction updateInitialDisplaySpan(frameTimestampSeconds: number): void {\n const span = startTimeToInitialDisplaySpan();\n if (!span) {\n logger.warn(`[TimeToDisplay] No span found or created, possibly performance is disabled.`);\n return;\n }\n\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return;\n }\n\n if (spanToJSON(span).parent_span_id !== spanToJSON(activeSpan).span_id) {\n logger.warn(`[TimeToDisplay] Initial display span is not a child of current active span.`);\n return;\n }\n\n if (spanToJSON(span).timestamp) {\n logger.warn(`[TimeToDisplay] ${spanToJSON(span).description} span already ended.`);\n return;\n }\n\n span.end(frameTimestampSeconds);\n span.setStatus('ok');\n logger.debug(`[TimeToDisplay] ${spanToJSON(span).description} span updated with end timestamp.`);\n\n if (fullDisplayBeforeInitialDisplay.has(activeSpan)) {\n fullDisplayBeforeInitialDisplay.delete(activeSpan);\n logger.debug(`[TimeToDisplay] Updating full display with initial display (${span.spanContext().spanId}) end.`);\n updateFullDisplaySpan(frameTimestampSeconds, span);\n }\n\n setSpanDurationAsMeasurement('time_to_initial_display', span);\n}\n\nfunction updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDisplaySpan?: Span): void {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to update ui.load.full_display in.`);\n return;\n }\n\n if (!(activeSpan instanceof SpanClass)) {\n logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);\n return;\n }\n\n const existingInitialDisplaySpan = passedInitialDisplaySpan\n || activeSpan.spanRecorder?.spans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n const initialDisplayEndTimestamp = existingInitialDisplaySpan && spanToJSON(existingInitialDisplaySpan).timestamp;\n if (!initialDisplayEndTimestamp) {\n fullDisplayBeforeInitialDisplay.set(activeSpan, true);\n logger.warn(`[TimeToDisplay] Full display called before initial display for active span (${activeSpan.spanContext().spanId}).`);\n return;\n }\n\n const span = startTimeToFullDisplaySpan();\n if (!span) {\n logger.warn(`[TimeToDisplay] No TimeToFullDisplay span found or created, possibly performance is disabled.`);\n return;\n }\n\n const spanJSON = spanToJSON(span);\n if (spanJSON.timestamp) {\n logger.warn(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span already ended.`);\n return;\n }\n\n if (initialDisplayEndTimestamp > frameTimestampSeconds) {\n logger.warn(`[TimeToDisplay] Using initial display end. Full display end frame timestamp is before initial display end.`);\n span.end(initialDisplayEndTimestamp);\n } else {\n span.end(frameTimestampSeconds);\n }\n\n span.setStatus('ok');\n logger.debug(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span updated with end timestamp.`);\n\n setSpanDurationAsMeasurement('time_to_full_display', span);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"timetodisplay.js","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEnI,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAEvD,IAAI,4BAA4B,GAAG,KAAK,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,OAAO,EAAc,CAAC;AAEnE;;GAEG;AACH,MAAM,+BAA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;QAC7G,OAAO;KACR;IAED,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,QAAQ,CAAC,SAAS,EAAE;QACtB,MAAM,CAAC,IAAI,CAAC,mBAAmB,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC,OAAO,uBAAuB,CAAC,CAAC;QACjG,OAAO;KACR;IAED,IAAI,0BAA0B,GAAG,qBAAqB,EAAE;QACtD,MAAM,CAAC,IAAI,CAAC,4GAA4G,CAAC,CAAC;QAC1H,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;KACtC;SAAM;QACL,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;KACjC;IAED,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,KAAK,CAAC,mBAAmB,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC,OAAO,oCAAoC,CAAC,CAAC;IAE/G,4BAA4B,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { getActiveSpan, getSpanDescendants, SPAN_STATUS_ERROR, SPAN_STATUS_OK, spanToJSON, startInactiveSpan } from '@sentry/core';\nimport type { Span,StartSpanOptions } from '@sentry/types';\nimport { fill, logger } from '@sentry/utils';\nimport * as React from 'react';\n\nimport { getRNSentryOnDrawReporter, nativeComponentExists } from './timetodisplaynative';\nimport type {RNSentryOnDrawNextFrameEvent } from './timetodisplaynative.types';\nimport { setSpanDurationAsMeasurement } from './utils';\n\nlet nativeComponentMissingLogged = false;\n\n/**\n * Flags of active spans with manual initial display.\n */\nexport const manualInitialDisplaySpans = new WeakMap<Span, true>();\n\n/**\n * Flag full display called before initial display for an active span.\n */\nconst fullDisplayBeforeInitialDisplay = new WeakMap<Span, true>();\n\nexport type TimeToDisplayProps = {\n children?: React.ReactNode;\n spanName?: string;\n record?: boolean;\n};\n\n/**\n * Component to measure time to initial display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToInitialDisplay(props: TimeToDisplayProps): React.ReactElement {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n manualInitialDisplaySpans.set(activeSpan, true);\n startTimeToInitialDisplaySpan();\n }\n\n return <TimeToDisplay initialDisplay={props.record}>{props.children}</TimeToDisplay>;\n}\n\n/**\n * Component to measure time to full display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToFullDisplay(props: TimeToDisplayProps): React.ReactElement {\n startTimeToFullDisplaySpan();\n return <TimeToDisplay fullDisplay={props.record}>{props.children}</TimeToDisplay>;\n}\n\nfunction TimeToDisplay(props: {\n children?: React.ReactNode;\n initialDisplay?: boolean;\n fullDisplay?: boolean;\n}): React.ReactElement {\n const RNSentryOnDrawReporter = getRNSentryOnDrawReporter();\n\n if (__DEV__ && !nativeComponentMissingLogged && !nativeComponentExists) {\n nativeComponentMissingLogged = true;\n // Using setTimeout with a delay of 0 milliseconds to defer execution and avoid printing the React stack trace.\n setTimeout(() => {\n logger.warn('TimeToInitialDisplay and TimeToFullDisplay are not supported on the web, Expo Go and New Architecture. Run native build or report an issue at https://github.com/getsentry/sentry-react-native');\n }, 0);\n }\n\n const onDraw = (event: { nativeEvent: RNSentryOnDrawNextFrameEvent }): void => onDrawNextFrame(event);\n\n return (\n <>\n <RNSentryOnDrawReporter\n onDrawNextFrame={onDraw}\n initialDisplay={props.initialDisplay}\n fullDisplay={props.fullDisplay} />\n {props.children}\n </>\n );\n}\n\n/**\n * Starts a new span for the initial display.\n *\n * Returns current span if already exists in the currently active span.\n */\nexport function startTimeToInitialDisplaySpan(\n options?: Omit<StartSpanOptions, 'op' | 'name'> & {\n name?: string;\n isAutoInstrumented?: boolean\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return undefined;\n }\n\n const existingSpan = getSpanDescendants(activeSpan).find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.initial_display span.`);\n return existingSpan\n }\n\n const initialDisplaySpan = startInactiveSpan({\n op: 'ui.load.initial_display',\n name: 'Time To Initial Display',\n startTime: spanToJSON(activeSpan).start_timestamp,\n ...options,\n });\n\n if (!initialDisplaySpan) {\n return undefined;\n }\n\n if (!options?.isAutoInstrumented) {\n manualInitialDisplaySpans.set(activeSpan, true);\n }\n return initialDisplaySpan;\n}\n\n/**\n * Starts a new span for the full display.\n *\n * Returns current span if already exists in the currently active span.\n */\nexport function startTimeToFullDisplaySpan(\n options: Omit<StartSpanOptions, 'op' | 'name'> & { name?: string, timeoutMs?: number } = {\n timeoutMs: 30_000,\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.full_display to.`);\n return undefined;\n }\n\n const descendantSpans = getSpanDescendants(activeSpan);\n\n const initialDisplaySpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (!initialDisplaySpan) {\n logger.warn(`[TimeToDisplay] No initial display span found to attach ui.load.full_display to.`);\n return undefined;\n }\n\n const existingSpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.full_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.full_display span.`);\n return existingSpan;\n }\n\n const fullDisplaySpan = startInactiveSpan({\n op: 'ui.load.full_display',\n name: 'Time To Full Display',\n startTime: spanToJSON(initialDisplaySpan).start_timestamp,\n ...options,\n });\n if (!fullDisplaySpan) {\n return undefined;\n }\n\n const timeout = setTimeout(() => {\n if (spanToJSON(fullDisplaySpan).timestamp) {\n return;\n }\n fullDisplaySpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'deadline_exceeded' });\n fullDisplaySpan.end(spanToJSON(initialDisplaySpan).timestamp);\n setSpanDurationAsMeasurement('time_to_full_display', fullDisplaySpan);\n logger.warn(`[TimeToDisplay] Full display span deadline_exceeded.`);\n }, options.timeoutMs);\n\n fill(fullDisplaySpan, 'end', (originalEnd: Span['end']) => (endTimestamp?: Parameters<Span['end']>[0]) => {\n clearTimeout(timeout);\n originalEnd.call(fullDisplaySpan, endTimestamp);\n });\n\n return fullDisplaySpan;\n}\n\nfunction onDrawNextFrame(event: { nativeEvent: RNSentryOnDrawNextFrameEvent }): void {\n logger.debug(`[TimeToDisplay] onDrawNextFrame: ${JSON.stringify(event.nativeEvent)}`);\n if (event.nativeEvent.type === 'fullDisplay') {\n return updateFullDisplaySpan(event.nativeEvent.newFrameTimestampInSeconds);\n }\n if (event.nativeEvent.type === 'initialDisplay') {\n return updateInitialDisplaySpan(event.nativeEvent.newFrameTimestampInSeconds);\n }\n}\n\nfunction updateInitialDisplaySpan(frameTimestampSeconds: number): void {\n const span = startTimeToInitialDisplaySpan();\n if (!span) {\n logger.warn(`[TimeToDisplay] No span found or created, possibly performance is disabled.`);\n return;\n }\n\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return;\n }\n\n if (spanToJSON(span).parent_span_id !== spanToJSON(activeSpan).span_id) {\n logger.warn(`[TimeToDisplay] Initial display span is not a child of current active span.`);\n return;\n }\n\n if (spanToJSON(span).timestamp) {\n logger.warn(`[TimeToDisplay] ${spanToJSON(span).description} span already ended.`);\n return;\n }\n\n span.end(frameTimestampSeconds);\n span.setStatus({ code: SPAN_STATUS_OK });\n logger.debug(`[TimeToDisplay] ${spanToJSON(span).description} span updated with end timestamp.`);\n\n if (fullDisplayBeforeInitialDisplay.has(activeSpan)) {\n fullDisplayBeforeInitialDisplay.delete(activeSpan);\n logger.debug(`[TimeToDisplay] Updating full display with initial display (${span.spanContext().spanId}) end.`);\n updateFullDisplaySpan(frameTimestampSeconds, span);\n }\n\n setSpanDurationAsMeasurement('time_to_initial_display', span);\n}\n\nfunction updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDisplaySpan?: Span): void {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to update ui.load.full_display in.`);\n return;\n }\n\n const existingInitialDisplaySpan = passedInitialDisplaySpan\n || getSpanDescendants(activeSpan).find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n const initialDisplayEndTimestamp = existingInitialDisplaySpan && spanToJSON(existingInitialDisplaySpan).timestamp;\n if (!initialDisplayEndTimestamp) {\n fullDisplayBeforeInitialDisplay.set(activeSpan, true);\n logger.warn(`[TimeToDisplay] Full display called before initial display for active span (${activeSpan.spanContext().spanId}).`);\n return;\n }\n\n const span = startTimeToFullDisplaySpan();\n if (!span) {\n logger.warn(`[TimeToDisplay] No TimeToFullDisplay span found or created, possibly performance is disabled.`);\n return;\n }\n\n const spanJSON = spanToJSON(span);\n if (spanJSON.timestamp) {\n logger.warn(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span already ended.`);\n return;\n }\n\n if (initialDisplayEndTimestamp > frameTimestampSeconds) {\n logger.warn(`[TimeToDisplay] Using initial display end. Full display end frame timestamp is before initial display end.`);\n span.end(initialDisplayEndTimestamp);\n } else {\n span.end(frameTimestampSeconds);\n }\n\n span.setStatus({ code: SPAN_STATUS_OK });\n logger.debug(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span updated with end timestamp.`);\n\n setSpanDurationAsMeasurement('time_to_full_display', span);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timetodisplaynative.types.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplaynative.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timetodisplaynative.types.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplaynative.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,4BAA4B;IAC3C,0BAA0B,EAAE,MAAM,CAAC;IACnC,IAAI,EAAE,gBAAgB,GAAG,aAAa,CAAC;CACxC;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,eAAe,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,4BAA4B,CAAA;KAAE,KAAK,IAAI,CAAC;IAChF,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Span } from '@sentry/types';
|
|
2
2
|
export interface ReactNavigationRoute {
|
|
3
3
|
name: string;
|
|
4
4
|
key: string;
|
|
@@ -18,12 +18,5 @@ export type RouteChangeContextData = {
|
|
|
18
18
|
hasBeenSeen: boolean;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
export
|
|
22
|
-
tags: {
|
|
23
|
-
'routing.instrumentation': string;
|
|
24
|
-
'routing.route.name': string;
|
|
25
|
-
};
|
|
26
|
-
data: RouteChangeContextData;
|
|
27
|
-
}
|
|
28
|
-
export type BeforeNavigate = (context: TransactionContext) => TransactionContext;
|
|
21
|
+
export type BeforeNavigate = (context: Span) => void;
|
|
29
22
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IAEZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,CAAC,EAAE;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,IAAI,CAAC;IACT,KAAK,EAAE;QACL,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/js/tracing/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/js/tracing/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Span } from '@sentry/types';\n\nexport interface ReactNavigationRoute {\n name: string;\n key: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n params: Record<string, any>;\n}\n\nexport interface ReactNavigationCurrentRoute extends ReactNavigationRoute {\n hasBeenSeen: boolean;\n}\n\nexport type RouteChangeContextData = {\n previousRoute?: {\n [key: string]: unknown;\n name: string;\n } | null;\n route: {\n [key: string]: unknown;\n name: string;\n hasBeenSeen: boolean;\n };\n};\n\nexport type BeforeNavigate = (context: Span) => void;\n"]}
|
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type IdleTransaction, type Span as SpanClass } from '@sentry/core';
|
|
3
|
-
import type { Span, Transaction as TransactionType, TransactionContext, TransactionSource } from '@sentry/types';
|
|
1
|
+
import type { MeasurementUnit, Span, SpanJSON, TransactionSource } from '@sentry/types';
|
|
4
2
|
export declare const defaultTransactionSource: TransactionSource;
|
|
5
3
|
export declare const customTransactionSource: TransactionSource;
|
|
6
|
-
export declare const getBlankTransactionContext: (name: string) => TransactionContext;
|
|
7
4
|
/**
|
|
8
5
|
* A margin of error of 50ms is allowed for the async native bridge call.
|
|
9
6
|
* Anything larger would reduce the accuracy of our frames measurements.
|
|
10
7
|
*/
|
|
11
8
|
export declare const MARGIN_OF_ERROR_SECONDS = 0.05;
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
export declare function adjustTransactionDuration(maxDurationMs: number, transaction: IdleTransaction, endTimestamp: number): void;
|
|
16
9
|
/**
|
|
17
10
|
* Returns the timestamp where the JS global scope was initialized.
|
|
18
11
|
*/
|
|
19
12
|
export declare function getTimeOriginMilliseconds(): number;
|
|
20
|
-
/**
|
|
21
|
-
* Calls the callback every time a child span of the transaction is finished.
|
|
22
|
-
*/
|
|
23
|
-
export declare function instrumentChildSpanFinish(transaction: Transaction, callback: (span: SpanClass, endTimestamp?: number) => void): void;
|
|
24
13
|
/**
|
|
25
14
|
* Determines if the timestamp is now or within the specified margin of error from now.
|
|
26
15
|
*/
|
|
27
|
-
export declare function isNearToNow(timestamp: number): boolean;
|
|
16
|
+
export declare function isNearToNow(timestamp: number | undefined): boolean;
|
|
28
17
|
/**
|
|
29
18
|
* Sets the duration of the span as a measurement.
|
|
30
19
|
* Uses `setMeasurement` function from @sentry/core.
|
|
@@ -34,11 +23,27 @@ export declare function setSpanDurationAsMeasurement(name: string, span: Span):
|
|
|
34
23
|
* Sets the duration of the span as a measurement.
|
|
35
24
|
* Uses `setMeasurement` function from @sentry/core.
|
|
36
25
|
*/
|
|
37
|
-
export declare function
|
|
26
|
+
export declare function setSpanDurationAsMeasurementOnSpan(name: string, span: Span, on: Span): void;
|
|
27
|
+
/**
|
|
28
|
+
* Sets measurement on the give span.
|
|
29
|
+
*/
|
|
30
|
+
export declare function setSpanMeasurement(span: Span, key: string, value: number, unit: MeasurementUnit): void;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the latest end timestamp of the child spans of the given span.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getLatestChildSpanEndTimestamp(span: Span): number | undefined;
|
|
38
35
|
/**
|
|
39
36
|
* Returns unix timestamp in ms of the bundle start time.
|
|
40
37
|
*
|
|
41
38
|
* If not available, returns undefined.
|
|
42
39
|
*/
|
|
43
40
|
export declare function getBundleStartTimestampMs(): number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Creates valid span JSON object from the given data.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createSpanJSON(from: Partial<SpanJSON> & Pick<Required<SpanJSON>, 'description' | 'start_timestamp' | 'timestamp' | 'origin'>): SpanJSON;
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
export declare function createChildSpanJSON(parent: SpanJSON, from: Partial<SpanJSON> & Pick<Required<SpanJSON>, 'description' | 'start_timestamp' | 'timestamp'>): SpanJSON;
|
|
44
49
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/utils.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKxF,eAAO,MAAM,wBAAwB,EAAE,iBAA+B,CAAC;AACvE,eAAO,MAAM,uBAAuB,EAAE,iBAA4B,CAAC;AAEnE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAI5C;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAElD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAKlE;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAO3E;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,GAAG,IAAI,CAO3F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,IAAI,CAKtG;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAM7E;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,GAAG,SAAS,CAe9D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,GAAG,iBAAiB,GAAG,WAAW,GAAG,QAAQ,CAAC,GAC7G,QAAQ,CAYV;AAID;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,GAAG,iBAAiB,GAAG,WAAW,CAAC,GAClG,QAAQ,CAQV"}
|
package/dist/js/tracing/utils.js
CHANGED
|
@@ -1,72 +1,27 @@
|
|
|
1
|
-
import { setMeasurement, spanToJSON } from '@sentry/core';
|
|
2
|
-
import { logger, timestampInSeconds } from '@sentry/utils';
|
|
1
|
+
import { getSpanDescendants, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, setMeasurement, spanToJSON, } from '@sentry/core';
|
|
2
|
+
import { dropUndefinedKeys, logger, timestampInSeconds, uuid4 } from '@sentry/utils';
|
|
3
3
|
import { RN_GLOBAL_OBJ } from '../utils/worldwide';
|
|
4
4
|
export const defaultTransactionSource = 'component';
|
|
5
5
|
export const customTransactionSource = 'custom';
|
|
6
|
-
export const getBlankTransactionContext = (name) => {
|
|
7
|
-
return {
|
|
8
|
-
name: 'Route Change',
|
|
9
|
-
op: 'navigation',
|
|
10
|
-
tags: {
|
|
11
|
-
'routing.instrumentation': name,
|
|
12
|
-
},
|
|
13
|
-
data: {},
|
|
14
|
-
metadata: {
|
|
15
|
-
source: defaultTransactionSource,
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
6
|
/**
|
|
20
7
|
* A margin of error of 50ms is allowed for the async native bridge call.
|
|
21
8
|
* Anything larger would reduce the accuracy of our frames measurements.
|
|
22
9
|
*/
|
|
23
10
|
export const MARGIN_OF_ERROR_SECONDS = 0.05;
|
|
24
11
|
const timeOriginMilliseconds = Date.now();
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
export function adjustTransactionDuration(maxDurationMs, transaction, endTimestamp) {
|
|
29
|
-
const diff = endTimestamp - transaction.startTimestamp;
|
|
30
|
-
const isOutdatedTransaction = endTimestamp && (diff > maxDurationMs || diff < 0);
|
|
31
|
-
if (isOutdatedTransaction) {
|
|
32
|
-
transaction.setStatus('deadline_exceeded');
|
|
33
|
-
transaction.setTag('maxTransactionDurationExceeded', 'true');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
12
|
/**
|
|
37
13
|
* Returns the timestamp where the JS global scope was initialized.
|
|
38
14
|
*/
|
|
39
15
|
export function getTimeOriginMilliseconds() {
|
|
40
16
|
return timeOriginMilliseconds;
|
|
41
17
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Calls the callback every time a child span of the transaction is finished.
|
|
44
|
-
*/
|
|
45
|
-
export function instrumentChildSpanFinish(transaction, callback) {
|
|
46
|
-
if (transaction.spanRecorder) {
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
48
|
-
const originalAdd = transaction.spanRecorder.add;
|
|
49
|
-
transaction.spanRecorder.add = (span) => {
|
|
50
|
-
originalAdd.apply(transaction.spanRecorder, [span]);
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
52
|
-
const originalSpanFinish = span.finish;
|
|
53
|
-
span.finish = (endTimestamp) => {
|
|
54
|
-
originalSpanFinish.apply(span, [endTimestamp]);
|
|
55
|
-
callback(span, endTimestamp);
|
|
56
|
-
};
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
58
|
-
const originalSpanEnd = span.end;
|
|
59
|
-
span.end = (endTimestamp) => {
|
|
60
|
-
originalSpanEnd.apply(span, [endTimestamp]);
|
|
61
|
-
callback(span, endTimestamp);
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
18
|
/**
|
|
67
19
|
* Determines if the timestamp is now or within the specified margin of error from now.
|
|
68
20
|
*/
|
|
69
21
|
export function isNearToNow(timestamp) {
|
|
22
|
+
if (!timestamp) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
70
25
|
return Math.abs(timestampInSeconds() - timestamp) <= MARGIN_OF_ERROR_SECONDS;
|
|
71
26
|
}
|
|
72
27
|
/**
|
|
@@ -84,12 +39,30 @@ export function setSpanDurationAsMeasurement(name, span) {
|
|
|
84
39
|
* Sets the duration of the span as a measurement.
|
|
85
40
|
* Uses `setMeasurement` function from @sentry/core.
|
|
86
41
|
*/
|
|
87
|
-
export function
|
|
42
|
+
export function setSpanDurationAsMeasurementOnSpan(name, span, on) {
|
|
88
43
|
const { timestamp: spanEnd, start_timestamp: spanStart } = spanToJSON(span);
|
|
89
44
|
if (!spanEnd || !spanStart) {
|
|
90
45
|
return;
|
|
91
46
|
}
|
|
92
|
-
|
|
47
|
+
setSpanMeasurement(on, name, (spanEnd - spanStart) * 1000, 'millisecond');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets measurement on the give span.
|
|
51
|
+
*/
|
|
52
|
+
export function setSpanMeasurement(span, key, value, unit) {
|
|
53
|
+
span.addEvent(key, {
|
|
54
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE]: value,
|
|
55
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT]: unit,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns the latest end timestamp of the child spans of the given span.
|
|
60
|
+
*/
|
|
61
|
+
export function getLatestChildSpanEndTimestamp(span) {
|
|
62
|
+
const childEndTimestamps = getSpanDescendants(span)
|
|
63
|
+
.map(span => spanToJSON(span).timestamp)
|
|
64
|
+
.filter(timestamp => !!timestamp);
|
|
65
|
+
return childEndTimestamps.length ? Math.max(...childEndTimestamps) : undefined;
|
|
93
66
|
}
|
|
94
67
|
/**
|
|
95
68
|
* Returns unix timestamp in ms of the bundle start time.
|
|
@@ -110,4 +83,17 @@ export function getBundleStartTimestampMs() {
|
|
|
110
83
|
const approxStartingTimeOrigin = Date.now() - RN_GLOBAL_OBJ.nativePerformanceNow();
|
|
111
84
|
return approxStartingTimeOrigin + bundleStartTime;
|
|
112
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Creates valid span JSON object from the given data.
|
|
88
|
+
*/
|
|
89
|
+
export function createSpanJSON(from) {
|
|
90
|
+
return dropUndefinedKeys(Object.assign(Object.assign({ status: 'ok' }, from), { span_id: from.span_id ? from.span_id : uuid4().substring(16), trace_id: from.trace_id ? from.trace_id : uuid4(), data: dropUndefinedKeys(Object.assign({ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: from.op, [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: from.origin }, (from.data ? from.data : {}))) }));
|
|
91
|
+
}
|
|
92
|
+
const SENTRY_DEFAULT_ORIGIN = 'manual';
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
export function createChildSpanJSON(parent, from) {
|
|
97
|
+
return createSpanJSON(Object.assign({ op: parent.op, trace_id: parent.trace_id, parent_span_id: parent.span_id, origin: parent.origin || SENTRY_DEFAULT_ORIGIN }, from));
|
|
98
|
+
}
|
|
113
99
|
//# sourceMappingURL=utils.js.map
|