@datadog/mobile-react-navigation 1.0.0-rc4 → 1.0.0-rc8
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/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js +67 -44
- package/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/react-navigation.js +2 -0
- package/lib/commonjs/rum/instrumentation/react-navigation.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumReactNavigationTracking.js +63 -45
- package/lib/module/rum/instrumentation/DdRumReactNavigationTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/react-navigation.js +2 -0
- package/lib/module/rum/instrumentation/react-navigation.js.map +1 -0
- package/lib/typescript/core/src/DdSdkReactNative.d.ts +6 -6
- package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +16 -4
- package/lib/typescript/core/src/InternalLog.d.ts +11 -0
- package/lib/typescript/core/src/SdkVerbosity.d.ts +9 -0
- package/lib/typescript/core/src/TimeProvider.d.ts +20 -0
- package/lib/typescript/core/src/Timer.d.ts +3 -2
- package/lib/typescript/core/src/index.d.ts +4 -2
- package/lib/typescript/core/src/rum/instrumentation/DdEventsInterceptor.d.ts +1 -0
- package/lib/typescript/core/src/rum/instrumentation/DdRumErrorTracking.d.ts +2 -2
- package/lib/typescript/core/src/rum/instrumentation/DdRumResourceTracking.d.ts +19 -9
- package/lib/typescript/core/src/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -3
- package/lib/typescript/core/src/rum/instrumentation/DdRumXhr.d.ts +13 -3
- package/lib/typescript/core/src/rum/instrumentation/ShallowObjectEqualityChecker.d.ts +4 -0
- package/lib/typescript/core/src/rum/instrumentation/URLHostParser.d.ts +6 -0
- package/lib/typescript/core/src/version.d.ts +1 -1
- package/lib/typescript/react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.d.ts +8 -3
- package/lib/typescript/react-navigation/src/rum/instrumentation/react-navigation.d.ts +116 -0
- package/package.json +11 -6
- package/src/__tests__/rum/instrumentation/DdRumReactNavigationTracking.test.tsx +467 -370
- package/src/__tests__/rum/instrumentation/__utils__/AppStateMock.ts +56 -0
- package/src/__tests__/rum/instrumentation/__utils__/Navigators/NavigatorsV5.tsx +105 -0
- package/src/__tests__/rum/instrumentation/__utils__/Navigators/NavigatorsV6.tsx +105 -0
- package/src/index.tsx +4 -1
- package/src/rum/instrumentation/DdRumReactNavigationTracking.tsx +136 -64
- package/src/rum/instrumentation/react-navigation.ts +158 -0
- package/lib/typescript/core/src/NativeSdkVerbosity.d.ts +0 -9
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { TimeProvider } from './TimeProvider';
|
|
1
2
|
/**
|
|
2
3
|
* Simple timer which records time ticks. Shouldn't be re-used once stopped.
|
|
3
4
|
* All timestamps/durations returned are in milliseconds.
|
|
4
5
|
*/
|
|
5
6
|
export default class Timer {
|
|
7
|
+
private timeProvider;
|
|
6
8
|
private times;
|
|
9
|
+
constructor(timeProvider?: TimeProvider);
|
|
7
10
|
get startTime(): number;
|
|
8
11
|
get stopTime(): number;
|
|
9
12
|
start(): void;
|
|
@@ -14,7 +17,5 @@ export default class Timer {
|
|
|
14
17
|
timeAt(label: string): number;
|
|
15
18
|
reset(): void;
|
|
16
19
|
private durationBetweenTicks;
|
|
17
|
-
private performanceNow;
|
|
18
|
-
private canUsePerformanceNow;
|
|
19
20
|
private checkLabelExists;
|
|
20
21
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { DdLogs, DdTrace, DdRum } from './foundation';
|
|
2
1
|
import { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
|
|
3
2
|
import { DdSdkReactNative } from './DdSdkReactNative';
|
|
3
|
+
import { InternalLog } from './InternalLog';
|
|
4
4
|
import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
|
|
5
|
+
import { SdkVerbosity } from './SdkVerbosity';
|
|
5
6
|
import { TrackingConsent } from './TrackingConsent';
|
|
6
|
-
|
|
7
|
+
import { DdLogs, DdTrace, DdRum } from './foundation';
|
|
8
|
+
export { DdLogs, DdTrace, DdRum, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type EventsInterceptor from './EventsInterceptor';
|
|
2
2
|
export declare const UNKNOWN_TARGET_NAME = "unknown_target";
|
|
3
3
|
export declare class DdEventsInterceptor implements EventsInterceptor {
|
|
4
|
+
static ACTION_EVENT_DROPPED_WARN_MESSAGE: string;
|
|
4
5
|
private debouncingStartedTimestamp;
|
|
5
6
|
interceptOnPress(...args: any[]): void;
|
|
6
7
|
private handleTargetEvent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
3
|
-
*/
|
|
2
|
+
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
3
|
+
*/
|
|
4
4
|
export declare class DdRumErrorTracking {
|
|
5
5
|
private static isTracking;
|
|
6
6
|
private static isInDefaultErrorHandler;
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
/// <reference types="react-native" />
|
|
2
|
+
import type { DdRumResourceTracingAttributes } from './DdRumXhr';
|
|
2
3
|
export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
|
|
3
4
|
export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
|
|
4
5
|
export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
|
|
5
6
|
export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
|
|
6
|
-
export declare const SAMPLED_HEADER_KEY = "x-datadog-sampled";
|
|
7
7
|
export declare const ORIGIN_RUM = "rum";
|
|
8
|
+
export declare const RESOURCE_SIZE_ERROR_MESSAGE = "Couldn't get resource size, because an error occured: ";
|
|
8
9
|
export declare function calculateResponseSize(xhr: XMLHttpRequest): number;
|
|
9
10
|
/**
|
|
10
|
-
* Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
|
|
11
|
-
*/
|
|
11
|
+
* Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
|
|
12
|
+
*/
|
|
12
13
|
export declare class DdRumResourceTracking {
|
|
13
14
|
private static isTracking;
|
|
15
|
+
private static tracingSamplingRate;
|
|
16
|
+
private static firstPartyHostsRegex;
|
|
14
17
|
private static originalXhrOpen;
|
|
15
18
|
private static originalXhrSend;
|
|
16
19
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
static startTracking(
|
|
20
|
+
* Starts tracking resources and sends a RUM Resource event every time a network request is detected.
|
|
21
|
+
*/
|
|
22
|
+
static startTracking({ tracingSamplingRate, firstPartyHosts }: {
|
|
23
|
+
tracingSamplingRate: number;
|
|
24
|
+
firstPartyHosts: string[];
|
|
25
|
+
}): void;
|
|
20
26
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
static startTrackingInternal(xhrType:
|
|
27
|
+
* Starts tracking resources and sends a RUM Resource event every time a fetch or XHR call is detected.
|
|
28
|
+
*/
|
|
29
|
+
static startTrackingInternal(xhrType: typeof XMLHttpRequest, { tracingSamplingRate, firstPartyHosts }: {
|
|
30
|
+
tracingSamplingRate: number;
|
|
31
|
+
firstPartyHosts: string[];
|
|
32
|
+
}): void;
|
|
24
33
|
static stopTracking(): void;
|
|
34
|
+
static getTracingAttributes(url: string): DdRumResourceTracingAttributes;
|
|
25
35
|
static proxyXhr(xhrType: any): void;
|
|
26
36
|
private static proxyOpen;
|
|
27
37
|
private static proxySend;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Provides RUM auto-instrumentation feature to track user interaction as RUM events.
|
|
3
|
-
* For now we are only covering the "onPress" events.
|
|
4
|
-
*/
|
|
2
|
+
* Provides RUM auto-instrumentation feature to track user interaction as RUM events.
|
|
3
|
+
* For now we are only covering the "onPress" events.
|
|
4
|
+
*/
|
|
5
5
|
export declare class DdRumUserInteractionTracking {
|
|
6
6
|
private static isTracking;
|
|
7
7
|
private static eventsInterceptor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react-native" />
|
|
2
|
-
import type Timer from
|
|
2
|
+
import type Timer from '../../Timer';
|
|
3
3
|
export interface DdRumXhr extends XMLHttpRequest {
|
|
4
4
|
_datadog_xhr: DdRumXhrContext;
|
|
5
5
|
}
|
|
@@ -8,6 +8,16 @@ export interface DdRumXhrContext {
|
|
|
8
8
|
url: string;
|
|
9
9
|
reported: boolean;
|
|
10
10
|
timer: Timer;
|
|
11
|
-
|
|
12
|
-
traceId: string;
|
|
11
|
+
tracingAttributes: DdRumResourceTracingAttributes;
|
|
13
12
|
}
|
|
13
|
+
export declare type DdRumResourceTracingAttributes = {
|
|
14
|
+
tracingStrategy: 'KEEP';
|
|
15
|
+
traceId: string;
|
|
16
|
+
spanId: string;
|
|
17
|
+
samplingPriorityHeader: '1';
|
|
18
|
+
} | {
|
|
19
|
+
tracingStrategy: 'DISCARD';
|
|
20
|
+
traceId?: void;
|
|
21
|
+
spanId?: void;
|
|
22
|
+
samplingPriorityHeader: '0';
|
|
23
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.0-
|
|
1
|
+
export declare const version = "1.0.0-rc8";
|
package/lib/typescript/react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NavigationContainerRef, Route } from
|
|
1
|
+
import type { NavigationContainerRef, Route } from './react-navigation';
|
|
2
2
|
export declare type ViewNamePredicate = (route: Route<string, any | undefined>, trackedName: string) => string;
|
|
3
3
|
/**
|
|
4
4
|
* Provides RUM integration for the [ReactNavigation](https://reactnavigation.org/) API.
|
|
@@ -6,8 +6,13 @@ export declare type ViewNamePredicate = (route: Route<string, any | undefined>,
|
|
|
6
6
|
export declare class DdRumReactNavigationTracking {
|
|
7
7
|
private static registeredContainer;
|
|
8
8
|
private static navigationStateChangeListener;
|
|
9
|
-
private static appStateListener;
|
|
10
9
|
private static viewNamePredicate;
|
|
10
|
+
private static backHandler;
|
|
11
|
+
static ROUTE_UNDEFINED_NAVIGATION_WARNING_MESSAGE: string;
|
|
12
|
+
static NULL_NAVIGATION_REF_ERROR_MESSAGE: string;
|
|
13
|
+
static NAVIGATION_REF_IN_USE_ERROR_MESSAGE: string;
|
|
14
|
+
static isAppExitingOnBackPress: () => boolean;
|
|
15
|
+
static onBackPress: () => boolean;
|
|
11
16
|
/**
|
|
12
17
|
* Starts tracking the NavigationContainer and sends a RUM View event every time the navigation route changed.
|
|
13
18
|
* @param navigationRef the reference to the real NavigationContainer.
|
|
@@ -20,5 +25,5 @@ export declare class DdRumReactNavigationTracking {
|
|
|
20
25
|
static stopTrackingViews(navigationRef: NavigationContainerRef | null): void;
|
|
21
26
|
private static handleRouteNavigation;
|
|
22
27
|
private static resolveNavigationStateChangeListener;
|
|
23
|
-
private static
|
|
28
|
+
private static appStateListener;
|
|
24
29
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains copy/pastes from react-navigation types. The types have been simplified to be able to work with
|
|
3
|
+
* both v5 and v6.
|
|
4
|
+
* This is needed because NavigationContainerRef became NavigationContainerRef<T> in v6, and so we cannot keep compatibility
|
|
5
|
+
* between the 2 types. Also this way we never import '@react-navigation/native-vX' in our code.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Route
|
|
9
|
+
*/
|
|
10
|
+
export declare type Route<RouteName extends string, Params extends object | undefined = object | undefined> = Readonly<{
|
|
11
|
+
/**
|
|
12
|
+
* Unique key for the route.
|
|
13
|
+
*/
|
|
14
|
+
key: string;
|
|
15
|
+
/**
|
|
16
|
+
* User-provided name for the route.
|
|
17
|
+
*/
|
|
18
|
+
name: RouteName;
|
|
19
|
+
}> & (undefined extends Params ? Readonly<{
|
|
20
|
+
/**
|
|
21
|
+
* Params for this route
|
|
22
|
+
*/
|
|
23
|
+
params?: Readonly<Params>;
|
|
24
|
+
}> : Readonly<{
|
|
25
|
+
/**
|
|
26
|
+
* Params for this route
|
|
27
|
+
*/
|
|
28
|
+
params: Readonly<Params>;
|
|
29
|
+
}>);
|
|
30
|
+
/**
|
|
31
|
+
* Navigation Container
|
|
32
|
+
*/
|
|
33
|
+
export declare type NavigationContainerRef = EventConsumer<NavigationContainerEventMap> & {
|
|
34
|
+
canGoBack(): boolean;
|
|
35
|
+
getCurrentRoute(): Route<string> | undefined;
|
|
36
|
+
};
|
|
37
|
+
export declare type NavigationContainerEventMap = {
|
|
38
|
+
/**
|
|
39
|
+
* Event which fires when the navigation state changes.
|
|
40
|
+
*/
|
|
41
|
+
state: {
|
|
42
|
+
data: {
|
|
43
|
+
/**
|
|
44
|
+
* The updated state object after the state change.
|
|
45
|
+
*/
|
|
46
|
+
state: any;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Event which fires when current options changes.
|
|
51
|
+
*/
|
|
52
|
+
options: {
|
|
53
|
+
data: {
|
|
54
|
+
options: object;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Event which fires when an action is dispatched.
|
|
59
|
+
* Only intended for debugging purposes, don't use it for app logic.
|
|
60
|
+
* This event will be emitted before state changes have been applied.
|
|
61
|
+
*/
|
|
62
|
+
__unsafe_action__: {
|
|
63
|
+
data: {
|
|
64
|
+
/**
|
|
65
|
+
* The action object which was dispatched.
|
|
66
|
+
*/
|
|
67
|
+
action: any;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the action was a no-op, i.e. resulted any state changes.
|
|
70
|
+
*/
|
|
71
|
+
noop: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Stack trace of the action, this will only be available during development.
|
|
74
|
+
*/
|
|
75
|
+
stack: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export declare type EventConsumer<EventMap extends EventMapBase> = {
|
|
80
|
+
/**
|
|
81
|
+
* Subscribe to events from the parent navigator.
|
|
82
|
+
*
|
|
83
|
+
* @param type Type of the event (e.g. `focus`, `blur`)
|
|
84
|
+
* @param callback Callback listener which is executed upon receiving the event.
|
|
85
|
+
*/
|
|
86
|
+
addListener<EventName extends Extract<keyof EventMap, string>>(type: EventName, callback: (...args: any[]) => any): () => void;
|
|
87
|
+
removeListener<EventName extends Extract<keyof EventMap, string>>(type: EventName, callback: (...args: any[]) => any): void;
|
|
88
|
+
};
|
|
89
|
+
export declare type EventMapBase = Record<string, {
|
|
90
|
+
data?: any;
|
|
91
|
+
canPreventDefault?: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* NavigationListener
|
|
95
|
+
*/
|
|
96
|
+
export declare type NavigationListener = (event: EventArg<string, boolean, any>) => void | null;
|
|
97
|
+
export declare type EventArg<EventName extends string, CanPreventDefault extends boolean | undefined = false, Data = undefined> = {
|
|
98
|
+
/**
|
|
99
|
+
* Type of the event (e.g. `focus`, `blur`)
|
|
100
|
+
*/
|
|
101
|
+
readonly type: EventName;
|
|
102
|
+
readonly target?: string;
|
|
103
|
+
} & (CanPreventDefault extends true ? {
|
|
104
|
+
/**
|
|
105
|
+
* Whether `event.preventDefault()` was called on this event object.
|
|
106
|
+
*/
|
|
107
|
+
readonly defaultPrevented: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Prevent the default action which happens on this event.
|
|
110
|
+
*/
|
|
111
|
+
preventDefault(): void;
|
|
112
|
+
} : any) & (undefined extends Data ? {
|
|
113
|
+
readonly data?: Readonly<Data>;
|
|
114
|
+
} : {
|
|
115
|
+
readonly data: Readonly<Data>;
|
|
116
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-navigation",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc8",
|
|
4
4
|
"description": "A client-side React Native module to interact with Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -36,15 +36,17 @@
|
|
|
36
36
|
"prepare": "bob build"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@datadog/mobile-react-native": "^1.0.0-
|
|
40
|
-
"@react-navigation/native": "5.9.2",
|
|
41
|
-
"@react-navigation/
|
|
39
|
+
"@datadog/mobile-react-native": "^1.0.0-rc8",
|
|
40
|
+
"@react-navigation/native-v5": "npm:@react-navigation/native@5.9.2",
|
|
41
|
+
"@react-navigation/native-v6": "npm:@react-navigation/native@6.0.9",
|
|
42
|
+
"@react-navigation/stack-v5": "npm:@react-navigation/stack@5.14.2",
|
|
43
|
+
"@react-navigation/stack-v6": "npm:@react-navigation/stack@6.2.1",
|
|
44
|
+
"@testing-library/react-native": "7.0.2",
|
|
42
45
|
"react-native-gesture-handler": "1.10.3",
|
|
43
46
|
"react-native-safe-area-context": "3.1.9"
|
|
44
47
|
},
|
|
45
48
|
"peerDependencies": {
|
|
46
49
|
"@datadog/mobile-react-native": "^1.0.0-beta4",
|
|
47
|
-
"@react-navigation/native": "^5.6.0",
|
|
48
50
|
"react": ">=16.13.1",
|
|
49
51
|
"react-native": ">=0.63.4 <1.0"
|
|
50
52
|
},
|
|
@@ -56,6 +58,9 @@
|
|
|
56
58
|
"setupFiles": [
|
|
57
59
|
"./../../node_modules/react-native-gesture-handler/jestSetup.js"
|
|
58
60
|
],
|
|
61
|
+
"testPathIgnorePatterns": [
|
|
62
|
+
"/__utils__/"
|
|
63
|
+
],
|
|
59
64
|
"transformIgnorePatterns": []
|
|
60
65
|
},
|
|
61
66
|
"react-native-builder-bob": {
|
|
@@ -72,5 +77,5 @@
|
|
|
72
77
|
]
|
|
73
78
|
]
|
|
74
79
|
},
|
|
75
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "67456f90ac95007f8f99beb065ccbf6ec9a6f478"
|
|
76
81
|
}
|