@datadog/mobile-react-native 2.6.4 → 2.6.6
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 +6 -6
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +17 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +26 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkBridgeExt.kt +12 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +5 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +7 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +38 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +7 -0
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +28 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +19 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +2 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +226 -4
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +6 -0
- package/android/src/test/resources/input/complete-configuration.json +2 -1
- package/datadog-configuration.schema.json +4 -0
- package/ios/Sources/DdSdk.mm +22 -0
- package/ios/Sources/DdSdkConfiguration.swift +5 -1
- package/ios/Sources/DdSdkImplementation.swift +29 -0
- package/ios/Sources/DdSdkNativeInitialization.swift +6 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +7 -3
- package/ios/Sources/SdkVersion.swift +1 -1
- package/jest/mock.js +3 -0
- package/lib/commonjs/DdSdkReactNative.js +24 -4
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +34 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +9 -16
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +33 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +2 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/commonjs/rum/sessionId/sessionIdHelper.js +67 -0
- package/lib/commonjs/rum/sessionId/sessionIdHelper.js.map +1 -0
- package/lib/commonjs/rum/types.js +5 -0
- package/lib/commonjs/rum/types.js.map +1 -1
- package/lib/commonjs/sdk/EventEmitter/EventEmitter.js +51 -0
- package/lib/commonjs/sdk/EventEmitter/EventEmitter.js.map +1 -0
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
- package/lib/commonjs/types.js +4 -2
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +24 -4
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +34 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/rum/DdRum.js +9 -16
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +33 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +2 -2
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/module/rum/sessionId/sessionIdHelper.js +56 -0
- package/lib/module/rum/sessionId/sessionIdHelper.js.map +1 -0
- package/lib/module/rum/types.js +5 -0
- package/lib/module/rum/types.js.map +1 -1
- package/lib/module/sdk/EventEmitter/EventEmitter.js +43 -0
- package/lib/module/sdk/EventEmitter/EventEmitter.js.map +1 -0
- package/lib/module/specs/NativeDdSdk.js.map +1 -1
- package/lib/module/types.js +4 -2
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +17 -2
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +8 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts.map +1 -1
- package/lib/typescript/rum/DdRum.d.ts +0 -1
- package/lib/typescript/rum/DdRum.d.ts.map +1 -1
- package/lib/typescript/rum/sessionId/sessionIdHelper.d.ts +26 -0
- package/lib/typescript/rum/sessionId/sessionIdHelper.d.ts.map +1 -0
- package/lib/typescript/sdk/EventEmitter/EventEmitter.d.ts +12 -0
- package/lib/typescript/sdk/EventEmitter/EventEmitter.d.ts.map +1 -0
- package/lib/typescript/sdk/UserInfoSingleton/types.d.ts +3 -2
- package/lib/typescript/sdk/UserInfoSingleton/types.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdSdk.d.ts +11 -0
- package/lib/typescript/specs/NativeDdSdk.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +22 -5
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +40 -5
- package/src/DdSdkReactNativeConfiguration.tsx +9 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +101 -12
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
- package/src/rum/DdRum.ts +13 -21
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +1 -1
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +2 -2
- package/src/rum/sessionId/__tests__/sessionIdHelper.test.ts +162 -0
- package/src/rum/sessionId/sessionIdHelper.ts +59 -0
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +1 -0
- package/src/sdk/EventEmitter/EventEmitter.ts +55 -0
- package/src/sdk/EventEmitter/__tests__/EventEmitter.test.ts +181 -0
- package/src/sdk/UserInfoSingleton/types.ts +5 -2
- package/src/specs/NativeDdSdk.ts +13 -0
- package/src/types.tsx +23 -5
- package/src/version.ts +1 -1
|
@@ -16,9 +16,20 @@ export interface Spec extends TurboModule {
|
|
|
16
16
|
setAttributes(attributes: Object): Promise<void>;
|
|
17
17
|
/**
|
|
18
18
|
* Set the user information.
|
|
19
|
+
* @deprecated: Use setUserInfo instead
|
|
19
20
|
* @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
|
|
20
21
|
*/
|
|
21
22
|
setUser(user: Object): Promise<Object>;
|
|
23
|
+
/**
|
|
24
|
+
* Set the user information.
|
|
25
|
+
* @param user: The user object (use builtin attributes: 'id', 'email', 'name', and any custom attribute under extraInfo).
|
|
26
|
+
*/
|
|
27
|
+
setUserInfo(user: Object): Promise<Object>;
|
|
28
|
+
/**
|
|
29
|
+
* Add custom attributes to the current user information
|
|
30
|
+
* @param extraInfo: The extraInfo object containing additionall custom attributes
|
|
31
|
+
*/
|
|
32
|
+
addUserExtraInfo(extraInfo: Object): Promise<Object>;
|
|
22
33
|
/**
|
|
23
34
|
* Set the tracking consent regarding the data collection.
|
|
24
35
|
* @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeDdSdk.d.ts","sourceRoot":"","sources":["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;IAE/C;;;;;OAKG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5E;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B;;;OAGG;IACH,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;;AAGD,wBAAsD"}
|
|
@@ -51,9 +51,10 @@ export declare class DdSdkConfiguration {
|
|
|
51
51
|
readonly bundleLogsWithTraces: boolean;
|
|
52
52
|
readonly trackNonFatalAnrs: boolean | undefined;
|
|
53
53
|
readonly appHangThreshold: number | undefined;
|
|
54
|
-
readonly resourceTracingSamplingRate: number
|
|
54
|
+
readonly resourceTracingSamplingRate: number;
|
|
55
55
|
readonly trackWatchdogTerminations: boolean | undefined;
|
|
56
56
|
readonly batchProcessingLevel: BatchProcessingLevel;
|
|
57
|
+
readonly initialResourceThreshold: number | undefined;
|
|
57
58
|
constructor(clientToken: string, env: string, applicationId: string, nativeCrashReportEnabled: boolean, nativeLongTaskThresholdMs: number, longTaskThresholdMs: number, sampleRate: number, site: string, trackingConsent: string, additionalConfiguration: object, telemetrySampleRate: number, vitalsUpdateFrequency: string, uploadFrequency: string, batchSize: string, trackFrustrations: boolean, trackBackgroundEvents: boolean, customEndpoints: {
|
|
58
59
|
rum?: string;
|
|
59
60
|
trace?: string;
|
|
@@ -74,7 +75,8 @@ export declare class DdSdkConfiguration {
|
|
|
74
75
|
} | undefined, serviceName: string | undefined, firstPartyHosts: {
|
|
75
76
|
match: string;
|
|
76
77
|
propagatorTypes: string[];
|
|
77
|
-
}[], bundleLogsWithRum: boolean, bundleLogsWithTraces: boolean, trackNonFatalAnrs: boolean | undefined, appHangThreshold: number | undefined, resourceTracingSamplingRate: number
|
|
78
|
+
}[], bundleLogsWithRum: boolean, bundleLogsWithTraces: boolean, trackNonFatalAnrs: boolean | undefined, appHangThreshold: number | undefined, resourceTracingSamplingRate: number, trackWatchdogTerminations: boolean | undefined, batchProcessingLevel: BatchProcessingLevel, // eslint-disable-next-line no-empty-function
|
|
79
|
+
initialResourceThreshold: number | undefined);
|
|
78
80
|
}
|
|
79
81
|
/**
|
|
80
82
|
* The entry point to initialize Datadog's features.
|
|
@@ -91,21 +93,36 @@ export type DdSdkType = {
|
|
|
91
93
|
*/
|
|
92
94
|
setAttributes(attributes: object): Promise<void>;
|
|
93
95
|
/**
|
|
94
|
-
*
|
|
96
|
+
* Sets the user information.
|
|
97
|
+
* @deprecated UserInfo id property is now mandatory (please user setUserInfo instead)
|
|
95
98
|
* @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
|
|
96
99
|
*/
|
|
97
100
|
setUser(user: object): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Sets the user information.
|
|
103
|
+
* @param id: A unique user identifier (relevant to your business domain)
|
|
104
|
+
* @param name: The user name or alias.
|
|
105
|
+
* @param email: The user email.
|
|
106
|
+
* @param extraInfo: Additional information.
|
|
107
|
+
*/
|
|
108
|
+
setUserInfo(userInfo: UserInfo): Promise<void>;
|
|
98
109
|
/**
|
|
99
110
|
* Add additional user information.
|
|
100
|
-
* @param extraUserInfo: The
|
|
111
|
+
* @param extraUserInfo: The additional information. (To set the id, name or email please user setUserInfo).
|
|
101
112
|
*/
|
|
102
|
-
addUserExtraInfo(extraUserInfo:
|
|
113
|
+
addUserExtraInfo(extraUserInfo: Record<string, unknown>): Promise<void>;
|
|
103
114
|
/**
|
|
104
115
|
* Set the tracking consent regarding the data collection.
|
|
105
116
|
* @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
|
|
106
117
|
*/
|
|
107
118
|
setTrackingConsent(trackingConsent: string): Promise<void>;
|
|
108
119
|
};
|
|
120
|
+
export type UserInfo = {
|
|
121
|
+
id: string;
|
|
122
|
+
name?: string;
|
|
123
|
+
email?: string;
|
|
124
|
+
extraInfo?: object;
|
|
125
|
+
};
|
|
109
126
|
/**
|
|
110
127
|
* The entry point to use Datadog's Trace feature.
|
|
111
128
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E;;GAEG;AACH,qBAAa,kBAAkB;IAEvB,QAAQ,CAAC,WAAW,EAAE,MAAM;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,QAAQ,CAAC,aAAa,EAAE,MAAM;IAC9B,QAAQ,CAAC,wBAAwB,EAAE,OAAO;IAC1C,QAAQ,CAAC,yBAAyB,EAAE,MAAM;IAC1C,QAAQ,CAAC,mBAAmB,EAAE,MAAM;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,eAAe,EAAE,MAAM;IAChC,QAAQ,CAAC,uBAAuB,EAAE,MAAM;IACxC,QAAQ,CAAC,mBAAmB,EAAE,MAAM;IACpC,QAAQ,CAAC,qBAAqB,EAAE,MAAM;IACtC,QAAQ,CAAC,eAAe,EAAE,MAAM;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,OAAO;IACnC,QAAQ,CAAC,qBAAqB,EAAE,OAAO;IACvC,QAAQ,CAAC,eAAe,EAAE;QACtB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB;IACD,QAAQ,CAAC,yBAAyB,EAAE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AC,CAAC;IAExE;;;OAGG;IACH,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB;;;;;OAKG;IACH,SAAS,CACL,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;;OAKG;IACH,UAAU,CACN,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "2.6.
|
|
1
|
+
export declare const version = "2.6.6";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.6",
|
|
4
4
|
"description": "A client-side React Native module to interact with Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"big-integer": "^1.6.52"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "c70476391a97ab9f62671426eb9ff1bbddeb5ea8"
|
|
104
104
|
}
|
package/src/DdSdkReactNative.tsx
CHANGED
|
@@ -29,6 +29,7 @@ import { DdRum } from './rum/DdRum';
|
|
|
29
29
|
import { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';
|
|
30
30
|
import { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';
|
|
31
31
|
import { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';
|
|
32
|
+
import { registerRumSessionIdListener } from './rum/sessionId/sessionIdHelper';
|
|
32
33
|
import { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';
|
|
33
34
|
import type { Attributes } from './sdk/AttributesSingleton/types';
|
|
34
35
|
import { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';
|
|
@@ -75,6 +76,7 @@ export class DdSdkReactNative {
|
|
|
75
76
|
initializationModeForTelemetry: InitializationModeForTelemetry;
|
|
76
77
|
}
|
|
77
78
|
): Promise<void> => {
|
|
79
|
+
registerRumSessionIdListener();
|
|
78
80
|
if (GlobalState.instance.isInitialized) {
|
|
79
81
|
InternalLog.log(
|
|
80
82
|
"Can't initialize Datadog, SDK was already initialized",
|
|
@@ -183,6 +185,7 @@ export class DdSdkReactNative {
|
|
|
183
185
|
|
|
184
186
|
/**
|
|
185
187
|
* Set the user information.
|
|
188
|
+
* @deprecated UserInfo id property is now mandatory (please user setUserInfo instead)
|
|
186
189
|
* @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
|
|
187
190
|
* @returns a Promise.
|
|
188
191
|
*/
|
|
@@ -196,21 +199,52 @@ export class DdSdkReactNative {
|
|
|
196
199
|
UserInfoSingleton.getInstance().setUserInfo(user);
|
|
197
200
|
};
|
|
198
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Sets the user information.
|
|
204
|
+
* @param id: A mandatory unique user identifier (relevant to your business domain).
|
|
205
|
+
* @param name: The user name or alias.
|
|
206
|
+
* @param email: The user email.
|
|
207
|
+
* @param extraInfo: Additional information.
|
|
208
|
+
* @returns a Promise.
|
|
209
|
+
*/
|
|
210
|
+
static setUserInfo = async (userInfo: {
|
|
211
|
+
id: string;
|
|
212
|
+
name?: string;
|
|
213
|
+
email?: string;
|
|
214
|
+
extraInfo?: Record<string, unknown>;
|
|
215
|
+
}): Promise<void> => {
|
|
216
|
+
InternalLog.log(
|
|
217
|
+
`Setting user ${JSON.stringify(userInfo)}`,
|
|
218
|
+
SdkVerbosity.DEBUG
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
await DdSdk.setUserInfo(userInfo);
|
|
222
|
+
UserInfoSingleton.getInstance().setUserInfo(userInfo);
|
|
223
|
+
};
|
|
224
|
+
|
|
199
225
|
/**
|
|
200
226
|
* Set the user information.
|
|
201
|
-
* @param extraUserInfo: The
|
|
227
|
+
* @param extraUserInfo: The additional information. (To set the id, name or email please user setUserInfo).
|
|
202
228
|
* @returns a Promise.
|
|
203
229
|
*/
|
|
204
230
|
static addUserExtraInfo = async (
|
|
205
|
-
extraUserInfo:
|
|
231
|
+
extraUserInfo: Record<string, unknown>
|
|
206
232
|
): Promise<void> => {
|
|
207
233
|
InternalLog.log(
|
|
208
234
|
`Adding extra user info ${JSON.stringify(extraUserInfo)}`,
|
|
209
235
|
SdkVerbosity.DEBUG
|
|
210
236
|
);
|
|
237
|
+
|
|
211
238
|
const userInfo = UserInfoSingleton.getInstance().getUserInfo();
|
|
212
|
-
const updatedUserInfo = {
|
|
213
|
-
|
|
239
|
+
const updatedUserInfo = {
|
|
240
|
+
...userInfo,
|
|
241
|
+
extraInfo: {
|
|
242
|
+
...userInfo.extraInfo,
|
|
243
|
+
...extraUserInfo
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
await DdSdk.addUserExtraInfo(extraUserInfo);
|
|
214
248
|
UserInfoSingleton.getInstance().setUserInfo(updatedUserInfo);
|
|
215
249
|
};
|
|
216
250
|
|
|
@@ -311,7 +345,8 @@ export class DdSdkReactNative {
|
|
|
311
345
|
configuration.appHangThreshold,
|
|
312
346
|
configuration.resourceTracingSamplingRate,
|
|
313
347
|
configuration.trackWatchdogTerminations,
|
|
314
|
-
configuration.batchProcessingLevel
|
|
348
|
+
configuration.batchProcessingLevel,
|
|
349
|
+
configuration.initialResourceThreshold
|
|
315
350
|
);
|
|
316
351
|
};
|
|
317
352
|
|
|
@@ -314,6 +314,14 @@ export class DdSdkReactNativeConfiguration {
|
|
|
314
314
|
*/
|
|
315
315
|
public appHangThreshold?: number;
|
|
316
316
|
|
|
317
|
+
/**
|
|
318
|
+
* The amount of time after a view starts where a Resource should be
|
|
319
|
+
* considered when calculating Time to Network-Settled (TNS). TNS will be
|
|
320
|
+
* calculated using all resources that start withing the specified threshold, in seconds.
|
|
321
|
+
* Defaults to 0.1 seconds.
|
|
322
|
+
*/
|
|
323
|
+
public initialResourceThreshold?: number;
|
|
324
|
+
|
|
317
325
|
/**
|
|
318
326
|
* Determines whether the SDK should track application termination by the watchdog on iOS. Default: `false`.
|
|
319
327
|
*/
|
|
@@ -460,6 +468,7 @@ export type PartialInitializationConfiguration = {
|
|
|
460
468
|
readonly bundleLogsWithRum?: boolean;
|
|
461
469
|
readonly bundleLogsWithTraces?: boolean;
|
|
462
470
|
readonly batchProcessingLevel?: BatchProcessingLevel;
|
|
471
|
+
readonly initialResourceThreshold?: number;
|
|
463
472
|
};
|
|
464
473
|
|
|
465
474
|
const setConfigurationAttribute = <
|
|
@@ -17,6 +17,7 @@ import { DdRum } from '../rum/DdRum';
|
|
|
17
17
|
import { DdRumErrorTracking } from '../rum/instrumentation/DdRumErrorTracking';
|
|
18
18
|
import { DdRumUserInteractionTracking } from '../rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';
|
|
19
19
|
import { DdRumResourceTracking } from '../rum/instrumentation/resourceTracking/DdRumResourceTracking';
|
|
20
|
+
import { registerRumSessionIdListener } from '../rum/sessionId/sessionIdHelper';
|
|
20
21
|
import { ErrorSource, PropagatorType, RumActionType } from '../rum/types';
|
|
21
22
|
import { AttributesSingleton } from '../sdk/AttributesSingleton/AttributesSingleton';
|
|
22
23
|
import { DdSdk } from '../sdk/DdSdk';
|
|
@@ -57,6 +58,15 @@ jest.mock('../rum/instrumentation/DdRumErrorTracking', () => {
|
|
|
57
58
|
};
|
|
58
59
|
});
|
|
59
60
|
|
|
61
|
+
jest.mock('../rum/sessionId/sessionIdHelper', () => {
|
|
62
|
+
return {
|
|
63
|
+
registerRumSessionIdListener: jest.fn(),
|
|
64
|
+
removeRumSessionIdListeners: jest.fn(),
|
|
65
|
+
getCachedRumSessionId: jest.fn(),
|
|
66
|
+
setCachedRumSessionId: jest.fn()
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
60
70
|
beforeEach(async () => {
|
|
61
71
|
GlobalState.instance.isInitialized = false;
|
|
62
72
|
DdSdkReactNative['wasAutoInstrumented'] = false;
|
|
@@ -78,6 +88,10 @@ beforeEach(async () => {
|
|
|
78
88
|
|
|
79
89
|
UserInfoSingleton.reset();
|
|
80
90
|
AttributesSingleton.reset();
|
|
91
|
+
|
|
92
|
+
(registerRumSessionIdListener as jest.MockedFunction<
|
|
93
|
+
() => void
|
|
94
|
+
>).mockClear();
|
|
81
95
|
});
|
|
82
96
|
|
|
83
97
|
describe('DdSdkReactNative', () => {
|
|
@@ -156,11 +170,13 @@ describe('DdSdkReactNative', () => {
|
|
|
156
170
|
});
|
|
157
171
|
|
|
158
172
|
expect(GlobalState.instance.isInitialized).toBe(false);
|
|
159
|
-
expect(
|
|
173
|
+
expect(
|
|
174
|
+
DdRumUserInteractionTracking.startTracking
|
|
175
|
+
).toHaveBeenCalledTimes(0);
|
|
176
|
+
expect(DdRumResourceTracking.startTracking).toHaveBeenCalledTimes(
|
|
160
177
|
0
|
|
161
178
|
);
|
|
162
|
-
expect(
|
|
163
|
-
expect(DdRumErrorTracking.startTracking).toBeCalledTimes(0);
|
|
179
|
+
expect(DdRumErrorTracking.startTracking).toHaveBeenCalledTimes(0);
|
|
164
180
|
});
|
|
165
181
|
|
|
166
182
|
it('initializes the SDK when initialize { explicit tracking consent }', async () => {
|
|
@@ -481,6 +497,29 @@ describe('DdSdkReactNative', () => {
|
|
|
481
497
|
ddSdkConfiguration.additionalConfiguration['_dd.version_suffix']
|
|
482
498
|
).toBeUndefined();
|
|
483
499
|
});
|
|
500
|
+
|
|
501
|
+
it('initializes with initialResourceThreshold when it is specified', async () => {
|
|
502
|
+
// GIVEN
|
|
503
|
+
const fakeAppId = '1';
|
|
504
|
+
const fakeClientToken = '2';
|
|
505
|
+
const fakeEnvName = 'env';
|
|
506
|
+
const configuration = new DdSdkReactNativeConfiguration(
|
|
507
|
+
fakeClientToken,
|
|
508
|
+
fakeEnvName,
|
|
509
|
+
fakeAppId
|
|
510
|
+
);
|
|
511
|
+
configuration.initialResourceThreshold = 0.123;
|
|
512
|
+
|
|
513
|
+
// WHEN
|
|
514
|
+
await DdSdkReactNative.initialize(configuration);
|
|
515
|
+
|
|
516
|
+
// THEN
|
|
517
|
+
expect(NativeModules.DdSdk.initialize).toHaveBeenCalledWith(
|
|
518
|
+
expect.objectContaining({
|
|
519
|
+
initialResourceThreshold: 0.123
|
|
520
|
+
})
|
|
521
|
+
);
|
|
522
|
+
});
|
|
484
523
|
});
|
|
485
524
|
|
|
486
525
|
describe('feature enablement', () => {
|
|
@@ -1017,6 +1056,29 @@ describe('DdSdkReactNative', () => {
|
|
|
1017
1056
|
logs: 'https://logs.example.com/'
|
|
1018
1057
|
});
|
|
1019
1058
|
});
|
|
1059
|
+
|
|
1060
|
+
it('registers RUM Session ID listener when initialize', async () => {
|
|
1061
|
+
// GIVEN
|
|
1062
|
+
const fakeAppId = '1';
|
|
1063
|
+
const fakeClientToken = '2';
|
|
1064
|
+
const fakeEnvName = 'env';
|
|
1065
|
+
const configuration = new DdSdkReactNativeConfiguration(
|
|
1066
|
+
fakeClientToken,
|
|
1067
|
+
fakeEnvName,
|
|
1068
|
+
fakeAppId,
|
|
1069
|
+
false,
|
|
1070
|
+
false,
|
|
1071
|
+
true
|
|
1072
|
+
);
|
|
1073
|
+
|
|
1074
|
+
NativeModules.DdSdk.initialize.mockResolvedValue(null);
|
|
1075
|
+
|
|
1076
|
+
// WHEN
|
|
1077
|
+
await DdSdkReactNative.initialize(configuration);
|
|
1078
|
+
|
|
1079
|
+
// THEN
|
|
1080
|
+
expect(registerRumSessionIdListener).toHaveBeenCalledTimes(1);
|
|
1081
|
+
});
|
|
1020
1082
|
});
|
|
1021
1083
|
|
|
1022
1084
|
describe('setAttributes', () => {
|
|
@@ -1048,28 +1110,55 @@ describe('DdSdkReactNative', () => {
|
|
|
1048
1110
|
// THEN
|
|
1049
1111
|
expect(DdSdk.setUser).toHaveBeenCalledTimes(1);
|
|
1050
1112
|
expect(DdSdk.setUser).toHaveBeenCalledWith(user);
|
|
1051
|
-
expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual(
|
|
1113
|
+
expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual(user);
|
|
1114
|
+
});
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
describe('setUserInfo', () => {
|
|
1118
|
+
it('calls SDK method when setUserInfo, and sets the user in UserProvider', async () => {
|
|
1119
|
+
// GIVEN
|
|
1120
|
+
const userInfo = {
|
|
1052
1121
|
id: 'id',
|
|
1053
|
-
|
|
1054
|
-
|
|
1122
|
+
name: 'name',
|
|
1123
|
+
email: 'email',
|
|
1124
|
+
extraInfo: {
|
|
1125
|
+
foo: 'bar'
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
// WHEN
|
|
1130
|
+
await DdSdkReactNative.setUserInfo(userInfo);
|
|
1131
|
+
|
|
1132
|
+
// THEN
|
|
1133
|
+
expect(DdSdk.setUserInfo).toHaveBeenCalledTimes(1);
|
|
1134
|
+
expect(DdSdk.setUserInfo).toHaveBeenCalledWith(userInfo);
|
|
1135
|
+
expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual(
|
|
1136
|
+
userInfo
|
|
1137
|
+
);
|
|
1055
1138
|
});
|
|
1056
1139
|
});
|
|
1057
1140
|
|
|
1058
1141
|
describe('addUserExtraInfo', () => {
|
|
1059
1142
|
it('calls SDK method when addUserExtraInfo, and updates the user in UserProvider', async () => {
|
|
1060
1143
|
// GIVEN
|
|
1061
|
-
await DdSdkReactNative.
|
|
1062
|
-
|
|
1144
|
+
await DdSdkReactNative.setUserInfo({
|
|
1145
|
+
id: 'id',
|
|
1146
|
+
extraInfo: { type: 'premium' }
|
|
1147
|
+
});
|
|
1148
|
+
const extraInfo = { foo: 'bar' };
|
|
1063
1149
|
|
|
1064
1150
|
// WHEN
|
|
1065
1151
|
await DdSdkReactNative.addUserExtraInfo(extraInfo);
|
|
1066
1152
|
|
|
1067
1153
|
// THEN
|
|
1068
|
-
expect(DdSdk.
|
|
1069
|
-
expect(DdSdk.
|
|
1154
|
+
expect(DdSdk.addUserExtraInfo).toHaveBeenCalledTimes(1);
|
|
1155
|
+
expect(DdSdk.addUserExtraInfo).toHaveBeenCalledWith(extraInfo);
|
|
1070
1156
|
expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual({
|
|
1071
|
-
id: '
|
|
1072
|
-
|
|
1157
|
+
id: 'id',
|
|
1158
|
+
extraInfo: {
|
|
1159
|
+
foo: 'bar',
|
|
1160
|
+
type: 'premium'
|
|
1161
|
+
}
|
|
1073
1162
|
});
|
|
1074
1163
|
});
|
|
1075
1164
|
});
|
|
@@ -121,7 +121,8 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
121
121
|
trace: 'https://trace.example.com/'
|
|
122
122
|
},
|
|
123
123
|
bundleLogsWithRum: true,
|
|
124
|
-
bundleLogsWithTraces: true
|
|
124
|
+
bundleLogsWithTraces: true,
|
|
125
|
+
initialResourceThreshold: 0.123
|
|
125
126
|
}
|
|
126
127
|
)
|
|
127
128
|
).toMatchInlineSnapshot(`
|
|
@@ -147,6 +148,7 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
147
148
|
"firstPartyHosts": [
|
|
148
149
|
"api.com",
|
|
149
150
|
],
|
|
151
|
+
"initialResourceThreshold": 0.123,
|
|
150
152
|
"logEventMapper": [Function],
|
|
151
153
|
"longTaskThresholdMs": 567,
|
|
152
154
|
"nativeCrashReportEnabled": true,
|
package/src/rum/DdRum.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
import type { GestureResponderEvent } from 'react-native';
|
|
7
|
-
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
8
7
|
|
|
9
8
|
import { InternalLog } from '../InternalLog';
|
|
10
9
|
import { SdkVerbosity } from '../SdkVerbosity';
|
|
@@ -30,6 +29,10 @@ import {
|
|
|
30
29
|
getTracingContext,
|
|
31
30
|
getTracingContextForPropagators
|
|
32
31
|
} from './instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders';
|
|
32
|
+
import {
|
|
33
|
+
getCachedRumSessionId,
|
|
34
|
+
setCachedRumSessionId
|
|
35
|
+
} from './sessionId/sessionIdHelper';
|
|
33
36
|
import type {
|
|
34
37
|
ErrorSource,
|
|
35
38
|
DdRumType,
|
|
@@ -41,11 +44,6 @@ import type {
|
|
|
41
44
|
|
|
42
45
|
const generateEmptyPromise = () => new Promise<void>(resolve => resolve());
|
|
43
46
|
|
|
44
|
-
const nativeEventEmitter =
|
|
45
|
-
Platform.OS === 'android'
|
|
46
|
-
? new NativeEventEmitter()
|
|
47
|
-
: new NativeEventEmitter(NativeModules.DdSdk);
|
|
48
|
-
|
|
49
47
|
class DdRumWrapper implements DdRumType {
|
|
50
48
|
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
51
49
|
private nativeRum: DdNativeRumType = require('../specs/NativeDdRum')
|
|
@@ -56,19 +54,10 @@ class DdRumWrapper implements DdRumType {
|
|
|
56
54
|
private actionEventMapper = generateActionEventMapper(undefined);
|
|
57
55
|
private timeProvider: TimeProvider = new DefaultTimeProvider();
|
|
58
56
|
|
|
59
|
-
private currentRumSessionId: string | null = null;
|
|
60
|
-
|
|
61
57
|
constructor() {
|
|
62
|
-
//
|
|
63
|
-
nativeEventEmitter.addListener('RumSessionStarted', (e: Event) => {
|
|
64
|
-
const field = 'sessionId';
|
|
65
|
-
const sessionId = e[field as keyof Event] as string | null;
|
|
66
|
-
this.currentRumSessionId = sessionId;
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// fetch the current session if any (because we might have missed the first RumSessionStarted event)
|
|
58
|
+
// Fetch the current session if any (because we might have missed the first RumSessionStarted event)
|
|
70
59
|
this.getCurrentSessionId().then(value => {
|
|
71
|
-
|
|
60
|
+
setCachedRumSessionId(value ?? null);
|
|
72
61
|
});
|
|
73
62
|
}
|
|
74
63
|
|
|
@@ -334,11 +323,14 @@ class DdRumWrapper implements DdRumType {
|
|
|
334
323
|
if (!GlobalState.instance.isInitialized) {
|
|
335
324
|
return undefined;
|
|
336
325
|
}
|
|
337
|
-
|
|
326
|
+
const sessionId = await this.nativeRum.getCurrentSessionId();
|
|
327
|
+
setCachedRumSessionId(sessionId ?? null);
|
|
328
|
+
|
|
329
|
+
return sessionId;
|
|
338
330
|
}
|
|
339
331
|
|
|
340
332
|
getCachedSessionId(): string | null {
|
|
341
|
-
return
|
|
333
|
+
return getCachedRumSessionId();
|
|
342
334
|
}
|
|
343
335
|
|
|
344
336
|
getTracingContext = (
|
|
@@ -350,7 +342,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
350
342
|
url,
|
|
351
343
|
tracingSamplingRate,
|
|
352
344
|
firstPartyHosts,
|
|
353
|
-
|
|
345
|
+
getCachedRumSessionId()
|
|
354
346
|
);
|
|
355
347
|
};
|
|
356
348
|
|
|
@@ -361,7 +353,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
361
353
|
return getTracingContextForPropagators(
|
|
362
354
|
propagators,
|
|
363
355
|
tracingSamplingRate,
|
|
364
|
-
|
|
356
|
+
getCachedRumSessionId()
|
|
365
357
|
);
|
|
366
358
|
};
|
|
367
359
|
|
package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts
CHANGED
|
@@ -101,14 +101,14 @@ export const getTracingHeadersFromAttributes = (
|
|
|
101
101
|
version: '00',
|
|
102
102
|
traceId: tracingAttributes.traceId,
|
|
103
103
|
parentId: tracingAttributes.spanId,
|
|
104
|
-
isSampled
|
|
104
|
+
isSampled
|
|
105
105
|
})
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
header: TRACESTATE_HEADER_KEY,
|
|
109
109
|
value: generateTraceStateHeader({
|
|
110
110
|
parentId: tracingAttributes.spanId,
|
|
111
|
-
isSampled
|
|
111
|
+
isSampled,
|
|
112
112
|
rumSessionId: tracingAttributes.rumSessionId
|
|
113
113
|
})
|
|
114
114
|
}
|