@datadog/mobile-react-native 2.3.5 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +6 -6
- package/android/build.gradle +4 -4
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +2 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +15 -0
- package/android/src/test/resources/input/complete-configuration.json +5 -1
- package/datadog-configuration.schema.json +54 -9
- package/datadog-sourcemaps.gradle +64 -1
- package/ios/Sources/DatadogSDKWrapper.swift +3 -3
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +2 -1
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +7 -4
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +10 -8
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +50 -48
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +14 -9
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -6
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +182 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +10 -57
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +18 -10
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +4 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/commonjs/trace/DdTrace.js +4 -2
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/utils/argsUtils.js +43 -0
- package/lib/commonjs/utils/argsUtils.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +2 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +7 -4
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/logs/DdLogs.js +9 -8
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/rum/DdRum.js +48 -47
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +14 -9
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -6
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +169 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +3 -54
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +13 -8
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +3 -2
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/module/trace/DdTrace.js +3 -2
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/utils/argsUtils.js +30 -0
- package/lib/module/utils/argsUtils.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +5 -1
- package/lib/typescript/rum/DdRum.d.ts +2 -2
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +12 -3
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +2 -3
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.d.ts +111 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +1 -24
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +2 -0
- package/lib/typescript/utils/argsUtils.d.ts +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +4 -1
- package/src/DdSdkReactNativeConfiguration.tsx +10 -4
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +7 -2
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +32 -0
- package/src/logs/DdLogs.ts +9 -8
- package/src/logs/__tests__/DdLogs.test.ts +543 -0
- package/src/rum/DdRum.ts +112 -94
- package/src/rum/__tests__/DdRum.test.ts +552 -0
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +23 -7
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +3 -4
- package/src/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.tsx +227 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/__utils__/TracingIdentifierUtils.ts +64 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/distributedTracing.test.ts +314 -42
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +4 -59
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +33 -19
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.ts +7 -2
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +134 -11
- package/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts +3 -0
- package/src/trace/DdTrace.ts +12 -2
- package/src/trace/__tests__/DdTrace.test.ts +146 -0
- package/src/utils/__tests__/argsUtils.test.ts +66 -0
- package/src/utils/argsUtils.ts +35 -0
- package/src/version.ts +1 -1
|
@@ -62,6 +62,7 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
62
62
|
"trackResources": false,
|
|
63
63
|
"trackingConsent": "granted",
|
|
64
64
|
"uploadFrequency": "AVERAGE",
|
|
65
|
+
"useAccessibilityLabel": true,
|
|
65
66
|
"verbosity": undefined,
|
|
66
67
|
"vitalsUpdateFrequency": "AVERAGE",
|
|
67
68
|
}
|
|
@@ -81,7 +82,8 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
81
82
|
errorEventMapper: event => event,
|
|
82
83
|
resourceEventMapper: event => event,
|
|
83
84
|
actionEventMapper: event => event,
|
|
84
|
-
actionNameAttribute: 'testID'
|
|
85
|
+
actionNameAttribute: 'testID',
|
|
86
|
+
useAccessibilityLabel: true
|
|
85
87
|
},
|
|
86
88
|
{
|
|
87
89
|
applicationId: 'fake-app-id',
|
|
@@ -166,6 +168,7 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
166
168
|
"trackResources": true,
|
|
167
169
|
"trackingConsent": "pending",
|
|
168
170
|
"uploadFrequency": "FREQUENT",
|
|
171
|
+
"useAccessibilityLabel": true,
|
|
169
172
|
"verbosity": "debug",
|
|
170
173
|
"version": "1.4.5",
|
|
171
174
|
"versionSuffix": "codepush-3",
|
|
@@ -181,7 +184,8 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
181
184
|
trackErrors: false,
|
|
182
185
|
trackInteractions: false,
|
|
183
186
|
trackResources: false,
|
|
184
|
-
resourceTracingSamplingRate: 0
|
|
187
|
+
resourceTracingSamplingRate: 0,
|
|
188
|
+
useAccessibilityLabel: false
|
|
185
189
|
},
|
|
186
190
|
{
|
|
187
191
|
applicationId: '',
|
|
@@ -238,6 +242,7 @@ describe('DdSdkReactNativeConfiguration', () => {
|
|
|
238
242
|
"trackResources": false,
|
|
239
243
|
"trackingConsent": "granted",
|
|
240
244
|
"uploadFrequency": "AVERAGE",
|
|
245
|
+
"useAccessibilityLabel": false,
|
|
241
246
|
"verbosity": undefined,
|
|
242
247
|
"version": "",
|
|
243
248
|
"versionSuffix": "",
|
|
@@ -77,6 +77,38 @@ it('M intercept and send a RUM event W onPress { Button component }', async () =
|
|
|
77
77
|
);
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
+
it('M intercept and send a RUM event with elementType W onPress { Button component, useAccessibilityLabel = false }', async () => {
|
|
81
|
+
// GIVEN
|
|
82
|
+
DdRumUserInteractionTracking.startTracking({
|
|
83
|
+
useAccessibilityLabel: false
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const { getByText } = render(
|
|
87
|
+
<View>
|
|
88
|
+
<Button title="Click me" onPress={event => {}} />
|
|
89
|
+
</View>
|
|
90
|
+
);
|
|
91
|
+
const testButton = getByText('Click me');
|
|
92
|
+
|
|
93
|
+
// WHEN
|
|
94
|
+
fireEvent(testButton, 'press', {
|
|
95
|
+
_targetInst: {
|
|
96
|
+
elementType: 'test_element_type',
|
|
97
|
+
memoizedProps: {
|
|
98
|
+
accessibilityLabel: 'click_me_button'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// THEN
|
|
104
|
+
expect(DdRum.addAction).toBeCalledWith(
|
|
105
|
+
'TAP',
|
|
106
|
+
'test_element_type',
|
|
107
|
+
expect.anything(),
|
|
108
|
+
expect.anything()
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
|
|
80
112
|
it('M intercept and send a RUM event W onPress { custom action name prop used }', async () => {
|
|
81
113
|
// GIVEN
|
|
82
114
|
DdRumUserInteractionTracking.startTracking({
|
package/src/logs/DdLogs.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';
|
|
8
8
|
import { SdkVerbosity } from '../SdkVerbosity';
|
|
9
9
|
import type { DdNativeLogsType } from '../nativeModulesTypes';
|
|
10
|
+
import { validateContext } from '../utils/argsUtils';
|
|
10
11
|
|
|
11
12
|
import { generateEventMapper } from './eventMapper';
|
|
12
13
|
import type {
|
|
@@ -49,11 +50,11 @@ class DdLogsWrapper implements DdLogsType {
|
|
|
49
50
|
args[1],
|
|
50
51
|
args[2],
|
|
51
52
|
args[3],
|
|
52
|
-
args[4]
|
|
53
|
+
validateContext(args[4]),
|
|
53
54
|
'debug'
|
|
54
55
|
);
|
|
55
56
|
}
|
|
56
|
-
return this.log(args[0], args[1]
|
|
57
|
+
return this.log(args[0], validateContext(args[1]), 'debug');
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
info = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {
|
|
@@ -63,11 +64,11 @@ class DdLogsWrapper implements DdLogsType {
|
|
|
63
64
|
args[1],
|
|
64
65
|
args[2],
|
|
65
66
|
args[3],
|
|
66
|
-
args[4]
|
|
67
|
+
validateContext(args[4]),
|
|
67
68
|
'info'
|
|
68
69
|
);
|
|
69
70
|
}
|
|
70
|
-
return this.log(args[0], args[1]
|
|
71
|
+
return this.log(args[0], validateContext(args[1]), 'info');
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
warn = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {
|
|
@@ -77,11 +78,11 @@ class DdLogsWrapper implements DdLogsType {
|
|
|
77
78
|
args[1],
|
|
78
79
|
args[2],
|
|
79
80
|
args[3],
|
|
80
|
-
args[4]
|
|
81
|
+
validateContext(args[4]),
|
|
81
82
|
'warn'
|
|
82
83
|
);
|
|
83
84
|
}
|
|
84
|
-
return this.log(args[0], args[1]
|
|
85
|
+
return this.log(args[0], validateContext(args[1]), 'warn');
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
error = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {
|
|
@@ -91,11 +92,11 @@ class DdLogsWrapper implements DdLogsType {
|
|
|
91
92
|
args[1],
|
|
92
93
|
args[2],
|
|
93
94
|
args[3],
|
|
94
|
-
args[4]
|
|
95
|
+
validateContext(args[4]),
|
|
95
96
|
'error'
|
|
96
97
|
);
|
|
97
98
|
}
|
|
98
|
-
return this.log(args[0], args[1]
|
|
99
|
+
return this.log(args[0], validateContext(args[1]), 'error');
|
|
99
100
|
};
|
|
100
101
|
|
|
101
102
|
/**
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { NativeModules } from 'react-native';
|
|
8
8
|
|
|
9
9
|
import { InternalLog } from '../../InternalLog';
|
|
10
|
+
import { SdkVerbosity } from '../../SdkVerbosity';
|
|
10
11
|
import type { DdNativeLogsType } from '../../nativeModulesTypes';
|
|
11
12
|
import { DdLogs } from '../DdLogs';
|
|
12
13
|
import type { LogEventMapper } from '../types';
|
|
@@ -217,4 +218,546 @@ describe('DdLogs', () => {
|
|
|
217
218
|
);
|
|
218
219
|
});
|
|
219
220
|
});
|
|
221
|
+
|
|
222
|
+
describe('log context', () => {
|
|
223
|
+
beforeEach(() => {
|
|
224
|
+
jest.clearAllMocks();
|
|
225
|
+
DdLogs.unregisterLogEventMapper();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe('debug logs', () => {
|
|
229
|
+
it('native context is empty W context is undefined', async () => {
|
|
230
|
+
await DdLogs.debug('message', undefined);
|
|
231
|
+
expect(NativeModules.DdLogs.debug).toHaveBeenCalledWith(
|
|
232
|
+
'message',
|
|
233
|
+
{}
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('native context is an object with nested property W context is an array', async () => {
|
|
238
|
+
await DdLogs.debug('message', [1, 2, 3]);
|
|
239
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
240
|
+
1,
|
|
241
|
+
expect.anything(),
|
|
242
|
+
SdkVerbosity.WARN
|
|
243
|
+
);
|
|
244
|
+
expect(
|
|
245
|
+
NativeModules.DdLogs.debug
|
|
246
|
+
).toHaveBeenCalledWith('message', { context: [1, 2, 3] });
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('native context is empty W context is raw type', async () => {
|
|
250
|
+
const obj: any = 123;
|
|
251
|
+
await DdLogs.debug('message', obj);
|
|
252
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
253
|
+
1,
|
|
254
|
+
expect.anything(),
|
|
255
|
+
SdkVerbosity.ERROR
|
|
256
|
+
);
|
|
257
|
+
expect(NativeModules.DdLogs.debug).toHaveBeenCalledWith(
|
|
258
|
+
'message',
|
|
259
|
+
{}
|
|
260
|
+
);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it('native context is unmodified W context is a valid object', async () => {
|
|
264
|
+
await DdLogs.debug('message', { test: '123' });
|
|
265
|
+
expect(
|
|
266
|
+
NativeModules.DdLogs.debug
|
|
267
|
+
).toHaveBeenCalledWith('message', { test: '123' });
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
describe('warn logs', () => {
|
|
272
|
+
it('native context is empty W context is undefined', async () => {
|
|
273
|
+
await DdLogs.warn('message', undefined);
|
|
274
|
+
expect(NativeModules.DdLogs.warn).toHaveBeenCalledWith(
|
|
275
|
+
'message',
|
|
276
|
+
{}
|
|
277
|
+
);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it('native context is an object with nested property W context is an array', async () => {
|
|
281
|
+
await DdLogs.warn('message', [1, 2, 3]);
|
|
282
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
283
|
+
1,
|
|
284
|
+
expect.anything(),
|
|
285
|
+
SdkVerbosity.WARN
|
|
286
|
+
);
|
|
287
|
+
expect(
|
|
288
|
+
NativeModules.DdLogs.warn
|
|
289
|
+
).toHaveBeenCalledWith('message', { context: [1, 2, 3] });
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('native context is empty W context is raw type', async () => {
|
|
293
|
+
const obj: any = 123;
|
|
294
|
+
await DdLogs.warn('message', obj);
|
|
295
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
296
|
+
1,
|
|
297
|
+
expect.anything(),
|
|
298
|
+
SdkVerbosity.ERROR
|
|
299
|
+
);
|
|
300
|
+
expect(NativeModules.DdLogs.warn).toHaveBeenCalledWith(
|
|
301
|
+
'message',
|
|
302
|
+
{}
|
|
303
|
+
);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('native context is unmodified W context is a valid object', async () => {
|
|
307
|
+
await DdLogs.warn('message', { test: '123' });
|
|
308
|
+
expect(
|
|
309
|
+
NativeModules.DdLogs.warn
|
|
310
|
+
).toHaveBeenCalledWith('message', { test: '123' });
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
describe('info logs', () => {
|
|
315
|
+
it('native context is empty W context is undefined', async () => {
|
|
316
|
+
await DdLogs.info('message', undefined);
|
|
317
|
+
expect(NativeModules.DdLogs.info).toHaveBeenCalledWith(
|
|
318
|
+
'message',
|
|
319
|
+
{}
|
|
320
|
+
);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it('native context is an object with nested property W context is an array', async () => {
|
|
324
|
+
await DdLogs.info('message', [1, 2, 3]);
|
|
325
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
326
|
+
1,
|
|
327
|
+
expect.anything(),
|
|
328
|
+
SdkVerbosity.WARN
|
|
329
|
+
);
|
|
330
|
+
expect(
|
|
331
|
+
NativeModules.DdLogs.info
|
|
332
|
+
).toHaveBeenCalledWith('message', { context: [1, 2, 3] });
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it('native context is empty W context is raw type', async () => {
|
|
336
|
+
const obj: any = 123;
|
|
337
|
+
await DdLogs.info('message', obj);
|
|
338
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
339
|
+
1,
|
|
340
|
+
expect.anything(),
|
|
341
|
+
SdkVerbosity.ERROR
|
|
342
|
+
);
|
|
343
|
+
expect(NativeModules.DdLogs.info).toHaveBeenCalledWith(
|
|
344
|
+
'message',
|
|
345
|
+
{}
|
|
346
|
+
);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it('native context is unmodified W context is a valid object', async () => {
|
|
350
|
+
await DdLogs.info('message', { test: '123' });
|
|
351
|
+
expect(
|
|
352
|
+
NativeModules.DdLogs.info
|
|
353
|
+
).toHaveBeenCalledWith('message', { test: '123' });
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
describe('error logs', () => {
|
|
358
|
+
it('native context is empty W context is undefined', async () => {
|
|
359
|
+
await DdLogs.error('message', undefined);
|
|
360
|
+
expect(NativeModules.DdLogs.error).toHaveBeenCalledWith(
|
|
361
|
+
'message',
|
|
362
|
+
{}
|
|
363
|
+
);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it('native context is an object with nested property W context is an array', async () => {
|
|
367
|
+
await DdLogs.error('message', [1, 2, 3]);
|
|
368
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
369
|
+
1,
|
|
370
|
+
expect.anything(),
|
|
371
|
+
SdkVerbosity.WARN
|
|
372
|
+
);
|
|
373
|
+
expect(
|
|
374
|
+
NativeModules.DdLogs.error
|
|
375
|
+
).toHaveBeenCalledWith('message', { context: [1, 2, 3] });
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it('native context is empty W context is raw type', async () => {
|
|
379
|
+
const obj: any = 123;
|
|
380
|
+
await DdLogs.error('message', obj);
|
|
381
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
382
|
+
1,
|
|
383
|
+
expect.anything(),
|
|
384
|
+
SdkVerbosity.ERROR
|
|
385
|
+
);
|
|
386
|
+
expect(NativeModules.DdLogs.error).toHaveBeenCalledWith(
|
|
387
|
+
'message',
|
|
388
|
+
{}
|
|
389
|
+
);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it('native context is unmodified W context is a valid object', async () => {
|
|
393
|
+
await DdLogs.error('message', { test: '123' });
|
|
394
|
+
expect(
|
|
395
|
+
NativeModules.DdLogs.error
|
|
396
|
+
).toHaveBeenCalledWith('message', { test: '123' });
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
describe('log with error context', () => {
|
|
402
|
+
beforeEach(() => {
|
|
403
|
+
jest.clearAllMocks();
|
|
404
|
+
DdLogs.unregisterLogEventMapper();
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
describe('debug logs', () => {
|
|
408
|
+
it('native context is empty W context is undefined', async () => {
|
|
409
|
+
await DdLogs.debug(
|
|
410
|
+
'message',
|
|
411
|
+
'kind',
|
|
412
|
+
'message',
|
|
413
|
+
'stacktrace',
|
|
414
|
+
undefined
|
|
415
|
+
);
|
|
416
|
+
expect(
|
|
417
|
+
NativeModules.DdLogs.debugWithError
|
|
418
|
+
).toHaveBeenCalledWith(
|
|
419
|
+
'message',
|
|
420
|
+
'kind',
|
|
421
|
+
'message',
|
|
422
|
+
'stacktrace',
|
|
423
|
+
{ '_dd.error.source_type': 'react-native' }
|
|
424
|
+
);
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
it('native context is an object with nested property W context is an array', async () => {
|
|
428
|
+
await DdLogs.debug('message', 'kind', 'message', 'stacktrace', [
|
|
429
|
+
1,
|
|
430
|
+
2,
|
|
431
|
+
3
|
|
432
|
+
]);
|
|
433
|
+
|
|
434
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
435
|
+
1,
|
|
436
|
+
expect.anything(),
|
|
437
|
+
SdkVerbosity.WARN
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
expect(
|
|
441
|
+
NativeModules.DdLogs.debugWithError
|
|
442
|
+
).toHaveBeenCalledWith(
|
|
443
|
+
'message',
|
|
444
|
+
'kind',
|
|
445
|
+
'message',
|
|
446
|
+
'stacktrace',
|
|
447
|
+
{
|
|
448
|
+
context: [1, 2, 3],
|
|
449
|
+
'_dd.error.source_type': 'react-native'
|
|
450
|
+
}
|
|
451
|
+
);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it('native context is empty W context is raw type', async () => {
|
|
455
|
+
const obj: any = 123;
|
|
456
|
+
await DdLogs.debug(
|
|
457
|
+
'message',
|
|
458
|
+
'kind',
|
|
459
|
+
'message',
|
|
460
|
+
'stacktrace',
|
|
461
|
+
obj
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
465
|
+
1,
|
|
466
|
+
expect.anything(),
|
|
467
|
+
SdkVerbosity.ERROR
|
|
468
|
+
);
|
|
469
|
+
|
|
470
|
+
expect(
|
|
471
|
+
NativeModules.DdLogs.debugWithError
|
|
472
|
+
).toHaveBeenCalledWith(
|
|
473
|
+
'message',
|
|
474
|
+
'kind',
|
|
475
|
+
'message',
|
|
476
|
+
'stacktrace',
|
|
477
|
+
{ '_dd.error.source_type': 'react-native' }
|
|
478
|
+
);
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
it('native context is unmodified W context is a valid object', async () => {
|
|
482
|
+
await DdLogs.debug('message', 'kind', 'message', 'stacktrace', {
|
|
483
|
+
test: '123'
|
|
484
|
+
});
|
|
485
|
+
expect(
|
|
486
|
+
NativeModules.DdLogs.debugWithError
|
|
487
|
+
).toHaveBeenCalledWith(
|
|
488
|
+
'message',
|
|
489
|
+
'kind',
|
|
490
|
+
'message',
|
|
491
|
+
'stacktrace',
|
|
492
|
+
{ test: '123', '_dd.error.source_type': 'react-native' }
|
|
493
|
+
);
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
describe('warn logs', () => {
|
|
498
|
+
it('native context is empty W context is undefined', async () => {
|
|
499
|
+
await DdLogs.warn(
|
|
500
|
+
'message',
|
|
501
|
+
'kind',
|
|
502
|
+
'message',
|
|
503
|
+
'stacktrace',
|
|
504
|
+
undefined
|
|
505
|
+
);
|
|
506
|
+
expect(
|
|
507
|
+
NativeModules.DdLogs.warnWithError
|
|
508
|
+
).toHaveBeenCalledWith(
|
|
509
|
+
'message',
|
|
510
|
+
'kind',
|
|
511
|
+
'message',
|
|
512
|
+
'stacktrace',
|
|
513
|
+
{ '_dd.error.source_type': 'react-native' }
|
|
514
|
+
);
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
it('native context is an object with nested property W context is an array', async () => {
|
|
518
|
+
await DdLogs.warn('message', 'kind', 'message', 'stacktrace', [
|
|
519
|
+
1,
|
|
520
|
+
2,
|
|
521
|
+
3
|
|
522
|
+
]);
|
|
523
|
+
|
|
524
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
525
|
+
1,
|
|
526
|
+
expect.anything(),
|
|
527
|
+
SdkVerbosity.WARN
|
|
528
|
+
);
|
|
529
|
+
|
|
530
|
+
expect(NativeModules.DdLogs.warnWithError).toHaveBeenCalledWith(
|
|
531
|
+
'message',
|
|
532
|
+
'kind',
|
|
533
|
+
'message',
|
|
534
|
+
'stacktrace',
|
|
535
|
+
{
|
|
536
|
+
context: [1, 2, 3],
|
|
537
|
+
'_dd.error.source_type': 'react-native'
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
it('native context is empty W context is raw type', async () => {
|
|
543
|
+
const obj: any = 123;
|
|
544
|
+
await DdLogs.warn(
|
|
545
|
+
'message',
|
|
546
|
+
'kind',
|
|
547
|
+
'message',
|
|
548
|
+
'stacktrace',
|
|
549
|
+
obj
|
|
550
|
+
);
|
|
551
|
+
|
|
552
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
553
|
+
1,
|
|
554
|
+
expect.anything(),
|
|
555
|
+
SdkVerbosity.ERROR
|
|
556
|
+
);
|
|
557
|
+
|
|
558
|
+
expect(
|
|
559
|
+
NativeModules.DdLogs.warnWithError
|
|
560
|
+
).toHaveBeenCalledWith(
|
|
561
|
+
'message',
|
|
562
|
+
'kind',
|
|
563
|
+
'message',
|
|
564
|
+
'stacktrace',
|
|
565
|
+
{ '_dd.error.source_type': 'react-native' }
|
|
566
|
+
);
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
it('native context is unmodified W context is a valid object', async () => {
|
|
570
|
+
await DdLogs.warn('message', 'kind', 'message', 'stacktrace', {
|
|
571
|
+
test: '123'
|
|
572
|
+
});
|
|
573
|
+
expect(
|
|
574
|
+
NativeModules.DdLogs.warnWithError
|
|
575
|
+
).toHaveBeenCalledWith(
|
|
576
|
+
'message',
|
|
577
|
+
'kind',
|
|
578
|
+
'message',
|
|
579
|
+
'stacktrace',
|
|
580
|
+
{ test: '123', '_dd.error.source_type': 'react-native' }
|
|
581
|
+
);
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
describe('info logs', () => {
|
|
586
|
+
it('native context is empty W context is undefined', async () => {
|
|
587
|
+
await DdLogs.info(
|
|
588
|
+
'message',
|
|
589
|
+
'kind',
|
|
590
|
+
'message',
|
|
591
|
+
'stacktrace',
|
|
592
|
+
undefined
|
|
593
|
+
);
|
|
594
|
+
expect(
|
|
595
|
+
NativeModules.DdLogs.infoWithError
|
|
596
|
+
).toHaveBeenCalledWith(
|
|
597
|
+
'message',
|
|
598
|
+
'kind',
|
|
599
|
+
'message',
|
|
600
|
+
'stacktrace',
|
|
601
|
+
{ '_dd.error.source_type': 'react-native' }
|
|
602
|
+
);
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
it('native context is an object with nested property W context is an array', async () => {
|
|
606
|
+
await DdLogs.info('message', 'kind', 'message', 'stacktrace', [
|
|
607
|
+
1,
|
|
608
|
+
2,
|
|
609
|
+
3
|
|
610
|
+
]);
|
|
611
|
+
|
|
612
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
613
|
+
1,
|
|
614
|
+
expect.anything(),
|
|
615
|
+
SdkVerbosity.WARN
|
|
616
|
+
);
|
|
617
|
+
|
|
618
|
+
expect(NativeModules.DdLogs.infoWithError).toHaveBeenCalledWith(
|
|
619
|
+
'message',
|
|
620
|
+
'kind',
|
|
621
|
+
'message',
|
|
622
|
+
'stacktrace',
|
|
623
|
+
{
|
|
624
|
+
context: [1, 2, 3],
|
|
625
|
+
'_dd.error.source_type': 'react-native'
|
|
626
|
+
}
|
|
627
|
+
);
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
it('native context is empty W context is raw type', async () => {
|
|
631
|
+
const obj: any = 123;
|
|
632
|
+
await DdLogs.info(
|
|
633
|
+
'message',
|
|
634
|
+
'kind',
|
|
635
|
+
'message',
|
|
636
|
+
'stacktrace',
|
|
637
|
+
obj
|
|
638
|
+
);
|
|
639
|
+
|
|
640
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
641
|
+
1,
|
|
642
|
+
expect.anything(),
|
|
643
|
+
SdkVerbosity.ERROR
|
|
644
|
+
);
|
|
645
|
+
|
|
646
|
+
expect(
|
|
647
|
+
NativeModules.DdLogs.infoWithError
|
|
648
|
+
).toHaveBeenCalledWith(
|
|
649
|
+
'message',
|
|
650
|
+
'kind',
|
|
651
|
+
'message',
|
|
652
|
+
'stacktrace',
|
|
653
|
+
{ '_dd.error.source_type': 'react-native' }
|
|
654
|
+
);
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
it('native context is unmodified W context is a valid object', async () => {
|
|
658
|
+
await DdLogs.info('message', 'kind', 'message', 'stacktrace', {
|
|
659
|
+
test: '123'
|
|
660
|
+
});
|
|
661
|
+
expect(
|
|
662
|
+
NativeModules.DdLogs.infoWithError
|
|
663
|
+
).toHaveBeenCalledWith(
|
|
664
|
+
'message',
|
|
665
|
+
'kind',
|
|
666
|
+
'message',
|
|
667
|
+
'stacktrace',
|
|
668
|
+
{ test: '123', '_dd.error.source_type': 'react-native' }
|
|
669
|
+
);
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
describe('error logs', () => {
|
|
674
|
+
it('native context is empty W context is undefined', async () => {
|
|
675
|
+
await DdLogs.error(
|
|
676
|
+
'message',
|
|
677
|
+
'kind',
|
|
678
|
+
'message',
|
|
679
|
+
'stacktrace',
|
|
680
|
+
undefined
|
|
681
|
+
);
|
|
682
|
+
expect(
|
|
683
|
+
NativeModules.DdLogs.errorWithError
|
|
684
|
+
).toHaveBeenCalledWith(
|
|
685
|
+
'message',
|
|
686
|
+
'kind',
|
|
687
|
+
'message',
|
|
688
|
+
'stacktrace',
|
|
689
|
+
{ '_dd.error.source_type': 'react-native' }
|
|
690
|
+
);
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
it('native context is an object with nested property W context is an array', async () => {
|
|
694
|
+
await DdLogs.error('message', 'kind', 'message', 'stacktrace', [
|
|
695
|
+
1,
|
|
696
|
+
2,
|
|
697
|
+
3
|
|
698
|
+
]);
|
|
699
|
+
|
|
700
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
701
|
+
1,
|
|
702
|
+
expect.anything(),
|
|
703
|
+
SdkVerbosity.WARN
|
|
704
|
+
);
|
|
705
|
+
|
|
706
|
+
expect(
|
|
707
|
+
NativeModules.DdLogs.errorWithError
|
|
708
|
+
).toHaveBeenCalledWith(
|
|
709
|
+
'message',
|
|
710
|
+
'kind',
|
|
711
|
+
'message',
|
|
712
|
+
'stacktrace',
|
|
713
|
+
{
|
|
714
|
+
context: [1, 2, 3],
|
|
715
|
+
'_dd.error.source_type': 'react-native'
|
|
716
|
+
}
|
|
717
|
+
);
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
it('native context is empty W context is raw type', async () => {
|
|
721
|
+
const obj: any = 123;
|
|
722
|
+
await DdLogs.error(
|
|
723
|
+
'message',
|
|
724
|
+
'kind',
|
|
725
|
+
'message',
|
|
726
|
+
'stacktrace',
|
|
727
|
+
obj
|
|
728
|
+
);
|
|
729
|
+
|
|
730
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
731
|
+
1,
|
|
732
|
+
expect.anything(),
|
|
733
|
+
SdkVerbosity.ERROR
|
|
734
|
+
);
|
|
735
|
+
|
|
736
|
+
expect(
|
|
737
|
+
NativeModules.DdLogs.errorWithError
|
|
738
|
+
).toHaveBeenCalledWith(
|
|
739
|
+
'message',
|
|
740
|
+
'kind',
|
|
741
|
+
'message',
|
|
742
|
+
'stacktrace',
|
|
743
|
+
{ '_dd.error.source_type': 'react-native' }
|
|
744
|
+
);
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
it('native context is unmodified W context is a valid object', async () => {
|
|
748
|
+
await DdLogs.error('message', 'kind', 'message', 'stacktrace', {
|
|
749
|
+
test: '123'
|
|
750
|
+
});
|
|
751
|
+
expect(
|
|
752
|
+
NativeModules.DdLogs.errorWithError
|
|
753
|
+
).toHaveBeenCalledWith(
|
|
754
|
+
'message',
|
|
755
|
+
'kind',
|
|
756
|
+
'message',
|
|
757
|
+
'stacktrace',
|
|
758
|
+
{ test: '123', '_dd.error.source_type': 'react-native' }
|
|
759
|
+
);
|
|
760
|
+
});
|
|
761
|
+
});
|
|
762
|
+
});
|
|
220
763
|
});
|