@datadog/mobile-react-native 3.3.0 → 3.4.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/DatadogSDKReactNative.podspec +7 -7
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +4 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +9 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +13 -6
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkSessionStartedListener.kt +93 -22
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +5 -1
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +5 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +9 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +68 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkSessionStartedListenerTest.kt +38 -1
- package/ios/Sources/DdRum.mm +6 -4
- package/ios/Sources/DdRumImplementation.swift +82 -7
- package/ios/Sources/DdSdkNativeInitialization.swift +24 -17
- package/ios/Sources/DdSdkSessionStartedListener.swift +28 -1
- package/ios/Sources/RNViewResolution.swift +88 -0
- package/ios/Sources/RUMMonitorInternalProtocol.swift +8 -0
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +16 -3
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/config/DatadogProviderConfiguration.js +3 -1
- package/lib/commonjs/config/DatadogProviderConfiguration.js.map +1 -1
- package/lib/commonjs/metro/debugIdResolver.js +5 -3
- package/lib/commonjs/metro/debugIdResolver.js.map +1 -1
- package/lib/commonjs/metro/plugin/metroSerializer.js +4 -3
- package/lib/commonjs/metro/plugin/metroSerializer.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +14 -1
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/eventMappers/actionEventMapper.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
- package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js +6 -1
- package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
- package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +16 -3
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/config/DatadogProviderConfiguration.js +3 -1
- package/lib/module/config/DatadogProviderConfiguration.js.map +1 -1
- package/lib/module/metro/debugIdResolver.js +5 -3
- package/lib/module/metro/debugIdResolver.js.map +1 -1
- package/lib/module/metro/plugin/metroSerializer.js +4 -3
- package/lib/module/metro/plugin/metroSerializer.js.map +1 -1
- package/lib/module/rum/DdRum.js +14 -1
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/eventMappers/actionEventMapper.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
- package/lib/module/sdk/AttributesEncoding/defaultEncoders.js +6 -1
- package/lib/module/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
- package/lib/module/specs/NativeDdRum.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/config/DatadogProviderConfiguration.d.ts +3 -1
- package/lib/typescript/config/DatadogProviderConfiguration.d.ts.map +1 -1
- package/lib/typescript/metro/debugIdResolver.d.ts.map +1 -1
- package/lib/typescript/metro/plugin/metroSerializer.d.ts +1 -1
- package/lib/typescript/metro/plugin/metroSerializer.d.ts.map +1 -1
- package/lib/typescript/nativeModulesTypes.d.ts +2 -1
- package/lib/typescript/nativeModulesTypes.d.ts.map +1 -1
- package/lib/typescript/rum/DdRum.d.ts.map +1 -1
- package/lib/typescript/rum/eventMappers/actionEventMapper.d.ts +1 -0
- package/lib/typescript/rum/eventMappers/actionEventMapper.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts.map +1 -1
- package/lib/typescript/sdk/AttributesEncoding/defaultEncoders.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdRum.d.ts +2 -1
- package/lib/typescript/specs/NativeDdRum.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +18 -2
- package/src/__tests__/DdSdkReactNative.test.tsx +1 -0
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +8 -0
- package/src/config/DatadogProviderConfiguration.ts +3 -1
- package/src/metro/__tests__/metro.test.ts +13 -0
- package/src/metro/debugIdResolver.ts +7 -3
- package/src/metro/plugin/metroSerializer.ts +11 -3
- package/src/nativeModulesTypes.ts +2 -0
- package/src/rum/DdRum.ts +25 -0
- package/src/rum/__tests__/DdRum.test.ts +33 -0
- package/src/rum/eventMappers/actionEventMapper.ts +1 -0
- package/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.ts +2 -1
- package/src/rum/instrumentation/interactionTracking/__tests__/DdBabelInteractionTracking.test.ts +28 -0
- package/src/sdk/AttributesEncoding/__tests__/defaultEncoders.test.ts +25 -1
- package/src/sdk/AttributesEncoding/defaultEncoders.ts +11 -1
- package/src/sdk/DatadogProvider/__tests__/__utils__/renderWithProvider.tsx +24 -7
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +19 -15
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +85 -54
- package/src/specs/NativeDdRum.ts +2 -0
- package/src/version.ts +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { render } from '@testing-library/react-native';
|
|
8
|
-
import { Animated, Button,
|
|
8
|
+
import { Animated, Button, Text, View } from 'react-native';
|
|
9
9
|
import React, { useState } from 'react';
|
|
10
10
|
|
|
11
11
|
import { DatadogProviderConfiguration } from '../../../../config/DatadogProviderConfiguration';
|
|
@@ -109,14 +109,31 @@ export const renderWithProvider = (params?: {
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* Mocks
|
|
113
|
-
*
|
|
112
|
+
* Mocks requestIdleCallback so that scheduled callbacks only run when
|
|
113
|
+
* {@link flushIdleCallbacks} is called. Restores the original value on
|
|
114
|
+
* {@link restore}.
|
|
114
115
|
*/
|
|
115
|
-
export const
|
|
116
|
-
const
|
|
116
|
+
export const mockIdleCallback = () => {
|
|
117
|
+
const callbacks: Array<() => void> = [];
|
|
118
|
+
const original = (globalThis as Record<string, unknown>)
|
|
119
|
+
.requestIdleCallback;
|
|
120
|
+
|
|
121
|
+
(globalThis as Record<string, unknown>).requestIdleCallback = (
|
|
122
|
+
cb: () => void
|
|
123
|
+
) => {
|
|
124
|
+
callbacks.push(cb);
|
|
125
|
+
return callbacks.length;
|
|
126
|
+
};
|
|
117
127
|
|
|
118
128
|
return {
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
flushIdleCallbacks: () => {
|
|
130
|
+
callbacks.splice(0).forEach(cb => cb());
|
|
131
|
+
},
|
|
132
|
+
restore: () => {
|
|
133
|
+
(globalThis as Record<
|
|
134
|
+
string,
|
|
135
|
+
unknown
|
|
136
|
+
>).requestIdleCallback = original;
|
|
137
|
+
}
|
|
121
138
|
};
|
|
122
139
|
};
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
|
|
23
23
|
import {
|
|
24
24
|
getDefaultConfiguration,
|
|
25
|
-
|
|
25
|
+
mockIdleCallback,
|
|
26
26
|
renderWithProvider
|
|
27
27
|
} from './__utils__/renderWithProvider';
|
|
28
28
|
|
|
@@ -190,20 +190,24 @@ describe('DatadogProvider', () => {
|
|
|
190
190
|
|
|
191
191
|
it('runs after initialization when ASYNC initialization', async () => {
|
|
192
192
|
const onInitialization = jest.fn();
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
193
|
+
const idle = mockIdleCallback();
|
|
194
|
+
try {
|
|
195
|
+
const configuration = getDefaultConfiguration();
|
|
196
|
+
configuration.initializationMode = InitializationMode.ASYNC;
|
|
197
|
+
const { getByText } = renderWithProvider({
|
|
198
|
+
onInitialization,
|
|
199
|
+
configuration
|
|
200
|
+
});
|
|
201
|
+
getByText('I am a test application');
|
|
202
|
+
await flushPromises();
|
|
203
|
+
expect(onInitialization).not.toHaveBeenCalled();
|
|
204
|
+
|
|
205
|
+
idle.flushIdleCallbacks();
|
|
206
|
+
await flushPromises();
|
|
207
|
+
expect(onInitialization).toHaveBeenCalledTimes(1);
|
|
208
|
+
} finally {
|
|
209
|
+
idle.restore();
|
|
210
|
+
}
|
|
207
211
|
});
|
|
208
212
|
it('runs after initialization when partial initialization', async () => {
|
|
209
213
|
const onInitialization = jest.fn();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { fireEvent } from '@testing-library/react-native';
|
|
8
|
-
import { NativeModules } from 'react-native';
|
|
8
|
+
import { InteractionManager, NativeModules } from 'react-native';
|
|
9
9
|
|
|
10
10
|
import { DdSdkReactNative } from '../../../DdSdkReactNative';
|
|
11
11
|
import { InitializationMode } from '../../../config/types';
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
|
|
23
23
|
import {
|
|
24
24
|
getDefaultConfiguration,
|
|
25
|
-
|
|
25
|
+
mockIdleCallback,
|
|
26
26
|
renderWithProvider,
|
|
27
27
|
renderWithProviderAndAnimation
|
|
28
28
|
} from './__utils__/renderWithProvider';
|
|
@@ -70,70 +70,101 @@ describe('DatadogProvider', () => {
|
|
|
70
70
|
|
|
71
71
|
expect(NativeModules.DdRum.addAction).toHaveBeenCalledTimes(1);
|
|
72
72
|
});
|
|
73
|
-
it('initializes the SDK
|
|
74
|
-
const
|
|
75
|
-
|
|
73
|
+
it('initializes the SDK without waiting for idle callback', async () => {
|
|
74
|
+
const idle = mockIdleCallback();
|
|
75
|
+
try {
|
|
76
|
+
const configuration = getDefaultConfiguration();
|
|
77
|
+
configuration.initializationMode = InitializationMode.SYNC;
|
|
78
|
+
renderWithProvider({ configuration });
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
await flushPromises();
|
|
81
|
+
|
|
82
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
83
|
+
|
|
84
|
+
idle.flushIdleCallbacks();
|
|
85
|
+
await flushPromises();
|
|
86
|
+
|
|
87
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
88
|
+
} finally {
|
|
89
|
+
idle.restore();
|
|
90
|
+
}
|
|
80
91
|
});
|
|
81
92
|
});
|
|
82
93
|
|
|
83
94
|
describe('initializationMode ASYNC', () => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
_targetInst: {
|
|
105
|
-
props: {
|
|
106
|
-
'dd-action-name': 'press button'
|
|
95
|
+
it('initializes the SDK when the idle callback fires', async () => {
|
|
96
|
+
const idle = mockIdleCallback();
|
|
97
|
+
try {
|
|
98
|
+
const configuration = getDefaultConfiguration();
|
|
99
|
+
configuration.initializationMode = InitializationMode.ASYNC;
|
|
100
|
+
|
|
101
|
+
const { getByText } = renderWithProvider({ configuration });
|
|
102
|
+
await flushPromises();
|
|
103
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(0);
|
|
104
|
+
|
|
105
|
+
idle.flushIdleCallbacks();
|
|
106
|
+
await flushPromises();
|
|
107
|
+
|
|
108
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
109
|
+
const button = getByText('test button');
|
|
110
|
+
fireEvent(button, 'press', {
|
|
111
|
+
_targetInst: {
|
|
112
|
+
props: {
|
|
113
|
+
'dd-action-name': 'press button'
|
|
114
|
+
}
|
|
107
115
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
116
|
+
});
|
|
117
|
+
expect(NativeModules.DdRum.addAction).toHaveBeenCalledTimes(1);
|
|
118
|
+
} finally {
|
|
119
|
+
idle.restore();
|
|
120
|
+
}
|
|
111
121
|
});
|
|
112
122
|
|
|
113
|
-
it('
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
it('defers initialization while animations are running', async () => {
|
|
124
|
+
const idle = mockIdleCallback();
|
|
125
|
+
try {
|
|
126
|
+
const configuration = getDefaultConfiguration();
|
|
127
|
+
configuration.initializationMode = InitializationMode.ASYNC;
|
|
117
128
|
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
renderWithProviderAndAnimation({ configuration });
|
|
130
|
+
await flushPromises();
|
|
131
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(0);
|
|
120
132
|
|
|
121
|
-
|
|
122
|
-
|
|
133
|
+
idle.flushIdleCallbacks();
|
|
134
|
+
await flushPromises();
|
|
123
135
|
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
137
|
+
} finally {
|
|
138
|
+
idle.restore();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
126
141
|
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
it('falls back to InteractionManager when requestIdleCallback is unavailable', async () => {
|
|
143
|
+
const original = (globalThis as Record<string, unknown>)
|
|
144
|
+
.requestIdleCallback;
|
|
145
|
+
(globalThis as Record<
|
|
146
|
+
string,
|
|
147
|
+
unknown
|
|
148
|
+
>).requestIdleCallback = undefined;
|
|
149
|
+
try {
|
|
150
|
+
const configuration = getDefaultConfiguration();
|
|
151
|
+
configuration.initializationMode = InitializationMode.ASYNC;
|
|
152
|
+
|
|
153
|
+
const handle = InteractionManager.createInteractionHandle();
|
|
154
|
+
renderWithProvider({ configuration });
|
|
155
|
+
await flushPromises();
|
|
156
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(0);
|
|
157
|
+
|
|
158
|
+
InteractionManager.clearInteractionHandle(handle);
|
|
159
|
+
await flushPromises();
|
|
160
|
+
|
|
161
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledTimes(1);
|
|
162
|
+
} finally {
|
|
163
|
+
(globalThis as Record<
|
|
164
|
+
string,
|
|
165
|
+
unknown
|
|
166
|
+
>).requestIdleCallback = original;
|
|
167
|
+
}
|
|
137
168
|
});
|
|
138
169
|
});
|
|
139
170
|
|
package/src/specs/NativeDdRum.ts
CHANGED
|
@@ -68,12 +68,14 @@ export interface Spec extends TurboModule {
|
|
|
68
68
|
* Add a RUM Action.
|
|
69
69
|
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
70
70
|
* @param name: The action name.
|
|
71
|
+
* @param touch: The native touch data for tap actions, or null for other action types.
|
|
71
72
|
* @param context: The additional context to send.
|
|
72
73
|
* @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
73
74
|
*/
|
|
74
75
|
addAction(
|
|
75
76
|
type: string,
|
|
76
77
|
name: string,
|
|
78
|
+
touch: Object | null,
|
|
77
79
|
context: Object,
|
|
78
80
|
timestampMs: number
|
|
79
81
|
): Promise<void>;
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '3.
|
|
2
|
+
export const version = '3.4.0';
|