@datadog/mobile-react-native 2.3.5 → 2.3.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/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/datadog-sourcemaps.gradle +64 -1
- package/ios/Sources/SdkVersion.swift +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/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/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/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/rum/DdRum.d.ts +2 -2
- package/lib/typescript/utils/argsUtils.d.ts +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- 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/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
package/src/rum/DdRum.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { SdkVerbosity } from '../SdkVerbosity';
|
|
|
12
12
|
import type { DdNativeRumType } from '../nativeModulesTypes';
|
|
13
13
|
import { bufferVoidNativeCall } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';
|
|
14
14
|
import { DdSdk } from '../sdk/DdSdk';
|
|
15
|
+
import { validateContext } from '../utils/argsUtils';
|
|
15
16
|
import { DefaultTimeProvider } from '../utils/time-provider/DefaultTimeProvider';
|
|
16
17
|
import type { TimeProvider } from '../utils/time-provider/TimeProvider';
|
|
17
18
|
|
|
@@ -51,7 +52,12 @@ class DdRumWrapper implements DdRumType {
|
|
|
51
52
|
SdkVerbosity.DEBUG
|
|
52
53
|
);
|
|
53
54
|
return bufferVoidNativeCall(() =>
|
|
54
|
-
this.nativeRum.startView(
|
|
55
|
+
this.nativeRum.startView(
|
|
56
|
+
key,
|
|
57
|
+
name,
|
|
58
|
+
validateContext(context),
|
|
59
|
+
timestampMs
|
|
60
|
+
)
|
|
55
61
|
);
|
|
56
62
|
};
|
|
57
63
|
|
|
@@ -62,7 +68,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
62
68
|
): Promise<void> => {
|
|
63
69
|
InternalLog.log(`Stopping RUM View #${key}`, SdkVerbosity.DEBUG);
|
|
64
70
|
return bufferVoidNativeCall(() =>
|
|
65
|
-
this.nativeRum.stopView(key, context, timestampMs)
|
|
71
|
+
this.nativeRum.stopView(key, validateContext(context), timestampMs)
|
|
66
72
|
);
|
|
67
73
|
};
|
|
68
74
|
|
|
@@ -78,7 +84,12 @@ class DdRumWrapper implements DdRumType {
|
|
|
78
84
|
);
|
|
79
85
|
this.lastActionData = { type, name };
|
|
80
86
|
return bufferVoidNativeCall(() =>
|
|
81
|
-
this.nativeRum.startAction(
|
|
87
|
+
this.nativeRum.startAction(
|
|
88
|
+
type,
|
|
89
|
+
name,
|
|
90
|
+
validateContext(context),
|
|
91
|
+
timestampMs
|
|
92
|
+
)
|
|
82
93
|
);
|
|
83
94
|
};
|
|
84
95
|
|
|
@@ -105,93 +116,6 @@ class DdRumWrapper implements DdRumType {
|
|
|
105
116
|
this.timeProvider = timeProvider;
|
|
106
117
|
};
|
|
107
118
|
|
|
108
|
-
private callNativeStopAction = (
|
|
109
|
-
type: RumActionType,
|
|
110
|
-
name: string,
|
|
111
|
-
context: object,
|
|
112
|
-
timestampMs: number
|
|
113
|
-
): Promise<void> => {
|
|
114
|
-
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
115
|
-
type,
|
|
116
|
-
name,
|
|
117
|
-
context,
|
|
118
|
-
timestampMs
|
|
119
|
-
});
|
|
120
|
-
if (!mappedEvent) {
|
|
121
|
-
return bufferVoidNativeCall(() =>
|
|
122
|
-
this.nativeRum.stopAction(
|
|
123
|
-
type,
|
|
124
|
-
name,
|
|
125
|
-
{
|
|
126
|
-
'_dd.action.drop_action': true
|
|
127
|
-
},
|
|
128
|
-
timestampMs
|
|
129
|
-
)
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return bufferVoidNativeCall(() =>
|
|
134
|
-
this.nativeRum.stopAction(
|
|
135
|
-
mappedEvent.type,
|
|
136
|
-
mappedEvent.name,
|
|
137
|
-
mappedEvent.context,
|
|
138
|
-
mappedEvent.timestampMs
|
|
139
|
-
)
|
|
140
|
-
);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
private getStopActionNativeCallArgs = (
|
|
144
|
-
args:
|
|
145
|
-
| [
|
|
146
|
-
type: RumActionType,
|
|
147
|
-
name: string,
|
|
148
|
-
context?: object,
|
|
149
|
-
timestampMs?: number
|
|
150
|
-
]
|
|
151
|
-
| [context?: object, timestampMs?: number]
|
|
152
|
-
):
|
|
153
|
-
| [
|
|
154
|
-
type: RumActionType,
|
|
155
|
-
name: string,
|
|
156
|
-
context: object,
|
|
157
|
-
timestampMs: number
|
|
158
|
-
]
|
|
159
|
-
| null => {
|
|
160
|
-
if (isNewStopActionAPI(args)) {
|
|
161
|
-
return [
|
|
162
|
-
args[0],
|
|
163
|
-
args[1],
|
|
164
|
-
args[2] || {},
|
|
165
|
-
args[3] || this.timeProvider.now()
|
|
166
|
-
];
|
|
167
|
-
}
|
|
168
|
-
if (isOldStopActionAPI(args)) {
|
|
169
|
-
if (this.lastActionData) {
|
|
170
|
-
DdSdk.telemetryDebug(
|
|
171
|
-
'DDdRum.stopAction called with the old signature'
|
|
172
|
-
);
|
|
173
|
-
const { type, name } = this.lastActionData;
|
|
174
|
-
return [
|
|
175
|
-
type,
|
|
176
|
-
name,
|
|
177
|
-
args[0] || {},
|
|
178
|
-
args[1] || this.timeProvider.now()
|
|
179
|
-
];
|
|
180
|
-
}
|
|
181
|
-
InternalLog.log(
|
|
182
|
-
'DdRum.startAction needs to be called before DdRum.stopAction',
|
|
183
|
-
SdkVerbosity.WARN
|
|
184
|
-
);
|
|
185
|
-
} else {
|
|
186
|
-
InternalLog.log(
|
|
187
|
-
'DdRum.stopAction was called with wrong arguments',
|
|
188
|
-
SdkVerbosity.WARN
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return null;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
119
|
addAction = (
|
|
196
120
|
type: RumActionType,
|
|
197
121
|
name: string,
|
|
@@ -202,7 +126,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
202
126
|
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
203
127
|
type,
|
|
204
128
|
name,
|
|
205
|
-
context,
|
|
129
|
+
context: validateContext(context),
|
|
206
130
|
timestampMs,
|
|
207
131
|
actionContext
|
|
208
132
|
});
|
|
@@ -234,8 +158,15 @@ class DdRumWrapper implements DdRumType {
|
|
|
234
158
|
`Starting RUM Resource #${key} ${method}: ${url}`,
|
|
235
159
|
SdkVerbosity.DEBUG
|
|
236
160
|
);
|
|
161
|
+
|
|
237
162
|
return bufferVoidNativeCall(() =>
|
|
238
|
-
this.nativeRum.startResource(
|
|
163
|
+
this.nativeRum.startResource(
|
|
164
|
+
key,
|
|
165
|
+
method,
|
|
166
|
+
url,
|
|
167
|
+
validateContext(context),
|
|
168
|
+
timestampMs
|
|
169
|
+
)
|
|
239
170
|
);
|
|
240
171
|
};
|
|
241
172
|
|
|
@@ -253,7 +184,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
253
184
|
statusCode,
|
|
254
185
|
kind,
|
|
255
186
|
size,
|
|
256
|
-
context,
|
|
187
|
+
context: validateContext(context),
|
|
257
188
|
timestampMs,
|
|
258
189
|
resourceContext
|
|
259
190
|
});
|
|
@@ -304,7 +235,7 @@ class DdRumWrapper implements DdRumType {
|
|
|
304
235
|
message,
|
|
305
236
|
source,
|
|
306
237
|
stacktrace,
|
|
307
|
-
context,
|
|
238
|
+
context: validateContext(context),
|
|
308
239
|
timestampMs
|
|
309
240
|
});
|
|
310
241
|
if (!mappedEvent) {
|
|
@@ -384,6 +315,93 @@ class DdRumWrapper implements DdRumType {
|
|
|
384
315
|
unregisterActionEventMapper() {
|
|
385
316
|
this.actionEventMapper = generateActionEventMapper(undefined);
|
|
386
317
|
}
|
|
318
|
+
|
|
319
|
+
private callNativeStopAction = (
|
|
320
|
+
type: RumActionType,
|
|
321
|
+
name: string,
|
|
322
|
+
context: object,
|
|
323
|
+
timestampMs: number
|
|
324
|
+
): Promise<void> => {
|
|
325
|
+
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
326
|
+
type,
|
|
327
|
+
name,
|
|
328
|
+
context: validateContext(context),
|
|
329
|
+
timestampMs
|
|
330
|
+
});
|
|
331
|
+
if (!mappedEvent) {
|
|
332
|
+
return bufferVoidNativeCall(() =>
|
|
333
|
+
this.nativeRum.stopAction(
|
|
334
|
+
type,
|
|
335
|
+
name,
|
|
336
|
+
{
|
|
337
|
+
'_dd.action.drop_action': true
|
|
338
|
+
},
|
|
339
|
+
timestampMs
|
|
340
|
+
)
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return bufferVoidNativeCall(() =>
|
|
345
|
+
this.nativeRum.stopAction(
|
|
346
|
+
mappedEvent.type,
|
|
347
|
+
mappedEvent.name,
|
|
348
|
+
mappedEvent.context,
|
|
349
|
+
mappedEvent.timestampMs
|
|
350
|
+
)
|
|
351
|
+
);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
private getStopActionNativeCallArgs = (
|
|
355
|
+
args:
|
|
356
|
+
| [
|
|
357
|
+
type: RumActionType,
|
|
358
|
+
name: string,
|
|
359
|
+
context?: object,
|
|
360
|
+
timestampMs?: number
|
|
361
|
+
]
|
|
362
|
+
| [context?: object, timestampMs?: number]
|
|
363
|
+
):
|
|
364
|
+
| [
|
|
365
|
+
type: RumActionType,
|
|
366
|
+
name: string,
|
|
367
|
+
context: object,
|
|
368
|
+
timestampMs: number
|
|
369
|
+
]
|
|
370
|
+
| null => {
|
|
371
|
+
if (isNewStopActionAPI(args)) {
|
|
372
|
+
return [
|
|
373
|
+
args[0],
|
|
374
|
+
args[1],
|
|
375
|
+
validateContext(args[2]),
|
|
376
|
+
args[3] || this.timeProvider.now()
|
|
377
|
+
];
|
|
378
|
+
}
|
|
379
|
+
if (isOldStopActionAPI(args)) {
|
|
380
|
+
if (this.lastActionData) {
|
|
381
|
+
DdSdk.telemetryDebug(
|
|
382
|
+
'DDdRum.stopAction called with the old signature'
|
|
383
|
+
);
|
|
384
|
+
const { type, name } = this.lastActionData;
|
|
385
|
+
return [
|
|
386
|
+
type,
|
|
387
|
+
name,
|
|
388
|
+
validateContext(args[0]),
|
|
389
|
+
args[1] || this.timeProvider.now()
|
|
390
|
+
];
|
|
391
|
+
}
|
|
392
|
+
InternalLog.log(
|
|
393
|
+
'DdRum.startAction needs to be called before DdRum.stopAction',
|
|
394
|
+
SdkVerbosity.WARN
|
|
395
|
+
);
|
|
396
|
+
} else {
|
|
397
|
+
InternalLog.log(
|
|
398
|
+
'DdRum.stopAction was called with wrong arguments',
|
|
399
|
+
SdkVerbosity.WARN
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return null;
|
|
404
|
+
};
|
|
387
405
|
}
|
|
388
406
|
|
|
389
407
|
const isNewStopActionAPI = (
|