@datadog/mobile-react-navigation 1.0.0-rc5 → 1.0.0-rc9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/lib/commonjs/index.js.map +1 -1
  2. package/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js +77 -51
  3. package/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js.map +1 -1
  4. package/lib/commonjs/rum/instrumentation/react-navigation.js +2 -0
  5. package/lib/commonjs/rum/instrumentation/react-navigation.js.map +1 -0
  6. package/lib/module/index.js.map +1 -1
  7. package/lib/module/rum/instrumentation/DdRumReactNavigationTracking.js +74 -52
  8. package/lib/module/rum/instrumentation/DdRumReactNavigationTracking.js.map +1 -1
  9. package/lib/module/rum/instrumentation/react-navigation.js +2 -0
  10. package/lib/module/rum/instrumentation/react-navigation.js.map +1 -0
  11. package/lib/typescript/core/src/DdSdkReactNative.d.ts +6 -6
  12. package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +15 -3
  13. package/lib/typescript/core/src/InternalLog.d.ts +5 -0
  14. package/lib/typescript/core/src/TimeProvider.d.ts +20 -0
  15. package/lib/typescript/core/src/Timer.d.ts +3 -2
  16. package/lib/typescript/core/src/index.d.ts +4 -3
  17. package/lib/typescript/core/src/rum/instrumentation/DdEventsInterceptor.d.ts +1 -0
  18. package/lib/typescript/core/src/rum/instrumentation/DdRumErrorTracking.d.ts +2 -2
  19. package/lib/typescript/core/src/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -3
  20. package/lib/typescript/core/src/rum/instrumentation/ShallowObjectEqualityChecker.d.ts +4 -0
  21. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +15 -0
  22. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +18 -0
  23. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/firstPartyHosts.d.ts +6 -0
  24. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.d.ts +8 -0
  25. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +19 -0
  26. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.d.ts +8 -0
  27. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.d.ts +6 -0
  28. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/resourceTiming.d.ts +17 -0
  29. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/implementation/URLHostParser.d.ts +6 -0
  30. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/implementation/XHRProxy.d.ts +25 -0
  31. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/implementation/responseSize.d.ts +3 -0
  32. package/lib/typescript/core/src/version.d.ts +1 -1
  33. package/lib/typescript/react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.d.ts +9 -3
  34. package/lib/typescript/react-navigation/src/rum/instrumentation/react-navigation.d.ts +116 -0
  35. package/package.json +11 -6
  36. package/src/__tests__/rum/instrumentation/DdRumReactNavigationTracking.test.tsx +481 -385
  37. package/src/__tests__/rum/instrumentation/__utils__/AppStateMock.ts +75 -0
  38. package/src/__tests__/rum/instrumentation/__utils__/AppStateMockLegacy.ts +61 -0
  39. package/src/__tests__/rum/instrumentation/__utils__/Navigators/NavigatorsV5.tsx +105 -0
  40. package/src/__tests__/rum/instrumentation/__utils__/Navigators/NavigatorsV6.tsx +105 -0
  41. package/src/index.tsx +4 -1
  42. package/src/rum/instrumentation/DdRumReactNavigationTracking.tsx +145 -64
  43. package/src/rum/instrumentation/react-navigation.ts +158 -0
  44. package/lib/typescript/core/src/rum/instrumentation/DdRumResourceTracking.d.ts +0 -30
  45. package/lib/typescript/core/src/rum/instrumentation/DdRumXhr.d.ts +0 -13
  46. package/lib/typescript/core/src/rum/instrumentation/TraceIdentifier.d.ts +0 -1
