@datadog/mobile-react-native 2.4.3 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +8 -6
- package/android/build.gradle +9 -5
- package/android/gradle.properties +1 -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 +5 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +15 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +5 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkSynthetics.kt +12 -0
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +19 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +19 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkBridgeExtTest.kt +28 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +17 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +2 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +4 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +2 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +55 -55
- package/datadog-configuration.schema.json +8 -0
- package/ios/Sources/DdSdkConfiguration.swift +5 -1
- package/ios/Sources/DdSdkNativeInitialization.swift +1 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +6 -2
- package/ios/Sources/SdkVersion.swift +1 -1
- package/jest/mock.js +4 -0
- package/lib/commonjs/DdSdkReactNative.js +22 -1
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +22 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +11 -9
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +7 -0
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +8 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/types.js.map +1 -1
- package/lib/commonjs/types.js +4 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +22 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +22 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/logs/DdLogs.js +11 -9
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/rum/DdRum.js +7 -0
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +8 -2
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/module/rum/types.js.map +1 -1
- package/lib/module/types.js +4 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +7 -0
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +22 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts.map +1 -1
- package/lib/typescript/logs/DdLogs.d.ts.map +1 -1
- package/lib/typescript/logs/types.d.ts +8 -4
- package/lib/typescript/logs/types.d.ts.map +1 -1
- package/lib/typescript/rum/DdRum.d.ts +2 -0
- package/lib/typescript/rum/DdRum.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts.map +1 -1
- package/lib/typescript/rum/types.d.ts +6 -0
- package/lib/typescript/rum/types.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +9 -1
- 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 +31 -1
- package/src/DdSdkReactNativeConfiguration.tsx +24 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +34 -0
- package/src/__tests__/mock.test.ts +1 -0
- package/src/logs/DdLogs.ts +21 -13
- package/src/logs/__tests__/DdLogs.test.ts +147 -0
- package/src/logs/__tests__/eventMapper.test.ts +37 -0
- package/src/logs/types.ts +8 -4
- package/src/rum/DdRum.ts +12 -0
- package/src/rum/__tests__/DdRum.test.ts +16 -0
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +12 -4
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/distributedTracing.test.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +9 -2
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +4 -7
- package/src/rum/types.ts +8 -0
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +5 -0
- package/src/types.tsx +10 -1
- package/src/version.ts +1 -1
|
@@ -48,6 +48,9 @@ export declare class DdSdkConfiguration {
|
|
|
48
48
|
}[];
|
|
49
49
|
readonly bundleLogsWithRum: boolean;
|
|
50
50
|
readonly bundleLogsWithTraces: boolean;
|
|
51
|
+
readonly trackNonFatalAnrs: boolean | undefined;
|
|
52
|
+
readonly appHangThreshold: number | undefined;
|
|
53
|
+
readonly resourceTracingSamplingRate: number | undefined;
|
|
51
54
|
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: {
|
|
52
55
|
rum?: string;
|
|
53
56
|
trace?: string;
|
|
@@ -68,7 +71,7 @@ export declare class DdSdkConfiguration {
|
|
|
68
71
|
} | undefined, serviceName: string | undefined, firstPartyHosts: {
|
|
69
72
|
match: string;
|
|
70
73
|
propagatorTypes: string[];
|
|
71
|
-
}[], bundleLogsWithRum: boolean, bundleLogsWithTraces: boolean);
|
|
74
|
+
}[], bundleLogsWithRum: boolean, bundleLogsWithTraces: boolean, trackNonFatalAnrs: boolean | undefined, appHangThreshold: number | undefined, resourceTracingSamplingRate: number | undefined);
|
|
72
75
|
}
|
|
73
76
|
/**
|
|
74
77
|
* The entry point to initialize Datadog's features.
|
|
@@ -89,6 +92,11 @@ export type DdSdkType = {
|
|
|
89
92
|
* @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
|
|
90
93
|
*/
|
|
91
94
|
setUser(user: object): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Add additional user information.
|
|
97
|
+
* @param extraUserInfo: The extra info object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
|
|
98
|
+
*/
|
|
99
|
+
addUserExtraInfo(extraUserInfo: object): Promise<void>;
|
|
92
100
|
/**
|
|
93
101
|
* Set the tracking consent regarding the data collection.
|
|
94
102
|
* @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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U,CAAC,aAAa,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7D;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErC;;;OAGG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvD;;;OAGG;IACH,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D,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.
|
|
1
|
+
export declare const version = "2.5.0";
|
|
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.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "A client-side React Native module to interact with Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"javaPackageName": "com.datadog.reactnative"
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "2ef793eaf02bf1ac20d49932ff13762177142430"
|
|
101
101
|
}
|
package/src/DdSdkReactNative.tsx
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { version as reactNativeVersion } from 'react-native/package.json';
|
|
7
8
|
import { InteractionManager } from 'react-native';
|
|
8
9
|
|
|
9
10
|
import {
|
|
@@ -48,6 +49,8 @@ export class DdSdkReactNative {
|
|
|
48
49
|
private static readonly DD_SDK_VERSION = '_dd.sdk_version';
|
|
49
50
|
private static readonly DD_VERSION = '_dd.version';
|
|
50
51
|
private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';
|
|
52
|
+
private static readonly DD_REACT_NATIVE_VERSION =
|
|
53
|
+
'_dd.react_native_version';
|
|
51
54
|
|
|
52
55
|
private static wasAutoInstrumented = false;
|
|
53
56
|
private static features?: AutoInstrumentationConfiguration;
|
|
@@ -193,6 +196,24 @@ export class DdSdkReactNative {
|
|
|
193
196
|
UserInfoSingleton.getInstance().setUserInfo(user);
|
|
194
197
|
};
|
|
195
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Set the user information.
|
|
201
|
+
* @param extraUserInfo: The extra info object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
|
|
202
|
+
* @returns a Promise.
|
|
203
|
+
*/
|
|
204
|
+
static addUserExtraInfo = async (
|
|
205
|
+
extraUserInfo: UserInfo
|
|
206
|
+
): Promise<void> => {
|
|
207
|
+
InternalLog.log(
|
|
208
|
+
`Adding extra user info ${JSON.stringify(extraUserInfo)}`,
|
|
209
|
+
SdkVerbosity.DEBUG
|
|
210
|
+
);
|
|
211
|
+
const userInfo = UserInfoSingleton.getInstance().getUserInfo();
|
|
212
|
+
const updatedUserInfo = { ...userInfo, ...extraUserInfo };
|
|
213
|
+
await DdSdk.setUser(updatedUserInfo);
|
|
214
|
+
UserInfoSingleton.getInstance().setUserInfo(updatedUserInfo);
|
|
215
|
+
};
|
|
216
|
+
|
|
196
217
|
/**
|
|
197
218
|
* Set the tracking consent regarding the data collection.
|
|
198
219
|
* @param trackingConsent: One of TrackingConsent values.
|
|
@@ -241,6 +262,12 @@ export class DdSdkReactNative {
|
|
|
241
262
|
] = `-${configuration.versionSuffix}`;
|
|
242
263
|
}
|
|
243
264
|
|
|
265
|
+
if (reactNativeVersion) {
|
|
266
|
+
configuration.additionalConfiguration[
|
|
267
|
+
DdSdkReactNative.DD_REACT_NATIVE_VERSION
|
|
268
|
+
] = `${reactNativeVersion}`;
|
|
269
|
+
}
|
|
270
|
+
|
|
244
271
|
return new DdSdkConfiguration(
|
|
245
272
|
configuration.clientToken,
|
|
246
273
|
configuration.env,
|
|
@@ -279,7 +306,10 @@ export class DdSdkReactNative {
|
|
|
279
306
|
configuration.serviceName,
|
|
280
307
|
formatFirstPartyHosts(configuration.firstPartyHosts),
|
|
281
308
|
configuration.bundleLogsWithRum,
|
|
282
|
-
configuration.bundleLogsWithTraces
|
|
309
|
+
configuration.bundleLogsWithTraces,
|
|
310
|
+
configuration.trackNonFatalAnrs,
|
|
311
|
+
configuration.appHangThreshold,
|
|
312
|
+
configuration.resourceTracingSamplingRate
|
|
283
313
|
);
|
|
284
314
|
};
|
|
285
315
|
|
|
@@ -267,6 +267,30 @@ export class DdSdkReactNativeConfiguration {
|
|
|
267
267
|
*/
|
|
268
268
|
public bundleLogsWithTraces: boolean = DEFAULTS.bundleLogsWithTraces;
|
|
269
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Enables tracking of non-fatal ANRs on Android.
|
|
272
|
+
* By default, the reporting of non-fatal ANRs on Android 30+ is disabled because it would
|
|
273
|
+
* create too much noise over fatal ANRs. On Android 29 and below, however,
|
|
274
|
+
* the reporting of non-fatal ANRs is enabled by default,
|
|
275
|
+
* as fatal ANRs cannot be reported on those versions.
|
|
276
|
+
*/
|
|
277
|
+
public trackNonFatalAnrs?: boolean;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The app hang threshold in seconds for non-fatal app hangs on iOS.
|
|
281
|
+
*
|
|
282
|
+
* App hangs are an iOS-specific type of error that happens when the application is unresponsive for too long.
|
|
283
|
+
* By default, app hangs reporting is disabled, but you can enable it and set your
|
|
284
|
+
* own threshold to monitor app hangs that last more than a specified
|
|
285
|
+
* duration by using the this parameter.
|
|
286
|
+
*
|
|
287
|
+
* Set the `appHangThreshold` parameter to the minimal duration you want
|
|
288
|
+
* app hangs to be reported. For example, enter 0.25 to report hangs lasting at least 250 ms.
|
|
289
|
+
* See [Configure the app hang threshold](https://docs.datadoghq.com/real_user_monitoring/error_tracking/mobile/ios/?tab=cocoapods#configure-the-app-hang-threshold)
|
|
290
|
+
* for more guidance on what to set this value to.
|
|
291
|
+
*/
|
|
292
|
+
public appHangThreshold?: number;
|
|
293
|
+
|
|
270
294
|
/**
|
|
271
295
|
* Specifies a custom prop to name RUM actions on elements having an `onPress` prop.
|
|
272
296
|
*
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { version as reactNativeVersion } from 'react-native/package.json';
|
|
7
8
|
import { NativeModules } from 'react-native';
|
|
8
9
|
|
|
9
10
|
import { DdSdkReactNativeConfiguration } from '../DdSdkReactNativeConfiguration';
|
|
@@ -114,6 +115,7 @@ describe('DdSdkReactNative', () => {
|
|
|
114
115
|
expect(ddSdkConfiguration.bundleLogsWithTraces).toBe(true);
|
|
115
116
|
|
|
116
117
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
118
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
117
119
|
'_dd.source': 'react-native',
|
|
118
120
|
'_dd.sdk_version': sdkVersion
|
|
119
121
|
});
|
|
@@ -148,6 +150,7 @@ describe('DdSdkReactNative', () => {
|
|
|
148
150
|
TrackingConsent.GRANTED
|
|
149
151
|
);
|
|
150
152
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
153
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
151
154
|
'_dd.source': 'react-native',
|
|
152
155
|
'_dd.sdk_version': sdkVersion
|
|
153
156
|
});
|
|
@@ -190,6 +193,7 @@ describe('DdSdkReactNative', () => {
|
|
|
190
193
|
expect(ddSdkConfiguration.env).toBe(fakeEnvName);
|
|
191
194
|
expect(ddSdkConfiguration.trackingConsent).toBe(fakeConsent);
|
|
192
195
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
196
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
193
197
|
'_dd.source': 'react-native',
|
|
194
198
|
'_dd.sdk_version': sdkVersion
|
|
195
199
|
});
|
|
@@ -222,6 +226,7 @@ describe('DdSdkReactNative', () => {
|
|
|
222
226
|
expect(ddSdkConfiguration.applicationId).toBe(fakeAppId);
|
|
223
227
|
expect(ddSdkConfiguration.env).toBe(fakeEnvName);
|
|
224
228
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
229
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
225
230
|
'_dd.source': 'react-native',
|
|
226
231
|
'_dd.sdk_version': sdkVersion
|
|
227
232
|
});
|
|
@@ -281,6 +286,7 @@ describe('DdSdkReactNative', () => {
|
|
|
281
286
|
expect(
|
|
282
287
|
ddSdkConfiguration.additionalConfiguration
|
|
283
288
|
).toStrictEqual({
|
|
289
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
284
290
|
'_dd.source': 'react-native',
|
|
285
291
|
'_dd.sdk_version': sdkVersion
|
|
286
292
|
});
|
|
@@ -503,6 +509,7 @@ describe('DdSdkReactNative', () => {
|
|
|
503
509
|
expect(ddSdkConfiguration.applicationId).toBe(fakeAppId);
|
|
504
510
|
expect(ddSdkConfiguration.env).toBe(fakeEnvName);
|
|
505
511
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
512
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
506
513
|
'_dd.source': 'react-native',
|
|
507
514
|
'_dd.sdk_version': sdkVersion
|
|
508
515
|
});
|
|
@@ -555,6 +562,7 @@ describe('DdSdkReactNative', () => {
|
|
|
555
562
|
}
|
|
556
563
|
]);
|
|
557
564
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
565
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
558
566
|
'_dd.source': 'react-native',
|
|
559
567
|
'_dd.sdk_version': sdkVersion
|
|
560
568
|
});
|
|
@@ -604,6 +612,7 @@ describe('DdSdkReactNative', () => {
|
|
|
604
612
|
expect(ddSdkConfiguration.applicationId).toBe(fakeAppId);
|
|
605
613
|
expect(ddSdkConfiguration.env).toBe(fakeEnvName);
|
|
606
614
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
615
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
607
616
|
'_dd.source': 'react-native',
|
|
608
617
|
'_dd.sdk_version': sdkVersion
|
|
609
618
|
});
|
|
@@ -804,6 +813,7 @@ describe('DdSdkReactNative', () => {
|
|
|
804
813
|
expect(ddSdkConfiguration.env).toBe(fakeEnvName);
|
|
805
814
|
expect(ddSdkConfiguration.serviceName).toBe(fakeServiceName);
|
|
806
815
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
816
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
807
817
|
'_dd.source': 'react-native',
|
|
808
818
|
'_dd.sdk_version': sdkVersion
|
|
809
819
|
});
|
|
@@ -839,6 +849,7 @@ describe('DdSdkReactNative', () => {
|
|
|
839
849
|
expect(ddSdkConfiguration.env).toBe(fakeEnvName);
|
|
840
850
|
expect(ddSdkConfiguration.verbosity).toBe(SdkVerbosity.DEBUG);
|
|
841
851
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
852
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
842
853
|
'_dd.source': 'react-native',
|
|
843
854
|
'_dd.sdk_version': sdkVersion
|
|
844
855
|
});
|
|
@@ -874,6 +885,7 @@ describe('DdSdkReactNative', () => {
|
|
|
874
885
|
expect(ddSdkConfiguration.env).toBe(fakeEnvName);
|
|
875
886
|
expect(ddSdkConfiguration.nativeViewTracking).toBe(true);
|
|
876
887
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
888
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
877
889
|
'_dd.source': 'react-native',
|
|
878
890
|
'_dd.sdk_version': sdkVersion
|
|
879
891
|
});
|
|
@@ -909,6 +921,7 @@ describe('DdSdkReactNative', () => {
|
|
|
909
921
|
expect(ddSdkConfiguration.env).toBe(fakeEnvName);
|
|
910
922
|
expect(ddSdkConfiguration.nativeInteractionTracking).toBe(true);
|
|
911
923
|
expect(ddSdkConfiguration.additionalConfiguration).toStrictEqual({
|
|
924
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
912
925
|
'_dd.source': 'react-native',
|
|
913
926
|
'_dd.sdk_version': sdkVersion
|
|
914
927
|
});
|
|
@@ -1042,6 +1055,25 @@ describe('DdSdkReactNative', () => {
|
|
|
1042
1055
|
});
|
|
1043
1056
|
});
|
|
1044
1057
|
|
|
1058
|
+
describe('addUserExtraInfo', () => {
|
|
1059
|
+
it('calls SDK method when addUserExtraInfo, and updates the user in UserProvider', async () => {
|
|
1060
|
+
// GIVEN
|
|
1061
|
+
await DdSdkReactNative.setUser({ id: 'id' });
|
|
1062
|
+
const extraInfo = { id: 'updatedId', foo: 'bar' };
|
|
1063
|
+
|
|
1064
|
+
// WHEN
|
|
1065
|
+
await DdSdkReactNative.addUserExtraInfo(extraInfo);
|
|
1066
|
+
|
|
1067
|
+
// THEN
|
|
1068
|
+
expect(DdSdk.setUser).toHaveBeenCalledTimes(2);
|
|
1069
|
+
expect(DdSdk.setUser).toHaveBeenCalledWith(extraInfo);
|
|
1070
|
+
expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual({
|
|
1071
|
+
id: 'updatedId',
|
|
1072
|
+
foo: 'bar'
|
|
1073
|
+
});
|
|
1074
|
+
});
|
|
1075
|
+
});
|
|
1076
|
+
|
|
1045
1077
|
describe('setTrackingConsent', () => {
|
|
1046
1078
|
it('calls SDK method when setTrackingConsent', async () => {
|
|
1047
1079
|
// GIVEN
|
|
@@ -1115,6 +1147,7 @@ describe('DdSdkReactNative', () => {
|
|
|
1115
1147
|
expect(
|
|
1116
1148
|
ddSdkConfiguration.additionalConfiguration
|
|
1117
1149
|
).toStrictEqual({
|
|
1150
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
1118
1151
|
'_dd.source': 'react-native',
|
|
1119
1152
|
'_dd.sdk_version': sdkVersion
|
|
1120
1153
|
});
|
|
@@ -1177,6 +1210,7 @@ describe('DdSdkReactNative', () => {
|
|
|
1177
1210
|
expect(
|
|
1178
1211
|
ddSdkConfiguration.additionalConfiguration
|
|
1179
1212
|
).toStrictEqual({
|
|
1213
|
+
'_dd.react_native_version': reactNativeVersion,
|
|
1180
1214
|
'_dd.source': 'react-native',
|
|
1181
1215
|
'_dd.sdk_version': sdkVersion
|
|
1182
1216
|
});
|
package/src/logs/DdLogs.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';
|
|
|
8
8
|
import { SdkVerbosity } from '../SdkVerbosity';
|
|
9
9
|
import type { DdNativeLogsType } from '../nativeModulesTypes';
|
|
10
10
|
import { DdAttributes } from '../rum/DdAttributes';
|
|
11
|
+
import type { ErrorSource } from '../rum/types';
|
|
11
12
|
import { validateContext } from '../utils/argsUtils';
|
|
12
13
|
|
|
13
14
|
import { generateEventMapper } from './eventMapper';
|
|
@@ -16,7 +17,8 @@ import type {
|
|
|
16
17
|
LogArguments,
|
|
17
18
|
LogEventMapper,
|
|
18
19
|
LogWithErrorArguments,
|
|
19
|
-
NativeLogWithError
|
|
20
|
+
NativeLogWithError,
|
|
21
|
+
RawLogWithError
|
|
20
22
|
} from './types';
|
|
21
23
|
|
|
22
24
|
const SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';
|
|
@@ -99,7 +101,8 @@ class DdLogsWrapper implements DdLogsType {
|
|
|
99
101
|
args[3],
|
|
100
102
|
validateContext(args[4]),
|
|
101
103
|
'error',
|
|
102
|
-
args[5]
|
|
104
|
+
args[5],
|
|
105
|
+
args[6]
|
|
103
106
|
);
|
|
104
107
|
}
|
|
105
108
|
return this.log(args[0], validateContext(args[1]), 'error');
|
|
@@ -177,26 +180,31 @@ class DdLogsWrapper implements DdLogsType {
|
|
|
177
180
|
stacktrace: string | undefined,
|
|
178
181
|
context: object,
|
|
179
182
|
status: 'debug' | 'info' | 'warn' | 'error',
|
|
180
|
-
fingerprint?: string
|
|
183
|
+
fingerprint?: string,
|
|
184
|
+
source?: ErrorSource
|
|
181
185
|
): Promise<void> => {
|
|
182
|
-
const
|
|
186
|
+
const rawLogEvent: RawLogWithError = {
|
|
183
187
|
message,
|
|
184
188
|
errorKind,
|
|
185
189
|
errorMessage,
|
|
186
190
|
stacktrace,
|
|
187
191
|
context,
|
|
188
192
|
status,
|
|
189
|
-
fingerprint: fingerprint ?? ''
|
|
190
|
-
|
|
191
|
-
|
|
193
|
+
fingerprint: fingerprint ?? '',
|
|
194
|
+
source
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const mappedEvent = this.logEventMapper.applyEventMapper(rawLogEvent);
|
|
198
|
+
|
|
199
|
+
if (!mappedEvent) {
|
|
192
200
|
this.printLogDroppedByMapper(message, status);
|
|
193
201
|
return generateEmptyPromise();
|
|
194
202
|
}
|
|
195
203
|
|
|
196
|
-
this.printLogTracked(
|
|
204
|
+
this.printLogTracked(mappedEvent.message, status);
|
|
197
205
|
try {
|
|
198
206
|
const updatedContext = {
|
|
199
|
-
...
|
|
207
|
+
...mappedEvent.context,
|
|
200
208
|
[DdAttributes.errorSourceType]: 'react-native'
|
|
201
209
|
};
|
|
202
210
|
|
|
@@ -205,10 +213,10 @@ class DdLogsWrapper implements DdLogsType {
|
|
|
205
213
|
}
|
|
206
214
|
|
|
207
215
|
return await this.nativeLogs[`${status}WithError`](
|
|
208
|
-
|
|
209
|
-
(
|
|
210
|
-
(
|
|
211
|
-
(
|
|
216
|
+
mappedEvent.message,
|
|
217
|
+
(mappedEvent as NativeLogWithError).errorKind,
|
|
218
|
+
(mappedEvent as NativeLogWithError).errorMessage,
|
|
219
|
+
(mappedEvent as NativeLogWithError).stacktrace,
|
|
212
220
|
updatedContext
|
|
213
221
|
);
|
|
214
222
|
} catch (error) {
|
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
import { NativeModules } from 'react-native';
|
|
8
8
|
|
|
9
|
+
import { DdSdkReactNativeConfiguration } from '../../DdSdkReactNativeConfiguration';
|
|
10
|
+
import { DdSdkReactNative } from '../../DdSdkReactNative';
|
|
9
11
|
import { InternalLog } from '../../InternalLog';
|
|
10
12
|
import { SdkVerbosity } from '../../SdkVerbosity';
|
|
11
13
|
import type { DdNativeLogsType } from '../../nativeModulesTypes';
|
|
14
|
+
import { ErrorSource } from '../../rum/types';
|
|
12
15
|
import { DdLogs } from '../DdLogs';
|
|
13
16
|
import type { LogEventMapper } from '../types';
|
|
14
17
|
|
|
@@ -135,6 +138,150 @@ describe('DdLogs', () => {
|
|
|
135
138
|
'debug'
|
|
136
139
|
);
|
|
137
140
|
});
|
|
141
|
+
|
|
142
|
+
it('log with error events can be filtered by error source', async () => {
|
|
143
|
+
const logEventMapper: LogEventMapper = logEvent => {
|
|
144
|
+
if (logEvent.source === ErrorSource.CONSOLE) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return logEvent;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
DdLogs.registerLogEventMapper(logEventMapper);
|
|
152
|
+
|
|
153
|
+
await DdLogs.error(
|
|
154
|
+
'message',
|
|
155
|
+
'kind',
|
|
156
|
+
'message',
|
|
157
|
+
'stacktrace',
|
|
158
|
+
{},
|
|
159
|
+
'fingerprint',
|
|
160
|
+
ErrorSource.CONSOLE
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
// Call with filtered ErrorSource.CONSOLE type
|
|
164
|
+
expect(NativeModules.DdLogs.error).not.toHaveBeenCalled();
|
|
165
|
+
expect(InternalLog.log).toHaveBeenCalledWith(
|
|
166
|
+
'error log dropped by log mapper: "message"',
|
|
167
|
+
'debug'
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
// Call with valid ErrorSource.CUSTOM type
|
|
171
|
+
await DdLogs.error(
|
|
172
|
+
'message',
|
|
173
|
+
'kind',
|
|
174
|
+
'message',
|
|
175
|
+
'stacktrace',
|
|
176
|
+
{},
|
|
177
|
+
'fingerprint',
|
|
178
|
+
ErrorSource.CUSTOM
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
expect(NativeModules.DdLogs.errorWithError).toHaveBeenCalledWith(
|
|
182
|
+
'message',
|
|
183
|
+
'kind',
|
|
184
|
+
'message',
|
|
185
|
+
'stacktrace',
|
|
186
|
+
{
|
|
187
|
+
'_dd.error.fingerprint': 'fingerprint',
|
|
188
|
+
'_dd.error.source_type': 'react-native'
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
expect(InternalLog.log).toHaveBeenCalledWith(
|
|
192
|
+
'Tracking error log "message"',
|
|
193
|
+
'debug'
|
|
194
|
+
);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('console errors can be filtered with mappers when trackErrors=true', async () => {
|
|
198
|
+
// GIVEN
|
|
199
|
+
const fakeAppId = '1';
|
|
200
|
+
const fakeClientToken = '2';
|
|
201
|
+
const fakeEnvName = 'env';
|
|
202
|
+
const configuration = new DdSdkReactNativeConfiguration(
|
|
203
|
+
fakeClientToken,
|
|
204
|
+
fakeEnvName,
|
|
205
|
+
fakeAppId,
|
|
206
|
+
false,
|
|
207
|
+
false,
|
|
208
|
+
true // Track Errors
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
// Register log event mapper to filter console log events
|
|
212
|
+
configuration.logEventMapper = logEvent => {
|
|
213
|
+
if (logEvent.source === ErrorSource.CONSOLE) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return logEvent;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
NativeModules.DdSdk.initialize.mockResolvedValue(null);
|
|
221
|
+
|
|
222
|
+
// WHEN
|
|
223
|
+
await DdSdkReactNative.initialize(configuration);
|
|
224
|
+
|
|
225
|
+
console.error('console-error-message');
|
|
226
|
+
expect(NativeModules.DdLogs.error).not.toHaveBeenCalled();
|
|
227
|
+
expect(InternalLog.log).toHaveBeenCalledWith(
|
|
228
|
+
'error log dropped by log mapper: "console-error-message"',
|
|
229
|
+
'debug'
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
// Call with valid ErrorSource.CUSTOM type
|
|
233
|
+
await DdLogs.error(
|
|
234
|
+
'message',
|
|
235
|
+
'kind',
|
|
236
|
+
'message',
|
|
237
|
+
'stacktrace',
|
|
238
|
+
{},
|
|
239
|
+
'fingerprint',
|
|
240
|
+
ErrorSource.CUSTOM
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
expect(NativeModules.DdLogs.errorWithError).toHaveBeenCalledWith(
|
|
244
|
+
'message',
|
|
245
|
+
'kind',
|
|
246
|
+
'message',
|
|
247
|
+
'stacktrace',
|
|
248
|
+
{
|
|
249
|
+
'_dd.error.fingerprint': 'fingerprint',
|
|
250
|
+
'_dd.error.source_type': 'react-native'
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
expect(InternalLog.log).toHaveBeenCalledWith(
|
|
254
|
+
'Tracking error log "message"',
|
|
255
|
+
'debug'
|
|
256
|
+
);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('console errors are reported in logs when trackErrors=true', async () => {
|
|
260
|
+
// GIVEN
|
|
261
|
+
const fakeAppId = '1';
|
|
262
|
+
const fakeClientToken = '2';
|
|
263
|
+
const fakeEnvName = 'env';
|
|
264
|
+
const configuration = new DdSdkReactNativeConfiguration(
|
|
265
|
+
fakeClientToken,
|
|
266
|
+
fakeEnvName,
|
|
267
|
+
fakeAppId,
|
|
268
|
+
false,
|
|
269
|
+
false,
|
|
270
|
+
true // Track Errors
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
NativeModules.DdSdk.initialize.mockResolvedValue(null);
|
|
274
|
+
|
|
275
|
+
// WHEN
|
|
276
|
+
await DdSdkReactNative.initialize(configuration);
|
|
277
|
+
|
|
278
|
+
console.error('console-error-message');
|
|
279
|
+
expect(NativeModules.DdLogs.error).not.toHaveBeenCalled();
|
|
280
|
+
expect(InternalLog.log).toHaveBeenCalledWith(
|
|
281
|
+
'Tracking error log "console-error-message"',
|
|
282
|
+
'debug'
|
|
283
|
+
);
|
|
284
|
+
});
|
|
138
285
|
});
|
|
139
286
|
|
|
140
287
|
describe('log with error', () => {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
8
|
+
import { ErrorSource } from '../../rum/types';
|
|
8
9
|
import { formatRawLogToLogEvent } from '../eventMapper';
|
|
9
10
|
|
|
10
11
|
describe('formatRawLogToLogEvent', () => {
|
|
@@ -84,4 +85,40 @@ describe('formatRawLogToLogEvent', () => {
|
|
|
84
85
|
attributes: { appType: 'student' }
|
|
85
86
|
});
|
|
86
87
|
});
|
|
88
|
+
|
|
89
|
+
it('formats a raw log with error attributes and with context, userInfo, attributes and source to a LogEvent', () => {
|
|
90
|
+
expect(
|
|
91
|
+
formatRawLogToLogEvent(
|
|
92
|
+
{
|
|
93
|
+
message: 'original',
|
|
94
|
+
errorKind: 'TypeError',
|
|
95
|
+
errorMessage: 'something went wrong',
|
|
96
|
+
stacktrace: 'stacktrace',
|
|
97
|
+
context: { loggedIn: true },
|
|
98
|
+
status: 'info',
|
|
99
|
+
source: ErrorSource.CONSOLE
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
userInfo: {
|
|
103
|
+
name: 'userName',
|
|
104
|
+
extraInfo: { loggedIn: true }
|
|
105
|
+
},
|
|
106
|
+
attributes: { appType: 'student' }
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
).toEqual({
|
|
110
|
+
message: 'original',
|
|
111
|
+
errorKind: 'TypeError',
|
|
112
|
+
errorMessage: 'something went wrong',
|
|
113
|
+
stacktrace: 'stacktrace',
|
|
114
|
+
context: { loggedIn: true },
|
|
115
|
+
status: 'info',
|
|
116
|
+
source: ErrorSource.CONSOLE,
|
|
117
|
+
userInfo: {
|
|
118
|
+
name: 'userName',
|
|
119
|
+
extraInfo: { loggedIn: true }
|
|
120
|
+
},
|
|
121
|
+
attributes: { appType: 'student' }
|
|
122
|
+
});
|
|
123
|
+
});
|
|
87
124
|
});
|
package/src/logs/types.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import type { ErrorSource } from '../rum/types';
|
|
7
8
|
import type { UserInfo } from '../sdk/UserInfoSingleton/types';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -49,12 +50,13 @@ export type RawLog = {
|
|
|
49
50
|
};
|
|
50
51
|
export type RawLogWithError = {
|
|
51
52
|
message: string;
|
|
52
|
-
errorKind
|
|
53
|
-
errorMessage
|
|
54
|
-
stacktrace
|
|
53
|
+
errorKind?: string;
|
|
54
|
+
errorMessage?: string;
|
|
55
|
+
stacktrace?: string;
|
|
55
56
|
context: object;
|
|
56
57
|
status: LogStatus;
|
|
57
58
|
fingerprint?: string;
|
|
59
|
+
source?: ErrorSource;
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
/**
|
|
@@ -82,6 +84,7 @@ export type LogEvent = {
|
|
|
82
84
|
errorMessage?: string;
|
|
83
85
|
stacktrace?: string;
|
|
84
86
|
fingerprint?: string;
|
|
87
|
+
readonly source?: ErrorSource;
|
|
85
88
|
// readonly date: number; // TODO: RUMM-2446 & RUMM-2447
|
|
86
89
|
readonly status: LogStatus;
|
|
87
90
|
readonly userInfo: UserInfo;
|
|
@@ -98,5 +101,6 @@ export type LogWithErrorArguments = [
|
|
|
98
101
|
errorMessage?: string,
|
|
99
102
|
stacktrace?: string,
|
|
100
103
|
context?: object,
|
|
101
|
-
fingerprint?: string
|
|
104
|
+
fingerprint?: string,
|
|
105
|
+
source?: ErrorSource
|
|
102
106
|
];
|