@datadog/mobile-react-native 3.5.0 → 3.5.2
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/DdFlagsImplementation.kt +4 -1
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdFlagsImplementationTest.kt +77 -0
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +10 -1
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/metro/plugin/metroSerializer.js +2 -2
- package/lib/commonjs/metro/plugin/metroSerializer.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +22 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +11 -4
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -1
- package/lib/commonjs/sdk/AttributesEncoding/helpers.js +5 -12
- package/lib/commonjs/sdk/AttributesEncoding/helpers.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +10 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/metro/plugin/metroSerializer.js +2 -2
- package/lib/module/metro/plugin/metroSerializer.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +22 -0
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +11 -4
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/module/sdk/AttributesEncoding/helpers.js +5 -12
- package/lib/module/sdk/AttributesEncoding/helpers.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts +1 -0
- package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts.map +1 -1
- package/lib/typescript/metro/plugin/metroSerializer.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +10 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +4 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts +3 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +17 -6
- package/src/config/async/PartialInitializationConfiguration.ts +1 -0
- package/src/metro/__tests__/metro.test.ts +19 -0
- package/src/metro/plugin/metroSerializer.ts +3 -2
- package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +26 -0
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +87 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +12 -4
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +61 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.ts +3 -0
- package/src/sdk/AttributesEncoding/__tests__/attributesEncoding.test.ts +13 -14
- package/src/sdk/AttributesEncoding/helpers.ts +9 -18
- package/src/version.ts +1 -1
package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts
CHANGED
|
@@ -455,6 +455,67 @@ describe('XHRProxy', () => {
|
|
|
455
455
|
);
|
|
456
456
|
});
|
|
457
457
|
|
|
458
|
+
it('applies a tracingSamplingRate updated via onTrackingUpdate to subsequent XHRs (regression: RUMS-5973)', async () => {
|
|
459
|
+
// GIVEN
|
|
460
|
+
const method = 'GET';
|
|
461
|
+
const url = 'https://api.example.com/v2/user';
|
|
462
|
+
const firstPartyHostsRegexMap = firstPartyHostsRegexMapBuilder([
|
|
463
|
+
{
|
|
464
|
+
match: 'api.example.com',
|
|
465
|
+
propagatorTypes: [PropagatorType.DATADOG]
|
|
466
|
+
}
|
|
467
|
+
]);
|
|
468
|
+
xhrProxy.onTrackingStart({
|
|
469
|
+
tracingSamplingRate: 0,
|
|
470
|
+
firstPartyHostsRegexMap
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
// WHEN: an XHR is opened with the initial rate of 0
|
|
474
|
+
const xhrBeforeUpdate = new XMLHttpRequestMock();
|
|
475
|
+
xhrBeforeUpdate.open(method, url);
|
|
476
|
+
xhrBeforeUpdate.send();
|
|
477
|
+
xhrBeforeUpdate.notifyResponseArrived();
|
|
478
|
+
xhrBeforeUpdate.complete(200, 'ok');
|
|
479
|
+
await flushPromises();
|
|
480
|
+
|
|
481
|
+
// AND: the tracking context is updated to 100
|
|
482
|
+
xhrProxy.onTrackingUpdate({
|
|
483
|
+
tracingSamplingRate: 100
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
// AND: a second XHR is opened
|
|
487
|
+
const xhrAfterUpdate = new XMLHttpRequestMock();
|
|
488
|
+
xhrAfterUpdate.open(method, url);
|
|
489
|
+
xhrAfterUpdate.send();
|
|
490
|
+
xhrAfterUpdate.notifyResponseArrived();
|
|
491
|
+
xhrAfterUpdate.complete(200, 'ok');
|
|
492
|
+
await flushPromises();
|
|
493
|
+
|
|
494
|
+
// THEN: the pre-update request keeps priority 0, the post-update one is sampled at 100%
|
|
495
|
+
expect(
|
|
496
|
+
xhrBeforeUpdate.requestHeaders.get(SAMPLING_PRIORITY_HEADER_KEY)
|
|
497
|
+
).toBe('0');
|
|
498
|
+
expect(
|
|
499
|
+
xhrAfterUpdate.requestHeaders.get(SAMPLING_PRIORITY_HEADER_KEY)
|
|
500
|
+
).toBe('1');
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
it('ignores onTrackingUpdate when tracking has not started', () => {
|
|
504
|
+
// GIVEN: tracking was never started, so XMLHttpRequest is not proxied
|
|
505
|
+
|
|
506
|
+
// WHEN
|
|
507
|
+
xhrProxy.onTrackingUpdate({
|
|
508
|
+
tracingSamplingRate: 100
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
// THEN: no throw, and a subsequent open is not instrumented
|
|
512
|
+
const xhr = new XMLHttpRequestMock();
|
|
513
|
+
xhr.open('GET', 'https://api.example.com/v2/user');
|
|
514
|
+
expect(
|
|
515
|
+
xhr.requestHeaders.get(SAMPLING_PRIORITY_HEADER_KEY)
|
|
516
|
+
).toBeUndefined();
|
|
517
|
+
});
|
|
518
|
+
|
|
458
519
|
it('adds the x-datadog-tracked-by header for first party host requests', async () => {
|
|
459
520
|
// GIVEN
|
|
460
521
|
const method = 'GET';
|
|
@@ -19,4 +19,7 @@ export type RegexMap = {
|
|
|
19
19
|
export abstract class RequestProxy {
|
|
20
20
|
abstract onTrackingStart: (context: RequestProxyOptions) => void;
|
|
21
21
|
abstract onTrackingStop: () => void;
|
|
22
|
+
abstract onTrackingUpdate: (context: {
|
|
23
|
+
tracingSamplingRate: number;
|
|
24
|
+
}) => void;
|
|
22
25
|
}
|
|
@@ -216,7 +216,7 @@ describe('encodeAttributes', () => {
|
|
|
216
216
|
);
|
|
217
217
|
});
|
|
218
218
|
|
|
219
|
-
it('does not modify original object when
|
|
219
|
+
it('does not modify original object when encoding many attributes', () => {
|
|
220
220
|
const input: Record<string, string> = {};
|
|
221
221
|
for (let i = 0; i < 200; i++) {
|
|
222
222
|
input[`k${i}`] = `v${i}`;
|
|
@@ -224,7 +224,7 @@ describe('encodeAttributes', () => {
|
|
|
224
224
|
const snapshot = { ...input };
|
|
225
225
|
|
|
226
226
|
const result = encodeAttributes(input);
|
|
227
|
-
expect(Object.keys(result)).toHaveLength(
|
|
227
|
+
expect(Object.keys(result)).toHaveLength(200);
|
|
228
228
|
expect(input).toEqual(snapshot); // original still has 200 keys
|
|
229
229
|
});
|
|
230
230
|
|
|
@@ -380,31 +380,30 @@ describe('encodeAttributes', () => {
|
|
|
380
380
|
);
|
|
381
381
|
});
|
|
382
382
|
|
|
383
|
-
it('
|
|
384
|
-
// Prepare
|
|
383
|
+
it('warns once when the 256 attribute limit is exceeded, but does not drop attributes', () => {
|
|
384
|
+
// Prepare 300 simple attributes — exceeds max=256
|
|
385
385
|
const input: Record<string, number> = {};
|
|
386
|
-
for (let i = 0; i <
|
|
386
|
+
for (let i = 0; i < 300; i++) {
|
|
387
387
|
input[`key${i}`] = i;
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
const result = encodeAttributes(input);
|
|
391
391
|
|
|
392
|
-
//
|
|
393
|
-
expect(Object.keys(result)).toHaveLength(
|
|
392
|
+
// All 300 attributes are preserved — no hard cap
|
|
393
|
+
expect(Object.keys(result)).toHaveLength(300);
|
|
394
394
|
|
|
395
|
-
//
|
|
395
|
+
// All attributes are present
|
|
396
396
|
expect(result).toHaveProperty('key0', 0);
|
|
397
|
-
expect(result).toHaveProperty('
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
expect(result).not.toHaveProperty('key128');
|
|
397
|
+
expect(result).toHaveProperty('key255', 255);
|
|
398
|
+
expect(result).toHaveProperty('key256', 256);
|
|
399
|
+
expect(result).toHaveProperty('key299', 299);
|
|
401
400
|
|
|
402
|
-
//
|
|
401
|
+
// A single warning is emitted when the limit is exceeded
|
|
403
402
|
expect(warn).toHaveBeenCalledWith(
|
|
404
403
|
expect.stringContaining('Attribute limit')
|
|
405
404
|
);
|
|
406
405
|
|
|
407
|
-
//
|
|
406
|
+
// Exactly one "limit exceeded" warning (not one per extra attribute)
|
|
408
407
|
const limitWarnings = (warn as jest.Mock).mock.calls.filter(([msg]) =>
|
|
409
408
|
msg.includes('Attribute limit')
|
|
410
409
|
);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { AttributeEncoder, Encodable } from './types';
|
|
8
8
|
import { formatPathForLog, isPlainObject, warn } from './utils';
|
|
9
9
|
|
|
10
|
-
const MAX_ATTRIBUTES =
|
|
10
|
+
const MAX_ATTRIBUTES = 256;
|
|
11
11
|
|
|
12
12
|
export interface EncodeContext {
|
|
13
13
|
numOfAttributes: number;
|
|
@@ -152,25 +152,16 @@ function addEncodedAttribute(
|
|
|
152
152
|
value: Encodable,
|
|
153
153
|
context: EncodeContext
|
|
154
154
|
): void {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (!context.limitReachedWarned) {
|
|
158
|
-
warn(
|
|
159
|
-
`Attribute limit of ${MAX_ATTRIBUTES} reached; further attributes will be dropped.`
|
|
160
|
-
);
|
|
161
|
-
context.limitReachedWarned = true;
|
|
162
|
-
}
|
|
155
|
+
out[path.join('.')] = value;
|
|
156
|
+
context.numOfAttributes++;
|
|
163
157
|
|
|
164
|
-
|
|
158
|
+
if (
|
|
159
|
+
context.numOfAttributes > MAX_ATTRIBUTES &&
|
|
160
|
+
!context.limitReachedWarned
|
|
161
|
+
) {
|
|
165
162
|
warn(
|
|
166
|
-
`
|
|
167
|
-
path
|
|
168
|
-
)}' because limit of ${MAX_ATTRIBUTES} attributes was reached. All further attributes will be dropped.`
|
|
163
|
+
`Attribute limit of ${MAX_ATTRIBUTES} exceeded; the backend may drop some attributes.`
|
|
169
164
|
);
|
|
170
|
-
|
|
171
|
-
return;
|
|
165
|
+
context.limitReachedWarned = true;
|
|
172
166
|
}
|
|
173
|
-
|
|
174
|
-
out[path.join('.')] = value;
|
|
175
|
-
context.numOfAttributes++;
|
|
176
167
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '3.5.
|
|
2
|
+
export const version = '3.5.2';
|