@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.
Files changed (189) hide show
  1. package/README.md +40 -5
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js +128 -65
  4. package/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js.map +1 -1
  5. package/lib/commonjs/rum/instrumentation/utils.js +31 -0
  6. package/lib/commonjs/rum/instrumentation/utils.js.map +1 -0
  7. package/lib/module/index.js.map +1 -1
  8. package/lib/module/rum/instrumentation/DdRumReactNavigationTracking.js +127 -64
  9. package/lib/module/rum/instrumentation/DdRumReactNavigationTracking.js.map +1 -1
  10. package/lib/module/rum/instrumentation/utils.js +25 -0
  11. package/lib/module/rum/instrumentation/utils.js.map +1 -0
  12. package/lib/typescript/core/src/DdAttributes.d.ts.map +1 -0
  13. package/lib/typescript/core/src/DdSdkReactNative.d.ts +49 -12
  14. package/lib/typescript/core/src/DdSdkReactNative.d.ts.map +1 -1
  15. package/lib/typescript/core/src/InternalLog.d.ts +1 -1
  16. package/lib/typescript/core/src/InternalLog.d.ts.map +1 -1
  17. package/lib/typescript/core/src/config/DatadogProviderConfiguration.d.ts +12 -0
  18. package/lib/typescript/core/src/config/DatadogProviderConfiguration.d.ts.map +1 -0
  19. package/lib/typescript/core/src/config/FileBasedConfiguration.d.ts +17 -0
  20. package/lib/typescript/core/src/config/FileBasedConfiguration.d.ts.map +1 -0
  21. package/lib/typescript/core/src/config/FileBasedConfiguration.type.d.ts +52 -0
  22. package/lib/typescript/core/src/config/FileBasedConfiguration.type.d.ts.map +1 -0
  23. package/lib/typescript/core/src/config/async/AutoInstrumentationConfiguration.d.ts +60 -0
  24. package/lib/typescript/core/src/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -0
  25. package/lib/typescript/core/src/config/async/PartialInitializationConfiguration.d.ts +47 -0
  26. package/lib/typescript/core/src/config/async/PartialInitializationConfiguration.d.ts.map +1 -0
  27. package/lib/typescript/core/src/config/async/asyncInitializationHelper.d.ts +5 -0
  28. package/lib/typescript/core/src/config/async/asyncInitializationHelper.d.ts.map +1 -0
  29. package/lib/typescript/core/src/config/features/CoreConfiguration.d.ts +52 -0
  30. package/lib/typescript/core/src/config/features/CoreConfiguration.d.ts.map +1 -0
  31. package/lib/typescript/core/src/config/features/CoreConfiguration.type.d.ts +90 -0
  32. package/lib/typescript/core/src/config/features/CoreConfiguration.type.d.ts.map +1 -0
  33. package/lib/typescript/core/src/config/features/CoreConfigurationNative.d.ts +54 -0
  34. package/lib/typescript/core/src/config/features/CoreConfigurationNative.d.ts.map +1 -0
  35. package/lib/typescript/core/src/config/features/LogsConfiguration.d.ts +17 -0
  36. package/lib/typescript/core/src/config/features/LogsConfiguration.d.ts.map +1 -0
  37. package/lib/typescript/core/src/config/features/LogsConfiguration.type.d.ts +24 -0
  38. package/lib/typescript/core/src/config/features/LogsConfiguration.type.d.ts.map +1 -0
  39. package/lib/typescript/core/src/config/features/LogsConfigurationNative.d.ts +6 -0
  40. package/lib/typescript/core/src/config/features/LogsConfigurationNative.d.ts.map +1 -0
  41. package/lib/typescript/core/src/config/features/RumConfiguration.d.ts +66 -0
  42. package/lib/typescript/core/src/config/features/RumConfiguration.d.ts.map +1 -0
  43. package/lib/typescript/core/src/config/features/RumConfiguration.type.d.ts +131 -0
  44. package/lib/typescript/core/src/config/features/RumConfiguration.type.d.ts.map +1 -0
  45. package/lib/typescript/core/src/config/features/RumConfigurationNative.d.ts +25 -0
  46. package/lib/typescript/core/src/config/features/RumConfigurationNative.d.ts.map +1 -0
  47. package/lib/typescript/core/src/config/features/TraceConfiguration.d.ts +10 -0
  48. package/lib/typescript/core/src/config/features/TraceConfiguration.d.ts.map +1 -0
  49. package/lib/typescript/core/src/config/features/TraceConfiguration.type.d.ts +11 -0
  50. package/lib/typescript/core/src/config/features/TraceConfiguration.type.d.ts.map +1 -0
  51. package/lib/typescript/core/src/config/features/TraceConfigurationNative.d.ts +4 -0
  52. package/lib/typescript/core/src/config/features/TraceConfigurationNative.d.ts.map +1 -0
  53. package/lib/typescript/core/src/config/types/BatchProcessingLevel.d.ts +18 -0
  54. package/lib/typescript/core/src/config/types/BatchProcessingLevel.d.ts.map +1 -0
  55. package/lib/typescript/core/src/config/types/BatchSize.d.ts +19 -0
  56. package/lib/typescript/core/src/config/types/BatchSize.d.ts.map +1 -0
  57. package/lib/typescript/core/src/config/types/InitializationMode.d.ts +5 -0
  58. package/lib/typescript/core/src/config/types/InitializationMode.d.ts.map +1 -0
  59. package/lib/typescript/core/src/config/types/InitializationModeForTelemetry.d.ts +2 -0
  60. package/lib/typescript/core/src/config/types/InitializationModeForTelemetry.d.ts.map +1 -0
  61. package/lib/typescript/core/src/config/types/ProxyConfiguration.d.ts.map +1 -0
  62. package/lib/typescript/core/src/config/types/SdkVerbosity.d.ts.map +1 -0
  63. package/lib/typescript/core/src/config/types/TrackingConsent.d.ts.map +1 -0
  64. package/lib/typescript/core/src/config/types/UploadFrequency.d.ts +18 -0
  65. package/lib/typescript/core/src/config/types/UploadFrequency.d.ts.map +1 -0
  66. package/lib/typescript/core/src/config/types/VitalsUpdateFrequency.d.ts +7 -0
  67. package/lib/typescript/core/src/config/types/VitalsUpdateFrequency.d.ts.map +1 -0
  68. package/lib/typescript/core/src/config/types/index.d.ts +10 -0
  69. package/lib/typescript/core/src/config/types/index.d.ts.map +1 -0
  70. package/lib/typescript/core/src/index.d.ts +20 -9
  71. package/lib/typescript/core/src/index.d.ts.map +1 -1
  72. package/lib/typescript/core/src/logs/DdLogs.d.ts +2 -1
  73. package/lib/typescript/core/src/logs/DdLogs.d.ts.map +1 -1
  74. package/lib/typescript/core/src/logs/eventMapper.d.ts +3 -2
  75. package/lib/typescript/core/src/logs/eventMapper.d.ts.map +1 -1
  76. package/lib/typescript/core/src/logs/types.d.ts +1 -16
  77. package/lib/typescript/core/src/logs/types.d.ts.map +1 -1
  78. package/lib/typescript/core/src/nativeModulesTypes.d.ts +2 -15
  79. package/lib/typescript/core/src/nativeModulesTypes.d.ts.map +1 -1
  80. package/lib/typescript/core/src/rum/DdRum.d.ts +10 -1
  81. package/lib/typescript/core/src/rum/DdRum.d.ts.map +1 -1
  82. package/lib/typescript/core/src/rum/eventMappers/errorEventMapper.d.ts +1 -1
  83. package/lib/typescript/core/src/rum/eventMappers/errorEventMapper.d.ts.map +1 -1
  84. package/lib/typescript/core/src/rum/helper.d.ts +10 -0
  85. package/lib/typescript/core/src/rum/helper.d.ts.map +1 -0
  86. package/lib/typescript/core/src/rum/instrumentation/DdRumErrorTracking.d.ts.map +1 -1
  87. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts +6 -6
  88. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts.map +1 -1
  89. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +7 -0
  90. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts.map +1 -1
  91. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +12 -6
  92. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts.map +1 -1
  93. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.d.ts +1 -0
  94. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/DatadogTracingContext.d.ts.map +1 -1
  95. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts +8 -0
  96. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts.map +1 -1
  97. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +5 -17
  98. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts.map +1 -1
  99. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.d.ts +20 -0
  100. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingAttributes.d.ts.map +1 -0
  101. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +3 -24
  102. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts.map +1 -1
  103. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.d.ts +12 -0
  104. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingSampling.d.ts.map +1 -0
  105. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/headers.d.ts +24 -0
  106. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/headers.d.ts.map +1 -0
  107. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +2 -1
  108. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts.map +1 -1
  109. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.d.ts.map +1 -1
  110. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +1 -1
  111. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts.map +1 -1
  112. package/lib/typescript/core/src/rum/types.d.ts +47 -7
  113. package/lib/typescript/core/src/rum/types.d.ts.map +1 -1
  114. package/lib/typescript/core/src/sdk/AccountInfoSingleton/AccountInfoSingleton.d.ts +15 -0
  115. package/lib/typescript/core/src/sdk/AccountInfoSingleton/AccountInfoSingleton.d.ts.map +1 -0
  116. package/lib/typescript/core/src/sdk/AccountInfoSingleton/types.d.ts +6 -0
  117. package/lib/typescript/core/src/sdk/AccountInfoSingleton/types.d.ts.map +1 -0
  118. package/lib/typescript/core/src/sdk/AttributesEncoding/attributesEncoding.d.ts +13 -0
  119. package/lib/typescript/core/src/sdk/AttributesEncoding/attributesEncoding.d.ts.map +1 -0
  120. package/lib/typescript/core/src/sdk/AttributesEncoding/defaultEncoders.d.ts +33 -0
  121. package/lib/typescript/core/src/sdk/AttributesEncoding/defaultEncoders.d.ts.map +1 -0
  122. package/lib/typescript/core/src/{utils → sdk/AttributesEncoding}/errorUtils.d.ts +4 -4
  123. package/lib/typescript/core/src/sdk/AttributesEncoding/errorUtils.d.ts.map +1 -0
  124. package/lib/typescript/core/src/sdk/AttributesEncoding/helpers.d.ts +17 -0
  125. package/lib/typescript/core/src/sdk/AttributesEncoding/helpers.d.ts.map +1 -0
  126. package/lib/typescript/core/src/sdk/AttributesEncoding/types.d.ts +21 -0
  127. package/lib/typescript/core/src/sdk/AttributesEncoding/types.d.ts.map +1 -0
  128. package/lib/typescript/core/src/sdk/AttributesEncoding/utils.d.ts +7 -0
  129. package/lib/typescript/core/src/sdk/AttributesEncoding/utils.d.ts.map +1 -0
  130. package/lib/typescript/core/src/sdk/AttributesSingleton/AttributesSingleton.d.ts +5 -1
  131. package/lib/typescript/core/src/sdk/AttributesSingleton/AttributesSingleton.d.ts.map +1 -1
  132. package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProvider.d.ts +4 -3
  133. package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProvider.d.ts.map +1 -1
  134. package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProviderState.d.ts +9 -0
  135. package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProviderState.d.ts.map +1 -0
  136. package/lib/typescript/core/src/sdk/DdSdk.d.ts +2 -3
  137. package/lib/typescript/core/src/sdk/DdSdk.d.ts.map +1 -1
  138. package/lib/typescript/core/src/sdk/DdSdkInternal.d.ts +39 -0
  139. package/lib/typescript/core/src/sdk/DdSdkInternal.d.ts.map +1 -0
  140. package/lib/typescript/core/src/sdk/EventMappers/EventMapper.d.ts +3 -1
  141. package/lib/typescript/core/src/sdk/EventMappers/EventMapper.d.ts.map +1 -1
  142. package/lib/typescript/core/src/sdk/GlobalState/GlobalState.d.ts +3 -3
  143. package/lib/typescript/core/src/sdk/GlobalState/GlobalState.d.ts.map +1 -1
  144. package/lib/typescript/core/src/sdk/UserInfoSingleton/UserInfoSingleton.d.ts +2 -1
  145. package/lib/typescript/core/src/sdk/UserInfoSingleton/UserInfoSingleton.d.ts.map +1 -1
  146. package/lib/typescript/core/src/sdk/UserInfoSingleton/types.d.ts +1 -2
  147. package/lib/typescript/core/src/sdk/UserInfoSingleton/types.d.ts.map +1 -1
  148. package/lib/typescript/core/src/specs/NativeDdRum.d.ts +45 -0
  149. package/lib/typescript/core/src/specs/NativeDdRum.d.ts.map +1 -1
  150. package/lib/typescript/core/src/specs/NativeDdSdk.d.ts +34 -6
  151. package/lib/typescript/core/src/specs/NativeDdSdk.d.ts.map +1 -1
  152. package/lib/typescript/core/src/trace/DdTrace.d.ts +1 -2
  153. package/lib/typescript/core/src/trace/DdTrace.d.ts.map +1 -1
  154. package/lib/typescript/core/src/types.d.ts +74 -92
  155. package/lib/typescript/core/src/types.d.ts.map +1 -1
  156. package/lib/typescript/core/src/utils/longTasksUtils.d.ts +1 -1
  157. package/lib/typescript/core/src/utils/longTasksUtils.d.ts.map +1 -1
  158. package/lib/typescript/core/src/utils/singletonUtils.d.ts +2 -0
  159. package/lib/typescript/core/src/utils/singletonUtils.d.ts.map +1 -0
  160. package/lib/typescript/core/src/version.d.ts +1 -1
  161. package/lib/typescript/core/src/version.d.ts.map +1 -1
  162. package/lib/typescript/react-navigation/src/index.d.ts +2 -2
  163. package/lib/typescript/react-navigation/src/index.d.ts.map +1 -1
  164. package/lib/typescript/react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.d.ts +41 -24
  165. package/lib/typescript/react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.d.ts.map +1 -1
  166. package/lib/typescript/react-navigation/src/rum/instrumentation/utils.d.ts +13 -0
  167. package/lib/typescript/react-navigation/src/rum/instrumentation/utils.d.ts.map +1 -0
  168. package/package.json +3 -3
  169. package/src/__tests__/rum/instrumentation/DdRumReactNavigationTracking.test.tsx +147 -14
  170. package/src/index.tsx +12 -2
  171. package/src/rum/instrumentation/DdRumReactNavigationTracking.tsx +168 -101
  172. package/src/rum/instrumentation/utils.ts +28 -0
  173. package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +0 -376
  174. package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts.map +0 -1
  175. package/lib/typescript/core/src/ProxyConfiguration.d.ts.map +0 -1
  176. package/lib/typescript/core/src/SdkVerbosity.d.ts.map +0 -1
  177. package/lib/typescript/core/src/TrackingConsent.d.ts.map +0 -1
  178. package/lib/typescript/core/src/rum/DdAttributes.d.ts.map +0 -1
  179. package/lib/typescript/core/src/rum/sessionId/sessionIdHelper.d.ts +0 -4
  180. package/lib/typescript/core/src/rum/sessionId/sessionIdHelper.d.ts.map +0 -1
  181. package/lib/typescript/core/src/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts +0 -34
  182. package/lib/typescript/core/src/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts.map +0 -1
  183. package/lib/typescript/core/src/utils/argsUtils.d.ts +0 -8
  184. package/lib/typescript/core/src/utils/argsUtils.d.ts.map +0 -1
  185. package/lib/typescript/core/src/utils/errorUtils.d.ts.map +0 -1
  186. /package/lib/typescript/core/src/{rum/DdAttributes.d.ts → DdAttributes.d.ts} +0 -0
  187. /package/lib/typescript/core/src/{ProxyConfiguration.d.ts → config/types/ProxyConfiguration.d.ts} +0 -0
  188. /package/lib/typescript/core/src/{SdkVerbosity.d.ts → config/types/SdkVerbosity.d.ts} +0 -0
  189. /package/lib/typescript/core/src/{TrackingConsent.d.ts → config/types/TrackingConsent.d.ts} +0 -0
