@datadog/mobile-react-native 1.0.0-rc9 → 1.1.1
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 +2 -1
- package/android/build.gradle +73 -3
- package/android/gradle.properties +1 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +86 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdLogs.kt +27 -11
- package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +305 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +280 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkBridgeExt.kt +2 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +29 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -4
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdTrace.kt +86 -0
- package/android/src/main/kotlin/com/datadog/reactnative/GlobalState.kt +32 -0
- package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +23 -0
- package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +60 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +170 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +408 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +1547 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +306 -0
- package/android/src/test/kotlin/com/datadog/reactnative/GlobalStateTest.kt +118 -0
- package/android/src/test/kotlin/com/datadog/reactnative/ProxyAuthenticatorTest.kt +123 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +33 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +43 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +22 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +267 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +26 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +33 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +20 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/Throwable.kt +31 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
- package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
- package/datadog-sourcemaps.gradle +137 -0
- package/ios/Sources/AnyEncodable.swift +138 -0
- package/ios/Sources/Attributes.swift +101 -0
- package/ios/Sources/DdLogs.swift +35 -11
- package/ios/Sources/DdRum.m +3 -1
- package/ios/Sources/DdRum.swift +184 -22
- package/ios/Sources/DdSdk.swift +190 -10
- package/ios/Sources/DdSdkConfiguration.swift +51 -0
- package/ios/Sources/DdTrace.swift +41 -6
- package/ios/Sources/GlobalState.swift +28 -0
- package/ios/Sources/QueueHolder.swift +10 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +5 -6
- package/lib/commonjs/DdSdkReactNative.js +14 -0
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/foundation.js +36 -2
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +36 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +4 -17
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -4
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +7 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -1
- package/lib/commonjs/types.js +26 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +14 -0
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +24 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/foundation.js +36 -2
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +26 -0
- package/lib/module/nativeModulesTypes.js.map +1 -0
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js +2 -14
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +3 -4
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js +7 -2
- package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +1 -1
- package/lib/module/types.js +23 -0
- package/lib/module/types.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 +2 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +20 -0
- package/lib/typescript/foundation.d.ts +3 -2
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/nativeModulesTypes.d.ts +168 -0
- package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +0 -15
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +2 -1
- package/lib/typescript/types.d.ts +42 -7
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +5 -4
- package/src/DdSdkReactNative.tsx +20 -0
- package/src/DdSdkReactNativeConfiguration.tsx +20 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +76 -0
- package/src/__tests__/foundation.test.ts +79 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +8 -8
- package/src/foundation.tsx +40 -11
- package/src/index.tsx +3 -0
- package/src/nativeModulesTypes.ts +258 -0
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +2 -17
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +3 -4
- package/src/rum/instrumentation/resourceTracking/domain/__tests__/firstPartyHosts.test.ts +22 -0
- package/src/rum/instrumentation/resourceTracking/domain/firstPartyHosts.ts +8 -1
- package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +2 -1
- package/src/types.tsx +62 -7
- package/src/version.ts +1 -1
- package/android/src/main/java/com/datadog/reactnative/DdRum.kt +0 -142
- package/android/src/main/java/com/datadog/reactnative/DdSdk.kt +0 -67
- package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +0 -51
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A configuration object to initialize Datadog's features.
|
|
3
|
+
*/
|
|
4
|
+
export declare class DdNativeSdkConfiguration {
|
|
5
|
+
readonly clientToken: string;
|
|
6
|
+
readonly env: string;
|
|
7
|
+
readonly applicationId: string;
|
|
8
|
+
readonly nativeCrashReportEnabled: boolean;
|
|
9
|
+
readonly sampleRate: number;
|
|
10
|
+
readonly site: string;
|
|
11
|
+
readonly trackingConsent: string;
|
|
12
|
+
readonly additionalConfig: object;
|
|
13
|
+
constructor(clientToken: string, env: string, applicationId: string, nativeCrashReportEnabled: boolean, sampleRate: number, site: string, trackingConsent: string, additionalConfig: object);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The entry point to initialize Datadog's features.
|
|
17
|
+
*/
|
|
18
|
+
export declare type DdNativeSdkType = {
|
|
19
|
+
/**
|
|
20
|
+
* Initializes Datadog's features.
|
|
21
|
+
* @param configuration: The configuration to use.
|
|
22
|
+
*/
|
|
23
|
+
initialize(configuration: DdNativeSdkConfiguration): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
|
|
26
|
+
* @param attributes: The global context attributes.
|
|
27
|
+
*/
|
|
28
|
+
setAttributes(attributes: object): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Set the user information.
|
|
31
|
+
* @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
|
|
32
|
+
*/
|
|
33
|
+
setUser(user: object): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Set the tracking consent regarding the data collection.
|
|
36
|
+
* @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
|
|
37
|
+
*/
|
|
38
|
+
setTrackingConsent(trackingConsent: string): Promise<void>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The entry point to use Datadog's Logs feature.
|
|
42
|
+
*/
|
|
43
|
+
export declare type DdNativeLogsType = {
|
|
44
|
+
/**
|
|
45
|
+
* Send a log with level debug.
|
|
46
|
+
* @param message: The message to send.
|
|
47
|
+
* @param context: The additional context to send.
|
|
48
|
+
*/
|
|
49
|
+
debug(message: string, context?: object): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Send a log with level info.
|
|
52
|
+
* @param message: The message to send.
|
|
53
|
+
* @param context: The additional context to send.
|
|
54
|
+
*/
|
|
55
|
+
info(message: string, context?: object): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Send a log with level warn.
|
|
58
|
+
* @param message: The message to send.
|
|
59
|
+
* @param context: The additional context to send.
|
|
60
|
+
*/
|
|
61
|
+
warn(message: string, context?: object): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Send a log with level error.
|
|
64
|
+
* @param message: The message to send.
|
|
65
|
+
* @param context: The additional context to send.
|
|
66
|
+
*/
|
|
67
|
+
error(message: string, context?: object): Promise<void>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The entry point to use Datadog's Trace feature.
|
|
71
|
+
*/
|
|
72
|
+
export declare type DdNativeTraceType = {
|
|
73
|
+
/**
|
|
74
|
+
* Start a span, and returns a unique identifier for the span.
|
|
75
|
+
* @param operation: The operation name of the span.
|
|
76
|
+
* @param context: The additional context to send.
|
|
77
|
+
* @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
|
|
78
|
+
*/
|
|
79
|
+
startSpan(operation: string, context?: object, timestampMs?: number): Promise<string>;
|
|
80
|
+
/**
|
|
81
|
+
* Finish a started span.
|
|
82
|
+
* @param spanId: The unique identifier of the span.
|
|
83
|
+
* @param context: The additional context to send.
|
|
84
|
+
* @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
85
|
+
*/
|
|
86
|
+
finishSpan(spanId: string, context?: object, timestampMs?: number): Promise<void>;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The entry point to use Datadog's RUM feature.
|
|
90
|
+
*/
|
|
91
|
+
export declare type DdNativeRumType = {
|
|
92
|
+
/**
|
|
93
|
+
* Start tracking a RUM View.
|
|
94
|
+
* @param key: The view unique key identifier.
|
|
95
|
+
* @param name: The view name.
|
|
96
|
+
* @param context: The additional context to send.
|
|
97
|
+
* @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
|
|
98
|
+
*/
|
|
99
|
+
startView(key: string, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Stop tracking a RUM View.
|
|
102
|
+
* @param key: The view unique key identifier.
|
|
103
|
+
* @param context: The additional context to send.
|
|
104
|
+
* @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
105
|
+
*/
|
|
106
|
+
stopView(key: string, context?: object, timestampMs?: number): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Start tracking a RUM Action.
|
|
109
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
110
|
+
* @param name: The action name.
|
|
111
|
+
* @param context: The additional context to send.
|
|
112
|
+
* @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
113
|
+
*/
|
|
114
|
+
startAction(type: ActionType, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Stop tracking the ongoing RUM Action.
|
|
117
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
118
|
+
* @param name: The action name.
|
|
119
|
+
* @param context: The additional context to send.
|
|
120
|
+
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
121
|
+
*/
|
|
122
|
+
stopAction(type: ActionType, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Add a RUM Action.
|
|
125
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
126
|
+
* @param name: The action name.
|
|
127
|
+
* @param context: The additional context to send.
|
|
128
|
+
* @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
129
|
+
*/
|
|
130
|
+
addAction(type: ActionType, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Start tracking a RUM Resource.
|
|
133
|
+
* @param key: The resource unique key identifier.
|
|
134
|
+
* @param method: The resource method (GET, POST, …).
|
|
135
|
+
* @param url: The resource url.
|
|
136
|
+
* @param context: The additional context to send.
|
|
137
|
+
* @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
|
|
138
|
+
*/
|
|
139
|
+
startResource(key: string, method: string, url: string, context?: object, timestampMs?: number): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Stop tracking a RUM Resource.
|
|
142
|
+
* @param key: The resource unique key identifier.
|
|
143
|
+
* @param statusCode: The resource status code.
|
|
144
|
+
* @param kind: The resource's kind (xhr, document, image, css, font, …).
|
|
145
|
+
* @param size: The resource size in bytes. If size is unknown, use -1.
|
|
146
|
+
* @param context: The additional context to send.
|
|
147
|
+
* @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
148
|
+
*/
|
|
149
|
+
stopResource(key: string, statusCode: number, kind: ResourceKind, size?: number, context?: object, timestampMs?: number): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Add a RUM Error.
|
|
152
|
+
* @param message: The error message.
|
|
153
|
+
* @param source: The error source (network, source, console, webview, custom).
|
|
154
|
+
* @param stacktrace: The error stacktrace.
|
|
155
|
+
* @param context: The additional context to send.
|
|
156
|
+
* @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
157
|
+
*/
|
|
158
|
+
addError(message: string, source: ErrorSource, stacktrace: string, context?: object, timestampMs?: number): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* 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.
|
|
161
|
+
* @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.
|
|
162
|
+
*/
|
|
163
|
+
addTiming(name: string): Promise<void>;
|
|
164
|
+
};
|
|
165
|
+
declare type ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';
|
|
166
|
+
declare type ResourceKind = 'image' | 'xhr' | 'beacon' | 'css' | 'document' | 'fetch' | 'font' | 'js' | 'media' | 'other' | 'native';
|
|
167
|
+
declare type ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';
|
|
168
|
+
export {};
|
|
@@ -9,18 +9,3 @@ export declare class DdEventsInterceptor implements EventsInterceptor {
|
|
|
9
9
|
private resolveElementTypeName;
|
|
10
10
|
private findClosestActionLabel;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Describe the type of a RUM Action.
|
|
14
|
-
*/
|
|
15
|
-
export declare enum RumActionType {
|
|
16
|
-
/** User tapped on a widget. */
|
|
17
|
-
TAP = "TAP",
|
|
18
|
-
/** User scrolled a view. */
|
|
19
|
-
SCROLL = "SCROLL",
|
|
20
|
-
/** User swiped on a view. */
|
|
21
|
-
SWIPE = "SWIPE",
|
|
22
|
-
/** User clicked on a widget (not used on Mobile). */
|
|
23
|
-
CLICK = "CLICK",
|
|
24
|
-
/** A custom action. */
|
|
25
|
-
CUSTOM = "CUSTOM"
|
|
26
|
-
}
|
package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { ResourceKind } from '../../../../../../../core/src/types';
|
|
1
2
|
import type { DdRumResourceTracingAttributes } from '../distributedTracing';
|
|
2
3
|
export interface RUMResource {
|
|
3
4
|
key: string;
|
|
4
5
|
request: {
|
|
5
6
|
method: string;
|
|
6
7
|
url: string;
|
|
7
|
-
kind:
|
|
8
|
+
kind: ResourceKind;
|
|
8
9
|
};
|
|
9
10
|
tracingAttributes: DdRumResourceTracingAttributes;
|
|
10
11
|
response: {
|
|
@@ -106,26 +106,38 @@ export declare type DdRumType = {
|
|
|
106
106
|
stopView(key: string, context?: object, timestampMs?: number): Promise<void>;
|
|
107
107
|
/**
|
|
108
108
|
* Start tracking a RUM Action.
|
|
109
|
-
* @param type: The action type (tap, scroll, swipe,
|
|
109
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
110
110
|
* @param name: The action name.
|
|
111
111
|
* @param context: The additional context to send.
|
|
112
112
|
* @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
113
113
|
*/
|
|
114
|
-
startAction(type:
|
|
114
|
+
startAction(type: RumActionType, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
115
115
|
/**
|
|
116
116
|
* Stop tracking the ongoing RUM Action.
|
|
117
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
118
|
+
* @param name: The action name.
|
|
119
|
+
* @param context: The additional context to send.
|
|
120
|
+
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
121
|
+
*/
|
|
122
|
+
stopAction(type: RumActionType, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Stop tracking the ongoing RUM Action.
|
|
125
|
+
*
|
|
126
|
+
* Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.
|
|
127
|
+
*
|
|
128
|
+
* @deprecated add the `type` and `name` of the action as first two arguments.
|
|
117
129
|
* @param context: The additional context to send.
|
|
118
130
|
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
119
131
|
*/
|
|
120
132
|
stopAction(context?: object, timestampMs?: number): Promise<void>;
|
|
121
133
|
/**
|
|
122
134
|
* Add a RUM Action.
|
|
123
|
-
* @param type: The action type (tap, scroll, swipe,
|
|
135
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
124
136
|
* @param name: The action name.
|
|
125
137
|
* @param context: The additional context to send.
|
|
126
138
|
* @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
127
139
|
*/
|
|
128
|
-
addAction(type:
|
|
140
|
+
addAction(type: RumActionType, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
129
141
|
/**
|
|
130
142
|
* Start tracking a RUM Resource.
|
|
131
143
|
* @param key: The resource unique key identifier.
|
|
@@ -144,19 +156,42 @@ export declare type DdRumType = {
|
|
|
144
156
|
* @param context: The additional context to send.
|
|
145
157
|
* @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
146
158
|
*/
|
|
147
|
-
stopResource(key: string, statusCode: number, kind:
|
|
159
|
+
stopResource(key: string, statusCode: number, kind: ResourceKind, size?: number, context?: object, timestampMs?: number): Promise<void>;
|
|
148
160
|
/**
|
|
149
161
|
* Add a RUM Error.
|
|
150
162
|
* @param message: The error message.
|
|
151
|
-
* @param source: The error source (network, source, console,
|
|
163
|
+
* @param source: The error source (network, source, console, webview, custom).
|
|
152
164
|
* @param stacktrace: The error stacktrace.
|
|
153
165
|
* @param context: The additional context to send.
|
|
154
166
|
* @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
155
167
|
*/
|
|
156
|
-
addError(message: string, source:
|
|
168
|
+
addError(message: string, source: ErrorSource, stacktrace: string, context?: object, timestampMs?: number): Promise<void>;
|
|
157
169
|
/**
|
|
158
170
|
* 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.
|
|
159
171
|
* @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.
|
|
160
172
|
*/
|
|
161
173
|
addTiming(name: string): Promise<void>;
|
|
162
174
|
};
|
|
175
|
+
/**
|
|
176
|
+
* Describe the type of a RUM Action.
|
|
177
|
+
*/
|
|
178
|
+
export declare enum RumActionType {
|
|
179
|
+
/** User tapped on a widget. */
|
|
180
|
+
TAP = "TAP",
|
|
181
|
+
/** User scrolled a view. */
|
|
182
|
+
SCROLL = "SCROLL",
|
|
183
|
+
/** User swiped on a view. */
|
|
184
|
+
SWIPE = "SWIPE",
|
|
185
|
+
/** User pressed hardware back button (Android only). */
|
|
186
|
+
BACK = "BACK",
|
|
187
|
+
/** A custom action. */
|
|
188
|
+
CUSTOM = "CUSTOM"
|
|
189
|
+
}
|
|
190
|
+
export declare type ResourceKind = 'image' | 'xhr' | 'beacon' | 'css' | 'document' | 'fetch' | 'font' | 'js' | 'media' | 'other' | 'native';
|
|
191
|
+
export declare enum ErrorSource {
|
|
192
|
+
NETWORK = "NETWORK",
|
|
193
|
+
SOURCE = "SOURCE",
|
|
194
|
+
CONSOLE = "CONSOLE",
|
|
195
|
+
WEBVIEW = "WEBVIEW",
|
|
196
|
+
CUSTOM = "CUSTOM"
|
|
197
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.1.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A client-side React Native module to interact with Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"ios/DdSdkReactNative.xcodeproj/project.xcworkspace/xcsharedata",
|
|
27
27
|
"ios/DdSdkReactNative.xcodeproj/project.xcworkspace/*.xcworkspacedata",
|
|
28
28
|
"ios/DdSdkReactNative.xcodeproj/*.pbxproj",
|
|
29
|
-
"DatadogSDKReactNative.podspec"
|
|
29
|
+
"DatadogSDKReactNative.podspec",
|
|
30
|
+
"datadog-sourcemaps.gradle"
|
|
30
31
|
],
|
|
31
32
|
"types": "lib/typescript/index.d.ts",
|
|
32
33
|
"react-native": "src/index",
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"scripts": {
|
|
39
40
|
"test": "jest",
|
|
40
41
|
"lint": "eslint .",
|
|
41
|
-
"prepare": "bob build"
|
|
42
|
+
"prepare": "rm -rf lib && yarn bob build"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"react": ">=16.13.1",
|
|
@@ -72,5 +73,5 @@
|
|
|
72
73
|
]
|
|
73
74
|
]
|
|
74
75
|
},
|
|
75
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "52f7fe64ad927163344c71ba99c4c680a83765bc"
|
|
76
77
|
}
|
package/src/DdSdkReactNative.tsx
CHANGED
|
@@ -26,6 +26,8 @@ export class DdSdkReactNative {
|
|
|
26
26
|
private static readonly DD_SDK_VERBOSITY_KEY = '_dd.sdk_verbosity';
|
|
27
27
|
private static readonly DD_NATIVE_VIEW_TRACKING_KEY =
|
|
28
28
|
'_dd.native_view_tracking';
|
|
29
|
+
private static readonly DD_VERSION = '_dd.version';
|
|
30
|
+
private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';
|
|
29
31
|
|
|
30
32
|
// Proxy
|
|
31
33
|
private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';
|
|
@@ -106,6 +108,24 @@ export class DdSdkReactNative {
|
|
|
106
108
|
] = configuration.serviceName;
|
|
107
109
|
}
|
|
108
110
|
|
|
111
|
+
if (configuration.version) {
|
|
112
|
+
configuration.additionalConfig[
|
|
113
|
+
DdSdkReactNative.DD_VERSION
|
|
114
|
+
] = `${configuration.version}${
|
|
115
|
+
configuration.versionSuffix
|
|
116
|
+
? `-${configuration.versionSuffix}`
|
|
117
|
+
: ''
|
|
118
|
+
}`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// If both version and version suffix are provided, we merge them into the version field.
|
|
122
|
+
// To avoid adding it in again the native part, we only set it if the version isn't set.
|
|
123
|
+
if (configuration.versionSuffix && !configuration.version) {
|
|
124
|
+
configuration.additionalConfig[
|
|
125
|
+
DdSdkReactNative.DD_VERSION_SUFFIX
|
|
126
|
+
] = `-${configuration.versionSuffix}`;
|
|
127
|
+
}
|
|
128
|
+
|
|
109
129
|
configuration.additionalConfig[
|
|
110
130
|
DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY
|
|
111
131
|
] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;
|
|
@@ -32,6 +32,26 @@ export class DdSdkReactNativeConfiguration {
|
|
|
32
32
|
public proxyConfig?: ProxyConfiguration = undefined;
|
|
33
33
|
public serviceName?: string = undefined;
|
|
34
34
|
public firstPartyHosts: string[] = [];
|
|
35
|
+
/**
|
|
36
|
+
* Overrides the reported version of the app.
|
|
37
|
+
* Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.
|
|
38
|
+
* Other special characters are converted to underscores.
|
|
39
|
+
*
|
|
40
|
+
* See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.
|
|
41
|
+
*
|
|
42
|
+
* Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.
|
|
43
|
+
*/
|
|
44
|
+
public version?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Add a suffix to the reported version of the app.
|
|
47
|
+
* Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.
|
|
48
|
+
* Other special characters are converted to underscores.
|
|
49
|
+
*
|
|
50
|
+
* See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.
|
|
51
|
+
*
|
|
52
|
+
* A dash (`-`) will be automatically added between the version and the suffix
|
|
53
|
+
*/
|
|
54
|
+
public versionSuffix?: string;
|
|
35
55
|
|
|
36
56
|
public additionalConfig: { [k: string]: any } = {};
|
|
37
57
|
|
|
@@ -347,6 +347,82 @@ describe('DdSdkReactNative', () => {
|
|
|
347
347
|
})
|
|
348
348
|
);
|
|
349
349
|
});
|
|
350
|
+
|
|
351
|
+
it('initializes with the version when a version is specified', async () => {
|
|
352
|
+
// GIVEN
|
|
353
|
+
const fakeAppId = '1';
|
|
354
|
+
const fakeClientToken = '2';
|
|
355
|
+
const fakeEnvName = 'env';
|
|
356
|
+
const configuration = new DdSdkReactNativeConfiguration(
|
|
357
|
+
fakeClientToken,
|
|
358
|
+
fakeEnvName,
|
|
359
|
+
fakeAppId
|
|
360
|
+
);
|
|
361
|
+
configuration.version = '2.0.0';
|
|
362
|
+
|
|
363
|
+
// WHEN
|
|
364
|
+
await DdSdkReactNative.initialize(configuration);
|
|
365
|
+
|
|
366
|
+
// THEN
|
|
367
|
+
const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
|
|
368
|
+
.calls[0][0] as DdSdkConfiguration;
|
|
369
|
+
expect(ddSdkConfiguration.additionalConfig['_dd.version']).toBe(
|
|
370
|
+
'2.0.0'
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
it('initialized with a version suffix when a version suffix is specified', async () => {
|
|
375
|
+
// GIVEN
|
|
376
|
+
const fakeAppId = '1';
|
|
377
|
+
const fakeClientToken = '2';
|
|
378
|
+
const fakeEnvName = 'env';
|
|
379
|
+
const configuration = new DdSdkReactNativeConfiguration(
|
|
380
|
+
fakeClientToken,
|
|
381
|
+
fakeEnvName,
|
|
382
|
+
fakeAppId
|
|
383
|
+
);
|
|
384
|
+
configuration.versionSuffix = 'codepush-3';
|
|
385
|
+
|
|
386
|
+
// WHEN
|
|
387
|
+
await DdSdkReactNative.initialize(configuration);
|
|
388
|
+
|
|
389
|
+
// THEN
|
|
390
|
+
const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
|
|
391
|
+
.calls[0][0] as DdSdkConfiguration;
|
|
392
|
+
expect(
|
|
393
|
+
ddSdkConfiguration.additionalConfig['_dd.version']
|
|
394
|
+
).toBeUndefined();
|
|
395
|
+
expect(
|
|
396
|
+
ddSdkConfiguration.additionalConfig['_dd.version_suffix']
|
|
397
|
+
).toBe('-codepush-3');
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it('initializes with the version when a version and version suffix are specified', async () => {
|
|
401
|
+
// GIVEN
|
|
402
|
+
const fakeAppId = '1';
|
|
403
|
+
const fakeClientToken = '2';
|
|
404
|
+
const fakeEnvName = 'env';
|
|
405
|
+
const configuration = new DdSdkReactNativeConfiguration(
|
|
406
|
+
fakeClientToken,
|
|
407
|
+
fakeEnvName,
|
|
408
|
+
fakeAppId
|
|
409
|
+
);
|
|
410
|
+
configuration.version = '2.0.0';
|
|
411
|
+
configuration.versionSuffix = 'codepush-3';
|
|
412
|
+
|
|
413
|
+
// WHEN
|
|
414
|
+
await DdSdkReactNative.initialize(configuration);
|
|
415
|
+
|
|
416
|
+
// THEN
|
|
417
|
+
const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
|
|
418
|
+
.calls[0][0] as DdSdkConfiguration;
|
|
419
|
+
expect(ddSdkConfiguration.additionalConfig['_dd.version']).toBe(
|
|
420
|
+
'2.0.0-codepush-3'
|
|
421
|
+
);
|
|
422
|
+
expect(
|
|
423
|
+
ddSdkConfiguration.additionalConfig['_dd.version_suffix']
|
|
424
|
+
).toBeUndefined();
|
|
425
|
+
});
|
|
350
426
|
});
|
|
351
427
|
|
|
352
428
|
describe('feature enablement', () => {
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { NativeModules } from 'react-native';
|
|
8
|
+
|
|
9
|
+
import { DdRum } from '../foundation';
|
|
10
|
+
|
|
11
|
+
jest.mock('../TimeProvider', () => {
|
|
12
|
+
return {
|
|
13
|
+
TimeProvider: jest.fn().mockImplementation(() => {
|
|
14
|
+
return { now: jest.fn().mockReturnValue(456) };
|
|
15
|
+
})
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('foundation', () => {
|
|
20
|
+
describe('DdRum.stopAction', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('calls the native SDK when called with new API', async () => {
|
|
26
|
+
await DdRum.stopAction('scroll', 'page', { user: 'me' }, 123);
|
|
27
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
28
|
+
'scroll',
|
|
29
|
+
'page',
|
|
30
|
+
{ user: 'me' },
|
|
31
|
+
123
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('calls the native SDK when called with new API with default values', async () => {
|
|
36
|
+
await DdRum.stopAction('scroll', 'page');
|
|
37
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
38
|
+
'scroll',
|
|
39
|
+
'page',
|
|
40
|
+
{},
|
|
41
|
+
456
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('does not call the native SDK when sartAction has not been called before and using old API', async () => {
|
|
46
|
+
await DdRum.stopAction({ user: 'me' }, 789);
|
|
47
|
+
expect(NativeModules.DdRum.stopAction).not.toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('calls the native SDK when called with old API', async () => {
|
|
51
|
+
await DdRum.startAction('scroll', 'page_old_api');
|
|
52
|
+
await DdRum.stopAction({ user: 'me' }, 789);
|
|
53
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
54
|
+
'scroll',
|
|
55
|
+
'page_old_api',
|
|
56
|
+
{ user: 'me' },
|
|
57
|
+
789
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('calls the native SDK when called with old API with default values', async () => {
|
|
62
|
+
await DdRum.startAction('scroll', 'page_old_api');
|
|
63
|
+
await DdRum.stopAction();
|
|
64
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledWith(
|
|
65
|
+
'scroll',
|
|
66
|
+
'page_old_api',
|
|
67
|
+
{},
|
|
68
|
+
456
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('cleans the action data when stopAction is called', async () => {
|
|
73
|
+
await DdRum.startAction('scroll', 'page_old_api');
|
|
74
|
+
await DdRum.stopAction();
|
|
75
|
+
await DdRum.stopAction();
|
|
76
|
+
expect(NativeModules.DdRum.stopAction).toHaveBeenCalledTimes(1);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -9,9 +9,9 @@ import { SdkVerbosity } from '../../../SdkVerbosity';
|
|
|
9
9
|
import { DdRum } from '../../../index';
|
|
10
10
|
import {
|
|
11
11
|
DdEventsInterceptor,
|
|
12
|
-
RumActionType,
|
|
13
12
|
UNKNOWN_TARGET_NAME
|
|
14
13
|
} from '../../../rum/instrumentation/DdEventsInterceptor';
|
|
14
|
+
import { RumActionType } from '../../../types';
|
|
15
15
|
|
|
16
16
|
jest.mock('../../../foundation', () => {
|
|
17
17
|
return {
|
|
@@ -61,7 +61,7 @@ it('M send a RUM Action event W interceptOnPress { arguments with dd-action-name
|
|
|
61
61
|
|
|
62
62
|
// THEN
|
|
63
63
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
64
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
64
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
65
65
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeDdActionLabel);
|
|
66
66
|
});
|
|
67
67
|
|
|
@@ -88,7 +88,7 @@ it('M send a RUM Action event W interceptOnPress { arguments with dd-action-name
|
|
|
88
88
|
|
|
89
89
|
// THEN
|
|
90
90
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
91
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
91
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
92
92
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeDdActionLabel);
|
|
93
93
|
});
|
|
94
94
|
|
|
@@ -106,7 +106,7 @@ it('M send a RUM Action event W interceptOnPress { arguments with accessibilityL
|
|
|
106
106
|
|
|
107
107
|
// THEN
|
|
108
108
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
109
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
109
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
110
110
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeAccessibilityLabel);
|
|
111
111
|
});
|
|
112
112
|
|
|
@@ -127,7 +127,7 @@ it('M send only one RUM Action event W interceptOnPress { called multiple times
|
|
|
127
127
|
|
|
128
128
|
// THEN
|
|
129
129
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
130
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
130
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
131
131
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeAccessibilityLabel);
|
|
132
132
|
});
|
|
133
133
|
|
|
@@ -141,7 +141,7 @@ it('M send a RUM Action event W interceptOnPress { no accessibilityLabel argumen
|
|
|
141
141
|
|
|
142
142
|
// THEN
|
|
143
143
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
144
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
144
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
145
145
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeElementType);
|
|
146
146
|
});
|
|
147
147
|
|
|
@@ -157,7 +157,7 @@ it('M send a RUM Action event W interceptOnPress { no accessibilityLabel argumen
|
|
|
157
157
|
|
|
158
158
|
// THEN
|
|
159
159
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
160
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
160
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
161
161
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(fakeElementType);
|
|
162
162
|
});
|
|
163
163
|
|
|
@@ -170,7 +170,7 @@ it('M send a RUM Action event W interceptOnPress { no accessibilityLabel, no ele
|
|
|
170
170
|
|
|
171
171
|
// THEN
|
|
172
172
|
expect(DdRum.addAction.mock.calls.length).toBe(1);
|
|
173
|
-
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP
|
|
173
|
+
expect(DdRum.addAction.mock.calls[0][0]).toBe(RumActionType.TAP);
|
|
174
174
|
expect(DdRum.addAction.mock.calls[0][1]).toBe(UNKNOWN_TARGET_NAME);
|
|
175
175
|
});
|
|
176
176
|
|