@@ -0,0 +1,158 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ /**
8
+ * This file contains copy/pastes from react-navigation types. The types have been simplified to be able to work with
9
+ * both v5 and v6.
10
+ * This is needed because NavigationContainerRef became NavigationContainerRef<T> in v6, and so we cannot keep compatibility
11
+ * between the 2 types. Also this way we never import '@react-navigation/native-vX' in our code.
12
+ */
13
+
14
+ /**
15
+ * Route
16
+ */
17
+
18
+ export declare type Route<
19
+ RouteName extends string,
20
+ Params extends object | undefined = object | undefined
21
+ > = Readonly<{
22
+ /**
23
+ * Unique key for the route.
24
+ */
25
+ key: string;
26
+ /**
27
+ * User-provided name for the route.
28
+ */
29
+ name: RouteName;
30
+ }> &
31
+ (undefined extends Params
32
+ ? Readonly<{
33
+ /**
34
+ * Params for this route
35
+ */
36
+ params?: Readonly<Params>;
37
+ }>
38
+ : Readonly<{
39
+ /**
40
+ * Params for this route
41
+ */
42
+ params: Readonly<Params>;
43
+ }>);
44
+
45
+ /**
46
+ * Navigation Container
47
+ */
48
+
49
+ export declare type NavigationContainerRef = EventConsumer<NavigationContainerEventMap> & {
50
+ canGoBack(): boolean;
51
+ getCurrentRoute(): Route<string> | undefined;
52
+ };
53
+
54
+ export declare type NavigationContainerEventMap = {
55
+ /**
56
+ * Event which fires when the navigation state changes.
57
+ */
58
+ state: {
59
+ data: {
60
+ /**
61
+ * The updated state object after the state change.
62
+ */
63
+ state: any;
64
+ };
65
+ };
66
+ /**
67
+ * Event which fires when current options changes.
68
+ */
69
+ options: {
70
+ data: {
71
+ options: object;
72
+ };
73
+ };
74
+ /**
75
+ * Event which fires when an action is dispatched.
76
+ * Only intended for debugging purposes, don't use it for app logic.
77
+ * This event will be emitted before state changes have been applied.
78
+ */
79
+ __unsafe_action__: {
80
+ data: {
81
+ /**
82
+ * The action object which was dispatched.
83
+ */
84
+ action: any;
85
+ /**
86
+ * Whether the action was a no-op, i.e. resulted any state changes.
87
+ */
88
+ noop: boolean;
89
+ /**
90
+ * Stack trace of the action, this will only be available during development.
91
+ */
92
+ stack: string | undefined;
93
+ };
94
+ };
95
+ };
96
+
97
+ export declare type EventConsumer<EventMap extends EventMapBase> = {
98
+ /**
99
+ * Subscribe to events from the parent navigator.
100
+ *
101
+ * @param type Type of the event (e.g. `focus`, `blur`)
102
+ * @param callback Callback listener which is executed upon receiving the event.
103
+ */
104
+ addListener<EventName extends Extract<keyof EventMap, string>>(
105
+ type: EventName,
106
+ callback: (...args: any[]) => any
107
+ ): () => void;
108
+ removeListener<EventName extends Extract<keyof EventMap, string>>(
109
+ type: EventName,
110
+ callback: (...args: any[]) => any
111
+ ): void;
112
+ };
113
+
114
+ export declare type EventMapBase = Record<
115
+ string,
116
+ {
117
+ data?: any;
118
+ canPreventDefault?: boolean;
119
+ }
120
+ >;
121
+
122
+ /**
123
+ * NavigationListener
124
+ */
125
+
126
+ export declare type NavigationListener = (
127
+ event: EventArg<string, boolean, any>
128
+ ) => void | null;
129
+
130
+ export declare type EventArg<
131
+ EventName extends string,
132
+ CanPreventDefault extends boolean | undefined = false,
133
+ Data = undefined
134
+ > = {
135
+ /**
136
+ * Type of the event (e.g. `focus`, `blur`)
137
+ */
138
+ readonly type: EventName;
139
+ readonly target?: string;
140
+ } & (CanPreventDefault extends true
141
+ ? {
142
+ /**
143
+ * Whether `event.preventDefault()` was called on this event object.
144
+ */
145
+ readonly defaultPrevented: boolean;
146
+ /**
147
+ * Prevent the default action which happens on this event.
148
+ */
149
+ preventDefault(): void;
150
+ }
151
+ : any) &
152
+ (undefined extends Data
153
+ ? {
154
+ readonly data?: Readonly<Data>;
155
+ }
156
+ : {
157
+ readonly data: Readonly<Data>;
158
+ });
@@ -1,30 +0,0 @@
1
- /// <reference types="react-native" />
2
- export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
3
- export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
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";
7
- export declare const ORIGIN_RUM = "rum";
8
- export declare function calculateResponseSize(xhr: XMLHttpRequest): number;
9
- /**
10
- * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
11
- */
12
- export declare class DdRumResourceTracking {
13
- private static isTracking;
14
- private static originalXhrOpen;
15
- private static originalXhrSend;
16
- /**
17
- * Starts tracking resources and sends a RUM Resource event every time a network request is detected.
18
- */
19
- static startTracking(): void;
20
- /**
21
- * Starts tracking resources and sends a RUM Resource event every time a fetch or XHR call is detected.
22
- */
23
- static startTrackingInternal(xhrType: any): void;
24
- static stopTracking(): void;
25
- static proxyXhr(xhrType: any): void;
26
- private static proxyOpen;
27
- private static proxySend;
28
- private static proxyOnReadyStateChange;
29
- private static reportXhr;
30
- }
@@ -1,13 +0,0 @@
1
- /// <reference types="react-native" />
2
- import type Timer from "../../Timer";
3
- export interface DdRumXhr extends XMLHttpRequest {
4
- _datadog_xhr: DdRumXhrContext;
5
- }
6
- export interface DdRumXhrContext {
7
- method: string;
8
- url: string;
9
- reported: boolean;
10
- timer: Timer;
11
- spanId: string;
12
- traceId: string;
13
- }
@@ -1 +0,0 @@
1
- export declare function generateTraceId(): string;