@sentry/react-native 8.3.0 → 8.4.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/RNSentry.podspec +1 -1
- package/android/libs/replay-stubs.jar +0 -0
- package/android/src/main/java/io/sentry/react/RNSentryStart.java +10 -0
- package/android/src/main/java/io/sentry/react/RNSentryVersion.java +1 -1
- package/dist/js/index.d.ts +2 -2
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +1 -1
- package/dist/js/index.js.map +1 -1
- package/dist/js/integrations/expocontext.d.ts.map +1 -1
- package/dist/js/integrations/expocontext.js +35 -1
- package/dist/js/integrations/expocontext.js.map +1 -1
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +3 -2
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/tools/metroconfig.d.ts +4 -0
- package/dist/js/tools/metroconfig.d.ts.map +1 -1
- package/dist/js/tools/metroconfig.js +46 -1
- package/dist/js/tools/metroconfig.js.map +1 -1
- package/dist/js/tracing/expoAsset.d.ts +42 -0
- package/dist/js/tracing/expoAsset.d.ts.map +1 -0
- package/dist/js/tracing/expoAsset.js +60 -0
- package/dist/js/tracing/expoAsset.js.map +1 -0
- package/dist/js/tracing/expoImage.d.ts +61 -0
- package/dist/js/tracing/expoImage.d.ts.map +1 -0
- package/dist/js/tracing/expoImage.js +101 -0
- package/dist/js/tracing/expoImage.js.map +1 -0
- package/dist/js/tracing/index.d.ts +4 -0
- package/dist/js/tracing/index.d.ts.map +1 -1
- package/dist/js/tracing/index.js +2 -0
- package/dist/js/tracing/index.js.map +1 -1
- package/dist/js/tracing/origin.d.ts +2 -0
- package/dist/js/tracing/origin.d.ts.map +1 -1
- package/dist/js/tracing/origin.js +2 -0
- package/dist/js/tracing/origin.js.map +1 -1
- package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
- package/dist/js/tracing/reactnavigation.js +9 -4
- package/dist/js/tracing/reactnavigation.js.map +1 -1
- package/dist/js/tracing/utils.d.ts +27 -1
- package/dist/js/tracing/utils.d.ts.map +1 -1
- package/dist/js/tracing/utils.js +66 -1
- package/dist/js/tracing/utils.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/ios/RNSentryVersion.m +1 -1
- package/package.json +9 -9
- package/plugin/build/utils.d.ts +1 -0
- package/plugin/build/utils.js +19 -1
- package/plugin/build/withSentry.d.ts +1 -0
- package/plugin/build/withSentry.js +28 -0
- package/ts3.8/dist/js/index.d.ts +2 -2
- package/ts3.8/dist/js/tracing/expoAsset.d.ts +42 -0
- package/ts3.8/dist/js/tracing/expoImage.d.ts +61 -0
- package/ts3.8/dist/js/tracing/index.d.ts +4 -0
- package/ts3.8/dist/js/tracing/origin.d.ts +2 -0
- package/ts3.8/dist/js/tracing/utils.d.ts +27 -1
- package/ts3.8/dist/js/version.d.ts +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { SPAN_ORIGIN_AUTO_RESOURCE_EXPO_ASSET } from './origin';
|
|
2
|
+
import { describeUrl, traceAsyncOperation } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps expo-asset's `Asset` class to add automated performance monitoring.
|
|
5
|
+
*
|
|
6
|
+
* This function instruments `Asset.loadAsync` static method
|
|
7
|
+
* to create performance spans that measure how long asset loading takes.
|
|
8
|
+
*
|
|
9
|
+
* @param assetClass - The `Asset` class from `expo-asset`
|
|
10
|
+
* @returns The same class with instrumented static methods
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { Asset } from 'expo-asset';
|
|
15
|
+
* import * as Sentry from '@sentry/react-native';
|
|
16
|
+
*
|
|
17
|
+
* Sentry.wrapExpoAsset(Asset);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function wrapExpoAsset(assetClass) {
|
|
21
|
+
if (!assetClass) {
|
|
22
|
+
return assetClass;
|
|
23
|
+
}
|
|
24
|
+
if (assetClass.__sentryWrapped) {
|
|
25
|
+
return assetClass;
|
|
26
|
+
}
|
|
27
|
+
wrapLoadAsync(assetClass);
|
|
28
|
+
assetClass.__sentryWrapped = true;
|
|
29
|
+
return assetClass;
|
|
30
|
+
}
|
|
31
|
+
function wrapLoadAsync(assetClass) {
|
|
32
|
+
if (!assetClass.loadAsync) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const originalLoadAsync = assetClass.loadAsync.bind(assetClass);
|
|
36
|
+
assetClass.loadAsync = ((moduleId) => {
|
|
37
|
+
const moduleIds = Array.isArray(moduleId) ? moduleId : [moduleId];
|
|
38
|
+
const assetCount = moduleIds.length;
|
|
39
|
+
const description = describeModuleIds(moduleIds);
|
|
40
|
+
return traceAsyncOperation({
|
|
41
|
+
op: 'resource.asset',
|
|
42
|
+
name: `Asset load ${description}`,
|
|
43
|
+
attributes: {
|
|
44
|
+
'sentry.origin': SPAN_ORIGIN_AUTO_RESOURCE_EXPO_ASSET,
|
|
45
|
+
'asset.count': assetCount,
|
|
46
|
+
},
|
|
47
|
+
}, () => originalLoadAsync(moduleId));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function describeModuleIds(moduleIds) {
|
|
51
|
+
if (moduleIds.length === 1) {
|
|
52
|
+
const id = moduleIds[0];
|
|
53
|
+
if (typeof id === 'string') {
|
|
54
|
+
return describeUrl(id);
|
|
55
|
+
}
|
|
56
|
+
return `asset #${id}`;
|
|
57
|
+
}
|
|
58
|
+
return `${moduleIds.length} assets`;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=expoAsset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expoAsset.js","sourceRoot":"","sources":["../../../src/js/tracing/expoAsset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM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AQ,EAAE;YAC1B,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC;SACxB;QACD,OAAO,UAAU,EAAE,EAAE,CAAC;KACvB;IACD,OAAO,GAAG,SAAS,CAAC,MAAM,SAAS,CAAC;AACtC,CAAC","sourcesContent":["import { SPAN_ORIGIN_AUTO_RESOURCE_EXPO_ASSET } from './origin';\nimport { describeUrl, traceAsyncOperation } from './utils';\n\n/**\n * Internal interface for expo-asset's Asset instance.\n * We define this to avoid a hard dependency on expo-asset.\n */\nexport interface ExpoAssetInstance {\n name: string;\n type: string;\n hash: string | null;\n uri: string;\n localUri: string | null;\n width: number | null;\n height: number | null;\n downloaded: boolean;\n downloadAsync(): Promise<ExpoAssetInstance>;\n}\n\n/**\n * Represents the expo-asset `Asset` class with its static methods.\n * We only describe the methods that we instrument.\n */\nexport interface ExpoAsset {\n loadAsync(moduleId: number | number[] | string | string[]): Promise<ExpoAssetInstance[]>;\n fromModule(virtualAssetModule: number | string): ExpoAssetInstance;\n}\n\n/**\n * Wraps expo-asset's `Asset` class to add automated performance monitoring.\n *\n * This function instruments `Asset.loadAsync` static method\n * to create performance spans that measure how long asset loading takes.\n *\n * @param assetClass - The `Asset` class from `expo-asset`\n * @returns The same class with instrumented static methods\n *\n * @example\n * ```typescript\n * import { Asset } from 'expo-asset';\n * import * as Sentry from '@sentry/react-native';\n *\n * Sentry.wrapExpoAsset(Asset);\n * ```\n */\nexport function wrapExpoAsset<T extends ExpoAsset>(assetClass: T): T {\n if (!assetClass) {\n return assetClass;\n }\n\n if ((assetClass as T & { __sentryWrapped?: boolean }).__sentryWrapped) {\n return assetClass;\n }\n\n wrapLoadAsync(assetClass);\n\n (assetClass as T & { __sentryWrapped?: boolean }).__sentryWrapped = true;\n\n return assetClass;\n}\n\nfunction wrapLoadAsync<T extends ExpoAsset>(assetClass: T): void {\n if (!assetClass.loadAsync) {\n return;\n }\n\n const originalLoadAsync = assetClass.loadAsync.bind(assetClass);\n\n assetClass.loadAsync = ((moduleId: number | number[] | string | string[]): Promise<ExpoAssetInstance[]> => {\n const moduleIds = Array.isArray(moduleId) ? moduleId : [moduleId];\n const assetCount = moduleIds.length;\n const description = describeModuleIds(moduleIds);\n\n return traceAsyncOperation(\n {\n op: 'resource.asset',\n name: `Asset load ${description}`,\n attributes: {\n 'sentry.origin': SPAN_ORIGIN_AUTO_RESOURCE_EXPO_ASSET,\n 'asset.count': assetCount,\n },\n },\n () => originalLoadAsync(moduleId),\n );\n }) as T['loadAsync'];\n}\n\nfunction describeModuleIds(moduleIds: (number | string)[]): string {\n if (moduleIds.length === 1) {\n const id = moduleIds[0];\n if (typeof id === 'string') {\n return describeUrl(id);\n }\n return `asset #${id}`;\n }\n return `${moduleIds.length} assets`;\n}\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal interface for expo-image's ImageSource.
|
|
3
|
+
* We define this to avoid a hard dependency on expo-image.
|
|
4
|
+
*/
|
|
5
|
+
interface ExpoImageSource {
|
|
6
|
+
uri?: string;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
width?: number | null;
|
|
9
|
+
height?: number | null;
|
|
10
|
+
cacheKey?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Internal interface for expo-image's ImageLoadOptions.
|
|
14
|
+
* We define this to avoid a hard dependency on expo-image.
|
|
15
|
+
*/
|
|
16
|
+
interface ExpoImageLoadOptions {
|
|
17
|
+
maxWidth?: number;
|
|
18
|
+
maxHeight?: number;
|
|
19
|
+
onError?(error: Error, retry: () => void): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Internal interface for expo-image's ImageRef.
|
|
23
|
+
* We define this to avoid a hard dependency on expo-image.
|
|
24
|
+
*/
|
|
25
|
+
interface ExpoImageRef {
|
|
26
|
+
readonly width: number;
|
|
27
|
+
readonly height: number;
|
|
28
|
+
readonly scale: number;
|
|
29
|
+
readonly mediaType: string | null;
|
|
30
|
+
readonly isAnimated?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Represents the expo-image `Image` class with its static methods.
|
|
34
|
+
* We only describe the methods that we instrument.
|
|
35
|
+
*/
|
|
36
|
+
export interface ExpoImage {
|
|
37
|
+
prefetch(urls: string | string[], cachePolicyOrOptions?: any): Promise<boolean>;
|
|
38
|
+
loadAsync(source: ExpoImageSource | string | number, options?: ExpoImageLoadOptions): Promise<ExpoImageRef>;
|
|
39
|
+
clearMemoryCache?(): Promise<boolean>;
|
|
40
|
+
clearDiskCache?(): Promise<boolean>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Wraps expo-image's `Image` class to add automated performance monitoring.
|
|
44
|
+
*
|
|
45
|
+
* This function instruments `Image.prefetch` and `Image.loadAsync` static methods
|
|
46
|
+
* to create performance spans that measure how long image prefetching and loading take.
|
|
47
|
+
*
|
|
48
|
+
* @param imageClass - The `Image` class from `expo-image`
|
|
49
|
+
* @returns The same class with instrumented static methods
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* import { Image } from 'expo-image';
|
|
54
|
+
* import * as Sentry from '@sentry/react-native';
|
|
55
|
+
*
|
|
56
|
+
* Sentry.wrapExpoImage(Image);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function wrapExpoImage<T extends ExpoImage>(imageClass: T): T;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=expoImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expoImage.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/expoImage.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,UAAU,eAAe;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,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';
|
|
3
|
+
import { describeUrl, sanitizeUrl, traceAsyncOperation } from './utils';
|
|
4
|
+
/**
|
|
5
|
+
* Wraps expo-image's `Image` class to add automated performance monitoring.
|
|
6
|
+
*
|
|
7
|
+
* This function instruments `Image.prefetch` and `Image.loadAsync` static methods
|
|
8
|
+
* to create performance spans that measure how long image prefetching and loading take.
|
|
9
|
+
*
|
|
10
|
+
* @param imageClass - The `Image` class from `expo-image`
|
|
11
|
+
* @returns The same class with instrumented static methods
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { Image } from 'expo-image';
|
|
16
|
+
* import * as Sentry from '@sentry/react-native';
|
|
17
|
+
*
|
|
18
|
+
* Sentry.wrapExpoImage(Image);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function wrapExpoImage(imageClass) {
|
|
22
|
+
if (!imageClass) {
|
|
23
|
+
return imageClass;
|
|
24
|
+
}
|
|
25
|
+
if (imageClass.__sentryWrapped) {
|
|
26
|
+
return imageClass;
|
|
27
|
+
}
|
|
28
|
+
wrapPrefetch(imageClass);
|
|
29
|
+
wrapLoadAsync(imageClass);
|
|
30
|
+
imageClass.__sentryWrapped = true;
|
|
31
|
+
return imageClass;
|
|
32
|
+
}
|
|
33
|
+
function wrapPrefetch(imageClass) {
|
|
34
|
+
if (!imageClass.prefetch) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const originalPrefetch = imageClass.prefetch.bind(imageClass);
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
imageClass.prefetch = ((urls, cachePolicyOrOptions) => {
|
|
40
|
+
const urlList = Array.isArray(urls) ? urls : [urls];
|
|
41
|
+
const urlCount = urlList.length;
|
|
42
|
+
const firstUrl = urlList[0] || 'unknown';
|
|
43
|
+
const description = urlCount === 1 ? describeUrl(firstUrl) : `${urlCount} images`;
|
|
44
|
+
const span = startInactiveSpan({
|
|
45
|
+
op: 'resource.image.prefetch',
|
|
46
|
+
name: `Image prefetch ${description}`,
|
|
47
|
+
attributes: Object.assign({ 'sentry.origin': SPAN_ORIGIN_AUTO_RESOURCE_EXPO_IMAGE, 'image.url_count': urlCount }, (urlCount === 1 ? { 'image.url': sanitizeUrl(firstUrl) } : undefined)),
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
return originalPrefetch(urls, cachePolicyOrOptions)
|
|
51
|
+
.then(result => {
|
|
52
|
+
if (result) {
|
|
53
|
+
span === null || span === void 0 ? void 0 : span.setStatus({ code: SPAN_STATUS_OK });
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
span === null || span === void 0 ? void 0 : span.setStatus({ code: SPAN_STATUS_ERROR, message: 'prefetch_failed' });
|
|
57
|
+
}
|
|
58
|
+
span === null || span === void 0 ? void 0 : span.end();
|
|
59
|
+
return result;
|
|
60
|
+
})
|
|
61
|
+
.catch((error) => {
|
|
62
|
+
span === null || span === void 0 ? void 0 : span.setStatus({ code: SPAN_STATUS_ERROR, message: String(error) });
|
|
63
|
+
span === null || span === void 0 ? void 0 : span.end();
|
|
64
|
+
throw error;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
span === null || span === void 0 ? void 0 : span.setStatus({ code: SPAN_STATUS_ERROR, message: String(error) });
|
|
69
|
+
span === null || span === void 0 ? void 0 : span.end();
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function wrapLoadAsync(imageClass) {
|
|
75
|
+
if (!imageClass.loadAsync) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const originalLoadAsync = imageClass.loadAsync.bind(imageClass);
|
|
79
|
+
imageClass.loadAsync = ((source, options) => {
|
|
80
|
+
const description = describeSource(source);
|
|
81
|
+
const imageUrl = typeof source === 'string' ? source : typeof source === 'object' && source.uri ? source.uri : undefined;
|
|
82
|
+
return traceAsyncOperation({
|
|
83
|
+
op: 'resource.image.load',
|
|
84
|
+
name: `Image load ${description}`,
|
|
85
|
+
attributes: Object.assign({ 'sentry.origin': SPAN_ORIGIN_AUTO_RESOURCE_EXPO_IMAGE }, (imageUrl ? { 'image.url': sanitizeUrl(imageUrl) } : undefined)),
|
|
86
|
+
}, () => originalLoadAsync(source, options));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function describeSource(source) {
|
|
90
|
+
if (typeof source === 'number') {
|
|
91
|
+
return `asset #${source}`;
|
|
92
|
+
}
|
|
93
|
+
if (typeof source === 'string') {
|
|
94
|
+
return describeUrl(source);
|
|
95
|
+
}
|
|
96
|
+
if (source.uri) {
|
|
97
|
+
return describeUrl(source.uri);
|
|
98
|
+
}
|
|
99
|
+
return 'unknown source';
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=expoImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expoImage.js","sourceRoot":"","sources":["../../../src/js/tracing/expoImage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,oCAAoC,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAgDxE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAsB,UAAa;IAC9D,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,UAAU,CAAC;KACnB;IAED,IAAK,UAAgD,CAAC,eAAe,EAAE;QACrE,OAAO,UAAU,CAAC;KACnB;IAED,YAAY,CAAC,UAAU,CAAC,CAAC;IACzB,aAAa,CAAC,UAAU,CAAC,CAAC;IAEzB,UAAgD,CAAC,eAAe,GAAG,IAAI,CAAC;IAEzE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,YAAY,CAAsB,UAAa;IACtD,IAA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AAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;QAE1G,OAAO,mBAAmB,CACxB;YACE,EAAE,EAAE,qBAAqB;YACzB,IAAI,EAAE,cAAc,WAAW,EAAE;YACjC,UAAU,kBACR,eAAe,EAAE,oCAAoC,IAClD,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CACnE;SACF,EACD,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CACzC,CAAC;IACJ,CAAC,CAAmB,CAAC;AACvB,CAAC;AAED,SAAS,cAAc,CAAC,MAAyC;IAC/D,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,UAAU,MAAM,EAAE,CAAC;KAC3B;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;KAC5B;IACD,IAAI,MAAM,CAAC,GAAG,EAAE;QACd,OAAO,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KAChC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import { SPAN_STATUS_ERROR, SPAN_STATUS_OK, startInactiveSpan } from '@sentry/core';\nimport { SPAN_ORIGIN_AUTO_RESOURCE_EXPO_IMAGE } from './origin';\nimport { describeUrl, sanitizeUrl, traceAsyncOperation } from './utils';\n\n/**\n * Internal interface for expo-image's ImageSource.\n * We define this to avoid a hard dependency on expo-image.\n */\ninterface ExpoImageSource {\n uri?: string;\n headers?: Record<string, string>;\n width?: number | null;\n height?: number | null;\n cacheKey?: string;\n}\n\n/**\n * Internal interface for expo-image's ImageLoadOptions.\n * We define this to avoid a hard dependency on expo-image.\n */\ninterface ExpoImageLoadOptions {\n maxWidth?: number;\n maxHeight?: number;\n onError?(error: Error, retry: () => void): void;\n}\n\n/**\n * Internal interface for expo-image's ImageRef.\n * We define this to avoid a hard dependency on expo-image.\n */\ninterface ExpoImageRef {\n readonly width: number;\n readonly height: number;\n readonly scale: number;\n readonly mediaType: string | null;\n readonly isAnimated?: boolean;\n}\n\n/**\n * Represents the expo-image `Image` class with its static methods.\n * We only describe the methods that we instrument.\n */\nexport interface ExpoImage {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n prefetch(urls: string | string[], cachePolicyOrOptions?: any): Promise<boolean>;\n loadAsync(source: ExpoImageSource | string | number, options?: ExpoImageLoadOptions): Promise<ExpoImageRef>;\n clearMemoryCache?(): Promise<boolean>;\n clearDiskCache?(): Promise<boolean>;\n}\n\n/**\n * Wraps expo-image's `Image` class to add automated performance monitoring.\n *\n * This function instruments `Image.prefetch` and `Image.loadAsync` static methods\n * to create performance spans that measure how long image prefetching and loading take.\n *\n * @param imageClass - The `Image` class from `expo-image`\n * @returns The same class with instrumented static methods\n *\n * @example\n * ```typescript\n * import { Image } from 'expo-image';\n * import * as Sentry from '@sentry/react-native';\n *\n * Sentry.wrapExpoImage(Image);\n * ```\n */\nexport function wrapExpoImage<T extends ExpoImage>(imageClass: T): T {\n if (!imageClass) {\n return imageClass;\n }\n\n if ((imageClass as T & { __sentryWrapped?: boolean }).__sentryWrapped) {\n return imageClass;\n }\n\n wrapPrefetch(imageClass);\n wrapLoadAsync(imageClass);\n\n (imageClass as T & { __sentryWrapped?: boolean }).__sentryWrapped = true;\n\n return imageClass;\n}\n\nfunction wrapPrefetch<T extends ExpoImage>(imageClass: T): void {\n if (!imageClass.prefetch) {\n return;\n }\n\n const originalPrefetch = imageClass.prefetch.bind(imageClass);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n imageClass.prefetch = ((urls: string | string[], cachePolicyOrOptions?: any): Promise<boolean> => {\n const urlList = Array.isArray(urls) ? urls : [urls];\n const urlCount = urlList.length;\n const firstUrl = urlList[0] || 'unknown';\n const description = urlCount === 1 ? describeUrl(firstUrl) : `${urlCount} images`;\n\n const span = startInactiveSpan({\n op: 'resource.image.prefetch',\n name: `Image prefetch ${description}`,\n attributes: {\n 'sentry.origin': SPAN_ORIGIN_AUTO_RESOURCE_EXPO_IMAGE,\n 'image.url_count': urlCount,\n ...(urlCount === 1 ? { 'image.url': sanitizeUrl(firstUrl) } : undefined),\n },\n });\n\n try {\n return originalPrefetch(urls, cachePolicyOrOptions)\n .then(result => {\n if (result) {\n span?.setStatus({ code: SPAN_STATUS_OK });\n } else {\n span?.setStatus({ code: SPAN_STATUS_ERROR, message: 'prefetch_failed' });\n }\n span?.end();\n return result;\n })\n .catch((error: unknown) => {\n span?.setStatus({ code: SPAN_STATUS_ERROR, message: String(error) });\n span?.end();\n throw error;\n });\n } catch (error) {\n span?.setStatus({ code: SPAN_STATUS_ERROR, message: String(error) });\n span?.end();\n throw error;\n }\n }) as T['prefetch'];\n}\n\nfunction wrapLoadAsync<T extends ExpoImage>(imageClass: T): void {\n if (!imageClass.loadAsync) {\n return;\n }\n\n const originalLoadAsync = imageClass.loadAsync.bind(imageClass);\n\n imageClass.loadAsync = ((\n source: ExpoImageSource | string | number,\n options?: ExpoImageLoadOptions,\n ): Promise<ExpoImageRef> => {\n const description = describeSource(source);\n\n const imageUrl =\n typeof source === 'string' ? source : typeof source === 'object' && source.uri ? source.uri : undefined;\n\n return traceAsyncOperation(\n {\n op: 'resource.image.load',\n name: `Image load ${description}`,\n attributes: {\n 'sentry.origin': SPAN_ORIGIN_AUTO_RESOURCE_EXPO_IMAGE,\n ...(imageUrl ? { 'image.url': sanitizeUrl(imageUrl) } : undefined),\n },\n },\n () => originalLoadAsync(source, options),\n );\n }) as T['loadAsync'];\n}\n\nfunction describeSource(source: ExpoImageSource | string | number): string {\n if (typeof source === 'number') {\n return `asset #${source}`;\n }\n if (typeof source === 'string') {\n return describeUrl(source);\n }\n if (source.uri) {\n return describeUrl(source.uri);\n }\n return 'unknown source';\n}\n"]}
|
|
@@ -4,6 +4,10 @@ export { reactNavigationIntegration } from './reactnavigation';
|
|
|
4
4
|
export { reactNativeNavigationIntegration } from './reactnativenavigation';
|
|
5
5
|
export { wrapExpoRouter } from './expoRouter';
|
|
6
6
|
export type { ExpoRouter } from './expoRouter';
|
|
7
|
+
export { wrapExpoImage } from './expoImage';
|
|
8
|
+
export type { ExpoImage } from './expoImage';
|
|
9
|
+
export { wrapExpoAsset } from './expoAsset';
|
|
10
|
+
export type { ExpoAsset } from './expoAsset';
|
|
7
11
|
export { startIdleNavigationSpan, startIdleSpan, getDefaultIdleNavigationSpanOptions } from './span';
|
|
8
12
|
export type { ReactNavigationCurrentRoute, ReactNavigationRoute } from './types';
|
|
9
13
|
export { ReactNativeProfiler } from './reactnativeprofiler';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,IAAI,qCAAqC,EACzD,uCAAuC,EACvC,gCAAgC,GACjC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,mCAAmC,EAAE,MAAM,QAAQ,CAAC;AAErG,YAAY,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,cAAc,OAAO,CAAC;AAEtB,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,IAAI,qCAAqC,EACzD,uCAAuC,EACvC,gCAAgC,GACjC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,mCAAmC,EAAE,MAAM,QAAQ,CAAC;AAErG,YAAY,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,cAAc,OAAO,CAAC;AAEtB,cAAc,iBAAiB,CAAC"}
|
package/dist/js/tracing/index.js
CHANGED
|
@@ -2,6 +2,8 @@ export { reactNativeTracingIntegration, INTEGRATION_NAME as REACT_NATIVE_TRACING
|
|
|
2
2
|
export { reactNavigationIntegration } from './reactnavigation';
|
|
3
3
|
export { reactNativeNavigationIntegration } from './reactnativenavigation';
|
|
4
4
|
export { wrapExpoRouter } from './expoRouter';
|
|
5
|
+
export { wrapExpoImage } from './expoImage';
|
|
6
|
+
export { wrapExpoAsset } from './expoAsset';
|
|
5
7
|
export { startIdleNavigationSpan, startIdleSpan, getDefaultIdleNavigationSpanOptions } from './span';
|
|
6
8
|
export { ReactNativeProfiler } from './reactnativeprofiler';
|
|
7
9
|
export { sentryTraceGesture } from './gesturetracing';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,IAAI,qCAAqC,EACzD,uCAAuC,EACvC,gCAAgC,GACjC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,mCAAmC,EAAE,MAAM,QAAQ,CAAC;AAIrG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,cAAc,OAAO,CAAC;AAEtB,cAAc,iBAAiB,CAAC","sourcesContent":["export {\n reactNativeTracingIntegration,\n INTEGRATION_NAME as REACT_NATIVE_TRACING_INTEGRATION_NAME,\n getCurrentReactNativeTracingIntegration,\n getReactNativeTracingIntegration,\n} from './reactnativetracing';\nexport type { ReactNativeTracingIntegration } from './reactnativetracing';\n\nexport { reactNavigationIntegration } from './reactnavigation';\nexport { reactNativeNavigationIntegration } from './reactnativenavigation';\n\nexport { wrapExpoRouter } from './expoRouter';\nexport type { ExpoRouter } from './expoRouter';\n\nexport { startIdleNavigationSpan, startIdleSpan, getDefaultIdleNavigationSpanOptions } from './span';\n\nexport type { ReactNavigationCurrentRoute, ReactNavigationRoute } from './types';\n\nexport { ReactNativeProfiler } from './reactnativeprofiler';\n\nexport { sentryTraceGesture } from './gesturetracing';\n\nexport * from './ops';\n\nexport * from './timetodisplay';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,IAAI,qCAAqC,EACzD,uCAAuC,EACvC,gCAAgC,GACjC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,mCAAmC,EAAE,MAAM,QAAQ,CAAC;AAIrG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,cAAc,OAAO,CAAC;AAEtB,cAAc,iBAAiB,CAAC","sourcesContent":["export {\n reactNativeTracingIntegration,\n INTEGRATION_NAME as REACT_NATIVE_TRACING_INTEGRATION_NAME,\n getCurrentReactNativeTracingIntegration,\n getReactNativeTracingIntegration,\n} from './reactnativetracing';\nexport type { ReactNativeTracingIntegration } from './reactnativetracing';\n\nexport { reactNavigationIntegration } from './reactnavigation';\nexport { reactNativeNavigationIntegration } from './reactnativenavigation';\n\nexport { wrapExpoRouter } from './expoRouter';\nexport type { ExpoRouter } from './expoRouter';\n\nexport { wrapExpoImage } from './expoImage';\nexport type { ExpoImage } from './expoImage';\n\nexport { wrapExpoAsset } from './expoAsset';\nexport type { ExpoAsset } from './expoAsset';\n\nexport { startIdleNavigationSpan, startIdleSpan, getDefaultIdleNavigationSpanOptions } from './span';\n\nexport type { ReactNavigationCurrentRoute, ReactNavigationRoute } from './types';\n\nexport { ReactNativeProfiler } from './reactnativeprofiler';\n\nexport { sentryTraceGesture } from './gesturetracing';\n\nexport * from './ops';\n\nexport * from './timetodisplay';\n"]}
|
|
@@ -8,4 +8,6 @@ export declare const SPAN_ORIGIN_AUTO_NAVIGATION_CUSTOM = "auto.navigation.custo
|
|
|
8
8
|
export declare const SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY = "auto.ui.time_to_display";
|
|
9
9
|
export declare const SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY = "manual.ui.time_to_display";
|
|
10
10
|
export declare const SPAN_ORIGIN_AUTO_EXPO_ROUTER_PREFETCH = "auto.expo_router.prefetch";
|
|
11
|
+
export declare const SPAN_ORIGIN_AUTO_RESOURCE_EXPO_IMAGE = "auto.resource.expo_image";
|
|
12
|
+
export declare const SPAN_ORIGIN_AUTO_RESOURCE_EXPO_ASSET = "auto.resource.expo_asset";
|
|
11
13
|
//# sourceMappingURL=origin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"origin.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/origin.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,qBAAqB,CAAC;AAC/D,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AAEnE,eAAO,MAAM,4BAA4B,qBAAqB,CAAC;AAC/D,eAAO,MAAM,0BAA0B,mBAAmB,CAAC;AAE3D,eAAO,MAAM,mDAAmD,4CAA4C,CAAC;AAC7G,eAAO,MAAM,4CAA4C,qCAAqC,CAAC;AAC/F,eAAO,MAAM,kCAAkC,2BAA2B,CAAC;AAE3E,eAAO,MAAM,mCAAmC,4BAA4B,CAAC;AAC7E,eAAO,MAAM,qCAAqC,8BAA8B,CAAC;AAEjF,eAAO,MAAM,qCAAqC,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"origin.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/origin.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,qBAAqB,CAAC;AAC/D,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AAEnE,eAAO,MAAM,4BAA4B,qBAAqB,CAAC;AAC/D,eAAO,MAAM,0BAA0B,mBAAmB,CAAC;AAE3D,eAAO,MAAM,mDAAmD,4CAA4C,CAAC;AAC7G,eAAO,MAAM,4CAA4C,qCAAqC,CAAC;AAC/F,eAAO,MAAM,kCAAkC,2BAA2B,CAAC;AAE3E,eAAO,MAAM,mCAAmC,4BAA4B,CAAC;AAC7E,eAAO,MAAM,qCAAqC,8BAA8B,CAAC;AAEjF,eAAO,MAAM,qCAAqC,8BAA8B,CAAC;AACjF,eAAO,MAAM,oCAAoC,6BAA6B,CAAC;AAC/E,eAAO,MAAM,oCAAoC,6BAA6B,CAAC"}
|
|
@@ -8,4 +8,6 @@ export const SPAN_ORIGIN_AUTO_NAVIGATION_CUSTOM = 'auto.navigation.custom';
|
|
|
8
8
|
export const SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY = 'auto.ui.time_to_display';
|
|
9
9
|
export const SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY = 'manual.ui.time_to_display';
|
|
10
10
|
export const SPAN_ORIGIN_AUTO_EXPO_ROUTER_PREFETCH = 'auto.expo_router.prefetch';
|
|
11
|
+
export const SPAN_ORIGIN_AUTO_RESOURCE_EXPO_IMAGE = 'auto.resource.expo_image';
|
|
12
|
+
export const SPAN_ORIGIN_AUTO_RESOURCE_EXPO_ASSET = 'auto.resource.expo_asset';
|
|
11
13
|
//# sourceMappingURL=origin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"origin.js","sourceRoot":"","sources":["../../../src/js/tracing/origin.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,4BAA4B,GAAG,kBAAkB,CAAC;AAC/D,MAAM,CAAC,MAAM,8BAA8B,GAAG,oBAAoB,CAAC;AAEnE,MAAM,CAAC,MAAM,4BAA4B,GAAG,kBAAkB,CAAC;AAC/D,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAE3D,MAAM,CAAC,MAAM,mDAAmD,GAAG,yCAAyC,CAAC;AAC7G,MAAM,CAAC,MAAM,4CAA4C,GAAG,kCAAkC,CAAC;AAC/F,MAAM,CAAC,MAAM,kCAAkC,GAAG,wBAAwB,CAAC;AAE3E,MAAM,CAAC,MAAM,mCAAmC,GAAG,yBAAyB,CAAC;AAC7E,MAAM,CAAC,MAAM,qCAAqC,GAAG,2BAA2B,CAAC;AAEjF,MAAM,CAAC,MAAM,qCAAqC,GAAG,2BAA2B,CAAC","sourcesContent":["export const SPAN_ORIGIN_AUTO_INTERACTION = 'auto.interaction';\nexport const SPAN_ORIGIN_MANUAL_INTERACTION = 'manual.interaction';\n\nexport const SPAN_ORIGIN_MANUAL_APP_START = 'manual.app.start';\nexport const SPAN_ORIGIN_AUTO_APP_START = 'auto.app.start';\n\nexport const SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NATIVE_NAVIGATION = 'auto.navigation.react_native_navigation';\nexport const SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NAVIGATION = 'auto.navigation.react_navigation';\nexport const SPAN_ORIGIN_AUTO_NAVIGATION_CUSTOM = 'auto.navigation.custom';\n\nexport const SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY = 'auto.ui.time_to_display';\nexport const SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY = 'manual.ui.time_to_display';\n\nexport const SPAN_ORIGIN_AUTO_EXPO_ROUTER_PREFETCH = 'auto.expo_router.prefetch';\n"]}
|
|
1
|
+
{"version":3,"file":"origin.js","sourceRoot":"","sources":["../../../src/js/tracing/origin.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,4BAA4B,GAAG,kBAAkB,CAAC;AAC/D,MAAM,CAAC,MAAM,8BAA8B,GAAG,oBAAoB,CAAC;AAEnE,MAAM,CAAC,MAAM,4BAA4B,GAAG,kBAAkB,CAAC;AAC/D,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAE3D,MAAM,CAAC,MAAM,mDAAmD,GAAG,yCAAyC,CAAC;AAC7G,MAAM,CAAC,MAAM,4CAA4C,GAAG,kCAAkC,CAAC;AAC/F,MAAM,CAAC,MAAM,kCAAkC,GAAG,wBAAwB,CAAC;AAE3E,MAAM,CAAC,MAAM,mCAAmC,GAAG,yBAAyB,CAAC;AAC7E,MAAM,CAAC,MAAM,qCAAqC,GAAG,2BAA2B,CAAC;AAEjF,MAAM,CAAC,MAAM,qCAAqC,GAAG,2BAA2B,CAAC;AACjF,MAAM,CAAC,MAAM,oCAAoC,GAAG,0BAA0B,CAAC;AAC/E,MAAM,CAAC,MAAM,oCAAoC,GAAG,0BAA0B,CAAC","sourcesContent":["export const SPAN_ORIGIN_AUTO_INTERACTION = 'auto.interaction';\nexport const SPAN_ORIGIN_MANUAL_INTERACTION = 'manual.interaction';\n\nexport const SPAN_ORIGIN_MANUAL_APP_START = 'manual.app.start';\nexport const SPAN_ORIGIN_AUTO_APP_START = 'auto.app.start';\n\nexport const SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NATIVE_NAVIGATION = 'auto.navigation.react_native_navigation';\nexport const SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NAVIGATION = 'auto.navigation.react_navigation';\nexport const SPAN_ORIGIN_AUTO_NAVIGATION_CUSTOM = 'auto.navigation.custom';\n\nexport const SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY = 'auto.ui.time_to_display';\nexport const SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY = 'manual.ui.time_to_display';\n\nexport const SPAN_ORIGIN_AUTO_EXPO_ROUTER_PREFETCH = 'auto.expo_router.prefetch';\nexport const SPAN_ORIGIN_AUTO_RESOURCE_EXPO_IMAGE = 'auto.resource.expo_image';\nexport const SPAN_ORIGIN_AUTO_RESOURCE_EXPO_ASSET = 'auto.resource.expo_asset';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnavigation.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAQ,MAAM,cAAc,CAAC;AA+B9D,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAIlD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CA2BpC;AA0BD,UAAU,iCAAiC;IACzC;;;;;OAKG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACH,0BAA0B,EAAE,OAAO,CAAC;IAEpC;;;;;OAKG;IACH,qCAAqC,EAAE,OAAO,CAAC;IAE/C;;;;;OAKG;IACH,4CAA4C,EAAE,OAAO,CAAC;IAEtD;;;;OAIG;IACH,uBAAuB,EAAE,OAAO,CAAC;IAEjC;;;;OAIG;IACH,+BAA+B,EAAE,OAAO,CAAC;IAEzC;;;;;;OAMG;IACH,sBAAsB,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,kOAQpC,QAAQ,iCAAiC,CAAC;IAC3C;;;OAGG;0DACmD,OAAO,KAAK,IAAI;aAC7D,iCAAiC;
|
|
1
|
+
{"version":3,"file":"reactnavigation.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAQ,MAAM,cAAc,CAAC;AA+B9D,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAIlD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CA2BpC;AA0BD,UAAU,iCAAiC;IACzC;;;;;OAKG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACH,0BAA0B,EAAE,OAAO,CAAC;IAEpC;;;;;OAKG;IACH,qCAAqC,EAAE,OAAO,CAAC;IAE/C;;;;;OAKG;IACH,4CAA4C,EAAE,OAAO,CAAC;IAEtD;;;;OAIG;IACH,uBAAuB,EAAE,OAAO,CAAC;IAEjC;;;;OAIG;IACH,+BAA+B,EAAE,OAAO,CAAC;IAEzC;;;;;;OAMG;IACH,sBAAsB,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,kOAQpC,QAAQ,iCAAiC,CAAC;IAC3C;;;OAGG;0DACmD,OAAO,KAAK,IAAI;aAC7D,iCAAiC;CA4W3C,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IAEZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB;AAED,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAQD;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,GACb,UAAU,CAAC,OAAO,0BAA0B,CAAC,GAAG,SAAS,CAE3D"}
|
|
@@ -86,6 +86,7 @@ export const reactNavigationIntegration = ({ routeChangeTimeoutMs = 1000, enable
|
|
|
86
86
|
let latestNavigationSpan;
|
|
87
87
|
let navigationProcessingSpan;
|
|
88
88
|
let initialStateHandled = false;
|
|
89
|
+
let isSetupComplete = false;
|
|
89
90
|
let stateChangeTimeout;
|
|
90
91
|
let recentRouteKeys = [];
|
|
91
92
|
if (enableTimeToInitialDisplay) {
|
|
@@ -120,12 +121,13 @@ export const reactNavigationIntegration = ({ routeChangeTimeoutMs = 1000, enable
|
|
|
120
121
|
startIdleNavigationSpan(undefined, true);
|
|
121
122
|
}
|
|
122
123
|
});
|
|
123
|
-
|
|
124
|
+
isSetupComplete = true;
|
|
124
125
|
if (!navigationContainer) {
|
|
125
126
|
// This is expected as navigation container is registered after the root component is mounted.
|
|
126
127
|
return undefined;
|
|
127
128
|
}
|
|
128
|
-
// Navigation container already registered,
|
|
129
|
+
// Navigation container already registered, create and populate initial span
|
|
130
|
+
startIdleNavigationSpan();
|
|
129
131
|
updateLatestNavigationSpanWithCurrentRoute();
|
|
130
132
|
initialStateHandled = true;
|
|
131
133
|
};
|
|
@@ -161,8 +163,11 @@ export const reactNavigationIntegration = ({ routeChangeTimeoutMs = 1000, enable
|
|
|
161
163
|
return undefined;
|
|
162
164
|
}
|
|
163
165
|
if (!latestNavigationSpan) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
+
if (!isSetupComplete) {
|
|
167
|
+
debug.log(`${INTEGRATION_NAME} Navigation container registered before integration setup. Initial span will be created when setup completes.`);
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
startIdleNavigationSpan();
|
|
166
171
|
}
|
|
167
172
|
// Navigation Container is registered after the first navigation
|
|
168
173
|
// Initial navigation span was started, after integration setup,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,KAAK,EACL,SAAS,EACT,aAAa,EACb,4BAA4B,EAC5B,gCAAgC,EAChC,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,M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;AAqBF;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAC3C,MAAc;IAEd,OAAO,MAAM,CAAC,oBAAoB,CAAgD,gBAAgB,CAAC,CAAC;AACtG,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, Integration, Span } from '@sentry/core';\nimport {\n addBreadcrumb,\n debug,\n getClient,\n isPlainObject,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_OK,\n spanToJSON,\n startInactiveSpan,\n timestampInSeconds,\n} from '@sentry/core';\nimport { getAppRegistryIntegration } from '../integrations/appRegistry';\nimport { isSentrySpan } from '../utils/span';\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\nimport type { UnsafeAction } from '../vendor/react-navigation/types';\nimport { NATIVE } from '../wrapper';\nimport { ignoreEmptyBackNavigation, ignoreEmptyRouteChangeTransactions } from './onSpanEndUtils';\nimport { SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NAVIGATION } from './origin';\nimport type { ReactNativeTracingIntegration } from './reactnativetracing';\nimport { getReactNativeTracingIntegration } from './reactnativetracing';\nimport { SEMANTIC_ATTRIBUTE_NAVIGATION_ACTION_TYPE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from './semanticAttributes';\nimport {\n DEFAULT_NAVIGATION_SPAN_NAME,\n defaultIdleOptions,\n getDefaultIdleNavigationSpanOptions,\n startIdleNavigationSpan as startGenericIdleNavigationSpan,\n} from './span';\nimport { addTimeToInitialDisplayFallback } from './timeToDisplayFallback';\n\nexport const INTEGRATION_NAME = 'ReactNavigation';\n\nconst NAVIGATION_HISTORY_MAX_SIZE = 200;\n\n/**\n * Extracts dynamic route parameters from a route name and its params.\n * Matches Expo Router style dynamic segments like `[id]` and `[...slug]`.\n *\n * Only params whose keys appear as dynamic segments in the route name are returned,\n * filtering out non-structural params (query params, etc.) that may contain PII.\n *\n * Note: dynamic segment values (e.g. the `123` in `profile/[id]`) may be user-identifiable.\n * This function only extracts params — callers are responsible for checking `sendDefaultPii`\n * before including the result in span attributes.\n *\n * Previous route params are intentionally not captured — only the current route's\n * structural params are needed for trace attribution.\n */\nexport function extractDynamicRouteParams(\n routeName: string,\n params?: Record<string, unknown>,\n): Record<string, string> | undefined {\n if (!params) {\n return undefined;\n }\n\n const dynamicKeys = new Set<string>();\n const pattern = /\\[(?:\\.\\.\\.)?(\\w+)\\]/g;\n let match: RegExpExecArray | null;\n while ((match = pattern.exec(routeName)) !== null) {\n if (match[1]) {\n dynamicKeys.add(match[1]);\n }\n }\n\n if (dynamicKeys.size === 0) {\n return undefined;\n }\n\n const result: Record<string, string> = {};\n for (const key of dynamicKeys) {\n if (key in params) {\n const value = params[key];\n result[`route.params.${key}`] = Array.isArray(value) ? value.join('/') : String(value ?? '');\n }\n }\n\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\n/**\n * Builds a full path from the navigation state by traversing nested navigators.\n * For example, with nested navigators: \"Home/Settings/Profile\"\n */\nfunction getPathFromState(state?: NavigationState): string | undefined {\n if (!state) {\n return undefined;\n }\n\n const routeNames: string[] = [];\n let currentState: NavigationState | undefined = state;\n\n while (currentState) {\n const index: number = currentState.index ?? 0;\n const route: NavigationRoute | undefined = currentState.routes[index];\n if (route?.name) {\n routeNames.push(route.name);\n }\n currentState = route?.state;\n }\n\n return routeNames.length > 0 ? routeNames.join('/') : undefined;\n}\n\ninterface ReactNavigationIntegrationOptions {\n /**\n * How long the instrumentation will wait for the route to mount after a change has been initiated,\n * before the transaction is discarded.\n *\n * @default 1_000 (ms)\n */\n routeChangeTimeoutMs: number;\n\n /**\n * Time to initial display measures the time it takes from\n * navigation dispatch to the render of the first frame of the new screen.\n *\n * @default false\n */\n enableTimeToInitialDisplay: boolean;\n\n /**\n * Does not sample transactions that are from routes that have been seen any more and don't have any spans.\n * This removes a lot of the clutter as most back navigation transactions are now ignored.\n *\n * @default true\n */\n ignoreEmptyBackNavigationTransactions: boolean;\n\n /**\n * Enabled measuring Time to Initial Display for routes that are already loaded in memory.\n * (a.k.a., Routes that the navigation integration has already seen.)\n *\n * @default false\n */\n enableTimeToInitialDisplayForPreloadedRoutes: boolean;\n\n /**\n * Whether to use the dispatched action data to populate the transaction metadata.\n *\n * @default false\n */\n useDispatchedActionData: boolean;\n\n /**\n * Whether to use the full paths for navigation routes.\n *\n * @default false\n */\n useFullPathsForNavigationRoutes: boolean;\n\n /**\n * Track performance of route prefetching operations.\n * Creates separate spans for PRELOAD actions to measure prefetch performance.\n * This is useful for Expo Router apps that use the prefetch functionality.\n *\n * @default false\n */\n enablePrefetchTracking: boolean;\n}\n\n/**\n * Instrumentation for React-Navigation V5 and above. See docs or sample app for usage.\n *\n * How this works:\n * - `_onDispatch` is called every time a dispatch happens and sets an IdleTransaction on the scope without any route context.\n * - `_onStateChange` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.\n * - If `_onStateChange` isn't called within `STATE_CHANGE_TIMEOUT_DURATION` of the dispatch, then the transaction is not sampled and finished.\n */\nexport const reactNavigationIntegration = ({\n routeChangeTimeoutMs = 1_000,\n enableTimeToInitialDisplay = false,\n ignoreEmptyBackNavigationTransactions = true,\n enableTimeToInitialDisplayForPreloadedRoutes = false,\n useDispatchedActionData = false,\n useFullPathsForNavigationRoutes = false,\n enablePrefetchTracking = false,\n}: Partial<ReactNavigationIntegrationOptions> = {}): Integration & {\n /**\n * Pass the ref to the navigation container to register it to the instrumentation\n * @param navigationContainerRef Ref to a `NavigationContainer`\n */\n registerNavigationContainer: (navigationContainerRef: unknown) => void;\n options: ReactNavigationIntegrationOptions;\n} => {\n let navigationContainer: NavigationContainer | undefined;\n\n let tracing: ReactNativeTracingIntegration | undefined;\n let idleSpanOptions: Parameters<typeof startGenericIdleNavigationSpan>[1] = defaultIdleOptions;\n let latestRoute: NavigationRoute | undefined;\n\n let latestNavigationSpan: Span | undefined;\n let navigationProcessingSpan: Span | undefined;\n\n let initialStateHandled: boolean = false;\n let stateChangeTimeout: ReturnType<typeof setTimeout> | undefined;\n let recentRouteKeys: string[] = [];\n\n if (enableTimeToInitialDisplay) {\n NATIVE.initNativeReactNavigationNewFrameTracking().catch((reason: unknown) => {\n debug.error(`${INTEGRATION_NAME} Failed to initialize native new frame tracking: ${reason}`);\n });\n }\n\n /**\n * Set the initial state and start initial navigation span for the current screen.\n */\n const afterAllSetup = (client: Client): void => {\n tracing = getReactNativeTracingIntegration(client);\n if (tracing) {\n idleSpanOptions = {\n finalTimeout: tracing.options.finalTimeoutMs,\n idleTimeout: tracing.options.idleTimeoutMs,\n };\n }\n\n if (initialStateHandled) {\n // We create an initial state here to ensure a transaction gets created before the first route mounts.\n // This assumes that the Sentry.init() call is made before the first route mounts.\n // If this is not the case, the first transaction will be nameless 'Route Changed'\n return undefined;\n }\n\n getAppRegistryIntegration(client)?.onRunApplication(() => {\n if (initialStateHandled) {\n // To avoid conflict with the initial transaction we check if it was already handled.\n // This ensures runApplication calls after the initial start are correctly traced.\n // This is used for example when Activity is (re)started on Android.\n debug.log('[ReactNavigationIntegration] Starting new idle navigation span based on runApplication call.');\n startIdleNavigationSpan(undefined, true);\n }\n });\n\n startIdleNavigationSpan();\n\n if (!navigationContainer) {\n // This is expected as navigation container is registered after the root component is mounted.\n return undefined;\n }\n\n // Navigation container already registered, just populate with route state\n updateLatestNavigationSpanWithCurrentRoute();\n initialStateHandled = true;\n };\n\n const registerNavigationContainer = (maybeNewNavigationContainer: unknown): void => {\n if (RN_GLOBAL_OBJ.__sentry_rn_v5_registered) {\n debug.log(`${INTEGRATION_NAME} Instrumentation already exists, but registering again...`);\n // In the past we have not allowed re-registering the navigation container to avoid unexpected behavior.\n // But this doesn't work for Android and re-recreating application main activity.\n // Where new navigation container is created and the old one is discarded. We need to re-register to\n // trace the new navigation container navigation.\n }\n\n let newNavigationContainer: NavigationContainer | undefined;\n if (isPlainObject(maybeNewNavigationContainer) && 'current' in maybeNewNavigationContainer) {\n newNavigationContainer = maybeNewNavigationContainer.current as NavigationContainer;\n } else {\n newNavigationContainer = maybeNewNavigationContainer as NavigationContainer;\n }\n\n if (navigationContainer === newNavigationContainer) {\n debug.log(`${INTEGRATION_NAME} Navigation container ref is the same as the one already registered.`);\n return;\n }\n navigationContainer = newNavigationContainer;\n\n if (!navigationContainer) {\n debug.warn(`${INTEGRATION_NAME} Received invalid navigation container ref!`);\n return undefined;\n }\n\n // This action is emitted on every dispatch\n navigationContainer.addListener('__unsafe_action__', startIdleNavigationSpan);\n navigationContainer.addListener('state', updateLatestNavigationSpanWithCurrentRoute);\n RN_GLOBAL_OBJ.__sentry_rn_v5_registered = true;\n\n if (initialStateHandled) {\n return undefined;\n }\n\n if (!latestNavigationSpan) {\n debug.log(`${INTEGRATION_NAME} Navigation container registered, but integration has not been setup yet.`);\n return undefined;\n }\n\n // Navigation Container is registered after the first navigation\n // Initial navigation span was started, after integration setup,\n // so now we populate it with the current route.\n updateLatestNavigationSpanWithCurrentRoute();\n initialStateHandled = true;\n };\n\n /**\n * To be called on every React-Navigation action dispatch.\n * It does not name the transaction or populate it with route information. Instead, it waits for the state to fully change\n * and gets the route information from there, @see updateLatestNavigationSpanWithCurrentRoute\n *\n * @param unknownEvent - The event object that contains navigation action data\n * @param isAppRestart - Whether this span is being started due to an app restart rather than a normal navigation action\n */\n const startIdleNavigationSpan = (unknownEvent?: unknown, isAppRestart = false): void => {\n const event = unknownEvent as UnsafeAction | undefined;\n if (useDispatchedActionData && event?.data.noop) {\n debug.log(`${INTEGRATION_NAME} Navigation action is a noop, not starting navigation span.`);\n return;\n }\n\n const navigationActionType = useDispatchedActionData ? event?.data.action.type : undefined;\n\n // Handle PRELOAD actions separately if prefetch tracking is enabled\n if (enablePrefetchTracking && navigationActionType === 'PRELOAD') {\n const preloadData = event?.data.action;\n const payload = preloadData?.payload;\n const targetRoute =\n payload && typeof payload === 'object' && 'name' in payload && typeof payload.name === 'string'\n ? payload.name\n : 'Unknown Route';\n\n debug.log(`${INTEGRATION_NAME} Starting prefetch span for route: ${targetRoute}`);\n\n const prefetchSpan = startInactiveSpan({\n op: 'navigation.prefetch',\n name: `Prefetch ${targetRoute}`,\n attributes: {\n 'route.name': targetRoute,\n },\n });\n\n // Store prefetch span to end it when state changes or timeout\n navigationProcessingSpan = prefetchSpan;\n\n // Set timeout to ensure we don't leave hanging spans\n stateChangeTimeout = setTimeout(() => {\n if (navigationProcessingSpan === prefetchSpan) {\n debug.log(`${INTEGRATION_NAME} Prefetch span timed out for route: ${targetRoute}`);\n prefetchSpan?.setStatus({ code: SPAN_STATUS_OK });\n prefetchSpan?.end();\n navigationProcessingSpan = undefined;\n }\n }, routeChangeTimeoutMs);\n\n return;\n }\n\n if (\n useDispatchedActionData &&\n navigationActionType &&\n [\n // Process common actions\n 'PRELOAD', // Still filter PRELOAD when enablePrefetchTracking is false\n 'SET_PARAMS',\n // Drawer actions\n 'OPEN_DRAWER',\n 'CLOSE_DRAWER',\n 'TOGGLE_DRAWER',\n ].includes(navigationActionType)\n ) {\n debug.log(`${INTEGRATION_NAME} Navigation action is ${navigationActionType}, not starting navigation span.`);\n return;\n }\n\n if (latestNavigationSpan) {\n debug.log(`${INTEGRATION_NAME} A transaction was detected that turned out to be a noop, discarding.`);\n _discardLatestTransaction();\n clearStateChangeTimeout();\n }\n\n latestNavigationSpan = startGenericIdleNavigationSpan(\n tracing?.options.beforeStartSpan\n ? tracing.options.beforeStartSpan(getDefaultIdleNavigationSpanOptions())\n : getDefaultIdleNavigationSpanOptions(),\n { ...idleSpanOptions, isAppRestart },\n );\n latestNavigationSpan?.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NAVIGATION);\n latestNavigationSpan?.setAttribute(SEMANTIC_ATTRIBUTE_NAVIGATION_ACTION_TYPE, navigationActionType);\n if (ignoreEmptyBackNavigationTransactions) {\n ignoreEmptyBackNavigation(getClient(), latestNavigationSpan);\n }\n // Always discard transactions that never receive route information\n const spanToCheck = latestNavigationSpan;\n ignoreEmptyRouteChangeTransactions(\n getClient(),\n spanToCheck,\n DEFAULT_NAVIGATION_SPAN_NAME,\n () => latestNavigationSpan === spanToCheck,\n );\n\n if (enableTimeToInitialDisplay && latestNavigationSpan) {\n NATIVE.setActiveSpanId(latestNavigationSpan.spanContext().spanId);\n navigationProcessingSpan = startInactiveSpan({\n op: 'navigation.processing',\n name: 'Navigation dispatch to navigation cancelled or screen mounted',\n startTime: spanToJSON(latestNavigationSpan).start_timestamp,\n });\n navigationProcessingSpan.setAttribute(\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NAVIGATION,\n );\n }\n\n stateChangeTimeout = setTimeout(_discardLatestTransaction, routeChangeTimeoutMs);\n };\n\n /**\n * To be called AFTER the state has been changed to populate the transaction with the current route.\n */\n const updateLatestNavigationSpanWithCurrentRoute = (): void => {\n const stateChangedTimestamp = timestampInSeconds();\n const previousRoute = latestRoute;\n\n if (!navigationContainer) {\n debug.warn(`${INTEGRATION_NAME} Missing navigation container ref. Route transactions will not be sent.`);\n return undefined;\n }\n\n const route = navigationContainer.getCurrentRoute();\n if (!route) {\n debug.log(`[${INTEGRATION_NAME}] Navigation state changed, but no route is rendered.`);\n return undefined;\n }\n\n if (!latestNavigationSpan) {\n debug.log(\n `[${INTEGRATION_NAME}] Navigation state changed, but navigation transaction was not started on dispatch.`,\n );\n return undefined;\n }\n\n addTimeToInitialDisplayFallback(latestNavigationSpan.spanContext().spanId, NATIVE.getNewScreenTimeToDisplay());\n\n if (previousRoute && previousRoute.key === route.key) {\n debug.log(`[${INTEGRATION_NAME}] Navigation state changed, but route is the same as previous.`);\n pushRecentRouteKey(route.key);\n latestRoute = route;\n\n // Clear the latest transaction as it has been handled.\n latestNavigationSpan = undefined;\n return undefined;\n }\n\n const routeHasBeenSeen = recentRouteKeys.includes(route.key);\n\n // Get the full navigation path for nested navigators\n let routeName = route.name;\n if (useFullPathsForNavigationRoutes) {\n const navigationState = navigationContainer.getState();\n routeName = getPathFromState(navigationState) || route.name;\n }\n\n navigationProcessingSpan?.updateName(`Navigation dispatch to screen ${routeName} mounted`);\n navigationProcessingSpan?.setStatus({ code: SPAN_STATUS_OK });\n navigationProcessingSpan?.end(stateChangedTimestamp);\n navigationProcessingSpan = undefined;\n\n if (spanToJSON(latestNavigationSpan).description === DEFAULT_NAVIGATION_SPAN_NAME) {\n latestNavigationSpan.updateName(routeName);\n }\n const sendDefaultPii = getClient()?.getOptions()?.sendDefaultPii ?? false;\n latestNavigationSpan.setAttributes({\n 'route.name': routeName,\n 'route.key': route.key,\n ...(sendDefaultPii ? extractDynamicRouteParams(routeName, route.params) : undefined),\n 'route.has_been_seen': routeHasBeenSeen,\n 'previous_route.name': previousRoute?.name,\n 'previous_route.key': previousRoute?.key,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n });\n\n // Clear the timeout so the transaction does not get cancelled.\n clearStateChangeTimeout();\n\n addBreadcrumb({\n category: 'navigation',\n type: 'navigation',\n message: `Navigation to ${routeName}`,\n data: {\n from: previousRoute?.name,\n to: routeName,\n },\n });\n\n tracing?.setCurrentRoute(routeName);\n\n pushRecentRouteKey(route.key);\n if (useFullPathsForNavigationRoutes) {\n latestRoute = { ...route, name: routeName };\n } else {\n latestRoute = route;\n }\n // Clear the latest transaction as it has been handled.\n latestNavigationSpan = undefined;\n };\n\n /** Pushes a recent route key, and removes earlier routes when there is greater than the max length */\n const pushRecentRouteKey = (key: string): void => {\n recentRouteKeys.push(key);\n\n if (recentRouteKeys.length > NAVIGATION_HISTORY_MAX_SIZE) {\n recentRouteKeys = recentRouteKeys.slice(recentRouteKeys.length - NAVIGATION_HISTORY_MAX_SIZE);\n }\n };\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n const _discardLatestTransaction = (): void => {\n if (latestNavigationSpan) {\n if (isSentrySpan(latestNavigationSpan)) {\n latestNavigationSpan['_sampled'] = false;\n }\n // TODO: What if it's not SentrySpan?\n latestNavigationSpan.end();\n latestNavigationSpan = undefined;\n }\n if (navigationProcessingSpan) {\n navigationProcessingSpan = undefined;\n }\n };\n\n const clearStateChangeTimeout = (): void => {\n if (typeof stateChangeTimeout !== 'undefined') {\n clearTimeout(stateChangeTimeout);\n stateChangeTimeout = undefined;\n }\n };\n\n return {\n name: INTEGRATION_NAME,\n afterAllSetup,\n registerNavigationContainer,\n options: {\n routeChangeTimeoutMs,\n enableTimeToInitialDisplay,\n ignoreEmptyBackNavigationTransactions,\n enableTimeToInitialDisplayForPreloadedRoutes,\n useDispatchedActionData,\n useFullPathsForNavigationRoutes,\n enablePrefetchTracking,\n },\n };\n};\n\nexport interface NavigationRoute {\n name: string;\n key: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n params?: Record<string, any>;\n state?: NavigationState;\n}\n\ninterface NavigationState {\n index?: number;\n routes: NavigationRoute[];\n}\n\ninterface NavigationContainer {\n addListener: (type: string, listener: (event?: unknown) => void) => void;\n getCurrentRoute: () => NavigationRoute;\n getState: () => NavigationState | undefined;\n}\n\n/**\n * Returns React Navigation integration of the given client.\n */\nexport function getReactNavigationIntegration(\n client: Client,\n): ReturnType<typeof reactNavigationIntegration> | undefined {\n return client.getIntegrationByName<ReturnType<typeof reactNavigationIntegration>>(INTEGRATION_NAME);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reactnavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,KAAK,EACL,SAAS,EACT,aAAa,EACb,4BAA4B,EAC5B,gCAAgC,EAChC,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,E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AA4C;YAC5C,uBAAuB;YACvB,+BAA+B;YAC/B,sBAAsB;SACvB;KACF,CAAC;AACJ,CAAC,CAAC;AAqBF;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAC3C,MAAc;IAEd,OAAO,MAAM,CAAC,oBAAoB,CAAgD,gBAAgB,CAAC,CAAC;AACtG,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, Integration, Span } from '@sentry/core';\nimport {\n addBreadcrumb,\n debug,\n getClient,\n isPlainObject,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_OK,\n spanToJSON,\n startInactiveSpan,\n timestampInSeconds,\n} from '@sentry/core';\nimport { getAppRegistryIntegration } from '../integrations/appRegistry';\nimport { isSentrySpan } from '../utils/span';\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\nimport type { UnsafeAction } from '../vendor/react-navigation/types';\nimport { NATIVE } from '../wrapper';\nimport { ignoreEmptyBackNavigation, ignoreEmptyRouteChangeTransactions } from './onSpanEndUtils';\nimport { SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NAVIGATION } from './origin';\nimport type { ReactNativeTracingIntegration } from './reactnativetracing';\nimport { getReactNativeTracingIntegration } from './reactnativetracing';\nimport { SEMANTIC_ATTRIBUTE_NAVIGATION_ACTION_TYPE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from './semanticAttributes';\nimport {\n DEFAULT_NAVIGATION_SPAN_NAME,\n defaultIdleOptions,\n getDefaultIdleNavigationSpanOptions,\n startIdleNavigationSpan as startGenericIdleNavigationSpan,\n} from './span';\nimport { addTimeToInitialDisplayFallback } from './timeToDisplayFallback';\n\nexport const INTEGRATION_NAME = 'ReactNavigation';\n\nconst NAVIGATION_HISTORY_MAX_SIZE = 200;\n\n/**\n * Extracts dynamic route parameters from a route name and its params.\n * Matches Expo Router style dynamic segments like `[id]` and `[...slug]`.\n *\n * Only params whose keys appear as dynamic segments in the route name are returned,\n * filtering out non-structural params (query params, etc.) that may contain PII.\n *\n * Note: dynamic segment values (e.g. the `123` in `profile/[id]`) may be user-identifiable.\n * This function only extracts params — callers are responsible for checking `sendDefaultPii`\n * before including the result in span attributes.\n *\n * Previous route params are intentionally not captured — only the current route's\n * structural params are needed for trace attribution.\n */\nexport function extractDynamicRouteParams(\n routeName: string,\n params?: Record<string, unknown>,\n): Record<string, string> | undefined {\n if (!params) {\n return undefined;\n }\n\n const dynamicKeys = new Set<string>();\n const pattern = /\\[(?:\\.\\.\\.)?(\\w+)\\]/g;\n let match: RegExpExecArray | null;\n while ((match = pattern.exec(routeName)) !== null) {\n if (match[1]) {\n dynamicKeys.add(match[1]);\n }\n }\n\n if (dynamicKeys.size === 0) {\n return undefined;\n }\n\n const result: Record<string, string> = {};\n for (const key of dynamicKeys) {\n if (key in params) {\n const value = params[key];\n result[`route.params.${key}`] = Array.isArray(value) ? value.join('/') : String(value ?? '');\n }\n }\n\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\n/**\n * Builds a full path from the navigation state by traversing nested navigators.\n * For example, with nested navigators: \"Home/Settings/Profile\"\n */\nfunction getPathFromState(state?: NavigationState): string | undefined {\n if (!state) {\n return undefined;\n }\n\n const routeNames: string[] = [];\n let currentState: NavigationState | undefined = state;\n\n while (currentState) {\n const index: number = currentState.index ?? 0;\n const route: NavigationRoute | undefined = currentState.routes[index];\n if (route?.name) {\n routeNames.push(route.name);\n }\n currentState = route?.state;\n }\n\n return routeNames.length > 0 ? routeNames.join('/') : undefined;\n}\n\ninterface ReactNavigationIntegrationOptions {\n /**\n * How long the instrumentation will wait for the route to mount after a change has been initiated,\n * before the transaction is discarded.\n *\n * @default 1_000 (ms)\n */\n routeChangeTimeoutMs: number;\n\n /**\n * Time to initial display measures the time it takes from\n * navigation dispatch to the render of the first frame of the new screen.\n *\n * @default false\n */\n enableTimeToInitialDisplay: boolean;\n\n /**\n * Does not sample transactions that are from routes that have been seen any more and don't have any spans.\n * This removes a lot of the clutter as most back navigation transactions are now ignored.\n *\n * @default true\n */\n ignoreEmptyBackNavigationTransactions: boolean;\n\n /**\n * Enabled measuring Time to Initial Display for routes that are already loaded in memory.\n * (a.k.a., Routes that the navigation integration has already seen.)\n *\n * @default false\n */\n enableTimeToInitialDisplayForPreloadedRoutes: boolean;\n\n /**\n * Whether to use the dispatched action data to populate the transaction metadata.\n *\n * @default false\n */\n useDispatchedActionData: boolean;\n\n /**\n * Whether to use the full paths for navigation routes.\n *\n * @default false\n */\n useFullPathsForNavigationRoutes: boolean;\n\n /**\n * Track performance of route prefetching operations.\n * Creates separate spans for PRELOAD actions to measure prefetch performance.\n * This is useful for Expo Router apps that use the prefetch functionality.\n *\n * @default false\n */\n enablePrefetchTracking: boolean;\n}\n\n/**\n * Instrumentation for React-Navigation V5 and above. See docs or sample app for usage.\n *\n * How this works:\n * - `_onDispatch` is called every time a dispatch happens and sets an IdleTransaction on the scope without any route context.\n * - `_onStateChange` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.\n * - If `_onStateChange` isn't called within `STATE_CHANGE_TIMEOUT_DURATION` of the dispatch, then the transaction is not sampled and finished.\n */\nexport const reactNavigationIntegration = ({\n routeChangeTimeoutMs = 1_000,\n enableTimeToInitialDisplay = false,\n ignoreEmptyBackNavigationTransactions = true,\n enableTimeToInitialDisplayForPreloadedRoutes = false,\n useDispatchedActionData = false,\n useFullPathsForNavigationRoutes = false,\n enablePrefetchTracking = false,\n}: Partial<ReactNavigationIntegrationOptions> = {}): Integration & {\n /**\n * Pass the ref to the navigation container to register it to the instrumentation\n * @param navigationContainerRef Ref to a `NavigationContainer`\n */\n registerNavigationContainer: (navigationContainerRef: unknown) => void;\n options: ReactNavigationIntegrationOptions;\n} => {\n let navigationContainer: NavigationContainer | undefined;\n\n let tracing: ReactNativeTracingIntegration | undefined;\n let idleSpanOptions: Parameters<typeof startGenericIdleNavigationSpan>[1] = defaultIdleOptions;\n let latestRoute: NavigationRoute | undefined;\n\n let latestNavigationSpan: Span | undefined;\n let navigationProcessingSpan: Span | undefined;\n\n let initialStateHandled: boolean = false;\n let isSetupComplete: boolean = false;\n let stateChangeTimeout: ReturnType<typeof setTimeout> | undefined;\n let recentRouteKeys: string[] = [];\n\n if (enableTimeToInitialDisplay) {\n NATIVE.initNativeReactNavigationNewFrameTracking().catch((reason: unknown) => {\n debug.error(`${INTEGRATION_NAME} Failed to initialize native new frame tracking: ${reason}`);\n });\n }\n\n /**\n * Set the initial state and start initial navigation span for the current screen.\n */\n const afterAllSetup = (client: Client): void => {\n tracing = getReactNativeTracingIntegration(client);\n if (tracing) {\n idleSpanOptions = {\n finalTimeout: tracing.options.finalTimeoutMs,\n idleTimeout: tracing.options.idleTimeoutMs,\n };\n }\n\n if (initialStateHandled) {\n // We create an initial state here to ensure a transaction gets created before the first route mounts.\n // This assumes that the Sentry.init() call is made before the first route mounts.\n // If this is not the case, the first transaction will be nameless 'Route Changed'\n return undefined;\n }\n\n getAppRegistryIntegration(client)?.onRunApplication(() => {\n if (initialStateHandled) {\n // To avoid conflict with the initial transaction we check if it was already handled.\n // This ensures runApplication calls after the initial start are correctly traced.\n // This is used for example when Activity is (re)started on Android.\n debug.log('[ReactNavigationIntegration] Starting new idle navigation span based on runApplication call.');\n startIdleNavigationSpan(undefined, true);\n }\n });\n\n isSetupComplete = true;\n\n if (!navigationContainer) {\n // This is expected as navigation container is registered after the root component is mounted.\n return undefined;\n }\n\n // Navigation container already registered, create and populate initial span\n startIdleNavigationSpan();\n updateLatestNavigationSpanWithCurrentRoute();\n initialStateHandled = true;\n };\n\n const registerNavigationContainer = (maybeNewNavigationContainer: unknown): void => {\n if (RN_GLOBAL_OBJ.__sentry_rn_v5_registered) {\n debug.log(`${INTEGRATION_NAME} Instrumentation already exists, but registering again...`);\n // In the past we have not allowed re-registering the navigation container to avoid unexpected behavior.\n // But this doesn't work for Android and re-recreating application main activity.\n // Where new navigation container is created and the old one is discarded. We need to re-register to\n // trace the new navigation container navigation.\n }\n\n let newNavigationContainer: NavigationContainer | undefined;\n if (isPlainObject(maybeNewNavigationContainer) && 'current' in maybeNewNavigationContainer) {\n newNavigationContainer = maybeNewNavigationContainer.current as NavigationContainer;\n } else {\n newNavigationContainer = maybeNewNavigationContainer as NavigationContainer;\n }\n\n if (navigationContainer === newNavigationContainer) {\n debug.log(`${INTEGRATION_NAME} Navigation container ref is the same as the one already registered.`);\n return;\n }\n navigationContainer = newNavigationContainer;\n\n if (!navigationContainer) {\n debug.warn(`${INTEGRATION_NAME} Received invalid navigation container ref!`);\n return undefined;\n }\n\n // This action is emitted on every dispatch\n navigationContainer.addListener('__unsafe_action__', startIdleNavigationSpan);\n navigationContainer.addListener('state', updateLatestNavigationSpanWithCurrentRoute);\n RN_GLOBAL_OBJ.__sentry_rn_v5_registered = true;\n\n if (initialStateHandled) {\n return undefined;\n }\n\n if (!latestNavigationSpan) {\n if (!isSetupComplete) {\n debug.log(\n `${INTEGRATION_NAME} Navigation container registered before integration setup. Initial span will be created when setup completes.`,\n );\n return undefined;\n }\n startIdleNavigationSpan();\n }\n\n // Navigation Container is registered after the first navigation\n // Initial navigation span was started, after integration setup,\n // so now we populate it with the current route.\n updateLatestNavigationSpanWithCurrentRoute();\n initialStateHandled = true;\n };\n\n /**\n * To be called on every React-Navigation action dispatch.\n * It does not name the transaction or populate it with route information. Instead, it waits for the state to fully change\n * and gets the route information from there, @see updateLatestNavigationSpanWithCurrentRoute\n *\n * @param unknownEvent - The event object that contains navigation action data\n * @param isAppRestart - Whether this span is being started due to an app restart rather than a normal navigation action\n */\n const startIdleNavigationSpan = (unknownEvent?: unknown, isAppRestart = false): void => {\n const event = unknownEvent as UnsafeAction | undefined;\n if (useDispatchedActionData && event?.data.noop) {\n debug.log(`${INTEGRATION_NAME} Navigation action is a noop, not starting navigation span.`);\n return;\n }\n\n const navigationActionType = useDispatchedActionData ? event?.data.action.type : undefined;\n\n // Handle PRELOAD actions separately if prefetch tracking is enabled\n if (enablePrefetchTracking && navigationActionType === 'PRELOAD') {\n const preloadData = event?.data.action;\n const payload = preloadData?.payload;\n const targetRoute =\n payload && typeof payload === 'object' && 'name' in payload && typeof payload.name === 'string'\n ? payload.name\n : 'Unknown Route';\n\n debug.log(`${INTEGRATION_NAME} Starting prefetch span for route: ${targetRoute}`);\n\n const prefetchSpan = startInactiveSpan({\n op: 'navigation.prefetch',\n name: `Prefetch ${targetRoute}`,\n attributes: {\n 'route.name': targetRoute,\n },\n });\n\n // Store prefetch span to end it when state changes or timeout\n navigationProcessingSpan = prefetchSpan;\n\n // Set timeout to ensure we don't leave hanging spans\n stateChangeTimeout = setTimeout(() => {\n if (navigationProcessingSpan === prefetchSpan) {\n debug.log(`${INTEGRATION_NAME} Prefetch span timed out for route: ${targetRoute}`);\n prefetchSpan?.setStatus({ code: SPAN_STATUS_OK });\n prefetchSpan?.end();\n navigationProcessingSpan = undefined;\n }\n }, routeChangeTimeoutMs);\n\n return;\n }\n\n if (\n useDispatchedActionData &&\n navigationActionType &&\n [\n // Process common actions\n 'PRELOAD', // Still filter PRELOAD when enablePrefetchTracking is false\n 'SET_PARAMS',\n // Drawer actions\n 'OPEN_DRAWER',\n 'CLOSE_DRAWER',\n 'TOGGLE_DRAWER',\n ].includes(navigationActionType)\n ) {\n debug.log(`${INTEGRATION_NAME} Navigation action is ${navigationActionType}, not starting navigation span.`);\n return;\n }\n\n if (latestNavigationSpan) {\n debug.log(`${INTEGRATION_NAME} A transaction was detected that turned out to be a noop, discarding.`);\n _discardLatestTransaction();\n clearStateChangeTimeout();\n }\n\n latestNavigationSpan = startGenericIdleNavigationSpan(\n tracing?.options.beforeStartSpan\n ? tracing.options.beforeStartSpan(getDefaultIdleNavigationSpanOptions())\n : getDefaultIdleNavigationSpanOptions(),\n { ...idleSpanOptions, isAppRestart },\n );\n latestNavigationSpan?.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NAVIGATION);\n latestNavigationSpan?.setAttribute(SEMANTIC_ATTRIBUTE_NAVIGATION_ACTION_TYPE, navigationActionType);\n if (ignoreEmptyBackNavigationTransactions) {\n ignoreEmptyBackNavigation(getClient(), latestNavigationSpan);\n }\n // Always discard transactions that never receive route information\n const spanToCheck = latestNavigationSpan;\n ignoreEmptyRouteChangeTransactions(\n getClient(),\n spanToCheck,\n DEFAULT_NAVIGATION_SPAN_NAME,\n () => latestNavigationSpan === spanToCheck,\n );\n\n if (enableTimeToInitialDisplay && latestNavigationSpan) {\n NATIVE.setActiveSpanId(latestNavigationSpan.spanContext().spanId);\n navigationProcessingSpan = startInactiveSpan({\n op: 'navigation.processing',\n name: 'Navigation dispatch to navigation cancelled or screen mounted',\n startTime: spanToJSON(latestNavigationSpan).start_timestamp,\n });\n navigationProcessingSpan.setAttribute(\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NAVIGATION,\n );\n }\n\n stateChangeTimeout = setTimeout(_discardLatestTransaction, routeChangeTimeoutMs);\n };\n\n /**\n * To be called AFTER the state has been changed to populate the transaction with the current route.\n */\n const updateLatestNavigationSpanWithCurrentRoute = (): void => {\n const stateChangedTimestamp = timestampInSeconds();\n const previousRoute = latestRoute;\n\n if (!navigationContainer) {\n debug.warn(`${INTEGRATION_NAME} Missing navigation container ref. Route transactions will not be sent.`);\n return undefined;\n }\n\n const route = navigationContainer.getCurrentRoute();\n if (!route) {\n debug.log(`[${INTEGRATION_NAME}] Navigation state changed, but no route is rendered.`);\n return undefined;\n }\n\n if (!latestNavigationSpan) {\n debug.log(\n `[${INTEGRATION_NAME}] Navigation state changed, but navigation transaction was not started on dispatch.`,\n );\n return undefined;\n }\n\n addTimeToInitialDisplayFallback(latestNavigationSpan.spanContext().spanId, NATIVE.getNewScreenTimeToDisplay());\n\n if (previousRoute && previousRoute.key === route.key) {\n debug.log(`[${INTEGRATION_NAME}] Navigation state changed, but route is the same as previous.`);\n pushRecentRouteKey(route.key);\n latestRoute = route;\n\n // Clear the latest transaction as it has been handled.\n latestNavigationSpan = undefined;\n return undefined;\n }\n\n const routeHasBeenSeen = recentRouteKeys.includes(route.key);\n\n // Get the full navigation path for nested navigators\n let routeName = route.name;\n if (useFullPathsForNavigationRoutes) {\n const navigationState = navigationContainer.getState();\n routeName = getPathFromState(navigationState) || route.name;\n }\n\n navigationProcessingSpan?.updateName(`Navigation dispatch to screen ${routeName} mounted`);\n navigationProcessingSpan?.setStatus({ code: SPAN_STATUS_OK });\n navigationProcessingSpan?.end(stateChangedTimestamp);\n navigationProcessingSpan = undefined;\n\n if (spanToJSON(latestNavigationSpan).description === DEFAULT_NAVIGATION_SPAN_NAME) {\n latestNavigationSpan.updateName(routeName);\n }\n const sendDefaultPii = getClient()?.getOptions()?.sendDefaultPii ?? false;\n latestNavigationSpan.setAttributes({\n 'route.name': routeName,\n 'route.key': route.key,\n ...(sendDefaultPii ? extractDynamicRouteParams(routeName, route.params) : undefined),\n 'route.has_been_seen': routeHasBeenSeen,\n 'previous_route.name': previousRoute?.name,\n 'previous_route.key': previousRoute?.key,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n });\n\n // Clear the timeout so the transaction does not get cancelled.\n clearStateChangeTimeout();\n\n addBreadcrumb({\n category: 'navigation',\n type: 'navigation',\n message: `Navigation to ${routeName}`,\n data: {\n from: previousRoute?.name,\n to: routeName,\n },\n });\n\n tracing?.setCurrentRoute(routeName);\n\n pushRecentRouteKey(route.key);\n if (useFullPathsForNavigationRoutes) {\n latestRoute = { ...route, name: routeName };\n } else {\n latestRoute = route;\n }\n // Clear the latest transaction as it has been handled.\n latestNavigationSpan = undefined;\n };\n\n /** Pushes a recent route key, and removes earlier routes when there is greater than the max length */\n const pushRecentRouteKey = (key: string): void => {\n recentRouteKeys.push(key);\n\n if (recentRouteKeys.length > NAVIGATION_HISTORY_MAX_SIZE) {\n recentRouteKeys = recentRouteKeys.slice(recentRouteKeys.length - NAVIGATION_HISTORY_MAX_SIZE);\n }\n };\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n const _discardLatestTransaction = (): void => {\n if (latestNavigationSpan) {\n if (isSentrySpan(latestNavigationSpan)) {\n latestNavigationSpan['_sampled'] = false;\n }\n // TODO: What if it's not SentrySpan?\n latestNavigationSpan.end();\n latestNavigationSpan = undefined;\n }\n if (navigationProcessingSpan) {\n navigationProcessingSpan = undefined;\n }\n };\n\n const clearStateChangeTimeout = (): void => {\n if (typeof stateChangeTimeout !== 'undefined') {\n clearTimeout(stateChangeTimeout);\n stateChangeTimeout = undefined;\n }\n };\n\n return {\n name: INTEGRATION_NAME,\n afterAllSetup,\n registerNavigationContainer,\n options: {\n routeChangeTimeoutMs,\n enableTimeToInitialDisplay,\n ignoreEmptyBackNavigationTransactions,\n enableTimeToInitialDisplayForPreloadedRoutes,\n useDispatchedActionData,\n useFullPathsForNavigationRoutes,\n enablePrefetchTracking,\n },\n };\n};\n\nexport interface NavigationRoute {\n name: string;\n key: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n params?: Record<string, any>;\n state?: NavigationState;\n}\n\ninterface NavigationState {\n index?: number;\n routes: NavigationRoute[];\n}\n\ninterface NavigationContainer {\n addListener: (type: string, listener: (event?: unknown) => void) => void;\n getCurrentRoute: () => NavigationRoute;\n getState: () => NavigationState | undefined;\n}\n\n/**\n * Returns React Navigation integration of the given client.\n */\nexport function getReactNavigationIntegration(\n client: Client,\n): ReturnType<typeof reactNavigationIntegration> | undefined {\n return client.getIntegrationByName<ReturnType<typeof reactNavigationIntegration>>(INTEGRATION_NAME);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MeasurementUnit, Span, SpanJSON, TransactionSource } from '@sentry/core';
|
|
1
|
+
import type { MeasurementUnit, Span, SpanJSON, StartSpanOptions, TransactionSource } from '@sentry/core';
|
|
2
2
|
export declare const defaultTransactionSource: TransactionSource;
|
|
3
3
|
export declare const customTransactionSource: TransactionSource;
|
|
4
4
|
/**
|
|
@@ -42,6 +42,32 @@ export declare function getBundleStartTimestampMs(): number | undefined;
|
|
|
42
42
|
* Creates valid span JSON object from the given data.
|
|
43
43
|
*/
|
|
44
44
|
export declare function createSpanJSON(from: Partial<SpanJSON> & Pick<Required<SpanJSON>, 'description' | 'start_timestamp' | 'timestamp' | 'origin'>): SpanJSON;
|
|
45
|
+
/**
|
|
46
|
+
* Wraps a function call that returns a `Promise` with an inactive span that
|
|
47
|
+
* is automatically ended on success or failure (both sync throws and async
|
|
48
|
+
* rejections).
|
|
49
|
+
*
|
|
50
|
+
* This is the standard pattern for instrumenting async SDK operations such as
|
|
51
|
+
* `Image.loadAsync` and `Asset.loadAsync`.
|
|
52
|
+
*
|
|
53
|
+
* The span status is always set by this utility (`ok` on resolve, `error` on
|
|
54
|
+
* reject or sync throw). If you need custom status logic (e.g. inspecting the
|
|
55
|
+
* resolved value), handle span lifecycle manually instead.
|
|
56
|
+
*
|
|
57
|
+
* @param spanOptions Options forwarded to `startInactiveSpan`.
|
|
58
|
+
* @param fn The function to call.
|
|
59
|
+
* @returns Whatever `fn` returns (the original `Promise`).
|
|
60
|
+
*/
|
|
61
|
+
export declare function traceAsyncOperation<T>(spanOptions: StartSpanOptions, fn: () => Promise<T>): Promise<T>;
|
|
62
|
+
/**
|
|
63
|
+
* Strips query string and fragment from a URL, preserving the scheme, host, and path.
|
|
64
|
+
*/
|
|
65
|
+
export declare function sanitizeUrl(url: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Extracts a short, human-readable description from a URL by stripping
|
|
68
|
+
* the query string, fragment, and path — returning only the filename.
|
|
69
|
+
*/
|
|
70
|
+
export declare function describeUrl(url: string): string;
|
|
45
71
|
/**
|
|
46
72
|
*
|
|
47
73
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/utils.ts"],"names":[],"mappings":"AAAA,O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