@datadog/mobile-react-native 2.13.2 → 2.14.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/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/logs/DdLogs.js +17 -13
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/rum/DdAttributes.js +7 -1
- package/lib/commonjs/rum/DdAttributes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +18 -11
- 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/utils/argsUtils.js +6 -0
- package/lib/commonjs/utils/argsUtils.js.map +1 -1
- package/lib/commonjs/utils/errorUtils.js +1 -13
- package/lib/commonjs/utils/errorUtils.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/logs/DdLogs.js +17 -13
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/rum/DdAttributes.js +7 -1
- package/lib/module/rum/DdAttributes.js.map +1 -1
- package/lib/module/rum/DdRum.js +18 -11
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +2 -2
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/utils/argsUtils.js +7 -0
- package/lib/module/utils/argsUtils.js.map +1 -1
- package/lib/module/utils/errorUtils.js +0 -11
- package/lib/module/utils/errorUtils.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/logs/DdLogs.d.ts.map +1 -1
- package/lib/typescript/rum/DdAttributes.d.ts +6 -0
- package/lib/typescript/rum/DdAttributes.d.ts.map +1 -1
- package/lib/typescript/rum/DdRum.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts.map +1 -1
- package/lib/typescript/utils/argsUtils.d.ts +6 -0
- package/lib/typescript/utils/argsUtils.d.ts.map +1 -1
- package/lib/typescript/utils/errorUtils.d.ts +0 -1
- package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/logs/DdLogs.ts +23 -13
- package/src/logs/__tests__/DdLogs.test.ts +64 -8
- package/src/rum/DdAttributes.ts +8 -1
- package/src/rum/DdRum.ts +26 -11
- package/src/rum/__tests__/DdRum.test.ts +16 -2
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +2 -8
- package/src/utils/argsUtils.ts +6 -0
- package/src/utils/errorUtils.ts +0 -13
- package/src/version.ts +1 -1
package/src/rum/DdRum.ts
CHANGED
|
@@ -7,12 +7,12 @@ import type { GestureResponderEvent } from 'react-native';
|
|
|
7
7
|
|
|
8
8
|
import { InternalLog } from '../InternalLog';
|
|
9
9
|
import { SdkVerbosity } from '../SdkVerbosity';
|
|
10
|
+
import { debugId } from '../metro/debugIdResolver';
|
|
10
11
|
import type { DdNativeRumType } from '../nativeModulesTypes';
|
|
11
12
|
import { bufferVoidNativeCall } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';
|
|
12
13
|
import { DdSdk } from '../sdk/DdSdk';
|
|
13
14
|
import { GlobalState } from '../sdk/GlobalState/GlobalState';
|
|
14
15
|
import { validateContext } from '../utils/argsUtils';
|
|
15
|
-
import { getErrorContext } from '../utils/errorUtils';
|
|
16
16
|
import { DefaultTimeProvider } from '../utils/time-provider/DefaultTimeProvider';
|
|
17
17
|
import type { TimeProvider } from '../utils/time-provider/TimeProvider';
|
|
18
18
|
|
|
@@ -141,13 +141,16 @@ class DdRumWrapper implements DdRumType {
|
|
|
141
141
|
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
142
142
|
type,
|
|
143
143
|
name,
|
|
144
|
-
context
|
|
144
|
+
context,
|
|
145
145
|
timestampMs,
|
|
146
146
|
actionContext
|
|
147
147
|
});
|
|
148
148
|
if (!mappedEvent) {
|
|
149
149
|
return generateEmptyPromise();
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
const validatedContext = validateContext(mappedEvent.context);
|
|
153
|
+
|
|
151
154
|
InternalLog.log(
|
|
152
155
|
`Adding RUM Action “${name}” (${type})`,
|
|
153
156
|
SdkVerbosity.DEBUG
|
|
@@ -156,7 +159,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
156
159
|
this.nativeRum.addAction(
|
|
157
160
|
mappedEvent.type,
|
|
158
161
|
mappedEvent.name,
|
|
159
|
-
|
|
162
|
+
validatedContext,
|
|
160
163
|
mappedEvent.timestampMs
|
|
161
164
|
)
|
|
162
165
|
);
|
|
@@ -199,7 +202,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
199
202
|
statusCode,
|
|
200
203
|
kind,
|
|
201
204
|
size,
|
|
202
|
-
context
|
|
205
|
+
context,
|
|
203
206
|
timestampMs,
|
|
204
207
|
resourceContext
|
|
205
208
|
});
|
|
@@ -223,6 +226,8 @@ class DdRumWrapper implements DdRumType {
|
|
|
223
226
|
);
|
|
224
227
|
}
|
|
225
228
|
|
|
229
|
+
const validatedContext = validateContext(mappedEvent.context);
|
|
230
|
+
|
|
226
231
|
InternalLog.log(
|
|
227
232
|
`Stopping RUM Resource #${key} status:${statusCode}`,
|
|
228
233
|
SdkVerbosity.DEBUG
|
|
@@ -233,7 +238,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
233
238
|
mappedEvent.statusCode,
|
|
234
239
|
mappedEvent.kind,
|
|
235
240
|
mappedEvent.size,
|
|
236
|
-
|
|
241
|
+
validatedContext,
|
|
237
242
|
mappedEvent.timestampMs
|
|
238
243
|
)
|
|
239
244
|
);
|
|
@@ -251,7 +256,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
251
256
|
message,
|
|
252
257
|
source,
|
|
253
258
|
stacktrace,
|
|
254
|
-
context
|
|
259
|
+
context,
|
|
255
260
|
timestampMs,
|
|
256
261
|
fingerprint: fingerprint ?? ''
|
|
257
262
|
});
|
|
@@ -260,8 +265,16 @@ class DdRumWrapper implements DdRumType {
|
|
|
260
265
|
return generateEmptyPromise();
|
|
261
266
|
}
|
|
262
267
|
InternalLog.log(`Adding RUM Error “${message}”`, SdkVerbosity.DEBUG);
|
|
263
|
-
|
|
268
|
+
|
|
269
|
+
const updatedContext: any = validateContext(mappedEvent.context);
|
|
270
|
+
|
|
264
271
|
updatedContext[DdAttributes.errorSourceType] = 'react-native';
|
|
272
|
+
|
|
273
|
+
const _debugId = debugId;
|
|
274
|
+
if (_debugId) {
|
|
275
|
+
updatedContext[DdAttributes.debugId] = _debugId;
|
|
276
|
+
}
|
|
277
|
+
|
|
265
278
|
return bufferVoidNativeCall(() =>
|
|
266
279
|
this.nativeRum.addError(
|
|
267
280
|
mappedEvent.message,
|
|
@@ -393,7 +406,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
393
406
|
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
394
407
|
type,
|
|
395
408
|
name,
|
|
396
|
-
context
|
|
409
|
+
context,
|
|
397
410
|
timestampMs
|
|
398
411
|
});
|
|
399
412
|
if (!mappedEvent) {
|
|
@@ -409,11 +422,13 @@ class DdRumWrapper implements DdRumType {
|
|
|
409
422
|
);
|
|
410
423
|
}
|
|
411
424
|
|
|
425
|
+
const validatedContext = validateContext(mappedEvent.context);
|
|
426
|
+
|
|
412
427
|
return bufferVoidNativeCall(() =>
|
|
413
428
|
this.nativeRum.stopAction(
|
|
414
429
|
mappedEvent.type,
|
|
415
430
|
mappedEvent.name,
|
|
416
|
-
|
|
431
|
+
validatedContext,
|
|
417
432
|
mappedEvent.timestampMs
|
|
418
433
|
)
|
|
419
434
|
);
|
|
@@ -440,7 +455,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
440
455
|
return [
|
|
441
456
|
args[0],
|
|
442
457
|
args[1],
|
|
443
|
-
|
|
458
|
+
args[2] || {},
|
|
444
459
|
args[3] || this.timeProvider.now()
|
|
445
460
|
];
|
|
446
461
|
}
|
|
@@ -453,7 +468,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
453
468
|
return [
|
|
454
469
|
type,
|
|
455
470
|
name,
|
|
456
|
-
|
|
471
|
+
args[0] || {},
|
|
457
472
|
args[1] || this.timeProvider.now()
|
|
458
473
|
];
|
|
459
474
|
}
|
|
@@ -1181,7 +1181,13 @@ describe('DdRum', () => {
|
|
|
1181
1181
|
|
|
1182
1182
|
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
1183
1183
|
1,
|
|
1184
|
-
expect.
|
|
1184
|
+
expect.stringContaining('Adding RUM Error'),
|
|
1185
|
+
SdkVerbosity.DEBUG
|
|
1186
|
+
);
|
|
1187
|
+
|
|
1188
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
1189
|
+
2,
|
|
1190
|
+
expect.stringContaining('Context will be empty'),
|
|
1185
1191
|
SdkVerbosity.ERROR
|
|
1186
1192
|
);
|
|
1187
1193
|
|
|
@@ -1208,7 +1214,15 @@ describe('DdRum', () => {
|
|
|
1208
1214
|
|
|
1209
1215
|
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
1210
1216
|
1,
|
|
1211
|
-
expect.
|
|
1217
|
+
expect.stringContaining('Adding RUM Error'),
|
|
1218
|
+
SdkVerbosity.DEBUG
|
|
1219
|
+
);
|
|
1220
|
+
|
|
1221
|
+
expect(InternalLog.log).toHaveBeenNthCalledWith(
|
|
1222
|
+
2,
|
|
1223
|
+
expect.stringContaining(
|
|
1224
|
+
'The given context is an array, it will be nested'
|
|
1225
|
+
),
|
|
1212
1226
|
SdkVerbosity.WARN
|
|
1213
1227
|
);
|
|
1214
1228
|
|
|
@@ -14,8 +14,7 @@ import {
|
|
|
14
14
|
getErrorStackTrace,
|
|
15
15
|
EMPTY_STACK_TRACE,
|
|
16
16
|
getErrorName,
|
|
17
|
-
DEFAULT_ERROR_NAME
|
|
18
|
-
getErrorContext
|
|
17
|
+
DEFAULT_ERROR_NAME
|
|
19
18
|
} from '../../utils/errorUtils';
|
|
20
19
|
import { executeWithDelay } from '../../utils/jsUtils';
|
|
21
20
|
import { DdRum } from '../DdRum';
|
|
@@ -146,12 +145,7 @@ export class DdRumErrorTracking {
|
|
|
146
145
|
context: object = {}
|
|
147
146
|
): Promise<[void, void]> => {
|
|
148
147
|
return Promise.all([
|
|
149
|
-
DdRum.addError(
|
|
150
|
-
message,
|
|
151
|
-
source,
|
|
152
|
-
stacktrace,
|
|
153
|
-
getErrorContext(context)
|
|
154
|
-
),
|
|
148
|
+
DdRum.addError(message, source, stacktrace, context),
|
|
155
149
|
DdLogs.error(
|
|
156
150
|
message,
|
|
157
151
|
errorName,
|
package/src/utils/argsUtils.ts
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
import { InternalLog } from '../InternalLog';
|
|
9
9
|
import { SdkVerbosity } from '../SdkVerbosity';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Validates the given context before passing it to the native SDKs.
|
|
13
|
+
* @param context the original context
|
|
14
|
+
* @returns the original context if it's a plain object, an object wrapping the context if it's an array,
|
|
15
|
+
* or an empty object if the context is of any other type.
|
|
16
|
+
*/
|
|
11
17
|
export const validateContext = (context: any) => {
|
|
12
18
|
if (!context) {
|
|
13
19
|
return {};
|
package/src/utils/errorUtils.ts
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { debugId } from '../metro/debugIdResolver';
|
|
8
|
-
|
|
9
7
|
export const EMPTY_MESSAGE = 'Unknown Error';
|
|
10
8
|
export const EMPTY_STACK_TRACE = '';
|
|
11
9
|
export const DEFAULT_ERROR_NAME = 'Error';
|
|
@@ -73,14 +71,3 @@ export const getErrorName = (error: unknown): string => {
|
|
|
73
71
|
}
|
|
74
72
|
return DEFAULT_ERROR_NAME;
|
|
75
73
|
};
|
|
76
|
-
|
|
77
|
-
export const getErrorContext = (originalContext: any): Record<string, any> => {
|
|
78
|
-
const _debugId = debugId;
|
|
79
|
-
if (!_debugId) {
|
|
80
|
-
return originalContext;
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
...originalContext,
|
|
84
|
-
'_dd.debug_id': _debugId
|
|
85
|
-
};
|
|
86
|
-
};
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '2.
|
|
2
|
+
export const version = '2.14.0';
|