@datadog/mobile-react-navigation 2.14.0 → 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/README.md
CHANGED
|
@@ -20,25 +20,53 @@ yarn add @datadog/mobile-react-navigation
|
|
|
20
20
|
|
|
21
21
|
### Track view navigation
|
|
22
22
|
|
|
23
|
-
To track changes in navigation as RUM Views, set the `onReady` callback of your `NavigationContainer` component as follow. You can use the optional `
|
|
24
|
-
|
|
25
|
-
Returning `null` in the `ViewNamePredicate` prevents the new RUM View from being created. The previous RUM View remains active.
|
|
23
|
+
To track changes in navigation as RUM Views, set the `onReady` callback of your `NavigationContainer` component as follow. You can use the optional `NavigationTrackingOptions` parameter to replace the default behaviour of the tracker regarding views, their names and their navigation parameters.
|
|
26
24
|
|
|
27
25
|
```js
|
|
28
26
|
import * as React from 'react';
|
|
29
|
-
import { DdRumReactNavigationTracking, ViewNamePredicate } from '@datadog/mobile-react-navigation';
|
|
27
|
+
import { DdRumReactNavigationTracking, ParamsTrackingPredicate, ViewNamePredicate, ViewTrackingPredicate } from '@datadog/mobile-react-navigation';
|
|
30
28
|
import { Route } from "@react-navigation/native";
|
|
31
29
|
|
|
30
|
+
// Sets a custom name for a tracked view
|
|
32
31
|
const viewNamePredicate: ViewNamePredicate = function customViewNamePredicate(route: Route<string, any | undefined>, trackedName: string) {
|
|
33
32
|
return "My custom View Name"
|
|
34
33
|
}
|
|
35
34
|
|
|
35
|
+
// Decides if a view should be tracked or not
|
|
36
|
+
const viewTrackingPredicate: ViewTrackingPredicate = function customViewTrackingPredicate(route: Route<string, any | undefined>) {
|
|
37
|
+
if (route.name === "AlertModal") {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Allows to define what navigation parameters should be tracked for a specific view
|
|
45
|
+
const paramsTrackingPredicate: ParamsTrackingPredicate = function customParamsTrackingPredicate(route: Route<string, any | undefined>) {
|
|
46
|
+
const filteredParams: any = {};
|
|
47
|
+
if (route.params?.creditCardNumber) {
|
|
48
|
+
filteredParams["creditCardNumber"] = "XXXX XXXX XXXX XXXX";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (route.params?.username) {
|
|
52
|
+
filteredParams["username"] = route.params.username;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return filteredParams;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const navigationTrackingOptions: NavigationTrackingOptions = {
|
|
59
|
+
viewNamePredicate,
|
|
60
|
+
viewTrackingPredicate,
|
|
61
|
+
paramsTrackingPredicate,
|
|
62
|
+
}
|
|
63
|
+
|
|
36
64
|
function App() {
|
|
37
65
|
const navigationRef = React.useRef(null);
|
|
38
66
|
return (
|
|
39
67
|
<View>
|
|
40
68
|
<NavigationContainer ref={navigationRef} onReady={() => {
|
|
41
|
-
DdRumReactNavigationTracking.startTrackingViews(navigationRef.current,
|
|
69
|
+
DdRumReactNavigationTracking.startTrackingViews(navigationRef.current, navigationTrackingOptions)
|
|
42
70
|
}}>
|
|
43
71
|
// …
|
|
44
72
|
</NavigationContainer>
|
|
@@ -46,6 +74,13 @@ function App() {
|
|
|
46
74
|
);
|
|
47
75
|
}
|
|
48
76
|
```
|
|
77
|
+
|
|
78
|
+
These predicates are optional, and when not set the default behavior will be used for each one of them. The default behaviors are as follows:
|
|
79
|
+
|
|
80
|
+
- ViewNamePredicate - directly forwards the view given name to RUM.
|
|
81
|
+
- ViewTrackingPredicate - tracks all views on RUM.
|
|
82
|
+
- ParamsTrackingPredicate - does not forward any parameters to RUM.
|
|
83
|
+
|
|
49
84
|
**Note**: Only one `NavigationContainer` can be tracked at the time. If you need to track another container, stop tracking the previous one first, using `DdRumReactNavigationTracking.stopTrackingViews()`.
|
|
50
85
|
|
|
51
86
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_DdRumReactNavigationTracking","require"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"names":["_DdRumReactNavigationTracking","require"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;AAYA,IAAAA,6BAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -7,12 +7,23 @@ exports.DdRumReactNavigationTracking = void 0;
|
|
|
7
7
|
var _mobileReactNative = require("@datadog/mobile-react-native");
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _NavigationTimeline = require("./NavigationTimeline");
|
|
10
|
+
var _utils = require("./utils");
|
|
10
11
|
/*
|
|
11
12
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
12
13
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
13
14
|
* Copyright 2016-Present Datadog, Inc.
|
|
14
15
|
*/
|
|
15
16
|
|
|
17
|
+
const REACT_NAVIGATION_TRACKING_MODULE = 'com.datadog.reactnative.rum.react_navigation_tracking';
|
|
18
|
+
function getGlobalInstance(key, objectConstructor) {
|
|
19
|
+
const symbol = Symbol.for(key);
|
|
20
|
+
const g = globalThis;
|
|
21
|
+
if (!(symbol in g)) {
|
|
22
|
+
g[symbol] = objectConstructor();
|
|
23
|
+
}
|
|
24
|
+
return g[symbol];
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
// AppStateStatus can have values:
|
|
17
28
|
// 'active' - The app is running in the foreground
|
|
18
29
|
// 'background' - The app is running in the background. The user is either in another app or on the home screen
|
|
@@ -20,11 +31,24 @@ var _NavigationTimeline = require("./NavigationTimeline");
|
|
|
20
31
|
// 'unknown' [iOS] - Initial value until the current app state is determined
|
|
21
32
|
// 'extension' [iOS] - The app is running as an app extension
|
|
22
33
|
|
|
34
|
+
function defaultViewNamePredicate(_route, trackedName) {
|
|
35
|
+
return trackedName;
|
|
36
|
+
}
|
|
37
|
+
function defaultParamsPredicate(_route) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
function defaultViewTrackingPredicate(_route) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
23
44
|
/**
|
|
24
45
|
* Provides RUM integration for the [ReactNavigation](https://reactnavigation.org/) API.
|
|
25
46
|
*/
|
|
26
|
-
class
|
|
27
|
-
|
|
47
|
+
class RumReactNavigationTracking {
|
|
48
|
+
ROUTE_UNDEFINED_NAVIGATION_WARNING_MESSAGE = 'A navigation change was detected but the RUM ViewEvent was dropped as the route was undefined.';
|
|
49
|
+
NULL_NAVIGATION_REF_ERROR_MESSAGE = 'Cannot track views with a null navigationRef.';
|
|
50
|
+
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.';
|
|
51
|
+
get navigationTimeline() {
|
|
28
52
|
if (!this.__INTERNAL._enableNavigationTimeline) {
|
|
29
53
|
return undefined;
|
|
30
54
|
}
|
|
@@ -33,18 +57,20 @@ class DdRumReactNavigationTracking {
|
|
|
33
57
|
}
|
|
34
58
|
return this._navigationTimeline;
|
|
35
59
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
60
|
+
registeredContainer = null;
|
|
61
|
+
navigationStateChangeListener = null;
|
|
62
|
+
previousRoute = undefined;
|
|
63
|
+
viewNamePredicate = defaultViewNamePredicate;
|
|
64
|
+
viewTrackingPredicate = defaultViewTrackingPredicate;
|
|
65
|
+
paramsTrackingPredicate = defaultParamsPredicate;
|
|
66
|
+
backHandler = null;
|
|
67
|
+
trackingState = 'NOT_TRACKING';
|
|
42
68
|
|
|
43
69
|
/**
|
|
44
70
|
* @internal
|
|
45
71
|
* DO NOT USE: This API is for internal testing only.
|
|
46
72
|
*/
|
|
47
|
-
|
|
73
|
+
__INTERNAL = {
|
|
48
74
|
/**
|
|
49
75
|
* @internal
|
|
50
76
|
* DO NOT USE: This API is for internal testing only.
|
|
@@ -58,18 +84,18 @@ class DdRumReactNavigationTracking {
|
|
|
58
84
|
return [...(this.navigationTimeline?.events ?? [])];
|
|
59
85
|
}
|
|
60
86
|
};
|
|
61
|
-
|
|
62
|
-
if (
|
|
87
|
+
isAppExitingOnBackPress = () => {
|
|
88
|
+
if (this.registeredContainer === null) {
|
|
63
89
|
return false;
|
|
64
90
|
}
|
|
65
|
-
if (
|
|
91
|
+
if (this.registeredContainer.canGoBack()) {
|
|
66
92
|
return false;
|
|
67
93
|
}
|
|
68
94
|
return true;
|
|
69
95
|
};
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
96
|
+
onBackPress = () => {
|
|
97
|
+
if (this.isAppExitingOnBackPress()) {
|
|
98
|
+
this.stopTrackingViews(this.registeredContainer);
|
|
73
99
|
}
|
|
74
100
|
// We always return false so we make sure the react-navigation callback is called.
|
|
75
101
|
// See https://reactnative.dev/docs/backhandler
|
|
@@ -79,26 +105,39 @@ class DdRumReactNavigationTracking {
|
|
|
79
105
|
/**
|
|
80
106
|
* Starts tracking the NavigationContainer and sends a RUM View event every time the navigation route changed.
|
|
81
107
|
* @param navigationRef the reference to the real NavigationContainer.
|
|
108
|
+
* @param trackingOptions the options object defining how views will be tracked. It contains:
|
|
109
|
+
* viewNamePredicate: the predicate to rename views.
|
|
110
|
+
* viewTrackingPredicate: the predicate to determine if a view should be tracked or not.
|
|
111
|
+
* paramsTrackingPredicate: the predicate to determine which parameters should be tracked for a given view.
|
|
82
112
|
*/
|
|
83
|
-
|
|
84
|
-
// eslint-disable-next-line func-names
|
|
85
|
-
viewNamePredicate = function (_route, trackedName) {
|
|
86
|
-
return trackedName;
|
|
87
|
-
}) {
|
|
113
|
+
startTrackingViews(navigationRef, trackingOptions) {
|
|
88
114
|
this.navigationTimeline?.addStartTrackingEvent();
|
|
115
|
+
const {
|
|
116
|
+
viewNamePredicate = defaultViewNamePredicate,
|
|
117
|
+
viewTrackingPredicate = defaultViewTrackingPredicate,
|
|
118
|
+
paramsTrackingPredicate = defaultParamsPredicate
|
|
119
|
+
} = trackingOptions ?? {};
|
|
89
120
|
if (navigationRef == null) {
|
|
90
|
-
_mobileReactNative.InternalLog.log(
|
|
121
|
+
_mobileReactNative.InternalLog.log(this.NULL_NAVIGATION_REF_ERROR_MESSAGE, _mobileReactNative.SdkVerbosity.ERROR);
|
|
91
122
|
return;
|
|
92
123
|
}
|
|
93
|
-
if (
|
|
94
|
-
_mobileReactNative.InternalLog.log(
|
|
95
|
-
} else if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
124
|
+
if (this.registeredContainer != null && this.registeredContainer !== navigationRef) {
|
|
125
|
+
_mobileReactNative.InternalLog.log(this.NAVIGATION_REF_IN_USE_ERROR_MESSAGE, _mobileReactNative.SdkVerbosity.ERROR);
|
|
126
|
+
} else if (this.registeredContainer == null) {
|
|
127
|
+
if (viewNamePredicate) {
|
|
128
|
+
this.viewNamePredicate = viewNamePredicate;
|
|
129
|
+
}
|
|
130
|
+
if (viewTrackingPredicate) {
|
|
131
|
+
this.viewTrackingPredicate = viewTrackingPredicate;
|
|
132
|
+
}
|
|
133
|
+
if (paramsTrackingPredicate) {
|
|
134
|
+
this.paramsTrackingPredicate = paramsTrackingPredicate;
|
|
135
|
+
}
|
|
136
|
+
this.registeredContainer = navigationRef;
|
|
137
|
+
const listener = this.resolveNavigationStateChangeListener();
|
|
99
138
|
navigationRef.addListener('state', listener);
|
|
100
|
-
|
|
101
|
-
this.appStateSubscription = _reactNative.AppState.addEventListener('change',
|
|
139
|
+
this.backHandler = _reactNative.BackHandler.addEventListener('hardwareBackPress', this.onBackPress);
|
|
140
|
+
this.appStateSubscription = _reactNative.AppState.addEventListener('change', this.appStateListener);
|
|
102
141
|
}
|
|
103
142
|
}
|
|
104
143
|
|
|
@@ -106,22 +145,18 @@ class DdRumReactNavigationTracking {
|
|
|
106
145
|
* Stops tracking the NavigationContainer.
|
|
107
146
|
* @param navigationRef the reference to the real NavigationContainer.
|
|
108
147
|
*/
|
|
109
|
-
|
|
148
|
+
stopTrackingViews(navigationRef) {
|
|
110
149
|
this.navigationTimeline?.addStopTrackingEvent();
|
|
111
150
|
this.previousRoute = undefined;
|
|
112
151
|
if (navigationRef != null) {
|
|
113
|
-
if (
|
|
114
|
-
navigationRef.removeListener('state',
|
|
152
|
+
if (this.navigationStateChangeListener) {
|
|
153
|
+
navigationRef.removeListener('state', this.navigationStateChangeListener);
|
|
115
154
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// eslint-disable-next-line func-names
|
|
122
|
-
DdRumReactNavigationTracking.viewNamePredicate = function (_route, trackedName) {
|
|
123
|
-
return trackedName;
|
|
124
|
-
};
|
|
155
|
+
this.backHandler?.remove();
|
|
156
|
+
this.backHandler = null;
|
|
157
|
+
this.registeredContainer = null;
|
|
158
|
+
this.navigationStateChangeListener = null;
|
|
159
|
+
this.resetPredicates();
|
|
125
160
|
}
|
|
126
161
|
|
|
127
162
|
// For versions of React Native below 0.65, addEventListener does not return a subscription.
|
|
@@ -136,60 +171,88 @@ class DdRumReactNavigationTracking {
|
|
|
136
171
|
} else if (_reactNative.AppState.removeEventListener) {
|
|
137
172
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
138
173
|
// @ts-ignore
|
|
139
|
-
_reactNative.AppState.removeEventListener('change',
|
|
174
|
+
_reactNative.AppState.removeEventListener('change', this.appStateListener);
|
|
140
175
|
}
|
|
141
176
|
}
|
|
142
|
-
|
|
177
|
+
_resetInternalStateForTesting() {
|
|
178
|
+
this._navigationTimeline = undefined;
|
|
179
|
+
this.registeredContainer = null;
|
|
180
|
+
this.navigationStateChangeListener = null;
|
|
181
|
+
this.previousRoute = undefined;
|
|
182
|
+
this.backHandler = null;
|
|
183
|
+
this.appStateSubscription = undefined;
|
|
184
|
+
this.previousAppState = undefined;
|
|
185
|
+
this.previousRouteKey = undefined;
|
|
186
|
+
this.trackingState = 'NOT_TRACKING';
|
|
187
|
+
this.resetPredicates();
|
|
188
|
+
}
|
|
189
|
+
resetPredicates() {
|
|
190
|
+
this.paramsTrackingPredicate = defaultParamsPredicate;
|
|
191
|
+
this.viewNamePredicate = defaultViewNamePredicate;
|
|
192
|
+
this.viewTrackingPredicate = defaultViewTrackingPredicate;
|
|
193
|
+
}
|
|
194
|
+
handleRouteNavigation(route, appStateStatus, stateEvent) {
|
|
143
195
|
if (route === undefined || route === null) {
|
|
144
|
-
_mobileReactNative.InternalLog.log(
|
|
196
|
+
_mobileReactNative.InternalLog.log(this.ROUTE_UNDEFINED_NAVIGATION_WARNING_MESSAGE, _mobileReactNative.SdkVerbosity.WARN);
|
|
145
197
|
// RUMM-1400 in some cases the route seem to be undefined
|
|
146
198
|
return;
|
|
147
199
|
}
|
|
148
200
|
const key = route.key;
|
|
149
|
-
const screenName =
|
|
201
|
+
const screenName = this.viewNamePredicate(route, route.name);
|
|
202
|
+
const customKey = (0, _utils.transformViewKey)(key, screenName);
|
|
150
203
|
if (key != null && screenName != null) {
|
|
151
204
|
// On iOS, the app can start in either "active", "background" or "unknown" state
|
|
152
205
|
if (appStateStatus !== 'background') {
|
|
153
206
|
this.previousRoute = route;
|
|
154
|
-
|
|
207
|
+
this.trackingState = 'TRACKING';
|
|
155
208
|
this.navigationTimeline?.addNavigationStateEvent('START_VIEW', key, stateEvent, {
|
|
156
209
|
activeView: undefined,
|
|
157
210
|
trackingState: this.trackingState
|
|
158
211
|
});
|
|
159
|
-
|
|
212
|
+
if (this.viewTrackingPredicate(route)) {
|
|
213
|
+
const params = this.paramsTrackingPredicate(route);
|
|
214
|
+
if (params) {
|
|
215
|
+
_mobileReactNative.DdRum.startView(customKey, screenName, {
|
|
216
|
+
params
|
|
217
|
+
});
|
|
218
|
+
} else {
|
|
219
|
+
_mobileReactNative.DdRum.startView(customKey, screenName);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
160
222
|
}
|
|
161
223
|
}
|
|
162
224
|
this.previousRouteKey = route.key;
|
|
163
225
|
}
|
|
164
|
-
|
|
226
|
+
handleAppStateChanged(route, appStateStatus) {
|
|
165
227
|
const appStateChangeEvent = this.navigationTimeline?.addAppStateChangeEvent(this.previousAppState, appStateStatus);
|
|
166
228
|
const key = route.key;
|
|
167
|
-
const screenName =
|
|
229
|
+
const screenName = this.viewNamePredicate(route, route.name);
|
|
230
|
+
const customKey = (0, _utils.transformViewKey)(key, screenName);
|
|
168
231
|
if (key != null && screenName != null) {
|
|
169
232
|
if (appStateStatus === 'background') {
|
|
170
|
-
|
|
233
|
+
this.trackingState = 'NOT_TRACKING';
|
|
171
234
|
this.navigationTimeline?.addNavigationStateEvent('STOP_VIEW', key, appStateChangeEvent, {
|
|
172
235
|
activeView: undefined,
|
|
173
236
|
trackingState: this.trackingState
|
|
174
237
|
});
|
|
175
|
-
_mobileReactNative.DdRum.stopView(
|
|
238
|
+
_mobileReactNative.DdRum.stopView(customKey);
|
|
176
239
|
this.previousRoute = undefined;
|
|
177
|
-
} else if (appStateStatus === 'active' &&
|
|
240
|
+
} else if (appStateStatus === 'active' && this.trackingState === 'NOT_TRACKING') {
|
|
178
241
|
// case when app goes into foreground,
|
|
179
242
|
// in that case navigation listener won't be called
|
|
180
|
-
|
|
243
|
+
this.handleRouteNavigation(route, _reactNative.AppState.currentState, appStateChangeEvent);
|
|
181
244
|
}
|
|
182
245
|
}
|
|
183
246
|
this.previousRouteKey = key;
|
|
184
247
|
this.previousAppState = appStateStatus;
|
|
185
248
|
}
|
|
186
|
-
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
const route =
|
|
249
|
+
resolveNavigationStateChangeListener() {
|
|
250
|
+
if (this.navigationStateChangeListener == null) {
|
|
251
|
+
this.navigationStateChangeListener = () => {
|
|
252
|
+
const route = this.registeredContainer?.getCurrentRoute();
|
|
190
253
|
const newRouteStateEvent = this.navigationTimeline?.addNewRouteEvent(this.previousRouteKey, route?.key);
|
|
191
254
|
if (route === undefined) {
|
|
192
|
-
_mobileReactNative.InternalLog.log(
|
|
255
|
+
_mobileReactNative.InternalLog.log(this.ROUTE_UNDEFINED_NAVIGATION_WARNING_MESSAGE, _mobileReactNative.SdkVerbosity.WARN);
|
|
193
256
|
return;
|
|
194
257
|
}
|
|
195
258
|
|
|
@@ -201,20 +264,20 @@ class DdRumReactNavigationTracking {
|
|
|
201
264
|
});
|
|
202
265
|
return;
|
|
203
266
|
}
|
|
204
|
-
|
|
267
|
+
this.handleRouteNavigation(route, _reactNative.AppState.currentState, newRouteStateEvent);
|
|
205
268
|
};
|
|
206
|
-
|
|
269
|
+
this.navigationStateChangeListener({});
|
|
207
270
|
}
|
|
208
|
-
return
|
|
271
|
+
return this.navigationStateChangeListener;
|
|
209
272
|
}
|
|
210
|
-
|
|
211
|
-
const currentRoute =
|
|
273
|
+
appStateListener = appStateStatus => {
|
|
274
|
+
const currentRoute = this.registeredContainer?.getCurrentRoute();
|
|
212
275
|
if (currentRoute === undefined || currentRoute === null) {
|
|
213
276
|
_mobileReactNative.InternalLog.log(`We could not determine the route when changing the application state to: ${appStateStatus}. No RUM View event will be sent in this case.`, _mobileReactNative.SdkVerbosity.ERROR);
|
|
214
277
|
return;
|
|
215
278
|
}
|
|
216
|
-
|
|
279
|
+
this.handleAppStateChanged(currentRoute, appStateStatus);
|
|
217
280
|
};
|
|
218
281
|
}
|
|
219
|
-
exports.DdRumReactNavigationTracking =
|
|
282
|
+
const DdRumReactNavigationTracking = exports.DdRumReactNavigationTracking = getGlobalInstance(REACT_NAVIGATION_TRACKING_MODULE, () => new RumReactNavigationTracking());
|
|
220
283
|
//# sourceMappingURL=DdRumReactNavigationTracking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_mobileReactNative","require","_reactNative","_NavigationTimeline","
|
|
1
|
+
{"version":3,"names":["_mobileReactNative","require","_reactNative","_NavigationTimeline","_utils","REACT_NAVIGATION_TRACKING_MODULE","getGlobalInstance","key","objectConstructor","symbol","Symbol","for","g","globalThis","defaultViewNamePredicate","_route","trackedName","defaultParamsPredicate","undefined","defaultViewTrackingPredicate","RumReactNavigationTracking","ROUTE_UNDEFINED_NAVIGATION_WARNING_MESSAGE","NULL_NAVIGATION_REF_ERROR_MESSAGE","NAVIGATION_REF_IN_USE_ERROR_MESSAGE","navigationTimeline","__INTERNAL","_enableNavigationTimeline","_navigationTimeline","NavigationTimeline","registeredContainer","navigationStateChangeListener","previousRoute","viewNamePredicate","viewTrackingPredicate","paramsTrackingPredicate","backHandler","trackingState","_getNavigationTimeline","events","isAppExitingOnBackPress","canGoBack","onBackPress","stopTrackingViews","startTrackingViews","navigationRef","trackingOptions","addStartTrackingEvent","InternalLog","log","SdkVerbosity","ERROR","listener","resolveNavigationStateChangeListener","addListener","BackHandler","addEventListener","appStateSubscription","AppState","appStateListener","addStopTrackingEvent","removeListener","remove","resetPredicates","removeEventListener","_resetInternalStateForTesting","previousAppState","previousRouteKey","handleRouteNavigation","route","appStateStatus","stateEvent","WARN","screenName","name","customKey","transformViewKey","addNavigationStateEvent","activeView","params","DdRum","startView","handleAppStateChanged","appStateChangeEvent","addAppStateChangeEvent","stopView","currentState","getCurrentRoute","newRouteStateEvent","addNewRouteEvent","currentRoute","DdRumReactNavigationTracking","exports"],"sourceRoot":"../../../../src","sources":["rum/instrumentation/DdRumReactNavigationTracking.tsx"],"mappings":";;;;;;AAMA,IAAAA,kBAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AAjBA;AACA;AACA;AACA;AACA;;AAeA,MAAMI,gCAAgC,GAClC,uDAAuD;AAE3D,SAASC,iBAAiBA,CAAIC,GAAW,EAAEC,iBAA0B,EAAK;EACtE,MAAMC,MAAM,GAAGC,MAAM,CAACC,GAAG,CAACJ,GAAG,CAAC;EAC9B,MAAMK,CAAC,GAAIC,UAAsD;EAEjE,IAAI,EAAEJ,MAAM,IAAIG,CAAC,CAAC,EAAE;IAChBA,CAAC,CAACH,MAAM,CAAC,GAAGD,iBAAiB,CAAC,CAAC;EACnC;EACA,OAAOI,CAAC,CAACH,MAAM,CAAC;AACpB;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAsBA,SAASK,wBAAwBA,CAC7BC,MAAsC,EACtCC,WAAmB,EACrB;EACE,OAAOA,WAAW;AACtB;AAEA,SAASC,sBAAsBA,CAACF,MAAsC,EAAE;EACpE,OAAOG,SAAS;AACpB;AAEA,SAASC,4BAA4BA,CAACJ,MAAsC,EAAE;EAC1E,OAAO,IAAI;AACf;;AAEA;AACA;AACA;AACA,MAAMK,0BAA0B,CAAC;EACpBC,0CAA0C,GAC/C,gGAAgG;EAC3FC,iCAAiC,GACtC,+CAA+C;EAC1CC,mCAAmC,GACxC,6KAA6K;EAGjL,IAAYC,kBAAkBA,CAAA,EAAmC;IAC7D,IAAI,CAAC,IAAI,CAACC,UAAU,CAACC,yBAAyB,EAAE;MAC5C,OAAOR,SAAS;IACpB;IAC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CAAC,CACzC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformViewKey = transformViewKey;
|
|
7
|
+
/**
|
|
8
|
+
* Transforms the view key format from 'ScreenName-uniqueId' to 'ScreenName/uniqueId'.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Input: key='Elements-lUQ9cId5lwk1o94euVh2B', screenName='Elements'
|
|
12
|
+
* // Output: 'Elements/lUQ9cId5lwk1o94euVh2B'
|
|
13
|
+
*
|
|
14
|
+
* @param key - The route key (e.g., 'Elements-lUQ9cId5lwk1o94euVh2B')
|
|
15
|
+
* @param screenName - The screen name (e.g., 'Elements')
|
|
16
|
+
* @returns The transformed key, or the original key if not in expected format
|
|
17
|
+
*/
|
|
18
|
+
function transformViewKey(key, screenName) {
|
|
19
|
+
if (!screenName || !key) {
|
|
20
|
+
return key;
|
|
21
|
+
}
|
|
22
|
+
const expectedPrefix = `${screenName}-`;
|
|
23
|
+
if (key.startsWith(expectedPrefix)) {
|
|
24
|
+
const uniqueId = key.slice(expectedPrefix.length);
|
|
25
|
+
return `${screenName}/${uniqueId}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Key is not in the expected format, use original
|
|
29
|
+
return key;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["transformViewKey","key","screenName","expectedPrefix","startsWith","uniqueId","slice","length"],"sourceRoot":"../../../../src","sources":["rum/instrumentation/utils.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,CAC5BC,GAAW,EACXC,UAAyB,EACnB;EACN,IAAI,CAACA,UAAU,IAAI,CAACD,GAAG,EAAE;IACrB,OAAOA,GAAG;EACd;EAEA,MAAME,cAAc,GAAG,GAAGD,UAAU,GAAG;EACvC,IAAID,GAAG,CAACG,UAAU,CAACD,cAAc,CAAC,EAAE;IAChC,MAAME,QAAQ,GAAGJ,GAAG,CAACK,KAAK,CAACH,cAAc,CAACI,MAAM,CAAC;IACjD,OAAO,GAAGL,UAAU,IAAIG,QAAQ,EAAE;EACtC;;EAEA;EACA,OAAOJ,GAAG;AACd","ignoreList":[]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DdRumReactNavigationTracking"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["DdRumReactNavigationTracking"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAQA,SAASA,4BAA4B,QAAQ,oDAAoD;AAEjG,SAASA,4BAA4B","ignoreList":[]}
|