@@ -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
- export declare class DdRumReactNavigationTracking {
8
- private static _navigationTimeline?;
9
- private static get navigationTimeline();
10
- private static registeredContainer;
11
- private static navigationStateChangeListener;
12
- private static previousRoute;
13
- private static viewNamePredicate;
14
- private static backHandler;
15
- private static appStateSubscription?;
16
- private static previousAppState;
17
- private static previousRouteKey;
18
- private static trackingState;
19
- static ROUTE_UNDEFINED_NAVIGATION_WARNING_MESSAGE: string;
20
- static NULL_NAVIGATION_REF_ERROR_MESSAGE: string;
21
- static NAVIGATION_REF_IN_USE_ERROR_MESSAGE: string;
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
- static __INTERNAL: {
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
- static isAppExitingOnBackPress: () => boolean;
39
- static onBackPress: () => boolean;
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
- static startTrackingViews(navigationRef: NavigationContainerRef | null, viewNamePredicate?: ViewNamePredicate): void;
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
- static stopTrackingViews(navigationRef: NavigationContainerRef | null): void;
50
- private static handleRouteNavigation;
51
- private static handleAppStateChanged;
52
- private static resolveNavigationStateChangeListener;
53
- private static appStateListener;
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;AAU5B,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;;GAEG;AACH,qBAAa,4BAA4B;IACrC,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAqB;IACxD,OAAO,CAAC,MAAM,KAAK,kBAAkB,GAQpC;IAED,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAgC;IAElE,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAmC;IAE/E,OAAO,CAAC,MAAM,CAAC,aAAa,CAA0C;IAEtE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAoB;IAEpD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAiC;IAE3D,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAA0B;IAE9D,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAA6B;IAE5D,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAqB;IAEpD,OAAO,CAAC,MAAM,CAAC,aAAa,CAA+C;IAE3E,MAAM,CAAC,0CAA0C,SACoD;IACrG,MAAM,CAAC,iCAAiC,SACY;IACpD,MAAM,CAAC,mCAAmC,SACwI;IAElL;;;OAGG;IACH,MAAM,CAAC,UAAU;QACb;;;WAGG;;QAEH;;;WAGG;;MAIL;IAEF,MAAM,CAAC,uBAAuB,QAAO,OAAO,CAQ1C;IAEF,MAAM,CAAC,WAAW,gBAShB;IAEF;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CACrB,aAAa,EAAE,sBAAsB,GAAG,IAAI,EAG5C,iBAAiB,GAAE,iBAKlB,GACF,IAAI;IAqCP;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CACpB,aAAa,EAAE,sBAAsB,GAAG,IAAI,GAC7C,IAAI;IA2CP,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAwCpC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IA8CpC,OAAO,CAAC,MAAM,CAAC,oCAAoC;IA8CnD,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAgB7B;CACL"}
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": "2.14.1",
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": "^2.14.1",
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": "ceddd4c317a90a7b19409146690022cd6889cb26"
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 { ViewNamePredicate } from '../../../rum/instrumentation/DdRumReactNavigationTracking';
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.registeredContainer = null;
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
- predicate
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
- predicate
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
- navigationRef2.current?.getCurrentRoute()?.key,
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
- expect(DdRum.stopView).toHaveBeenCalledWith(
478
- navigationRef.current?.getCurrentRoute()?.key
607
+
608
+ const currentRoute = navigationRef.current?.getCurrentRoute();
609
+ const transformedKey = transformViewKey(
610
+ currentRoute?.key,
611
+ currentRoute?.name
479
612
  );
480
- expect(
481
- typeof navigationRef.current?.getCurrentRoute()?.key
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 { ViewNamePredicate } from './rum/instrumentation/DdRumReactNavigationTracking';
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 { ViewNamePredicate };
17
+ export type {
18
+ NavigationTrackingOptions,
19
+ ViewNamePredicate,
20
+ ViewTrackingPredicate,
21
+ ParamsTrackingPredicate
22
+ };