@datadog/mobile-react-navigation 2.14.1 → 3.0.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/README.md +40 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js +128 -65
- package/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/utils.js +31 -0
- package/lib/commonjs/rum/instrumentation/utils.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumReactNavigationTracking.js +127 -64
- package/lib/module/rum/instrumentation/DdRumReactNavigationTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/utils.js +25 -0
- package/lib/module/rum/instrumentation/utils.js.map +1 -0
- package/lib/typescript/core/src/DdAttributes.d.ts.map +1 -0
- package/lib/typescript/core/src/DdSdkReactNative.d.ts +49 -12
- package/lib/typescript/core/src/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/core/src/InternalLog.d.ts +1 -1
- package/lib/typescript/core/src/InternalLog.d.ts.map +1 -1
- package/lib/typescript/core/src/config/DatadogProviderConfiguration.d.ts +12 -0
- package/lib/typescript/core/src/config/DatadogProviderConfiguration.d.ts.map +1 -0
- package/lib/typescript/core/src/config/FileBasedConfiguration.d.ts +17 -0
- package/lib/typescript/core/src/config/FileBasedConfiguration.d.ts.map +1 -0
- package/lib/typescript/core/src/config/FileBasedConfiguration.type.d.ts +52 -0
- package/lib/typescript/core/src/config/FileBasedConfiguration.type.d.ts.map +1 -0
- package/lib/typescript/core/src/config/async/AutoInstrumentationConfiguration.d.ts +60 -0
- package/lib/typescript/core/src/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -0
- package/lib/typescript/core/src/config/async/PartialInitializationConfiguration.d.ts +47 -0
- package/lib/typescript/core/src/config/async/PartialInitializationConfiguration.d.ts.map +1 -0
- package/lib/typescript/core/src/config/async/asyncInitializationHelper.d.ts +5 -0
- package/lib/typescript/core/src/config/async/asyncInitializationHelper.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/CoreConfiguration.d.ts +52 -0
- package/lib/typescript/core/src/config/features/CoreConfiguration.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/CoreConfiguration.type.d.ts +90 -0
- package/lib/typescript/core/src/config/features/CoreConfiguration.type.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/CoreConfigurationNative.d.ts +54 -0
- package/lib/typescript/core/src/config/features/CoreConfigurationNative.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/LogsConfiguration.d.ts +17 -0
- package/lib/typescript/core/src/config/features/LogsConfiguration.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/LogsConfiguration.type.d.ts +24 -0
- package/lib/typescript/core/src/config/features/LogsConfiguration.type.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/LogsConfigurationNative.d.ts +6 -0
- package/lib/typescript/core/src/config/features/LogsConfigurationNative.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/RumConfiguration.d.ts +66 -0
- package/lib/typescript/core/src/config/features/RumConfiguration.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/RumConfiguration.type.d.ts +131 -0
- package/lib/typescript/core/src/config/features/RumConfiguration.type.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/RumConfigurationNative.d.ts +25 -0
- package/lib/typescript/core/src/config/features/RumConfigurationNative.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/TraceConfiguration.d.ts +10 -0
- package/lib/typescript/core/src/config/features/TraceConfiguration.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/TraceConfiguration.type.d.ts +11 -0
- package/lib/typescript/core/src/config/features/TraceConfiguration.type.d.ts.map +1 -0
- package/lib/typescript/core/src/config/features/TraceConfigurationNative.d.ts +4 -0
- package/lib/typescript/core/src/config/features/TraceConfigurationNative.d.ts.map +1 -0
- package/lib/typescript/core/src/config/types/BatchProcessingLevel.d.ts +18 -0
- package/lib/typescript/core/src/config/types/BatchProcessingLevel.d.ts.map +1 -0
- package/lib/typescript/core/src/config/types/BatchSize.d.ts +19 -0
- package/lib/typescript/core/src/config/types/BatchSize.d.ts.map +1 -0
- package/lib/typescript/core/src/config/types/InitializationMode.d.ts +5 -0
- package/lib/typescript/core/src/config/types/InitializationMode.d.ts.map +1 -0
- package/lib/typescript/core/src/config/types/InitializationModeForTelemetry.d.ts +2 -0
- package/lib/typescript/core/src/config/types/InitializationModeForTelemetry.d.ts.map +1 -0
- package/lib/typescript/core/src/config/types/ProxyConfiguration.d.ts.map +1 -0
- package/lib/typescript/core/src/config/types/SdkVerbosity.d.ts.map +1 -0
- package/lib/typescript/core/src/config/types/TrackingConsent.d.ts.map +1 -0
- package/lib/typescript/core/src/config/types/UploadFrequency.d.ts +18 -0
- package/lib/typescript/core/src/config/types/UploadFrequency.d.ts.map +1 -0
- package/lib/typescript/core/src/config/types/VitalsUpdateFrequency.d.ts +7 -0
- package/lib/typescript/core/src/config/types/VitalsUpdateFrequency.d.ts.map +1 -0
- package/lib/typescript/core/src/config/types/index.d.ts +10 -0
- package/lib/typescript/core/src/config/types/index.d.ts.map +1 -0
- package/lib/typescript/core/src/index.d.ts +20 -9
- package/lib/typescript/core/src/index.d.ts.map +1 -1
- package/lib/typescript/core/src/logs/DdLogs.d.ts +2 -1
- package/lib/typescript/core/src/logs/DdLogs.d.ts.map +1 -1
- package/lib/typescript/core/src/logs/eventMapper.d.ts +3 -2
- package/lib/typescript/core/src/logs/eventMapper.d.ts.map +1 -1
- package/lib/typescript/core/src/logs/types.d.ts +1 -16
- package/lib/typescript/core/src/logs/types.d.ts.map +1 -1
- package/lib/typescript/core/src/nativeModulesTypes.d.ts +2 -15
- package/lib/typescript/core/src/nativeModulesTypes.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/DdRum.d.ts +10 -1
- package/lib/typescript/core/src/rum/DdRum.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/eventMappers/errorEventMapper.d.ts +1 -1
- package/lib/typescript/core/src/rum/eventMappers/errorEventMapper.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/helper.d.ts +10 -0
- package/lib/typescript/core/src/rum/helper.d.ts.map +1 -0
- package/lib/typescript/core/src/rum/instrumentation/DdRumErrorTracking.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts +6 -6
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +7 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +12 -6
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.d.ts +1 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts +8 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +5 -17
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.d.ts +20 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.d.ts.map +1 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +3 -24
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.d.ts +12 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.d.ts.map +1 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/headers.d.ts +24 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/headers.d.ts.map +1 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +2 -1
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +1 -1
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts.map +1 -1
- package/lib/typescript/core/src/rum/types.d.ts +47 -7
- package/lib/typescript/core/src/rum/types.d.ts.map +1 -1
- package/lib/typescript/core/src/sdk/AccountInfoSingleton/AccountInfoSingleton.d.ts +15 -0
- package/lib/typescript/core/src/sdk/AccountInfoSingleton/AccountInfoSingleton.d.ts.map +1 -0
- package/lib/typescript/core/src/sdk/AccountInfoSingleton/types.d.ts +6 -0
- package/lib/typescript/core/src/sdk/AccountInfoSingleton/types.d.ts.map +1 -0
- package/lib/typescript/core/src/sdk/AttributesEncoding/attributesEncoding.d.ts +13 -0
- package/lib/typescript/core/src/sdk/AttributesEncoding/attributesEncoding.d.ts.map +1 -0
- package/lib/typescript/core/src/sdk/AttributesEncoding/defaultEncoders.d.ts +33 -0
- package/lib/typescript/core/src/sdk/AttributesEncoding/defaultEncoders.d.ts.map +1 -0
- package/lib/typescript/core/src/{utils → sdk/AttributesEncoding}/errorUtils.d.ts +4 -4
- package/lib/typescript/core/src/sdk/AttributesEncoding/errorUtils.d.ts.map +1 -0
- package/lib/typescript/core/src/sdk/AttributesEncoding/helpers.d.ts +17 -0
- package/lib/typescript/core/src/sdk/AttributesEncoding/helpers.d.ts.map +1 -0
- package/lib/typescript/core/src/sdk/AttributesEncoding/types.d.ts +21 -0
- package/lib/typescript/core/src/sdk/AttributesEncoding/types.d.ts.map +1 -0
- package/lib/typescript/core/src/sdk/AttributesEncoding/utils.d.ts +7 -0
- package/lib/typescript/core/src/sdk/AttributesEncoding/utils.d.ts.map +1 -0
- package/lib/typescript/core/src/sdk/AttributesSingleton/AttributesSingleton.d.ts +5 -1
- package/lib/typescript/core/src/sdk/AttributesSingleton/AttributesSingleton.d.ts.map +1 -1
- package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProvider.d.ts +4 -3
- package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProvider.d.ts.map +1 -1
- package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProviderState.d.ts +9 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProviderState.d.ts.map +1 -0
- package/lib/typescript/core/src/sdk/DdSdk.d.ts +2 -3
- package/lib/typescript/core/src/sdk/DdSdk.d.ts.map +1 -1
- package/lib/typescript/core/src/sdk/DdSdkInternal.d.ts +39 -0
- package/lib/typescript/core/src/sdk/DdSdkInternal.d.ts.map +1 -0
- package/lib/typescript/core/src/sdk/EventMappers/EventMapper.d.ts +3 -1
- package/lib/typescript/core/src/sdk/EventMappers/EventMapper.d.ts.map +1 -1
- package/lib/typescript/core/src/sdk/GlobalState/GlobalState.d.ts +3 -3
- package/lib/typescript/core/src/sdk/GlobalState/GlobalState.d.ts.map +1 -1
- package/lib/typescript/core/src/sdk/UserInfoSingleton/UserInfoSingleton.d.ts +2 -1
- package/lib/typescript/core/src/sdk/UserInfoSingleton/UserInfoSingleton.d.ts.map +1 -1
- package/lib/typescript/core/src/sdk/UserInfoSingleton/types.d.ts +1 -2
- package/lib/typescript/core/src/sdk/UserInfoSingleton/types.d.ts.map +1 -1
- package/lib/typescript/core/src/specs/NativeDdRum.d.ts +45 -0
- package/lib/typescript/core/src/specs/NativeDdRum.d.ts.map +1 -1
- package/lib/typescript/core/src/specs/NativeDdSdk.d.ts +34 -6
- package/lib/typescript/core/src/specs/NativeDdSdk.d.ts.map +1 -1
- package/lib/typescript/core/src/trace/DdTrace.d.ts +1 -2
- package/lib/typescript/core/src/trace/DdTrace.d.ts.map +1 -1
- package/lib/typescript/core/src/types.d.ts +74 -92
- package/lib/typescript/core/src/types.d.ts.map +1 -1
- package/lib/typescript/core/src/utils/longTasksUtils.d.ts +1 -1
- package/lib/typescript/core/src/utils/longTasksUtils.d.ts.map +1 -1
- package/lib/typescript/core/src/utils/singletonUtils.d.ts +2 -0
- package/lib/typescript/core/src/utils/singletonUtils.d.ts.map +1 -0
- package/lib/typescript/core/src/version.d.ts +1 -1
- package/lib/typescript/core/src/version.d.ts.map +1 -1
- package/lib/typescript/react-navigation/src/index.d.ts +2 -2
- package/lib/typescript/react-navigation/src/index.d.ts.map +1 -1
- package/lib/typescript/react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.d.ts +41 -24
- package/lib/typescript/react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.d.ts.map +1 -1
- package/lib/typescript/react-navigation/src/rum/instrumentation/utils.d.ts +13 -0
- package/lib/typescript/react-navigation/src/rum/instrumentation/utils.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/__tests__/rum/instrumentation/DdRumReactNavigationTracking.test.tsx +147 -14
- package/src/index.tsx +12 -2
- package/src/rum/instrumentation/DdRumReactNavigationTracking.tsx +168 -101
- package/src/rum/instrumentation/utils.ts +28 -0
- package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +0 -376
- package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts.map +0 -1
- package/lib/typescript/core/src/ProxyConfiguration.d.ts.map +0 -1
- package/lib/typescript/core/src/SdkVerbosity.d.ts.map +0 -1
- package/lib/typescript/core/src/TrackingConsent.d.ts.map +0 -1
- package/lib/typescript/core/src/rum/DdAttributes.d.ts.map +0 -1
- package/lib/typescript/core/src/rum/sessionId/sessionIdHelper.d.ts +0 -4
- package/lib/typescript/core/src/rum/sessionId/sessionIdHelper.d.ts.map +0 -1
- package/lib/typescript/core/src/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts +0 -34
- package/lib/typescript/core/src/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts.map +0 -1
- package/lib/typescript/core/src/utils/argsUtils.d.ts +0 -8
- package/lib/typescript/core/src/utils/argsUtils.d.ts.map +0 -1
- package/lib/typescript/core/src/utils/errorUtils.d.ts.map +0 -1
- /package/lib/typescript/core/src/{rum/DdAttributes.d.ts → DdAttributes.d.ts} +0 -0
- /package/lib/typescript/core/src/{ProxyConfiguration.d.ts → config/types/ProxyConfiguration.d.ts} +0 -0
- /package/lib/typescript/core/src/{SdkVerbosity.d.ts → config/types/SdkVerbosity.d.ts} +0 -0
- /package/lib/typescript/core/src/{TrackingConsent.d.ts → config/types/TrackingConsent.d.ts} +0 -0
package/lib/typescript/react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.d.ts
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
import type { StateEvent } from './NavigationTimeline';
|
|
2
2
|
import type { NavigationContainerRef, Route } from './react-navigation';
|
|
3
|
+
export type NavigationTrackingOptions = {
|
|
4
|
+
viewNamePredicate?: ViewNamePredicate;
|
|
5
|
+
viewTrackingPredicate?: ViewTrackingPredicate;
|
|
6
|
+
paramsTrackingPredicate?: ParamsTrackingPredicate;
|
|
7
|
+
};
|
|
3
8
|
export type ViewNamePredicate = (route: Route<string, any | undefined>, trackedName: string) => string | null;
|
|
9
|
+
export type ViewTrackingPredicate = (route: Route<string, any | undefined>) => boolean;
|
|
10
|
+
export type ParamsTrackingPredicate = (route: Route<string, any | undefined>) => object | undefined;
|
|
4
11
|
/**
|
|
5
12
|
* Provides RUM integration for the [ReactNavigation](https://reactnavigation.org/) API.
|
|
6
13
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
declare class RumReactNavigationTracking {
|
|
15
|
+
readonly ROUTE_UNDEFINED_NAVIGATION_WARNING_MESSAGE = "A navigation change was detected but the RUM ViewEvent was dropped as the route was undefined.";
|
|
16
|
+
readonly NULL_NAVIGATION_REF_ERROR_MESSAGE = "Cannot track views with a null navigationRef.";
|
|
17
|
+
readonly NAVIGATION_REF_IN_USE_ERROR_MESSAGE = "Cannot track new navigation container while another one is still tracked. Please call `DdRumReactNavigationTracking.stopTrackingViews` on the previous container reference.";
|
|
18
|
+
private _navigationTimeline?;
|
|
19
|
+
private get navigationTimeline();
|
|
20
|
+
private registeredContainer;
|
|
21
|
+
private navigationStateChangeListener;
|
|
22
|
+
private previousRoute;
|
|
23
|
+
private viewNamePredicate;
|
|
24
|
+
private viewTrackingPredicate;
|
|
25
|
+
private paramsTrackingPredicate;
|
|
26
|
+
private backHandler;
|
|
27
|
+
private appStateSubscription?;
|
|
28
|
+
private previousAppState;
|
|
29
|
+
private previousRouteKey;
|
|
30
|
+
private trackingState;
|
|
22
31
|
/**
|
|
23
32
|
* @internal
|
|
24
33
|
* DO NOT USE: This API is for internal testing only.
|
|
25
34
|
*/
|
|
26
|
-
|
|
35
|
+
__INTERNAL: {
|
|
27
36
|
/**
|
|
28
37
|
* @internal
|
|
29
38
|
* DO NOT USE: This API is for internal testing only.
|
|
@@ -35,21 +44,29 @@ export declare class DdRumReactNavigationTracking {
|
|
|
35
44
|
*/
|
|
36
45
|
_getNavigationTimeline: () => StateEvent[];
|
|
37
46
|
};
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
isAppExitingOnBackPress: () => boolean;
|
|
48
|
+
onBackPress: () => boolean;
|
|
40
49
|
/**
|
|
41
50
|
* Starts tracking the NavigationContainer and sends a RUM View event every time the navigation route changed.
|
|
42
51
|
* @param navigationRef the reference to the real NavigationContainer.
|
|
52
|
+
* @param trackingOptions the options object defining how views will be tracked. It contains:
|
|
53
|
+
* viewNamePredicate: the predicate to rename views.
|
|
54
|
+
* viewTrackingPredicate: the predicate to determine if a view should be tracked or not.
|
|
55
|
+
* paramsTrackingPredicate: the predicate to determine which parameters should be tracked for a given view.
|
|
43
56
|
*/
|
|
44
|
-
|
|
57
|
+
startTrackingViews(navigationRef: NavigationContainerRef | null, trackingOptions?: NavigationTrackingOptions): void;
|
|
45
58
|
/**
|
|
46
59
|
* Stops tracking the NavigationContainer.
|
|
47
60
|
* @param navigationRef the reference to the real NavigationContainer.
|
|
48
61
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
private
|
|
52
|
-
private
|
|
53
|
-
private
|
|
62
|
+
stopTrackingViews(navigationRef: NavigationContainerRef | null): void;
|
|
63
|
+
_resetInternalStateForTesting(): void;
|
|
64
|
+
private resetPredicates;
|
|
65
|
+
private handleRouteNavigation;
|
|
66
|
+
private handleAppStateChanged;
|
|
67
|
+
private resolveNavigationStateChangeListener;
|
|
68
|
+
private appStateListener;
|
|
54
69
|
}
|
|
70
|
+
export declare const DdRumReactNavigationTracking: RumReactNavigationTracking;
|
|
71
|
+
export {};
|
|
55
72
|
//# sourceMappingURL=DdRumReactNavigationTracking.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DdRumReactNavigationTracking.d.ts","sourceRoot":"","sources":["../../../../../../src/rum/instrumentation/DdRumReactNavigationTracking.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EACR,sBAAsB,EACtB,KAAK,EAER,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"DdRumReactNavigationTracking.d.ts","sourceRoot":"","sources":["../../../../../../src/rum/instrumentation/DdRumReactNavigationTracking.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EACR,sBAAsB,EACtB,KAAK,EAER,MAAM,oBAAoB,CAAC;AAwB5B,MAAM,MAAM,yBAAyB,GAAG;IACpC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAC5B,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,CAAC,EACrC,WAAW,EAAE,MAAM,KAClB,MAAM,GAAG,IAAI,CAAC;AAEnB,MAAM,MAAM,qBAAqB,GAAG,CAChC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,CAAC,KACpC,OAAO,CAAC;AAEb,MAAM,MAAM,uBAAuB,GAAG,CAClC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,CAAC,KACpC,MAAM,GAAG,SAAS,CAAC;AAiBxB;;GAEG;AACH,cAAM,0BAA0B;IAC5B,QAAQ,CAAC,0CAA0C,oGACkD;IACrG,QAAQ,CAAC,iCAAiC,mDACU;IACpD,QAAQ,CAAC,mCAAmC,iLACsI;IAElL,OAAO,CAAC,mBAAmB,CAAC,CAAqB;IACjD,OAAO,KAAK,kBAAkB,GAQ7B;IAED,OAAO,CAAC,mBAAmB,CAAuC;IAElE,OAAO,CAAC,6BAA6B,CAAmC;IAExE,OAAO,CAAC,aAAa,CAA0C;IAE/D,OAAO,CAAC,iBAAiB,CAA+C;IACxE,OAAO,CAAC,qBAAqB,CAAuD;IACpF,OAAO,CAAC,uBAAuB,CAAmD;IAElF,OAAO,CAAC,WAAW,CAAwC;IAE3D,OAAO,CAAC,oBAAoB,CAAC,CAA0B;IAEvD,OAAO,CAAC,gBAAgB,CAA6B;IAErD,OAAO,CAAC,gBAAgB,CAAqB;IAE7C,OAAO,CAAC,aAAa,CAA+C;IAEpE;;;OAGG;IACH,UAAU;QACN;;;WAGG;;QAEH;;;WAGG;;MAIL;IAEF,uBAAuB,QAAO,OAAO,CAQnC;IAEF,WAAW,gBAOT;IAEF;;;;;;;OAOG;IACH,kBAAkB,CACd,aAAa,EAAE,sBAAsB,GAAG,IAAI,EAC5C,eAAe,CAAC,EAAE,yBAAyB,GAC5C,IAAI;IAqDP;;;OAGG;IACH,iBAAiB,CAAC,aAAa,EAAE,sBAAsB,GAAG,IAAI,GAAG,IAAI;IAkCrE,6BAA6B,IAAI,IAAI;IAarC,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,qBAAqB;IA6C7B,OAAO,CAAC,qBAAqB;IA4C7B,OAAO,CAAC,oCAAoC;IA4C5C,OAAO,CAAC,gBAAgB,CAatB;CACL;AAED,eAAO,MAAM,4BAA4B,4BAGxC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms the view key format from 'ScreenName-uniqueId' to 'ScreenName/uniqueId'.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* // Input: key='Elements-lUQ9cId5lwk1o94euVh2B', screenName='Elements'
|
|
6
|
+
* // Output: 'Elements/lUQ9cId5lwk1o94euVh2B'
|
|
7
|
+
*
|
|
8
|
+
* @param key - The route key (e.g., 'Elements-lUQ9cId5lwk1o94euVh2B')
|
|
9
|
+
* @param screenName - The screen name (e.g., 'Elements')
|
|
10
|
+
* @returns The transformed key, or the original key if not in expected format
|
|
11
|
+
*/
|
|
12
|
+
export declare function transformViewKey(key: string, screenName: string | null): string;
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../src/rum/instrumentation/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC5B,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,GAAG,IAAI,GAC1B,MAAM,CAaR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-navigation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A client-side React Native module to interact with Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prepare": "rm -rf lib && yarn bob build"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@datadog/mobile-react-native": "^
|
|
39
|
+
"@datadog/mobile-react-native": "^3.0.0",
|
|
40
40
|
"@react-navigation/native-v5": "npm:@react-navigation/native@5.9.8",
|
|
41
41
|
"@react-navigation/native-v6": "npm:@react-navigation/native@6.1.2",
|
|
42
42
|
"@react-navigation/stack-v5": "npm:@react-navigation/stack@5.14.2",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
]
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "2a8f57a6b7fa68cfa8a03ae202d65ecc64e3e42d"
|
|
87
87
|
}
|
|
@@ -12,8 +12,13 @@ import mockBackHandler from 'react-native/Libraries/Utilities/__mocks__/BackHand
|
|
|
12
12
|
import { AppState, BackHandler } from 'react-native';
|
|
13
13
|
import React, { createRef } from 'react';
|
|
14
14
|
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
ParamsTrackingPredicate,
|
|
17
|
+
ViewNamePredicate,
|
|
18
|
+
ViewTrackingPredicate
|
|
19
|
+
} from '../../../rum/instrumentation/DdRumReactNavigationTracking';
|
|
16
20
|
import { DdRumReactNavigationTracking } from '../../../rum/instrumentation/DdRumReactNavigationTracking';
|
|
21
|
+
import { transformViewKey } from '../../../rum/instrumentation/utils';
|
|
17
22
|
|
|
18
23
|
import { AppStateMockLegacy } from './__utils__/AppStateMockLegacy';
|
|
19
24
|
import { AppStateMock } from './__utils__/AppStateMock';
|
|
@@ -82,9 +87,7 @@ beforeEach(() => {
|
|
|
82
87
|
mocked(BackHandler.exitApp).mockClear();
|
|
83
88
|
|
|
84
89
|
// @ts-ignore
|
|
85
|
-
DdRumReactNavigationTracking.
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
DdRumReactNavigationTracking.navigationStateChangeListener = null;
|
|
90
|
+
DdRumReactNavigationTracking._resetInternalStateForTesting();
|
|
88
91
|
});
|
|
89
92
|
|
|
90
93
|
// Unit tests
|
|
@@ -164,7 +167,9 @@ describe.each([
|
|
|
164
167
|
};
|
|
165
168
|
DdRumReactNavigationTracking.startTrackingViews(
|
|
166
169
|
navigationRef.current,
|
|
167
|
-
|
|
170
|
+
{
|
|
171
|
+
viewNamePredicate: predicate
|
|
172
|
+
}
|
|
168
173
|
);
|
|
169
174
|
|
|
170
175
|
// WHEN
|
|
@@ -196,7 +201,9 @@ describe.each([
|
|
|
196
201
|
|
|
197
202
|
DdRumReactNavigationTracking.startTrackingViews(
|
|
198
203
|
navigationRef.current,
|
|
199
|
-
|
|
204
|
+
{
|
|
205
|
+
viewNamePredicate: predicate
|
|
206
|
+
}
|
|
200
207
|
);
|
|
201
208
|
|
|
202
209
|
// WHEN
|
|
@@ -207,6 +214,126 @@ describe.each([
|
|
|
207
214
|
expect(DdRum.startView).not.toHaveBeenCalled();
|
|
208
215
|
});
|
|
209
216
|
|
|
217
|
+
it('sends a related RUM ViewEvent when switching screens { viewTrackingPredicate returns true }', async () => {
|
|
218
|
+
// GIVEN
|
|
219
|
+
const navigationRef = createRef<any>();
|
|
220
|
+
const { getByText } = render(
|
|
221
|
+
<FakeNavigator1 navigationRef={navigationRef} />
|
|
222
|
+
);
|
|
223
|
+
const goToAboutButton = getByText('Go to About');
|
|
224
|
+
|
|
225
|
+
// eslint-disable-next-line func-names
|
|
226
|
+
const predicate: ViewTrackingPredicate = function (
|
|
227
|
+
_route: Route<string, any | undefined>
|
|
228
|
+
) {
|
|
229
|
+
return true;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
DdRumReactNavigationTracking.startTrackingViews(
|
|
233
|
+
navigationRef.current,
|
|
234
|
+
{
|
|
235
|
+
viewTrackingPredicate: predicate
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
// WHEN
|
|
240
|
+
expect(goToAboutButton).toBeTruthy();
|
|
241
|
+
fireEvent(goToAboutButton, 'press');
|
|
242
|
+
|
|
243
|
+
// THEN
|
|
244
|
+
expect(DdRum.startView).toHaveBeenCalledTimes(2);
|
|
245
|
+
expect(DdRum.startView).toHaveBeenCalledWith(
|
|
246
|
+
expect.any(String),
|
|
247
|
+
'Home'
|
|
248
|
+
);
|
|
249
|
+
expect(DdRum.startView).toHaveBeenCalledWith(
|
|
250
|
+
expect.any(String),
|
|
251
|
+
'About'
|
|
252
|
+
);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('sends a related RUM ViewEvent when switching screens { viewTrackingPredicate returns true for Home screen only }', async () => {
|
|
256
|
+
// GIVEN
|
|
257
|
+
const navigationRef = createRef<any>();
|
|
258
|
+
const { getByText } = render(
|
|
259
|
+
<FakeNavigator1 navigationRef={navigationRef} />
|
|
260
|
+
);
|
|
261
|
+
const goToAboutButton = getByText('Go to About');
|
|
262
|
+
|
|
263
|
+
// eslint-disable-next-line func-names
|
|
264
|
+
const predicate: ViewTrackingPredicate = function (
|
|
265
|
+
_route: Route<string, any | undefined>
|
|
266
|
+
) {
|
|
267
|
+
return _route.name === 'Home';
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
DdRumReactNavigationTracking.startTrackingViews(
|
|
271
|
+
navigationRef.current,
|
|
272
|
+
{
|
|
273
|
+
viewTrackingPredicate: predicate
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
// WHEN
|
|
278
|
+
expect(goToAboutButton).toBeTruthy();
|
|
279
|
+
fireEvent(goToAboutButton, 'press');
|
|
280
|
+
|
|
281
|
+
// THEN
|
|
282
|
+
expect(DdRum.startView).toHaveBeenCalledTimes(1);
|
|
283
|
+
expect(DdRum.startView).toHaveBeenCalledWith(
|
|
284
|
+
expect.any(String),
|
|
285
|
+
'Home'
|
|
286
|
+
);
|
|
287
|
+
expect(DdRum.startView).not.toHaveBeenCalledWith(
|
|
288
|
+
expect.any(String),
|
|
289
|
+
'About'
|
|
290
|
+
);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('sends a related RUM ViewEvent when switching screens { viewParamsPredicate returns params object }', async () => {
|
|
294
|
+
// GIVEN
|
|
295
|
+
const navigationRef = createRef<any>();
|
|
296
|
+
const { getByText } = render(
|
|
297
|
+
<FakeNavigator1 navigationRef={navigationRef} />
|
|
298
|
+
);
|
|
299
|
+
const goToAboutButton = getByText('Go to About');
|
|
300
|
+
const testParams = {
|
|
301
|
+
param1: true,
|
|
302
|
+
param2: 'abc'
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// eslint-disable-next-line func-names
|
|
306
|
+
const predicate: ParamsTrackingPredicate = function (
|
|
307
|
+
_route: Route<string, any | undefined>
|
|
308
|
+
) {
|
|
309
|
+
return testParams;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
DdRumReactNavigationTracking.startTrackingViews(
|
|
313
|
+
navigationRef.current,
|
|
314
|
+
{
|
|
315
|
+
paramsTrackingPredicate: predicate
|
|
316
|
+
}
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
// WHEN
|
|
320
|
+
expect(goToAboutButton).toBeTruthy();
|
|
321
|
+
fireEvent(goToAboutButton, 'press');
|
|
322
|
+
|
|
323
|
+
// THEN
|
|
324
|
+
expect(DdRum.startView).toHaveBeenCalledTimes(2);
|
|
325
|
+
expect(DdRum.startView).toHaveBeenCalledWith(
|
|
326
|
+
expect.any(String),
|
|
327
|
+
'Home',
|
|
328
|
+
{ params: testParams }
|
|
329
|
+
);
|
|
330
|
+
expect(DdRum.startView).toHaveBeenCalledWith(
|
|
331
|
+
expect.any(String),
|
|
332
|
+
'About',
|
|
333
|
+
{ params: testParams }
|
|
334
|
+
);
|
|
335
|
+
});
|
|
336
|
+
|
|
210
337
|
it('only registers once when startTrackingViews{ multiple times }', async () => {
|
|
211
338
|
// GIVEN
|
|
212
339
|
const navigationRef = createRef<any>();
|
|
@@ -229,7 +356,7 @@ describe.each([
|
|
|
229
356
|
expect(DdRum.startView).toHaveBeenCalledTimes(2);
|
|
230
357
|
});
|
|
231
358
|
|
|
232
|
-
it('does nothing when startTrackingViews { undefined any ', async () => {
|
|
359
|
+
it('does nothing when startTrackingViews { undefined any }', async () => {
|
|
233
360
|
// WHEN
|
|
234
361
|
DdRumReactNavigationTracking.startTrackingViews(null);
|
|
235
362
|
|
|
@@ -373,11 +500,14 @@ describe.each([
|
|
|
373
500
|
// THEN
|
|
374
501
|
expect(DdRum.startView).toHaveBeenCalledTimes(4);
|
|
375
502
|
expect(DdRum.startView).toHaveBeenCalledWith(
|
|
376
|
-
navigationRef2StartRoute.key,
|
|
503
|
+
transformViewKey(navigationRef2StartRoute.key, 'Home'),
|
|
377
504
|
'Home'
|
|
378
505
|
);
|
|
379
506
|
expect(DdRum.startView).toHaveBeenCalledWith(
|
|
380
|
-
|
|
507
|
+
transformViewKey(
|
|
508
|
+
navigationRef2.current?.getCurrentRoute()?.key,
|
|
509
|
+
'About'
|
|
510
|
+
),
|
|
381
511
|
'About'
|
|
382
512
|
);
|
|
383
513
|
});
|
|
@@ -474,12 +604,15 @@ describe.each([
|
|
|
474
604
|
|
|
475
605
|
// THEN
|
|
476
606
|
expect(DdRum.stopView).toHaveBeenCalledTimes(1);
|
|
477
|
-
|
|
478
|
-
|
|
607
|
+
|
|
608
|
+
const currentRoute = navigationRef.current?.getCurrentRoute();
|
|
609
|
+
const transformedKey = transformViewKey(
|
|
610
|
+
currentRoute?.key,
|
|
611
|
+
currentRoute?.name
|
|
479
612
|
);
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
).toBe('string');
|
|
613
|
+
|
|
614
|
+
expect(DdRum.stopView).toHaveBeenCalledWith(transformedKey);
|
|
615
|
+
expect(typeof transformedKey).toBe('string');
|
|
483
616
|
});
|
|
484
617
|
|
|
485
618
|
it('restarts last view when app goes into foreground', async () => {
|
package/src/index.tsx
CHANGED
|
@@ -4,9 +4,19 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
NavigationTrackingOptions,
|
|
9
|
+
ViewNamePredicate,
|
|
10
|
+
ViewTrackingPredicate,
|
|
11
|
+
ParamsTrackingPredicate
|
|
12
|
+
} from './rum/instrumentation/DdRumReactNavigationTracking';
|
|
8
13
|
import { DdRumReactNavigationTracking } from './rum/instrumentation/DdRumReactNavigationTracking';
|
|
9
14
|
|
|
10
15
|
export { DdRumReactNavigationTracking };
|
|
11
16
|
|
|
12
|
-
export type {
|
|
17
|
+
export type {
|
|
18
|
+
NavigationTrackingOptions,
|
|
19
|
+
ViewNamePredicate,
|
|
20
|
+
ViewTrackingPredicate,
|
|
21
|
+
ParamsTrackingPredicate
|
|
22
|
+
};
|