@datadog/mobile-react-native 1.7.0 → 1.8.0-rc0
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 +14 -1
- package/android/build.gradle +20 -7
- package/android/src/main/kotlin/com/datadog/reactnative/{DdLogs.kt → DdLogsImplementation.kt} +3 -17
- package/android/src/main/kotlin/com/datadog/reactnative/{DdRum.kt → DdRumImplementation.kt} +2 -18
- package/android/src/main/kotlin/com/datadog/reactnative/{DdSdk.kt → DdSdkImplementation.kt} +3 -14
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +34 -17
- package/android/src/main/kotlin/com/datadog/reactnative/{DdTrace.kt → DdTraceImplementation.kt} +6 -11
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdLogs.kt +148 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +199 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +90 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdTrace.kt +46 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +163 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +200 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +91 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +47 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +3 -13
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +2 -6
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +33 -33
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +2 -6
- package/ios/Sources/{DdSdkReactNative-Bridging-Header.h → DatadogSDKReactNative.h} +2 -1
- package/ios/Sources/DdLogs.h +24 -0
- package/ios/Sources/DdLogs.mm +149 -0
- package/ios/Sources/{DdLogs.swift → DdLogsImplementation.swift} +20 -29
- package/ios/Sources/DdRum.h +24 -0
- package/ios/Sources/DdRum.mm +188 -0
- package/ios/Sources/{DdRum.swift → DdRumImplementation.swift} +28 -35
- package/ios/Sources/DdSdk.h +24 -0
- package/ios/Sources/DdSdk.mm +119 -0
- package/ios/Sources/{DdSdk.swift → DdSdkImplementation.swift} +20 -25
- package/ios/Sources/DdTrace.h +24 -0
- package/ios/Sources/DdTrace.mm +66 -0
- package/ios/Sources/{DdTrace.swift → DdTraceImplementation.swift} +10 -17
- package/ios/Sources/QueueHolder.swift +8 -0
- package/jest/mock.js +6 -1
- package/lib/commonjs/DdSdkReactNative.js +32 -49
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +18 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +33 -40
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +13 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +104 -106
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/eventMappers/errorEventMapper.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/sdk/DdSdk.js +3 -3
- package/lib/commonjs/sdk/DdSdk.js.map +1 -1
- package/lib/commonjs/specs/NativeDdLogs.js +20 -0
- package/lib/commonjs/specs/NativeDdLogs.js.map +1 -0
- package/lib/commonjs/specs/NativeDdRum.js +20 -0
- package/lib/commonjs/specs/NativeDdRum.js.map +1 -0
- package/lib/commonjs/specs/NativeDdSdk.js +20 -0
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -0
- package/lib/commonjs/specs/NativeDdTrace.js +20 -0
- package/lib/commonjs/specs/NativeDdTrace.js.map +1 -0
- package/lib/commonjs/trace/DdTrace.js +10 -12
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +27 -44
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +18 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/logs/DdLogs.js +33 -39
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +13 -0
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +100 -101
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/eventMappers/errorEventMapper.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/sdk/DdSdk.js +3 -2
- package/lib/module/sdk/DdSdk.js.map +1 -1
- package/lib/module/specs/NativeDdLogs.js +14 -0
- package/lib/module/specs/NativeDdLogs.js.map +1 -0
- package/lib/module/specs/NativeDdRum.js +14 -0
- package/lib/module/specs/NativeDdRum.js.map +1 -0
- package/lib/module/specs/NativeDdSdk.js +14 -0
- package/lib/module/specs/NativeDdSdk.js.map +1 -0
- package/lib/module/specs/NativeDdTrace.js +14 -0
- package/lib/module/specs/NativeDdTrace.js.map +1 -0
- package/lib/module/trace/DdTrace.js +10 -11
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +4 -4
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +14 -0
- package/lib/typescript/logs/DdLogs.d.ts +4 -4
- package/lib/typescript/nativeModulesTypes.d.ts +28 -168
- package/lib/typescript/rum/DdRum.d.ts +12 -12
- package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +4 -4
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +4 -0
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +3 -1
- package/lib/typescript/specs/NativeDdLogs.d.ts +69 -0
- package/lib/typescript/specs/NativeDdRum.d.ts +92 -0
- package/lib/typescript/specs/NativeDdSdk.d.ts +46 -0
- package/lib/typescript/specs/NativeDdTrace.d.ts +23 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +10 -2
- package/src/DdSdkReactNative.tsx +12 -10
- package/src/DdSdkReactNativeConfiguration.tsx +22 -0
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
- package/src/__tests__/longTasksUtils.test.ts +5 -0
- package/src/__tests__/mock.test.ts +89 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +54 -0
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +118 -68
- package/src/logs/DdLogs.ts +11 -11
- package/src/logs/__tests__/DdLogs.test.ts +1 -1
- package/src/nativeModulesTypes.ts +49 -254
- package/src/rum/DdRum.ts +36 -32
- package/src/rum/eventMappers/errorEventMapper.ts +4 -4
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +15 -0
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +6 -2
- package/src/sdk/DdSdk.ts +2 -3
- package/src/specs/NativeDdLogs.ts +110 -0
- package/src/specs/NativeDdRum.ts +151 -0
- package/src/specs/NativeDdSdk.ts +62 -0
- package/src/specs/NativeDdTrace.ts +42 -0
- package/src/trace/DdTrace.ts +9 -9
- package/src/version.ts +1 -1
- package/ios/Sources/DdLogs.m +0 -62
- package/ios/Sources/DdRum.m +0 -82
- package/ios/Sources/DdSdk.m +0 -41
- package/ios/Sources/DdTrace.m +0 -23
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Do not import this Spec directly, use DdNativeRumType instead.
|
|
4
|
+
*/
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
readonly getConstants: () => {};
|
|
7
|
+
/**
|
|
8
|
+
* Start tracking a RUM View.
|
|
9
|
+
* @param key: The view unique key identifier.
|
|
10
|
+
* @param name: The view name.
|
|
11
|
+
* @param context: The additional context to send.
|
|
12
|
+
* @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
|
|
13
|
+
*/
|
|
14
|
+
startView(key: string, name: string, context: Object, timestampMs: number): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Stop tracking a RUM View.
|
|
17
|
+
* @param key: The view unique key identifier.
|
|
18
|
+
* @param context: The additional context to send.
|
|
19
|
+
* @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
20
|
+
*/
|
|
21
|
+
stopView(key: string, context: Object, timestampMs: number): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Start tracking a RUM Action.
|
|
24
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
25
|
+
* @param name: The action name.
|
|
26
|
+
* @param context: The additional context to send.
|
|
27
|
+
* @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
28
|
+
*/
|
|
29
|
+
startAction(type: string, name: string, context: Object, timestampMs: number): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Stop tracking the ongoing RUM Action.
|
|
32
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
33
|
+
* @param name: The action name.
|
|
34
|
+
* @param context: The additional context to send.
|
|
35
|
+
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
36
|
+
*/
|
|
37
|
+
stopAction(type: string, name: string, context: Object, timestampMs: number): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Add a RUM Action.
|
|
40
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
41
|
+
* @param name: The action name.
|
|
42
|
+
* @param context: The additional context to send.
|
|
43
|
+
* @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
44
|
+
*/
|
|
45
|
+
addAction(type: string, name: string, context: Object, timestampMs: number): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Start tracking a RUM Resource.
|
|
48
|
+
* @param key: The resource unique key identifier.
|
|
49
|
+
* @param method: The resource method (GET, POST, …).
|
|
50
|
+
* @param url: The resource url.
|
|
51
|
+
* @param context: The additional context to send.
|
|
52
|
+
* @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
|
|
53
|
+
*/
|
|
54
|
+
startResource(key: string, method: string, url: string, context: Object, timestampMs: number): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Stop tracking a RUM Resource.
|
|
57
|
+
* @param key: The resource unique key identifier.
|
|
58
|
+
* @param statusCode: The resource status code.
|
|
59
|
+
* @param kind: The resource's kind (xhr, document, image, css, font, …).
|
|
60
|
+
* @param size: The resource size in bytes. If size is unknown, use -1.
|
|
61
|
+
* @param context: The additional context to send.
|
|
62
|
+
* @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
63
|
+
*/
|
|
64
|
+
stopResource(key: string, statusCode: number, kind: string, size: number, context: Object, timestampMs: number): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Add a RUM Error.
|
|
67
|
+
* @param message: The error message.
|
|
68
|
+
* @param source: The error source (network, source, console, webview, custom).
|
|
69
|
+
* @param stacktrace: The error stacktrace.
|
|
70
|
+
* @param context: The additional context to send.
|
|
71
|
+
* @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
72
|
+
*/
|
|
73
|
+
addError(message: string, source: string, stacktrace: string, context: Object, timestampMs: number): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.
|
|
76
|
+
* @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
|
|
77
|
+
*/
|
|
78
|
+
addTiming(name: string): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Stops the current RUM Session.
|
|
81
|
+
*/
|
|
82
|
+
stopSession(): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Adds the result of evaluating a feature flag with a given name and value to the view.
|
|
85
|
+
* Feature flag evaluations are local to the active view and are cleared when the view is stopped.
|
|
86
|
+
* @param name: The name of the feature flag
|
|
87
|
+
* @param value: The value of the feature flag, encapsulated in an Object to accept all types
|
|
88
|
+
*/
|
|
89
|
+
addFeatureFlagEvaluation(name: string, value: Object): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
declare const _default: Spec | null;
|
|
92
|
+
export default _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Do not import this Spec directly, use DdNativeSdkType instead.
|
|
4
|
+
*/
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
readonly getConstants: () => {};
|
|
7
|
+
/**
|
|
8
|
+
* Initializes Datadog's features.
|
|
9
|
+
* @param configuration: The configuration to use.
|
|
10
|
+
*/
|
|
11
|
+
initialize(configuration: Object): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
|
|
14
|
+
* @param attributes: The global context attributes.
|
|
15
|
+
*/
|
|
16
|
+
setAttributes(attributes: Object): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Set the user information.
|
|
19
|
+
* @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
|
|
20
|
+
*/
|
|
21
|
+
setUser(user: Object): Promise<Object>;
|
|
22
|
+
/**
|
|
23
|
+
* Set the tracking consent regarding the data collection.
|
|
24
|
+
* @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
|
|
25
|
+
*/
|
|
26
|
+
setTrackingConsent(trackingConsent: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Sends internal telemetry debug message
|
|
29
|
+
* @param message debug message
|
|
30
|
+
*/
|
|
31
|
+
telemetryDebug(message: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Sends internal telemetry error
|
|
34
|
+
* @param message error message
|
|
35
|
+
* @param stack error stack
|
|
36
|
+
* @param kind error kind
|
|
37
|
+
*/
|
|
38
|
+
telemetryError(message: string, stack: string, kind: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Send webview telemetry logs
|
|
41
|
+
* @param message event description
|
|
42
|
+
*/
|
|
43
|
+
consumeWebviewEvent(message: string): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
declare const _default: Spec | null;
|
|
46
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Do not import this Spec directly, use DdNativeTraceType instead.
|
|
4
|
+
*/
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
readonly getConstants: () => {};
|
|
7
|
+
/**
|
|
8
|
+
* Start a span, and returns a unique identifier for the span.
|
|
9
|
+
* @param operation: The operation name of the span.
|
|
10
|
+
* @param context: The additional context to send.
|
|
11
|
+
* @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
|
|
12
|
+
*/
|
|
13
|
+
startSpan(operation: string, context: Object, timestampMs: number): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Finish a started span.
|
|
16
|
+
* @param spanId: The unique identifier of the span.
|
|
17
|
+
* @param context: The additional context to send.
|
|
18
|
+
* @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
19
|
+
*/
|
|
20
|
+
finishSpan(spanId: string, context: Object, timestampMs: number): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: Spec | null;
|
|
23
|
+
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.8.0-rc0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0-rc0",
|
|
4
4
|
"description": "A client-side React Native module to interact with Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -77,5 +77,13 @@
|
|
|
77
77
|
]
|
|
78
78
|
]
|
|
79
79
|
},
|
|
80
|
-
"
|
|
80
|
+
"codegenConfig": {
|
|
81
|
+
"name": "DdSdkReactNative",
|
|
82
|
+
"type": "modules",
|
|
83
|
+
"jsSrcsDir": "./src/specs",
|
|
84
|
+
"android": {
|
|
85
|
+
"javaPackageName": "com.datadog.reactnative"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"gitHead": "ddc6223ac9ac6b2d03884db91d1ce22e8c68f756"
|
|
81
89
|
}
|
package/src/DdSdkReactNative.tsx
CHANGED
|
@@ -70,14 +70,14 @@ export class DdSdkReactNative {
|
|
|
70
70
|
* @param configuration the configuration for the SDK library
|
|
71
71
|
* @returns a Promise.
|
|
72
72
|
*/
|
|
73
|
-
static async
|
|
73
|
+
static initialize = async (
|
|
74
74
|
configuration: DdSdkReactNativeConfiguration
|
|
75
|
-
): Promise<void> {
|
|
75
|
+
): Promise<void> => {
|
|
76
76
|
await DdSdkReactNative.initializeNativeSDK(configuration, {
|
|
77
77
|
initializationModeForTelemetry: 'LEGACY'
|
|
78
78
|
});
|
|
79
79
|
DdSdkReactNative.enableFeatures(configuration);
|
|
80
|
-
}
|
|
80
|
+
};
|
|
81
81
|
|
|
82
82
|
private static initializeNativeSDK = async (
|
|
83
83
|
configuration: DdSdkReactNativeConfiguration,
|
|
@@ -209,14 +209,14 @@ export class DdSdkReactNative {
|
|
|
209
209
|
* @returns a Promise.
|
|
210
210
|
*/
|
|
211
211
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
212
|
-
static async
|
|
212
|
+
static setAttributes = async (attributes: Attributes): Promise<void> => {
|
|
213
213
|
InternalLog.log(
|
|
214
214
|
`Setting attributes ${JSON.stringify(attributes)}`,
|
|
215
215
|
SdkVerbosity.DEBUG
|
|
216
216
|
);
|
|
217
217
|
await DdSdk.setAttributes(attributes);
|
|
218
218
|
AttributesSingleton.getInstance().setAttributes(attributes);
|
|
219
|
-
}
|
|
219
|
+
};
|
|
220
220
|
|
|
221
221
|
/**
|
|
222
222
|
* Set the user information.
|
|
@@ -224,24 +224,24 @@ export class DdSdkReactNative {
|
|
|
224
224
|
* @returns a Promise.
|
|
225
225
|
*/
|
|
226
226
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
227
|
-
static async
|
|
227
|
+
static setUser = async (user: UserInfo): Promise<void> => {
|
|
228
228
|
InternalLog.log(
|
|
229
229
|
`Setting user ${JSON.stringify(user)}`,
|
|
230
230
|
SdkVerbosity.DEBUG
|
|
231
231
|
);
|
|
232
232
|
await DdSdk.setUser(user);
|
|
233
233
|
UserInfoSingleton.getInstance().setUserInfo(user);
|
|
234
|
-
}
|
|
234
|
+
};
|
|
235
235
|
|
|
236
236
|
/**
|
|
237
237
|
* Set the tracking consent regarding the data collection.
|
|
238
238
|
* @param trackingConsent: One of TrackingConsent values.
|
|
239
239
|
* @returns a Promise.
|
|
240
240
|
*/
|
|
241
|
-
static setTrackingConsent(consent: TrackingConsent): Promise<void> {
|
|
241
|
+
static setTrackingConsent = (consent: TrackingConsent): Promise<void> => {
|
|
242
242
|
InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);
|
|
243
243
|
return DdSdk.setTrackingConsent(consent);
|
|
244
|
-
}
|
|
244
|
+
};
|
|
245
245
|
|
|
246
246
|
private static buildConfiguration = (
|
|
247
247
|
configuration: DdSdkReactNativeConfiguration
|
|
@@ -327,7 +327,9 @@ export class DdSdkReactNative {
|
|
|
327
327
|
return;
|
|
328
328
|
}
|
|
329
329
|
if (configuration.trackInteractions) {
|
|
330
|
-
DdRumUserInteractionTracking.startTracking(
|
|
330
|
+
DdRumUserInteractionTracking.startTracking({
|
|
331
|
+
actionNameAttribute: configuration.actionNameAttribute
|
|
332
|
+
});
|
|
331
333
|
}
|
|
332
334
|
|
|
333
335
|
if (configuration.trackResources) {
|
|
@@ -240,6 +240,19 @@ export class DdSdkReactNativeConfiguration {
|
|
|
240
240
|
*/
|
|
241
241
|
public trackBackgroundEvents: boolean = DEFAULTS.trackBackgroundEvents;
|
|
242
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Specifies a custom prop to name RUM actions on elements having an `onPress` prop.
|
|
245
|
+
*
|
|
246
|
+
* For example if you set it to `testID`, the value of the `testID` prop is used as a custom action name:
|
|
247
|
+
*
|
|
248
|
+
* ```js
|
|
249
|
+
* <TouchableOpacity testID="Dismiss notification" onPress={() => dismiss()}>
|
|
250
|
+
* ```
|
|
251
|
+
*
|
|
252
|
+
* `dd-action-name` is favored when both attributes are present on an element.
|
|
253
|
+
*/
|
|
254
|
+
public actionNameAttribute?: string;
|
|
255
|
+
|
|
243
256
|
public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;
|
|
244
257
|
|
|
245
258
|
public errorEventMapper: ErrorEventMapper | null =
|
|
@@ -280,6 +293,7 @@ export type AutoInstrumentationConfiguration = {
|
|
|
280
293
|
readonly errorEventMapper?: ErrorEventMapper | null;
|
|
281
294
|
readonly resourceEventMapper?: ResourceEventMapper | null;
|
|
282
295
|
readonly actionEventMapper?: ActionEventMapper | null;
|
|
296
|
+
readonly actionNameAttribute?: string;
|
|
283
297
|
};
|
|
284
298
|
|
|
285
299
|
/**
|
|
@@ -295,6 +309,7 @@ export type AutoInstrumentationParameters = {
|
|
|
295
309
|
readonly errorEventMapper: ErrorEventMapper | null;
|
|
296
310
|
readonly resourceEventMapper: ResourceEventMapper | null;
|
|
297
311
|
readonly actionEventMapper: ActionEventMapper | null;
|
|
312
|
+
readonly actionNameAttribute?: string;
|
|
298
313
|
};
|
|
299
314
|
|
|
300
315
|
/**
|
|
@@ -439,6 +454,13 @@ export const buildConfigurationFromPartialConfiguration = (
|
|
|
439
454
|
},
|
|
440
455
|
SdkConfiguration
|
|
441
456
|
);
|
|
457
|
+
setConfigurationAttribute(
|
|
458
|
+
{
|
|
459
|
+
name: 'actionNameAttribute',
|
|
460
|
+
value: features.actionNameAttribute
|
|
461
|
+
},
|
|
462
|
+
SdkConfiguration
|
|
463
|
+
);
|
|
442
464
|
|
|
443
465
|
return SdkConfiguration;
|
|
444
466
|
};
|
|
@@ -77,7 +77,8 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
77
77
|
logEventMapper: event => event,
|
|
78
78
|
errorEventMapper: event => event,
|
|
79
79
|
resourceEventMapper: event => event,
|
|
80
|
-
actionEventMapper: event => event
|
|
80
|
+
actionEventMapper: event => event,
|
|
81
|
+
actionNameAttribute: 'testID'
|
|
81
82
|
},
|
|
82
83
|
{
|
|
83
84
|
applicationId: 'fake-app-id',
|
|
@@ -111,6 +112,7 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
111
112
|
).toMatchInlineSnapshot(`
|
|
112
113
|
DdSdkReactNativeConfiguration {
|
|
113
114
|
"actionEventMapper": [Function],
|
|
115
|
+
"actionNameAttribute": "testID",
|
|
114
116
|
"additionalConfig": {
|
|
115
117
|
"additionalField": "fake-value",
|
|
116
118
|
},
|
|
@@ -1,3 +1,8 @@
|
|
|
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
|
+
*/
|
|
1
6
|
import { adaptLongTaskThreshold } from '../longTasksUtils';
|
|
2
7
|
|
|
3
8
|
describe('adaptLongTaskThreshold', () => {
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
import * as mock from '../../jest/mock';
|
|
8
|
+
import { DdLogs, DdRum, DdTrace, DdSdkReactNative } from '../index';
|
|
9
|
+
|
|
10
|
+
// 🚨 READ THIS FIRST IF THIS TEST IS FAILING
|
|
11
|
+
/*
|
|
12
|
+
* This test is made to make sure the `jest/mock` file is complete.
|
|
13
|
+
* If this test fails it can mean 2 possible things:
|
|
14
|
+
*
|
|
15
|
+
* 1. You added/renamed a private property to one of the tested class
|
|
16
|
+
* In this case, add the private property to the list of private properties below.
|
|
17
|
+
* There are not supposed to be used by our customers so they aren't mocked.
|
|
18
|
+
*
|
|
19
|
+
* 2. You added/renamed/deleted a public property from one of the tested class
|
|
20
|
+
* In this case, make sure the public property is correctly mocked.
|
|
21
|
+
* ⚠️ Only arrow functions will appear in properties!
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const privateProperties = {
|
|
25
|
+
DdTrace: ['nativeTrace'],
|
|
26
|
+
DdLogs: [
|
|
27
|
+
'nativeLogs',
|
|
28
|
+
'logEventMapper',
|
|
29
|
+
'printLogDroppedSdkNotInitialized',
|
|
30
|
+
'printlogDroppedByMapper',
|
|
31
|
+
'printLogTracked',
|
|
32
|
+
'log',
|
|
33
|
+
'logWithError'
|
|
34
|
+
],
|
|
35
|
+
DdRum: [
|
|
36
|
+
'nativeRum',
|
|
37
|
+
'errorEventMapper',
|
|
38
|
+
'resourceEventMapper',
|
|
39
|
+
'actionEventMapper',
|
|
40
|
+
'callNativeStopAction',
|
|
41
|
+
'getStopActionNativeCallArgs'
|
|
42
|
+
],
|
|
43
|
+
DdSdkReactNative: [
|
|
44
|
+
'DD_SOURCE_KEY',
|
|
45
|
+
'DD_SDK_VERSION',
|
|
46
|
+
'DD_SERVICE_NAME',
|
|
47
|
+
'DD_SDK_VERBOSITY_KEY',
|
|
48
|
+
'DD_NATIVE_VIEW_TRACKING_KEY',
|
|
49
|
+
'DD_NATIVE_INTERACTION_TRACKING_KEY',
|
|
50
|
+
'DD_VERSION',
|
|
51
|
+
'DD_VERSION_SUFFIX',
|
|
52
|
+
'DD_PROXY_TYPE_KEY',
|
|
53
|
+
'DD_PROXY_ADDRESS_KEY',
|
|
54
|
+
'DD_PROXY_PORT_KEY',
|
|
55
|
+
'DD_PROXY_USERNAME_KEY',
|
|
56
|
+
'DD_PROXY_PASSWORD_KEY',
|
|
57
|
+
'wasInitialized',
|
|
58
|
+
'wasAutoInstrumented',
|
|
59
|
+
'initializeNativeSDK',
|
|
60
|
+
'_initializeFromDatadogProviderWithConfigurationAsync',
|
|
61
|
+
'buildConfiguration'
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const getPublicPropertiesFromModule = (
|
|
66
|
+
module: Record<string, unknown>,
|
|
67
|
+
moduleName: string
|
|
68
|
+
) => {
|
|
69
|
+
return Object.keys(module).filter(
|
|
70
|
+
key => !privateProperties[moduleName].includes(key)
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
describe('official mock', () => {
|
|
75
|
+
describe.each([{ DdTrace }, { DdLogs }, { DdRum }, { DdSdkReactNative }])(
|
|
76
|
+
'mocks module: %s',
|
|
77
|
+
moduleObject => {
|
|
78
|
+
// We get the name of the module and the module from our object list
|
|
79
|
+
const [moduleName, module] = Object.entries(moduleObject)[0];
|
|
80
|
+
|
|
81
|
+
it.each(getPublicPropertiesFromModule(module, moduleName))(
|
|
82
|
+
'for key: %s',
|
|
83
|
+
key => {
|
|
84
|
+
expect(mock[moduleName][key]).not.toBeUndefined();
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
});
|
|
@@ -66,6 +66,60 @@ it('M send a RUM Action event W interceptOnPress { arguments with dd-action-name
|
|
|
66
66
|
expect(DdRum.addAction.mock.calls[0][4]).toBe(fakeArguments);
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
it('M send a RUM Action event W interceptOnPress { arguments with actionNameAttribute } ', async () => {
|
|
70
|
+
// GIVEN
|
|
71
|
+
const eventsInterceptor = new DdEventsInterceptor({
|
|
72
|
+
actionNameAttribute: 'testID'
|
|
73
|
+
});
|
|
74
|
+
const fakeAccessibilityLabel = 'target_name';
|
|
75
|
+
const fakeTestId = 'testID';
|
|
76
|
+
const fakeArguments = {
|
|
77
|
+
_targetInst: {
|
|
78
|
+
memoizedProps: {
|
|
79
|
+
accessibilityLabel: fakeAccessibilityLabel,
|
|
80
|
+
testID: fakeTestId
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// WHEN
|
|
86
|
+
eventsInterceptor.interceptOnPress(fakeArguments);
|
|
87
|
+
|
|
88
|
+
// THEN
|
|
89
|
+
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
90
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
91
|
+
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeTestId);
|
|
92
|
+
expect(DdRum.addAction.mock.calls[0][4]).toBe(fakeArguments);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('M send a RUM Action event W interceptOnPress { arguments with dd-action-name over actionNameAttribute } ', async () => {
|
|
96
|
+
// GIVEN
|
|
97
|
+
const eventsInterceptor = new DdEventsInterceptor({
|
|
98
|
+
actionNameAttribute: 'testID'
|
|
99
|
+
});
|
|
100
|
+
const fakeAccessibilityLabel = 'target_name';
|
|
101
|
+
const fakeTestId = 'testID';
|
|
102
|
+
const fakeDdActionLabel = 'DdActionLabel';
|
|
103
|
+
const fakeArguments = {
|
|
104
|
+
_targetInst: {
|
|
105
|
+
memoizedProps: {
|
|
106
|
+
accessibilityLabel: fakeAccessibilityLabel,
|
|
107
|
+
'dd-action-name': fakeDdActionLabel,
|
|
108
|
+
testID: fakeTestId
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// WHEN
|
|
114
|
+
eventsInterceptor.interceptOnPress(fakeArguments);
|
|
115
|
+
|
|
116
|
+
// THEN
|
|
117
|
+
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
118
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
119
|
+
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeDdActionLabel);
|
|
120
|
+
expect(DdRum.addAction.mock.calls[0][4]).toBe(fakeArguments);
|
|
121
|
+
});
|
|
122
|
+
|
|
69
123
|
it('M send a RUM Action event W interceptOnPress { arguments with dd-action-name on a parent node} ', async () => {
|
|
70
124
|
// GIVEN
|
|
71
125
|
const fakeAccessibilityLabel = 'target_name';
|