@datadog/mobile-react-navigation 1.0.0-beta4 → 1.0.0-rc4
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 +51 -1
- package/lib/commonjs/index.js +8 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js +36 -18
- package/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumReactNavigationTracking.js +35 -17
- package/lib/module/rum/instrumentation/DdRumReactNavigationTracking.js.map +1 -1
- package/lib/typescript/core/src/DdSdkReactNative.d.ts +11 -0
- package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +6 -0
- package/lib/typescript/core/src/NativeSdkVerbosity.d.ts +9 -0
- package/lib/typescript/core/src/ProxyConfiguration.d.ts +56 -0
- package/lib/typescript/core/src/Timer.d.ts +20 -0
- package/lib/typescript/core/src/index.d.ts +2 -1
- package/lib/typescript/core/src/rum/instrumentation/DdEventsInterceptor.d.ts +2 -0
- package/lib/typescript/core/src/rum/instrumentation/DdRumErrorTracking.d.ts +2 -0
- package/lib/typescript/core/src/rum/instrumentation/DdRumResourceTracking.d.ts +4 -0
- package/lib/typescript/core/src/rum/instrumentation/DdRumXhr.d.ts +2 -2
- package/lib/typescript/core/src/types.d.ts +25 -24
- package/lib/typescript/core/src/version.d.ts +1 -0
- package/lib/typescript/react-navigation/src/index.d.ts +2 -2
- package/lib/typescript/react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.d.ts +5 -3
- package/package.json +6 -10
- package/src/__tests__/rum/instrumentation/DdRumReactNavigationTracking.test.tsx +397 -0
- package/src/index.tsx +2 -2
- package/src/rum/instrumentation/DdRumReactNavigationTracking.tsx +44 -17
package/README.md
CHANGED
|
@@ -1 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
# React-Native Monitoring for `react-navigation` components
|
|
2
|
+
|
|
3
|
+
Datadog *Real User Monitoring (RUM)* enables you to visualize and analyze the real-time performance and user journeys of your application’s individual users. This specific package adds support to the [`react-navigation`][1] library.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
**Note**: This package is an integration for [`react-navigation`][1] library, please make sure you first install and setup the core [`mobile-react-native`][2] SDK.
|
|
8
|
+
|
|
9
|
+
To install with NPM, run:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @datadog/mobile-react-navigation
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
To install with Yarn, run:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
yarn add @datadog/mobile-react-navigation
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Track view navigation
|
|
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 `ViewNamePredicate` parameter to replace the automatically detected View name with something more relevant to your use case.
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import * as React from 'react';
|
|
27
|
+
import { DdRumReactNavigationTracking, ViewNamePredicate } from '@datadog/mobile-react-navigation';
|
|
28
|
+
import { Route } from "@react-navigation/native";
|
|
29
|
+
|
|
30
|
+
const viewNamePredicate: ViewNamePredicate = function customViewNamePredicate(route: Route<string, any | undefined>, trackedName: string) {
|
|
31
|
+
return "My custom View Name"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function App() {
|
|
35
|
+
const navigationRef = React.useRef(null);
|
|
36
|
+
return (
|
|
37
|
+
<View>
|
|
38
|
+
<NavigationContainer ref={navigationRef} onReady={() => {
|
|
39
|
+
DdRumReactNavigationTracking.startTrackingViews(navigationRef.current, viewNamePredicate)
|
|
40
|
+
}}>
|
|
41
|
+
// …
|
|
42
|
+
</NavigationContainer>
|
|
43
|
+
</View>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
**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()`.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
[1]: https://github.com/react-navigation/react-navigation
|
|
51
|
+
[2]: https://github.com/DataDog/dd-sdk-reactnative/tree/main/packages/core
|
package/lib/commonjs/index.js
CHANGED
|
@@ -6,11 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "DdRumReactNavigationTracking", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return _DdRumReactNavigationTracking.
|
|
9
|
+
return _DdRumReactNavigationTracking.DdRumReactNavigationTracking;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ViewNamePredicate", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _DdRumReactNavigationTracking.ViewNamePredicate;
|
|
10
16
|
}
|
|
11
17
|
});
|
|
12
18
|
|
|
13
|
-
var _DdRumReactNavigationTracking =
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
var _DdRumReactNavigationTracking = require("./rum/instrumentation/DdRumReactNavigationTracking");
|
|
16
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdRumReactNavigationTracking, ViewNamePredicate } from './rum/instrumentation/DdRumReactNavigationTracking';\n\nexport { DdRumReactNavigationTracking, ViewNamePredicate };\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.DdRumReactNavigationTracking = void 0;
|
|
7
7
|
|
|
8
8
|
var _mobileReactNative = require("@datadog/mobile-react-native");
|
|
9
9
|
|
|
@@ -19,14 +19,18 @@ class DdRumReactNavigationTracking {
|
|
|
19
19
|
* Starts tracking the NavigationContainer and sends a RUM View event every time the navigation route changed.
|
|
20
20
|
* @param navigationRef the reference to the real NavigationContainer.
|
|
21
21
|
*/
|
|
22
|
-
static startTrackingViews(navigationRef) {
|
|
22
|
+
static startTrackingViews(navigationRef, viewNamePredicate = function (_route, trackedName) {
|
|
23
|
+
return trackedName;
|
|
24
|
+
}) {
|
|
23
25
|
if (navigationRef == null) {
|
|
26
|
+
console.log("Cannot track views with a null navigationRef");
|
|
24
27
|
return;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
if (DdRumReactNavigationTracking.registeredContainer != null && this.registeredContainer !== navigationRef) {
|
|
28
31
|
console.error('Cannot track new navigation container while another one is still tracked');
|
|
29
32
|
} else if (DdRumReactNavigationTracking.registeredContainer == null) {
|
|
33
|
+
DdRumReactNavigationTracking.viewNamePredicate = viewNamePredicate;
|
|
30
34
|
const listener = DdRumReactNavigationTracking.resolveNavigationStateChangeListener();
|
|
31
35
|
DdRumReactNavigationTracking.handleRouteNavigation(navigationRef.getCurrentRoute());
|
|
32
36
|
navigationRef.addListener("state", listener);
|
|
@@ -45,15 +49,33 @@ class DdRumReactNavigationTracking {
|
|
|
45
49
|
if (navigationRef != null) {
|
|
46
50
|
navigationRef.removeListener("state", DdRumReactNavigationTracking.navigationStateChangeListener);
|
|
47
51
|
DdRumReactNavigationTracking.registeredContainer = null;
|
|
52
|
+
|
|
53
|
+
DdRumReactNavigationTracking.viewNamePredicate = function (_route, trackedName) {
|
|
54
|
+
return trackedName;
|
|
55
|
+
};
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
|
|
51
|
-
static handleRouteNavigation(route) {
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
static handleRouteNavigation(route, appStateStatus = undefined) {
|
|
60
|
+
var _predicate;
|
|
61
|
+
|
|
62
|
+
if (route == undefined || route == null) {
|
|
63
|
+
// RUMM-1400 in some cases the route seem to be undefined
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const key = route.key;
|
|
68
|
+
const predicate = DdRumReactNavigationTracking.viewNamePredicate;
|
|
69
|
+
const screenName = (_predicate = predicate(route, route.name)) !== null && _predicate !== void 0 ? _predicate : route.name;
|
|
54
70
|
|
|
55
71
|
if (key != null && screenName != null) {
|
|
56
|
-
|
|
72
|
+
if (appStateStatus === 'background') {
|
|
73
|
+
_mobileReactNative.DdRum.stopView(key);
|
|
74
|
+
} else if (appStateStatus === 'active' || appStateStatus == undefined) {
|
|
75
|
+
// case when app goes into foreground,
|
|
76
|
+
// in that case navigation listener won't be called
|
|
77
|
+
_mobileReactNative.DdRum.startView(key, screenName);
|
|
78
|
+
}
|
|
57
79
|
}
|
|
58
80
|
}
|
|
59
81
|
|
|
@@ -93,18 +115,12 @@ class DdRumReactNavigationTracking {
|
|
|
93
115
|
var _DdRumReactNavigation;
|
|
94
116
|
|
|
95
117
|
const currentRoute = (_DdRumReactNavigation = DdRumReactNavigationTracking.registeredContainer) === null || _DdRumReactNavigation === void 0 ? void 0 : _DdRumReactNavigation.getCurrentRoute();
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (currentViewKey != null && currentViewName != null) {
|
|
100
|
-
if (appStateStatus === 'background') {
|
|
101
|
-
_mobileReactNative.DdRum.stopView(currentViewKey, Date.now(), {});
|
|
102
|
-
} else if (appStateStatus === 'active') {
|
|
103
|
-
// case when app goes into foreground, in that case navigation listener
|
|
104
|
-
// won't be called
|
|
105
|
-
_mobileReactNative.DdRum.startView(currentViewKey, currentViewName, Date.now(), {});
|
|
106
|
-
}
|
|
118
|
+
|
|
119
|
+
if (currentRoute == undefined) {
|
|
120
|
+
return;
|
|
107
121
|
}
|
|
122
|
+
|
|
123
|
+
DdRumReactNavigationTracking.handleRouteNavigation(currentRoute, appStateStatus);
|
|
108
124
|
}; // AppState is singleton, so we should add a listener only once in the app lifetime
|
|
109
125
|
|
|
110
126
|
|
|
@@ -114,11 +130,13 @@ class DdRumReactNavigationTracking {
|
|
|
114
130
|
|
|
115
131
|
}
|
|
116
132
|
|
|
117
|
-
exports.
|
|
133
|
+
exports.DdRumReactNavigationTracking = DdRumReactNavigationTracking;
|
|
118
134
|
|
|
119
135
|
_defineProperty(DdRumReactNavigationTracking, "registeredContainer", void 0);
|
|
120
136
|
|
|
121
137
|
_defineProperty(DdRumReactNavigationTracking, "navigationStateChangeListener", void 0);
|
|
122
138
|
|
|
123
139
|
_defineProperty(DdRumReactNavigationTracking, "appStateListener", void 0);
|
|
140
|
+
|
|
141
|
+
_defineProperty(DdRumReactNavigationTracking, "viewNamePredicate", void 0);
|
|
124
142
|
//# sourceMappingURL=DdRumReactNavigationTracking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumReactNavigationTracking.tsx"],"names":["DdRumReactNavigationTracking","startTrackingViews","navigationRef","registeredContainer","console","error","listener","resolveNavigationStateChangeListener","handleRouteNavigation","getCurrentRoute","addListener","registerAppStateListenerIfNeeded","stopTrackingViews","removeListener","navigationStateChangeListener","route","key","screenName","name","DdRum","startView","Date","now","event","data","state","routes","index","undefined","nestedRoute","appStateListener","appStateStatus","currentRoute","currentViewKey","currentViewName","stopView","AppState","addEventListener"],"mappings":";;;;;;;AAOA;;AACA;;;;AAMA;AACA;AACA;AACe,MAAMA,4BAAN,CAAmC;AAQ9C;AACJ;AACA;AACA;AAC6B,SAAlBC,kBAAkB,CAACC,aAAD,EAAqD;AAC1E,QAAIA,aAAa,IAAI,IAArB,EAA2B;AACvB;AACH;;AAED,QAAIF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,IAAIS,cAAc,KAAK,QAAvB,EAAiC;AACpC;AACA;AACAZ,qCAAMC,SAAN,CAAgBa,cAAhB,EAAgCC,eAAhC,EAAiDb,IAAI,CAACC,GAAL,EAAjD,EAA6D,EAA7D;AACH;AACJ;AACJ,OAfD,CADuD,CAkBvD;;;AACAc,4BAASC,gBAAT,CAA0B,QAA1B,EAAoCrC,4BAA4B,CAAC8B,gBAAjE;AACH;AACJ;;AA/F6C;;;;gBAA7B9B,4B;;gBAAAA,4B;;gBAAAA,4B","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { EventArg, NavigationContainerRef, Route } from \"@react-navigation/native\";\nimport { DdRum } from '@datadog/mobile-react-native';\nimport { AppState, AppStateStatus } from 'react-native';\n\ndeclare type NavigationListener = (event: EventArg<string, boolean, any>) => void | null\n\ndeclare type AppStateListener = (appStateStatus: AppStateStatus) => void | null\n\n/**\n * Provides RUM integration for the [ReactNavigation](https://reactnavigation.org/) API.\n */\nexport default class DdRumReactNavigationTracking {\n\n private static registeredContainer: NavigationContainerRef | null;\n \n private static navigationStateChangeListener: NavigationListener;\n\n private static appStateListener: AppStateListener;\n\n /**\n * Starts tracking the NavigationContainer and sends a RUM View event every time the navigation route changed.\n * @param navigationRef the reference to the real NavigationContainer.\n */\n static startTrackingViews(navigationRef: NavigationContainerRef | null): void {\n if (navigationRef == null) {\n return;\n }\n\n if (DdRumReactNavigationTracking.registeredContainer != null && this.registeredContainer !== navigationRef) {\n console.error('Cannot track new navigation container while another one is still tracked');\n } else if (DdRumReactNavigationTracking.registeredContainer == null) {\n const listener = DdRumReactNavigationTracking.resolveNavigationStateChangeListener();\n DdRumReactNavigationTracking.handleRouteNavigation(navigationRef.getCurrentRoute());\n navigationRef.addListener(\"state\", listener);\n DdRumReactNavigationTracking.registeredContainer = navigationRef;\n }\n\n DdRumReactNavigationTracking.registerAppStateListenerIfNeeded();\n }\n\n /**\n * Stops tracking the NavigationContainer.\n * @param navigationRef the reference to the real NavigationContainer.\n */\n static stopTrackingViews(navigationRef: NavigationContainerRef | null): void {\n if (navigationRef != null) {\n navigationRef.removeListener(\"state\", DdRumReactNavigationTracking.navigationStateChangeListener);\n DdRumReactNavigationTracking.registeredContainer = null;\n }\n }\n\n private static handleRouteNavigation(route: Route<string, any | undefined> | undefined) {\n const key = route?.key;\n const screenName = route?.name;\n if (key != null && screenName != null) {\n DdRum.startView(key, screenName, Date.now(), {});\n }\n }\n\n private static resolveNavigationStateChangeListener(): NavigationListener {\n if (DdRumReactNavigationTracking.navigationStateChangeListener == null) {\n DdRumReactNavigationTracking.navigationStateChangeListener = (event: EventArg<string, boolean, any>) => {\n let route = event.data?.state?.routes[event.data?.state?.index];\n\n if (route == undefined) {\n // RUMM-1400 in some cases the route seem to be undefined\n return\n }\n\n while (route.state != undefined) {\n const nestedRoute = route.state.routes[route.state.index];\n if (nestedRoute == undefined) {\n // RUMM-1400 in some cases the route seem to be undefined\n break;\n }\n route = nestedRoute\n }\n\n DdRumReactNavigationTracking.handleRouteNavigation(route);\n };\n }\n return DdRumReactNavigationTracking.navigationStateChangeListener;\n }\n\n private static registerAppStateListenerIfNeeded() {\n if (DdRumReactNavigationTracking.appStateListener == null) {\n DdRumReactNavigationTracking.appStateListener = (appStateStatus: AppStateStatus) => {\n\n const currentRoute = DdRumReactNavigationTracking.registeredContainer?.getCurrentRoute();\n const currentViewKey = currentRoute?.key;\n const currentViewName = currentRoute?.name;\n\n if (currentViewKey != null && currentViewName != null) {\n if (appStateStatus === 'background') {\n DdRum.stopView(currentViewKey, Date.now(), {});\n } else if (appStateStatus === 'active') {\n // case when app goes into foreground, in that case navigation listener\n // won't be called\n DdRum.startView(currentViewKey, currentViewName, Date.now(), {});\n }\n }\n };\n\n // AppState is singleton, so we should add a listener only once in the app lifetime\n AppState.addEventListener(\"change\", DdRumReactNavigationTracking.appStateListener);\n }\n }\n\n}\n\n"]}
|
|
1
|
+
{"version":3,"sources":["DdRumReactNavigationTracking.tsx"],"names":["DdRumReactNavigationTracking","startTrackingViews","navigationRef","viewNamePredicate","_route","trackedName","console","log","registeredContainer","error","listener","resolveNavigationStateChangeListener","handleRouteNavigation","getCurrentRoute","addListener","registerAppStateListenerIfNeeded","stopTrackingViews","removeListener","navigationStateChangeListener","route","appStateStatus","undefined","key","predicate","screenName","name","DdRum","stopView","startView","event","data","state","routes","index","nestedRoute","appStateListener","currentRoute","AppState","addEventListener"],"mappings":";;;;;;;AAOA;;AACA;;;;AAcA;AACA;AACA;AACO,MAAMA,4BAAN,CAAmC;AAUtC;AACJ;AACA;AACA;AAC6B,SAAlBC,kBAAkB,CACjBC,aADiB,EAEjBC,iBAAoC,GAAG,UAAUC,MAAV,EAAkDC,WAAlD,EAAuE;AAAE,WAAOA,WAAP;AAAqB,GAFpH,EAGb;AAER,QAAIH,aAAa,IAAI,IAArB,EAA2B;AACvBI,MAAAA,OAAO,CAACC,GAAR,CAAa,8CAAb;AACA;AACH;;AAED,QAAIP,4BAA4B,CAACQ,mBAA7B,IAAoD,IAApD,IAA4D,KAAKA,mBAAL,KAA6BN,aAA7F,EAA4G;AACxGI,MAAAA,OAAO,CAACG,KAAR,CAAc,0EAAd;AACH,KAFD,MAEO,IAAIT,4BAA4B,CAACQ,mBAA7B,IAAoD,IAAxD,EAA8D;AACjER,MAAAA,4BAA4B,CAACG,iBAA7B,GAAiDA,iBAAjD;AACA,YAAMO,QAAQ,GAAGV,4BAA4B,CAACW,oCAA7B,EAAjB;AACAX,MAAAA,4BAA4B,CAACY,qBAA7B,CAAmDV,aAAa,CAACW,eAAd,EAAnD;AACAX,MAAAA,aAAa,CAACY,WAAd,CAA0B,OAA1B,EAAmCJ,QAAnC;AACAV,MAAAA,4BAA4B,CAACQ,mBAA7B,GAAmDN,aAAnD;AACH;;AAGDF,IAAAA,4BAA4B,CAACe,gCAA7B;AACH;AAED;AACJ;AACA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AAf,sDAAG,kBAAmBC,MAAnB,iBAA0BH,KAAK,CAACC,IAAhC,uEAA0B,aAAYC,KAAtC,uDAA0B,mBAAmBE,KAA7C,CAAZ;;AAEA,YAAId,KAAK,IAAIE,SAAb,EAAwB;AACpB;AACA;AACH;;AAED,eAAOF,KAAK,CAACY,KAAN,IAAeV,SAAtB,EAAiC;AAC7B,gBAAMa,WAAW,GAAGf,KAAK,CAACY,KAAN,CAAYC,MAAZ,CAAmBb,KAAK,CAACY,KAAN,CAAYE,KAA/B,CAApB;;AACA,cAAIC,WAAW,IAAIb,SAAnB,EAA8B;AAC1B;AACA;AACH;;AACDF,UAAAA,KAAK,GAAGe,WAAR;AACH;;AAEDlC,QAAAA,4BAA4B,CAACY,qBAA7B,CAAmDO,KAAnD;AACH,OAlBD;AAmBH;;AACD,WAAOnB,4BAA4B,CAACkB,6BAApC;AACH;;AAE8C,SAAhCH,gCAAgC,GAAG;AAC9C,QAAIf,4BAA4B,CAACmC,gBAA7B,IAAiD,IAArD,EAA2D;AACvDnC,MAAAA,4BAA4B,CAACmC,gBAA7B,GAAiDf,cAAD,IAAoC;AAAA;;AAEhF,cAAMgB,YAAY,4BAAGpC,4BAA4B,CAACQ,mBAAhC,0DAAG,sBAAkDK,eAAlD,EAArB;;AACA,YAAIuB,YAAY,IAAIf,SAApB,EAA+B;AAC3B;AACH;;AAEDrB,QAAAA,4BAA4B,CAACY,qBAA7B,CAAmDwB,YAAnD,EAAiEhB,cAAjE;AACH,OARD,CADuD,CAWvD;;;AACAiB,4BAASC,gBAAT,CAA0B,QAA1B,EAAoCtC,4BAA4B,CAACmC,gBAAjE;AACH;AACJ;;AAlHqC;;;;gBAA7BnC,4B;;gBAAAA,4B;;gBAAAA,4B;;gBAAAA,4B","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { EventArg, NavigationContainerRef, Route } from \"@react-navigation/native\";\nimport { DdRum } from '@datadog/mobile-react-native';\nimport { AppState, AppStateStatus } from 'react-native';\n\ndeclare type NavigationListener = (event: EventArg<string, boolean, any>) => void | null\n\n// AppStateStatus can have values: \n// 'active' - The app is running in the foreground\n// 'background' - The app is running in the background. The user is either in another app or on the home screen\n// 'inactive' [iOS] - This is a transition state that currently never happens for typical React Native apps.\n// 'unknown' [iOS] - Initial value until the current app state is determined\n// 'extension' [iOS] - The app is running as an app extension\ndeclare type AppStateListener = (appStateStatus: AppStateStatus) => void | null\n\nexport type ViewNamePredicate = (route: Route<string, any | undefined>, trackedName: string) => string\n\n/**\n * Provides RUM integration for the [ReactNavigation](https://reactnavigation.org/) API.\n */\nexport class DdRumReactNavigationTracking {\n\n private static registeredContainer: NavigationContainerRef | null;\n \n private static navigationStateChangeListener: NavigationListener;\n\n private static appStateListener: AppStateListener;\n\n private static viewNamePredicate: ViewNamePredicate;\n\n /**\n * Starts tracking the NavigationContainer and sends a RUM View event every time the navigation route changed.\n * @param navigationRef the reference to the real NavigationContainer.\n */\n static startTrackingViews(\n navigationRef: NavigationContainerRef | null,\n viewNamePredicate: ViewNamePredicate = function (_route: Route<string, any | undefined>, trackedName: string) { return trackedName; }\n ): void {\n\n if (navigationRef == null) {\n console.log (\"Cannot track views with a null navigationRef\");\n return;\n }\n\n if (DdRumReactNavigationTracking.registeredContainer != null && this.registeredContainer !== navigationRef) {\n console.error('Cannot track new navigation container while another one is still tracked');\n } else if (DdRumReactNavigationTracking.registeredContainer == null) {\n DdRumReactNavigationTracking.viewNamePredicate = viewNamePredicate;\n const listener = DdRumReactNavigationTracking.resolveNavigationStateChangeListener();\n DdRumReactNavigationTracking.handleRouteNavigation(navigationRef.getCurrentRoute());\n navigationRef.addListener(\"state\", listener);\n DdRumReactNavigationTracking.registeredContainer = navigationRef;\n }\n\n\n DdRumReactNavigationTracking.registerAppStateListenerIfNeeded();\n }\n\n /**\n * Stops tracking the NavigationContainer.\n * @param navigationRef the reference to the real NavigationContainer.\n */\n static stopTrackingViews(navigationRef: NavigationContainerRef | null): void {\n if (navigationRef != null) {\n navigationRef.removeListener(\"state\", DdRumReactNavigationTracking.navigationStateChangeListener);\n DdRumReactNavigationTracking.registeredContainer = null;\n DdRumReactNavigationTracking.viewNamePredicate = function (_route: Route<string, any | undefined>, trackedName: string) { return trackedName; }\n }\n }\n\n private static handleRouteNavigation(\n route: Route<string, any | undefined> | undefined, \n appStateStatus: AppStateStatus | undefined = undefined\n ) {\n if (route == undefined || route == null) {\n // RUMM-1400 in some cases the route seem to be undefined\n return\n }\n const key = route.key;\n\n const predicate = DdRumReactNavigationTracking.viewNamePredicate;\n const screenName = predicate(route, route.name) ?? route.name;\n\n if (key != null && screenName != null) {\n if (appStateStatus === 'background') {\n DdRum.stopView(key);\n } else if (appStateStatus === 'active' || appStateStatus == undefined) {\n // case when app goes into foreground, \n // in that case navigation listener won't be called\n DdRum.startView(key, screenName);\n }\n }\n }\n\n private static resolveNavigationStateChangeListener(): NavigationListener {\n if (DdRumReactNavigationTracking.navigationStateChangeListener == null) {\n DdRumReactNavigationTracking.navigationStateChangeListener = (event: EventArg<string, boolean, any>) => {\n let route = event.data?.state?.routes[event.data?.state?.index];\n\n if (route == undefined) {\n // RUMM-1400 in some cases the route seem to be undefined\n return\n }\n\n while (route.state != undefined) {\n const nestedRoute = route.state.routes[route.state.index];\n if (nestedRoute == undefined) {\n // RUMM-1400 in some cases the route seem to be undefined\n break;\n }\n route = nestedRoute\n }\n\n DdRumReactNavigationTracking.handleRouteNavigation(route);\n };\n }\n return DdRumReactNavigationTracking.navigationStateChangeListener;\n }\n\n private static registerAppStateListenerIfNeeded() {\n if (DdRumReactNavigationTracking.appStateListener == null) {\n DdRumReactNavigationTracking.appStateListener = (appStateStatus: AppStateStatus) => {\n\n const currentRoute = DdRumReactNavigationTracking.registeredContainer?.getCurrentRoute();\n if (currentRoute == undefined) {\n return;\n }\n\n DdRumReactNavigationTracking.handleRouteNavigation(currentRoute, appStateStatus);\n };\n\n // AppState is singleton, so we should add a listener only once in the app lifetime\n AppState.addEventListener(\"change\", DdRumReactNavigationTracking.appStateListener);\n }\n }\n\n}\n\n"]}
|
package/lib/module/index.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
|
-
import DdRumReactNavigationTracking from './rum/instrumentation/DdRumReactNavigationTracking';
|
|
7
|
-
export { DdRumReactNavigationTracking };
|
|
6
|
+
import { DdRumReactNavigationTracking, ViewNamePredicate } from './rum/instrumentation/DdRumReactNavigationTracking';
|
|
7
|
+
export { DdRumReactNavigationTracking, ViewNamePredicate };
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["DdRumReactNavigationTracking"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["DdRumReactNavigationTracking","ViewNamePredicate"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,4BAAT,EAAuCC,iBAAvC,QAAgE,oDAAhE;AAEA,SAASD,4BAAT,EAAuCC,iBAAvC","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdRumReactNavigationTracking, ViewNamePredicate } from './rum/instrumentation/DdRumReactNavigationTracking';\n\nexport { DdRumReactNavigationTracking, ViewNamePredicate };\n"]}
|
|
@@ -11,19 +11,23 @@ import { AppState } from 'react-native';
|
|
|
11
11
|
/**
|
|
12
12
|
* Provides RUM integration for the [ReactNavigation](https://reactnavigation.org/) API.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export class DdRumReactNavigationTracking {
|
|
15
15
|
/**
|
|
16
16
|
* Starts tracking the NavigationContainer and sends a RUM View event every time the navigation route changed.
|
|
17
17
|
* @param navigationRef the reference to the real NavigationContainer.
|
|
18
18
|
*/
|
|
19
|
-
static startTrackingViews(navigationRef) {
|
|
19
|
+
static startTrackingViews(navigationRef, viewNamePredicate = function (_route, trackedName) {
|
|
20
|
+
return trackedName;
|
|
21
|
+
}) {
|
|
20
22
|
if (navigationRef == null) {
|
|
23
|
+
console.log("Cannot track views with a null navigationRef");
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
if (DdRumReactNavigationTracking.registeredContainer != null && this.registeredContainer !== navigationRef) {
|
|
25
28
|
console.error('Cannot track new navigation container while another one is still tracked');
|
|
26
29
|
} else if (DdRumReactNavigationTracking.registeredContainer == null) {
|
|
30
|
+
DdRumReactNavigationTracking.viewNamePredicate = viewNamePredicate;
|
|
27
31
|
const listener = DdRumReactNavigationTracking.resolveNavigationStateChangeListener();
|
|
28
32
|
DdRumReactNavigationTracking.handleRouteNavigation(navigationRef.getCurrentRoute());
|
|
29
33
|
navigationRef.addListener("state", listener);
|
|
@@ -42,15 +46,33 @@ export default class DdRumReactNavigationTracking {
|
|
|
42
46
|
if (navigationRef != null) {
|
|
43
47
|
navigationRef.removeListener("state", DdRumReactNavigationTracking.navigationStateChangeListener);
|
|
44
48
|
DdRumReactNavigationTracking.registeredContainer = null;
|
|
49
|
+
|
|
50
|
+
DdRumReactNavigationTracking.viewNamePredicate = function (_route, trackedName) {
|
|
51
|
+
return trackedName;
|
|
52
|
+
};
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
|
|
48
|
-
static handleRouteNavigation(route) {
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
static handleRouteNavigation(route, appStateStatus = undefined) {
|
|
57
|
+
var _predicate;
|
|
58
|
+
|
|
59
|
+
if (route == undefined || route == null) {
|
|
60
|
+
// RUMM-1400 in some cases the route seem to be undefined
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const key = route.key;
|
|
65
|
+
const predicate = DdRumReactNavigationTracking.viewNamePredicate;
|
|
66
|
+
const screenName = (_predicate = predicate(route, route.name)) !== null && _predicate !== void 0 ? _predicate : route.name;
|
|
51
67
|
|
|
52
68
|
if (key != null && screenName != null) {
|
|
53
|
-
|
|
69
|
+
if (appStateStatus === 'background') {
|
|
70
|
+
DdRum.stopView(key);
|
|
71
|
+
} else if (appStateStatus === 'active' || appStateStatus == undefined) {
|
|
72
|
+
// case when app goes into foreground,
|
|
73
|
+
// in that case navigation listener won't be called
|
|
74
|
+
DdRum.startView(key, screenName);
|
|
75
|
+
}
|
|
54
76
|
}
|
|
55
77
|
}
|
|
56
78
|
|
|
@@ -90,18 +112,12 @@ export default class DdRumReactNavigationTracking {
|
|
|
90
112
|
var _DdRumReactNavigation;
|
|
91
113
|
|
|
92
114
|
const currentRoute = (_DdRumReactNavigation = DdRumReactNavigationTracking.registeredContainer) === null || _DdRumReactNavigation === void 0 ? void 0 : _DdRumReactNavigation.getCurrentRoute();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (currentViewKey != null && currentViewName != null) {
|
|
97
|
-
if (appStateStatus === 'background') {
|
|
98
|
-
DdRum.stopView(currentViewKey, Date.now(), {});
|
|
99
|
-
} else if (appStateStatus === 'active') {
|
|
100
|
-
// case when app goes into foreground, in that case navigation listener
|
|
101
|
-
// won't be called
|
|
102
|
-
DdRum.startView(currentViewKey, currentViewName, Date.now(), {});
|
|
103
|
-
}
|
|
115
|
+
|
|
116
|
+
if (currentRoute == undefined) {
|
|
117
|
+
return;
|
|
104
118
|
}
|
|
119
|
+
|
|
120
|
+
DdRumReactNavigationTracking.handleRouteNavigation(currentRoute, appStateStatus);
|
|
105
121
|
}; // AppState is singleton, so we should add a listener only once in the app lifetime
|
|
106
122
|
|
|
107
123
|
|
|
@@ -116,4 +132,6 @@ _defineProperty(DdRumReactNavigationTracking, "registeredContainer", void 0);
|
|
|
116
132
|
_defineProperty(DdRumReactNavigationTracking, "navigationStateChangeListener", void 0);
|
|
117
133
|
|
|
118
134
|
_defineProperty(DdRumReactNavigationTracking, "appStateListener", void 0);
|
|
135
|
+
|
|
136
|
+
_defineProperty(DdRumReactNavigationTracking, "viewNamePredicate", void 0);
|
|
119
137
|
//# sourceMappingURL=DdRumReactNavigationTracking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumReactNavigationTracking.tsx"],"names":["DdRum","AppState","DdRumReactNavigationTracking","startTrackingViews","navigationRef","registeredContainer","console","error","listener","resolveNavigationStateChangeListener","handleRouteNavigation","getCurrentRoute","addListener","registerAppStateListenerIfNeeded","stopTrackingViews","removeListener","navigationStateChangeListener","route","key","screenName","name","startView","Date","now","event","data","state","routes","index","undefined","nestedRoute","appStateListener","appStateStatus","currentRoute","currentViewKey","currentViewName","stopView","addEventListener"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,KAAT,QAAsB,8BAAtB;AACA,SAASC,QAAT,QAAyC,cAAzC;;AAMA;AACA;AACA;AACA,eAAe,MAAMC,4BAAN,CAAmC;AAQ9C;AACJ;AACA;AACA;AAC6B,SAAlBC,kBAAkB,CAACC,aAAD,EAAqD;AAC1E,QAAIA,aAAa,IAAI,IAArB,EAA2B;AACvB;AACH;;AAED,QAAIF,4BAA4B,CAACG,mBAA7B,IAAoD,IAApD,IAA4D,KAAKA,mBAAL,KAA6BD,aAA7F,EAA4G;AACxGE,MAAAA,OAAO,CAACC,KAAR,CAAc,0EAAd;AACH,KAFD,MAEO,IAAIL,4BAA4B,CAACG,mBAA7B,IAAoD,IAAxD,EAA8D;AACjE,YAAMG,QAAQ,GAAGN,4BAA4B,CAACO,oCAA7B,EAAjB;AACAP,MAAAA,4BAA4B,CAACQ,qBAA7B,CAAmDN,aAAa,CAACO,eAAd,EAAnD;AACAP,MAAAA,aAAa,CAACQ,WA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;;gBAAAA,4B","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { EventArg, NavigationContainerRef, Route } from \"@react-navigation/native\";\nimport { DdRum } from '@datadog/mobile-react-native';\nimport { AppState, AppStateStatus } from 'react-native';\n\ndeclare type NavigationListener = (event: EventArg<string, boolean, any>) => void | null\n\ndeclare type AppStateListener = (appStateStatus: AppStateStatus) => void | null\n\n/**\n * Provides RUM integration for the [ReactNavigation](https://reactnavigation.org/) API.\n */\nexport default class DdRumReactNavigationTracking {\n\n private static registeredContainer: NavigationContainerRef | null;\n \n private static navigationStateChangeListener: NavigationListener;\n\n private static appStateListener: AppStateListener;\n\n /**\n * Starts tracking the NavigationContainer and sends a RUM View event every time the navigation route changed.\n * @param navigationRef the reference to the real NavigationContainer.\n */\n static startTrackingViews(navigationRef: NavigationContainerRef | null): void {\n if (navigationRef == null) {\n return;\n }\n\n if (DdRumReactNavigationTracking.registeredContainer != null && this.registeredContainer !== navigationRef) {\n console.error('Cannot track new navigation container while another one is still tracked');\n } else if (DdRumReactNavigationTracking.registeredContainer == null) {\n const listener = DdRumReactNavigationTracking.resolveNavigationStateChangeListener();\n DdRumReactNavigationTracking.handleRouteNavigation(navigationRef.getCurrentRoute());\n navigationRef.addListener(\"state\", listener);\n DdRumReactNavigationTracking.registeredContainer = navigationRef;\n }\n\n DdRumReactNavigationTracking.registerAppStateListenerIfNeeded();\n }\n\n /**\n * Stops tracking the NavigationContainer.\n * @param navigationRef the reference to the real NavigationContainer.\n */\n static stopTrackingViews(navigationRef: NavigationContainerRef | null): void {\n if (navigationRef != null) {\n navigationRef.removeListener(\"state\", DdRumReactNavigationTracking.navigationStateChangeListener);\n DdRumReactNavigationTracking.registeredContainer = null;\n }\n }\n\n private static handleRouteNavigation(route: Route<string, any | undefined> | undefined) {\n const key = route?.key;\n const screenName = route?.name;\n if (key != null && screenName != null) {\n DdRum.startView(key, screenName, Date.now(), {});\n }\n }\n\n private static resolveNavigationStateChangeListener(): NavigationListener {\n if (DdRumReactNavigationTracking.navigationStateChangeListener == null) {\n DdRumReactNavigationTracking.navigationStateChangeListener = (event: EventArg<string, boolean, any>) => {\n let route = event.data?.state?.routes[event.data?.state?.index];\n\n if (route == undefined) {\n // RUMM-1400 in some cases the route seem to be undefined\n return\n }\n\n while (route.state != undefined) {\n const nestedRoute = route.state.routes[route.state.index];\n if (nestedRoute == undefined) {\n // RUMM-1400 in some cases the route seem to be undefined\n break;\n }\n route = nestedRoute\n }\n\n DdRumReactNavigationTracking.handleRouteNavigation(route);\n };\n }\n return DdRumReactNavigationTracking.navigationStateChangeListener;\n }\n\n private static registerAppStateListenerIfNeeded() {\n if (DdRumReactNavigationTracking.appStateListener == null) {\n DdRumReactNavigationTracking.appStateListener = (appStateStatus: AppStateStatus) => {\n\n const currentRoute = DdRumReactNavigationTracking.registeredContainer?.getCurrentRoute();\n const currentViewKey = currentRoute?.key;\n const currentViewName = currentRoute?.name;\n\n if (currentViewKey != null && currentViewName != null) {\n if (appStateStatus === 'background') {\n DdRum.stopView(currentViewKey, Date.now(), {});\n } else if (appStateStatus === 'active') {\n // case when app goes into foreground, in that case navigation listener\n // won't be called\n DdRum.startView(currentViewKey, currentViewName, Date.now(), {});\n }\n }\n };\n\n // AppState is singleton, so we should add a listener only once in the app lifetime\n AppState.addEventListener(\"change\", DdRumReactNavigationTracking.appStateListener);\n }\n }\n\n}\n\n"]}
|
|
1
|
+
{"version":3,"sources":["DdRumReactNavigationTracking.tsx"],"names":["DdRum","AppState","DdRumReactNavigationTracking","startTrackingViews","navigationRef","viewNamePredicate","_route","trackedName","console","log","registeredContainer","error","listener","resolveNavigationStateChangeListener","handleRouteNavigation","getCurrentRoute","addListener","registerAppStateListenerIfNeeded","stopTrackingViews","removeListener","navigationStateChangeListener","route","appStateStatus","undefined","key","predicate","screenName","name","stopView","startView","event","data","state","routes","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,IAAeT,SAAtB,EAAiC;AAC7B,gBAAMY,WAAW,GAAGd,KAAK,CAACW,KAAN,CAAYC,MAAZ,CAAmBZ,KAAK,CAACW,KAAN,CAAYE,KAA/B,CAApB;;AACA,cAAIC,WAAW,IAAIZ,SAAnB,EAA8B;AAC1B;AACA;AACH;;AACDF,UAAAA,KAAK,GAAGc,WAAR;AACH;;AAEDjC,QAAAA,4BAA4B,CAACY,qBAA7B,CAAmDO,KAAnD;AACH,OAlBD;AAmBH;;AACD,WAAOnB,4BAA4B,CAACkB,6BAApC;AACH;;AAE8C,SAAhCH,gCAAgC,GAAG;AAC9C,QAAIf,4BAA4B,CAACkC,gBAA7B,IAAiD,IAArD,EAA2D;AACvDlC,MAAAA,4BAA4B,CAACkC,gBAA7B,GAAiDd,cAAD,IAAoC;AAAA;;AAEhF,cAAMe,YAAY,4BAAGnC,4BAA4B,CAACQ,mBAAhC,0DAAG,sBAAkDK,eAAlD,EAArB;;AACA,YAAIsB,YAAY,IAAId,SAApB,EAA+B;AAC3B;AACH;;AAEDrB,QAAAA,4BAA4B,CAACY,qBAA7B,CAAmDuB,YAAnD,EAAiEf,cAAjE;AACH,OARD,CADuD,CAWvD;;;AACArB,MAAAA,QAAQ,CAACqC,gBAAT,CAA0B,QAA1B,EAAoCpC,4BAA4B,CAACkC,gBAAjE;AACH;AACJ;;AAlHqC;;gBAA7BlC,4B;;gBAAAA,4B;;gBAAAA,4B;;gBAAAA,4B","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { EventArg, NavigationContainerRef, Route } from \"@react-navigation/native\";\nimport { DdRum } from '@datadog/mobile-react-native';\nimport { AppState, AppStateStatus } from 'react-native';\n\ndeclare type NavigationListener = (event: EventArg<string, boolean, any>) => void | null\n\n// AppStateStatus can have values: \n// 'active' - The app is running in the foreground\n// 'background' - The app is running in the background. The user is either in another app or on the home screen\n// 'inactive' [iOS] - This is a transition state that currently never happens for typical React Native apps.\n// 'unknown' [iOS] - Initial value until the current app state is determined\n// 'extension' [iOS] - The app is running as an app extension\ndeclare type AppStateListener = (appStateStatus: AppStateStatus) => void | null\n\nexport type ViewNamePredicate = (route: Route<string, any | undefined>, trackedName: string) => string\n\n/**\n * Provides RUM integration for the [ReactNavigation](https://reactnavigation.org/) API.\n */\nexport class DdRumReactNavigationTracking {\n\n private static registeredContainer: NavigationContainerRef | null;\n \n private static navigationStateChangeListener: NavigationListener;\n\n private static appStateListener: AppStateListener;\n\n private static viewNamePredicate: ViewNamePredicate;\n\n /**\n * Starts tracking the NavigationContainer and sends a RUM View event every time the navigation route changed.\n * @param navigationRef the reference to the real NavigationContainer.\n */\n static startTrackingViews(\n navigationRef: NavigationContainerRef | null,\n viewNamePredicate: ViewNamePredicate = function (_route: Route<string, any | undefined>, trackedName: string) { return trackedName; }\n ): void {\n\n if (navigationRef == null) {\n console.log (\"Cannot track views with a null navigationRef\");\n return;\n }\n\n if (DdRumReactNavigationTracking.registeredContainer != null && this.registeredContainer !== navigationRef) {\n console.error('Cannot track new navigation container while another one is still tracked');\n } else if (DdRumReactNavigationTracking.registeredContainer == null) {\n DdRumReactNavigationTracking.viewNamePredicate = viewNamePredicate;\n const listener = DdRumReactNavigationTracking.resolveNavigationStateChangeListener();\n DdRumReactNavigationTracking.handleRouteNavigation(navigationRef.getCurrentRoute());\n navigationRef.addListener(\"state\", listener);\n DdRumReactNavigationTracking.registeredContainer = navigationRef;\n }\n\n\n DdRumReactNavigationTracking.registerAppStateListenerIfNeeded();\n }\n\n /**\n * Stops tracking the NavigationContainer.\n * @param navigationRef the reference to the real NavigationContainer.\n */\n static stopTrackingViews(navigationRef: NavigationContainerRef | null): void {\n if (navigationRef != null) {\n navigationRef.removeListener(\"state\", DdRumReactNavigationTracking.navigationStateChangeListener);\n DdRumReactNavigationTracking.registeredContainer = null;\n DdRumReactNavigationTracking.viewNamePredicate = function (_route: Route<string, any | undefined>, trackedName: string) { return trackedName; }\n }\n }\n\n private static handleRouteNavigation(\n route: Route<string, any | undefined> | undefined, \n appStateStatus: AppStateStatus | undefined = undefined\n ) {\n if (route == undefined || route == null) {\n // RUMM-1400 in some cases the route seem to be undefined\n return\n }\n const key = route.key;\n\n const predicate = DdRumReactNavigationTracking.viewNamePredicate;\n const screenName = predicate(route, route.name) ?? route.name;\n\n if (key != null && screenName != null) {\n if (appStateStatus === 'background') {\n DdRum.stopView(key);\n } else if (appStateStatus === 'active' || appStateStatus == undefined) {\n // case when app goes into foreground, \n // in that case navigation listener won't be called\n DdRum.startView(key, screenName);\n }\n }\n }\n\n private static resolveNavigationStateChangeListener(): NavigationListener {\n if (DdRumReactNavigationTracking.navigationStateChangeListener == null) {\n DdRumReactNavigationTracking.navigationStateChangeListener = (event: EventArg<string, boolean, any>) => {\n let route = event.data?.state?.routes[event.data?.state?.index];\n\n if (route == undefined) {\n // RUMM-1400 in some cases the route seem to be undefined\n return\n }\n\n while (route.state != undefined) {\n const nestedRoute = route.state.routes[route.state.index];\n if (nestedRoute == undefined) {\n // RUMM-1400 in some cases the route seem to be undefined\n break;\n }\n route = nestedRoute\n }\n\n DdRumReactNavigationTracking.handleRouteNavigation(route);\n };\n }\n return DdRumReactNavigationTracking.navigationStateChangeListener;\n }\n\n private static registerAppStateListenerIfNeeded() {\n if (DdRumReactNavigationTracking.appStateListener == null) {\n DdRumReactNavigationTracking.appStateListener = (appStateStatus: AppStateStatus) => {\n\n const currentRoute = DdRumReactNavigationTracking.registeredContainer?.getCurrentRoute();\n if (currentRoute == undefined) {\n return;\n }\n\n DdRumReactNavigationTracking.handleRouteNavigation(currentRoute, appStateStatus);\n };\n\n // AppState is singleton, so we should add a listener only once in the app lifetime\n AppState.addEventListener(\"change\", DdRumReactNavigationTracking.appStateListener);\n }\n }\n\n}\n\n"]}
|
|
@@ -5,6 +5,17 @@ import type { TrackingConsent } from "./TrackingConsent";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class DdSdkReactNative {
|
|
7
7
|
private static readonly DD_SOURCE_KEY;
|
|
8
|
+
private static readonly DD_SDK_VERSION;
|
|
9
|
+
private static readonly DD_SERVICE_NAME;
|
|
10
|
+
private static readonly DD_SDK_VERBOSITY_KEY;
|
|
11
|
+
private static readonly DD_NATIVE_VIEW_TRACKING_KEY;
|
|
12
|
+
private static readonly DD_PROXY_TYPE_KEY;
|
|
13
|
+
private static readonly DD_PROXY_ADDRESS_KEY;
|
|
14
|
+
private static readonly DD_PROXY_PORT_KEY;
|
|
15
|
+
private static readonly DD_PROXY_USERNAME_KEY;
|
|
16
|
+
private static readonly DD_PROXY_PASSWORD_KEY;
|
|
17
|
+
private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY;
|
|
18
|
+
private static readonly NATIVE_LONG_TASK_THRESHOLD_MS;
|
|
8
19
|
private static wasInitialized;
|
|
9
20
|
/**
|
|
10
21
|
* Initializes the Datadog SDK.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { TrackingConsent } from './TrackingConsent';
|
|
2
|
+
import type { NativeSdkVerbosity } from './NativeSdkVerbosity';
|
|
3
|
+
import type { ProxyConfiguration } from './ProxyConfiguration';
|
|
2
4
|
/**
|
|
3
5
|
* The SDK configuration class.
|
|
4
6
|
* It will be used to configure the SDK functionality at initialization.
|
|
@@ -14,6 +16,10 @@ export declare class DdSdkReactNativeConfiguration {
|
|
|
14
16
|
nativeCrashReportEnabled: boolean;
|
|
15
17
|
sampleRate: number;
|
|
16
18
|
site: string;
|
|
19
|
+
verbosity: NativeSdkVerbosity | undefined;
|
|
20
|
+
nativeViewTracking: boolean;
|
|
21
|
+
proxyConfig?: ProxyConfiguration;
|
|
22
|
+
serviceName?: string;
|
|
17
23
|
additionalConfig: {
|
|
18
24
|
[k: string]: any;
|
|
19
25
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy server configuration.
|
|
3
|
+
*/
|
|
4
|
+
declare class ProxyConfiguration {
|
|
5
|
+
/**
|
|
6
|
+
* Proxy type.
|
|
7
|
+
*/
|
|
8
|
+
readonly type: ProxyType;
|
|
9
|
+
/**
|
|
10
|
+
* Proxy address. Can be either in the IP address format, ex. "1.1.1.1", or hostname, ex. "example.com".
|
|
11
|
+
*/
|
|
12
|
+
readonly address: string;
|
|
13
|
+
/**
|
|
14
|
+
* Proxy port.
|
|
15
|
+
*/
|
|
16
|
+
readonly port: number;
|
|
17
|
+
/**
|
|
18
|
+
* Username for Basic authentication scheme.
|
|
19
|
+
*
|
|
20
|
+
* Note: "SOCKS + authentication" scheme is not supported.
|
|
21
|
+
*/
|
|
22
|
+
readonly username?: string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Password for Basic authentication scheme.
|
|
25
|
+
*/
|
|
26
|
+
readonly password?: string | undefined;
|
|
27
|
+
constructor(
|
|
28
|
+
/**
|
|
29
|
+
* Proxy type.
|
|
30
|
+
*/
|
|
31
|
+
type: ProxyType,
|
|
32
|
+
/**
|
|
33
|
+
* Proxy address. Can be either in the IP address format, ex. "1.1.1.1", or hostname, ex. "example.com".
|
|
34
|
+
*/
|
|
35
|
+
address: string,
|
|
36
|
+
/**
|
|
37
|
+
* Proxy port.
|
|
38
|
+
*/
|
|
39
|
+
port: number,
|
|
40
|
+
/**
|
|
41
|
+
* Username for Basic authentication scheme.
|
|
42
|
+
*
|
|
43
|
+
* Note: "SOCKS + authentication" scheme is not supported.
|
|
44
|
+
*/
|
|
45
|
+
username?: string | undefined,
|
|
46
|
+
/**
|
|
47
|
+
* Password for Basic authentication scheme.
|
|
48
|
+
*/
|
|
49
|
+
password?: string | undefined);
|
|
50
|
+
}
|
|
51
|
+
declare enum ProxyType {
|
|
52
|
+
HTTP = "http",
|
|
53
|
+
HTTPS = "https",
|
|
54
|
+
SOCKS = "socks"
|
|
55
|
+
}
|
|
56
|
+
export { ProxyConfiguration, ProxyType };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple timer which records time ticks. Shouldn't be re-used once stopped.
|
|
3
|
+
* All timestamps/durations returned are in milliseconds.
|
|
4
|
+
*/
|
|
5
|
+
export default class Timer {
|
|
6
|
+
private times;
|
|
7
|
+
get startTime(): number;
|
|
8
|
+
get stopTime(): number;
|
|
9
|
+
start(): void;
|
|
10
|
+
stop(): void;
|
|
11
|
+
recordTick(label: string): void;
|
|
12
|
+
hasTickFor(label: string): boolean;
|
|
13
|
+
durationBetween(startLabel: string, endLabel: string): number;
|
|
14
|
+
timeAt(label: string): number;
|
|
15
|
+
reset(): void;
|
|
16
|
+
private durationBetweenTicks;
|
|
17
|
+
private performanceNow;
|
|
18
|
+
private canUsePerformanceNow;
|
|
19
|
+
private checkLabelExists;
|
|
20
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DdLogs, DdTrace, DdRum } from './foundation';
|
|
2
2
|
import { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
|
|
3
3
|
import { DdSdkReactNative } from './DdSdkReactNative';
|
|
4
|
+
import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
|
|
4
5
|
import { TrackingConsent } from './TrackingConsent';
|
|
5
|
-
export { DdLogs, DdTrace, DdRum, DdSdkReactNativeConfiguration, DdSdkReactNative, TrackingConsent };
|
|
6
|
+
export { DdLogs, DdTrace, DdRum, DdSdkReactNativeConfiguration, DdSdkReactNative, ProxyConfiguration, ProxyType, TrackingConsent };
|
|
@@ -5,6 +5,8 @@ export declare class DdEventsInterceptor implements EventsInterceptor {
|
|
|
5
5
|
interceptOnPress(...args: any[]): void;
|
|
6
6
|
private handleTargetEvent;
|
|
7
7
|
private resolveTargetName;
|
|
8
|
+
private resolveElementTypeName;
|
|
9
|
+
private findClosestActionLabel;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Describe the type of a RUM Action.
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare class DdRumErrorTracking {
|
|
5
5
|
private static isTracking;
|
|
6
|
+
private static isInDefaultErrorHandler;
|
|
6
7
|
private static defaultErrorHandler;
|
|
7
8
|
private static defaultConsoleError;
|
|
8
9
|
/**
|
|
@@ -11,5 +12,6 @@ export declare class DdRumErrorTracking {
|
|
|
11
12
|
static startTracking(): void;
|
|
12
13
|
static onGlobalError(error: any, isFatal?: boolean): void;
|
|
13
14
|
static onConsoleError(...params: unknown[]): void;
|
|
15
|
+
private static getErrorMessage;
|
|
14
16
|
private static getErrorStackTrace;
|
|
15
17
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
/// <reference types="react-native" />
|
|
1
2
|
export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
|
|
2
3
|
export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
|
|
3
4
|
export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
|
|
5
|
+
export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
|
|
6
|
+
export declare const SAMPLED_HEADER_KEY = "x-datadog-sampled";
|
|
4
7
|
export declare const ORIGIN_RUM = "rum";
|
|
8
|
+
export declare function calculateResponseSize(xhr: XMLHttpRequest): number;
|
|
5
9
|
/**
|
|
6
10
|
* Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
|
|
7
11
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="react-native" />
|
|
2
|
+
import type Timer from "../../Timer";
|
|
2
3
|
export interface DdRumXhr extends XMLHttpRequest {
|
|
3
4
|
_datadog_xhr: DdRumXhrContext;
|
|
4
5
|
}
|
|
5
6
|
export interface DdRumXhrContext {
|
|
6
7
|
method: string;
|
|
7
8
|
url: string;
|
|
8
|
-
startTime: number;
|
|
9
|
-
responseStartTime: number;
|
|
10
9
|
reported: boolean;
|
|
10
|
+
timer: Timer;
|
|
11
11
|
spanId: string;
|
|
12
12
|
traceId: string;
|
|
13
13
|
}
|