@datadog/mobile-react-native 3.8.0 → 3.10.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.
Files changed (143) hide show
  1. package/android/src/main/kotlin/com/datadog/reactnative/DdFlagsImplementation.kt +6 -3
  2. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +16 -8
  3. package/android/src/main/kotlin/com/datadog/reactnative/FrameRateProvider.kt +11 -6
  4. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  5. package/android/src/test/kotlin/com/datadog/reactnative/DdFlagsImplementationTest.kt +19 -0
  6. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +131 -0
  7. package/datadog-configuration.schema.json +11 -0
  8. package/ios/Sources/DdRumImplementation.swift +2 -2
  9. package/ios/Sources/DdSdkConfiguration.swift +13 -0
  10. package/ios/Sources/DdSdkImplementation.swift +4 -3
  11. package/ios/Sources/DdSdkNativeInitialization.swift +26 -8
  12. package/ios/Sources/JSRefreshRateListener.swift +6 -2
  13. package/ios/Sources/RNDdSdkConfiguration.swift +9 -0
  14. package/ios/Sources/SdkVersion.swift +1 -1
  15. package/lib/commonjs/DdSdkReactNative.js +16 -16
  16. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  17. package/lib/commonjs/config/FileBasedConfiguration.js +3 -1
  18. package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
  19. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +3 -0
  20. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  21. package/lib/commonjs/config/features/RumConfiguration.js +8 -0
  22. package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
  23. package/lib/commonjs/flags/FlagsClient.js +81 -8
  24. package/lib/commonjs/flags/FlagsClient.js.map +1 -1
  25. package/lib/commonjs/flags/configuration/precomputed.js +2 -3
  26. package/lib/commonjs/flags/configuration/precomputed.js.map +1 -1
  27. package/lib/commonjs/flags/internal.js.map +1 -1
  28. package/lib/commonjs/rum/DdRum.js +2 -2
  29. package/lib/commonjs/rum/DdRum.js.map +1 -1
  30. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +3 -3
  31. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  32. package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js +1 -1
  33. package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
  34. package/lib/commonjs/sdk/AttributesEncoding/helpers.js +3 -3
  35. package/lib/commonjs/sdk/AttributesEncoding/helpers.js.map +1 -1
  36. package/lib/commonjs/sdk/AttributesEncoding/utils.js +8 -0
  37. package/lib/commonjs/sdk/AttributesEncoding/utils.js.map +1 -1
  38. package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
  39. package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
  40. package/lib/commonjs/sdk/DdSdkInternal.js +22 -22
  41. package/lib/commonjs/sdk/DdSdkInternal.js.map +1 -1
  42. package/lib/commonjs/sdk/EventMappers/EventMapper.js +2 -2
  43. package/lib/commonjs/sdk/EventMappers/EventMapper.js.map +1 -1
  44. package/lib/commonjs/utils/time-provider/TimeProvider.js +4 -1
  45. package/lib/commonjs/utils/time-provider/TimeProvider.js.map +1 -1
  46. package/lib/commonjs/version.js +1 -1
  47. package/lib/commonjs/version.js.map +1 -1
  48. package/lib/module/DdSdkReactNative.js +16 -16
  49. package/lib/module/DdSdkReactNative.js.map +1 -1
  50. package/lib/module/config/FileBasedConfiguration.js +3 -1
  51. package/lib/module/config/FileBasedConfiguration.js.map +1 -1
  52. package/lib/module/config/async/AutoInstrumentationConfiguration.js +3 -0
  53. package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  54. package/lib/module/config/features/RumConfiguration.js +8 -0
  55. package/lib/module/config/features/RumConfiguration.js.map +1 -1
  56. package/lib/module/flags/FlagsClient.js +81 -8
  57. package/lib/module/flags/FlagsClient.js.map +1 -1
  58. package/lib/module/flags/configuration/precomputed.js +2 -3
  59. package/lib/module/flags/configuration/precomputed.js.map +1 -1
  60. package/lib/module/flags/internal.js.map +1 -1
  61. package/lib/module/rum/DdRum.js +2 -2
  62. package/lib/module/rum/DdRum.js.map +1 -1
  63. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +3 -3
  64. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  65. package/lib/module/sdk/AttributesEncoding/defaultEncoders.js +2 -2
  66. package/lib/module/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
  67. package/lib/module/sdk/AttributesEncoding/helpers.js +4 -4
  68. package/lib/module/sdk/AttributesEncoding/helpers.js.map +1 -1
  69. package/lib/module/sdk/AttributesEncoding/utils.js +7 -0
  70. package/lib/module/sdk/AttributesEncoding/utils.js.map +1 -1
  71. package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
  72. package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
  73. package/lib/module/sdk/DdSdkInternal.js +21 -22
  74. package/lib/module/sdk/DdSdkInternal.js.map +1 -1
  75. package/lib/module/sdk/EventMappers/EventMapper.js +2 -2
  76. package/lib/module/sdk/EventMappers/EventMapper.js.map +1 -1
  77. package/lib/module/utils/time-provider/TimeProvider.js +4 -1
  78. package/lib/module/utils/time-provider/TimeProvider.js.map +1 -1
  79. package/lib/module/version.js +1 -1
  80. package/lib/module/version.js.map +1 -1
  81. package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -1
  82. package/lib/typescript/config/FileBasedConfiguration.type.d.ts +2 -0
  83. package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
  84. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +4 -0
  85. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
  86. package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts +2 -0
  87. package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts.map +1 -1
  88. package/lib/typescript/config/features/RumConfiguration.d.ts +4 -0
  89. package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
  90. package/lib/typescript/config/features/RumConfiguration.type.d.ts +21 -0
  91. package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
  92. package/lib/typescript/config/features/RumConfigurationNative.d.ts +2 -0
  93. package/lib/typescript/config/features/RumConfigurationNative.d.ts.map +1 -1
  94. package/lib/typescript/flags/FlagsClient.d.ts +38 -1
  95. package/lib/typescript/flags/FlagsClient.d.ts.map +1 -1
  96. package/lib/typescript/flags/internal.d.ts +1 -0
  97. package/lib/typescript/flags/internal.d.ts.map +1 -1
  98. package/lib/typescript/flags/types.d.ts +1 -1
  99. package/lib/typescript/flags/types.d.ts.map +1 -1
  100. package/lib/typescript/sdk/AttributesEncoding/defaultEncoders.d.ts.map +1 -1
  101. package/lib/typescript/sdk/AttributesEncoding/utils.d.ts +1 -0
  102. package/lib/typescript/sdk/AttributesEncoding/utils.d.ts.map +1 -1
  103. package/lib/typescript/sdk/DdSdkInternal.d.ts +1 -8
  104. package/lib/typescript/sdk/DdSdkInternal.d.ts.map +1 -1
  105. package/lib/typescript/utils/time-provider/TimeProvider.d.ts.map +1 -1
  106. package/lib/typescript/version.d.ts +1 -1
  107. package/lib/typescript/version.d.ts.map +1 -1
  108. package/package.json +2 -2
  109. package/src/DdSdkReactNative.tsx +16 -16
  110. package/src/__tests__/DdSdkReactNative.test.tsx +272 -19
  111. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +12 -0
  112. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +3 -3
  113. package/src/config/FileBasedConfiguration.ts +6 -1
  114. package/src/config/FileBasedConfiguration.type.ts +2 -0
  115. package/src/config/__tests__/FileBasedConfiguration.test.ts +79 -0
  116. package/src/config/__tests__/__fixtures__/configuration-all-fields.json +2 -0
  117. package/src/config/async/AutoInstrumentationConfiguration.ts +9 -0
  118. package/src/config/async/PartialInitializationConfiguration.ts +2 -0
  119. package/src/config/features/RumConfiguration.ts +10 -0
  120. package/src/config/features/RumConfiguration.type.ts +23 -0
  121. package/src/config/features/RumConfigurationNative.ts +2 -0
  122. package/src/flags/FlagsClient.ts +128 -19
  123. package/src/flags/__tests__/FlagsClient.test.ts +167 -0
  124. package/src/flags/configuration/precomputed.ts +2 -3
  125. package/src/flags/internal.ts +2 -0
  126. package/src/flags/types.ts +2 -0
  127. package/src/rum/DdRum.ts +2 -2
  128. package/src/rum/__tests__/DdRum.test.ts +4 -4
  129. package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +3 -3
  130. package/src/rum/instrumentation/interactionTracking/__tests__/DdBabelInteractionTracking.test.ts +104 -1
  131. package/src/sdk/AttributesEncoding/__tests__/attributesEncoding.test.ts +25 -0
  132. package/src/sdk/AttributesEncoding/defaultEncoders.ts +6 -2
  133. package/src/sdk/AttributesEncoding/helpers.ts +6 -6
  134. package/src/sdk/AttributesEncoding/utils.ts +8 -0
  135. package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +2 -2
  136. package/src/sdk/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +5 -5
  137. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +165 -0
  138. package/src/sdk/DdSdkInternal.ts +23 -30
  139. package/src/sdk/EventMappers/EventMapper.ts +2 -2
  140. package/src/sdk/EventMappers/__tests__/EventMapper.test.ts +2 -2
  141. package/src/utils/__tests__/TimeProvider.test.tsx +49 -0
  142. package/src/utils/time-provider/TimeProvider.tsx +10 -1
  143. package/src/version.ts +1 -1
@@ -18,13 +18,15 @@ import { ProxyConfiguration, ProxyType, SdkVerbosity } from '../config/types';
18
18
  import { DdLogs } from '../logs/DdLogs';
19
19
  import { DdRum } from '../rum/DdRum';
20
20
  import { DdRumErrorTracking } from '../rum/instrumentation/DdRumErrorTracking';
21
+ import { DdBabelInteractionTracking } from '../rum/instrumentation/interactionTracking/DdBabelInteractionTracking';
21
22
  import { DdRumUserInteractionTracking } from '../rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';
22
23
  import { DdRumResourceTracking } from '../rum/instrumentation/resourceTracking/DdRumResourceTracking';
23
24
  import { PropagatorType, RumActionType } from '../rum/types';
24
25
  import { AttributesSingleton } from '../sdk/AttributesSingleton/AttributesSingleton';
25
- import { NativeDdSdk } from '../sdk/DdSdkInternal';
26
+ import { DdSdkWrapper } from '../sdk/DdSdkInternal';
26
27
  import { GlobalState } from '../sdk/GlobalState/GlobalState';
27
28
  import { UserInfoSingleton } from '../sdk/UserInfoSingleton/UserInfoSingleton';
29
+ import NativeDdSdkSpec from '../specs/NativeDdSdk';
28
30
  import type { LogEvent } from '../types';
29
31
  import { ErrorSource } from '../types';
30
32
  import { version as sdkVersion } from '../version';
@@ -427,6 +429,94 @@ describe('DdSdkReactNative', () => {
427
429
  ).toBe(false);
428
430
  });
429
431
 
432
+ it('initializes with nativeIosResourceTracking undefined when not specified', async () => {
433
+ // GIVEN
434
+ const configuration = new CoreConfiguration('2', 'env');
435
+ configuration.rumConfiguration = new RumConfiguration('1');
436
+
437
+ // WHEN
438
+ await DdSdkReactNative.initialize(configuration);
439
+
440
+ // THEN
441
+ const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
442
+ .calls[0][0] as DdSdkNativeConfiguration;
443
+ expect(ddSdkConfiguration.rumConfiguration).toBeDefined();
444
+ expect(
445
+ ddSdkConfiguration.rumConfiguration?.nativeIosResourceTracking
446
+ ).toBeUndefined();
447
+ });
448
+
449
+ it.each([true, false])(
450
+ 'initializes with nativeIosResourceTracking %s when it is specified',
451
+ async value => {
452
+ // GIVEN
453
+ const configuration = new CoreConfiguration('2', 'env');
454
+ configuration.rumConfiguration = new RumConfiguration(
455
+ '1',
456
+ false,
457
+ false,
458
+ false,
459
+ { nativeIosResourceTracking: value }
460
+ );
461
+
462
+ // WHEN
463
+ await DdSdkReactNative.initialize(configuration);
464
+
465
+ // THEN
466
+ const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
467
+ .calls[0][0] as DdSdkNativeConfiguration;
468
+ expect(
469
+ ddSdkConfiguration.rumConfiguration
470
+ ?.nativeIosResourceTracking
471
+ ).toBe(value);
472
+ }
473
+ );
474
+
475
+ it('initializes with nativeIosResourceTrackingDisallowList undefined when not specified', async () => {
476
+ // GIVEN
477
+ const configuration = new CoreConfiguration('2', 'env');
478
+ configuration.rumConfiguration = new RumConfiguration('1');
479
+
480
+ // WHEN
481
+ await DdSdkReactNative.initialize(configuration);
482
+
483
+ // THEN
484
+ const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
485
+ .calls[0][0] as DdSdkNativeConfiguration;
486
+ expect(ddSdkConfiguration.rumConfiguration).toBeDefined();
487
+ expect(
488
+ ddSdkConfiguration.rumConfiguration
489
+ ?.nativeIosResourceTrackingDisallowList
490
+ ).toBeUndefined();
491
+ });
492
+
493
+ it('initializes with nativeIosResourceTrackingDisallowList when it is specified', async () => {
494
+ // GIVEN
495
+ const disallowList = [
496
+ 'https://3p.example.com/*',
497
+ 'https://cdn.example.com/a'
498
+ ];
499
+ const configuration = new CoreConfiguration('2', 'env');
500
+ configuration.rumConfiguration = new RumConfiguration(
501
+ '1',
502
+ false,
503
+ false,
504
+ false,
505
+ { nativeIosResourceTrackingDisallowList: disallowList }
506
+ );
507
+
508
+ // WHEN
509
+ await DdSdkReactNative.initialize(configuration);
510
+
511
+ // THEN
512
+ const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
513
+ .calls[0][0] as DdSdkNativeConfiguration;
514
+ expect(
515
+ ddSdkConfiguration.rumConfiguration
516
+ ?.nativeIosResourceTrackingDisallowList
517
+ ).toEqual(disallowList);
518
+ });
519
+
430
520
  it('initializes with bundleLogsWithTraces false when it is specified', async () => {
431
521
  // GIVEN
432
522
  const fakeAppId = '1';
@@ -564,6 +654,50 @@ describe('DdSdkReactNative', () => {
564
654
  });
565
655
 
566
656
  describe('feature enablement', () => {
657
+ describe('Babel interaction tracking', () => {
658
+ const originalConfig = DdBabelInteractionTracking.config;
659
+ const originalPluginFlag =
660
+ globalThis.__DD_RN_BABEL_PLUGIN_ENABLED__;
661
+
662
+ beforeEach(() => {
663
+ globalThis.__DD_RN_BABEL_PLUGIN_ENABLED__ = true;
664
+ NativeModules.DdSdk.initialize.mockResolvedValue(null);
665
+ });
666
+
667
+ afterEach(() => {
668
+ globalThis.__DD_RN_BABEL_PLUGIN_ENABLED__ = originalPluginFlag;
669
+ DdBabelInteractionTracking.config = originalConfig;
670
+ });
671
+
672
+ it.each([
673
+ { useAccessibilityLabel: false, expected: false },
674
+ { useAccessibilityLabel: true, expected: true },
675
+ { useAccessibilityLabel: undefined, expected: true }
676
+ ])(
677
+ 'respects useAccessibilityLabel=$useAccessibilityLabel during initialization',
678
+ async ({ useAccessibilityLabel, expected }) => {
679
+ const configuration = new CoreConfiguration('2', 'env');
680
+ configuration.rumConfiguration = new RumConfiguration(
681
+ '1',
682
+ true,
683
+ false,
684
+ false,
685
+ { useAccessibilityLabel }
686
+ );
687
+
688
+ await DdSdkReactNative.initialize(configuration);
689
+
690
+ expect(DdBabelInteractionTracking.config).toEqual({
691
+ trackInteractions: true,
692
+ useAccessibilityLabel: expected
693
+ });
694
+ expect(
695
+ DdRumUserInteractionTracking.startTracking
696
+ ).not.toHaveBeenCalled();
697
+ }
698
+ );
699
+ });
700
+
567
701
  it('enables user interaction feature when initialize { user interaction config enabled }', async () => {
568
702
  // GIVEN
569
703
  const fakeAppId = '1';
@@ -1184,8 +1318,8 @@ describe('DdSdkReactNative', () => {
1184
1318
  await DdSdkReactNative.addAttribute(key, value);
1185
1319
 
1186
1320
  // THEN
1187
- expect(NativeDdSdk.addAttribute).toHaveBeenCalledTimes(1);
1188
- expect(NativeDdSdk.addAttribute).toHaveBeenCalledWith(key, {
1321
+ expect(NativeDdSdkSpec.addAttribute).toHaveBeenCalledTimes(1);
1322
+ expect(NativeDdSdkSpec.addAttribute).toHaveBeenCalledWith(key, {
1189
1323
  value
1190
1324
  });
1191
1325
  expect(AttributesSingleton.getInstance().getAttribute(key)).toEqual(
@@ -1205,8 +1339,8 @@ describe('DdSdkReactNative', () => {
1205
1339
  await DdSdkReactNative.removeAttribute(key);
1206
1340
 
1207
1341
  // THEN
1208
- expect(NativeDdSdk.removeAttribute).toHaveBeenCalledTimes(1);
1209
- expect(NativeDdSdk.removeAttribute).toHaveBeenCalledWith(key);
1342
+ expect(NativeDdSdkSpec.removeAttribute).toHaveBeenCalledTimes(1);
1343
+ expect(NativeDdSdkSpec.removeAttribute).toHaveBeenCalledWith(key);
1210
1344
  expect(AttributesSingleton.getInstance().getAttribute(key)).toEqual(
1211
1345
  undefined
1212
1346
  );
@@ -1223,8 +1357,10 @@ describe('DdSdkReactNative', () => {
1223
1357
  await DdSdkReactNative.addAttributes(attributes);
1224
1358
 
1225
1359
  // THEN
1226
- expect(NativeDdSdk.addAttributes).toHaveBeenCalledTimes(1);
1227
- expect(NativeDdSdk.addAttributes).toHaveBeenCalledWith(attributes);
1360
+ expect(NativeDdSdkSpec.addAttributes).toHaveBeenCalledTimes(1);
1361
+ expect(NativeDdSdkSpec.addAttributes).toHaveBeenCalledWith(
1362
+ attributes
1363
+ );
1228
1364
  expect(AttributesSingleton.getInstance().getAttributes()).toEqual({
1229
1365
  foo: 'bar'
1230
1366
  });
@@ -1241,8 +1377,8 @@ describe('DdSdkReactNative', () => {
1241
1377
  await DdSdkReactNative.removeAttributes(['foo', 'baz']);
1242
1378
 
1243
1379
  // THEN
1244
- expect(NativeDdSdk.removeAttributes).toHaveBeenCalledTimes(1);
1245
- expect(NativeDdSdk.removeAttributes).toHaveBeenCalledWith([
1380
+ expect(NativeDdSdkSpec.removeAttributes).toHaveBeenCalledTimes(1);
1381
+ expect(NativeDdSdkSpec.removeAttributes).toHaveBeenCalledWith([
1246
1382
  'foo',
1247
1383
  'baz'
1248
1384
  ]);
@@ -1268,8 +1404,8 @@ describe('DdSdkReactNative', () => {
1268
1404
  await DdSdkReactNative.setUserInfo(userInfo);
1269
1405
 
1270
1406
  // THEN
1271
- expect(NativeDdSdk.setUserInfo).toHaveBeenCalledTimes(1);
1272
- expect(NativeDdSdk.setUserInfo).toHaveBeenCalledWith(userInfo);
1407
+ expect(NativeDdSdkSpec.setUserInfo).toHaveBeenCalledTimes(1);
1408
+ expect(NativeDdSdkSpec.setUserInfo).toHaveBeenCalledWith(userInfo);
1273
1409
  expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual(
1274
1410
  userInfo
1275
1411
  );
@@ -1289,8 +1425,8 @@ describe('DdSdkReactNative', () => {
1289
1425
  await DdSdkReactNative.addUserExtraInfo(extraInfo);
1290
1426
 
1291
1427
  // THEN
1292
- expect(NativeDdSdk.addUserExtraInfo).toHaveBeenCalledTimes(1);
1293
- expect(NativeDdSdk.addUserExtraInfo).toHaveBeenCalledWith(
1428
+ expect(NativeDdSdkSpec.addUserExtraInfo).toHaveBeenCalledTimes(1);
1429
+ expect(NativeDdSdkSpec.addUserExtraInfo).toHaveBeenCalledWith(
1294
1430
  extraInfo
1295
1431
  );
1296
1432
  expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual({
@@ -1310,7 +1446,7 @@ describe('DdSdkReactNative', () => {
1310
1446
  await DdSdkReactNative.addUserExtraInfo(extraInfo);
1311
1447
 
1312
1448
  // THEN
1313
- expect(NativeDdSdk.addUserExtraInfo).toHaveBeenCalledWith(
1449
+ expect(NativeDdSdkSpec.addUserExtraInfo).toHaveBeenCalledWith(
1314
1450
  extraInfo
1315
1451
  );
1316
1452
  expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual({
@@ -1339,8 +1475,8 @@ describe('DdSdkReactNative', () => {
1339
1475
  await DdSdkReactNative.clearUserInfo();
1340
1476
 
1341
1477
  // THEN
1342
- expect(NativeDdSdk.clearUserInfo).toHaveBeenCalledTimes(1);
1343
- expect(NativeDdSdk.setUserInfo).toHaveBeenCalled();
1478
+ expect(NativeDdSdkSpec.clearUserInfo).toHaveBeenCalledTimes(1);
1479
+ expect(NativeDdSdkSpec.setUserInfo).toHaveBeenCalled();
1344
1480
  expect(
1345
1481
  UserInfoSingleton.getInstance().getUserInfo()
1346
1482
  ).toBeUndefined();
@@ -1357,8 +1493,8 @@ describe('DdSdkReactNative', () => {
1357
1493
  DdSdkReactNative.setTrackingConsent(consent);
1358
1494
 
1359
1495
  // THEN
1360
- expect(NativeDdSdk.setTrackingConsent).toHaveBeenCalledTimes(1);
1361
- expect(NativeDdSdk.setTrackingConsent).toHaveBeenCalledWith(
1496
+ expect(NativeDdSdkSpec.setTrackingConsent).toHaveBeenCalledTimes(1);
1497
+ expect(NativeDdSdkSpec.setTrackingConsent).toHaveBeenCalledWith(
1362
1498
  consent
1363
1499
  );
1364
1500
  });
@@ -1370,7 +1506,7 @@ describe('DdSdkReactNative', () => {
1370
1506
  DdSdkReactNative.clearAllData();
1371
1507
 
1372
1508
  // THEN
1373
- expect(NativeDdSdk.clearAllData).toHaveBeenCalledTimes(1);
1509
+ expect(NativeDdSdkSpec.clearAllData).toHaveBeenCalledTimes(1);
1374
1510
  });
1375
1511
  });
1376
1512
 
@@ -1500,4 +1636,121 @@ describe('DdSdkReactNative', () => {
1500
1636
  });
1501
1637
  }
1502
1638
  );
1639
+ describe('routing through DdSdkWrapper', () => {
1640
+ it('DdSdkReactNative.addAttribute reaches the native spec via the wrapper', async () => {
1641
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'addAttribute');
1642
+
1643
+ await DdSdkReactNative.addAttribute('key', 'value');
1644
+
1645
+ expect(spy).toHaveBeenCalled();
1646
+ spy.mockRestore();
1647
+ });
1648
+
1649
+ it('DdSdkReactNative.removeAttribute reaches the native spec via the wrapper', async () => {
1650
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'removeAttribute');
1651
+
1652
+ await DdSdkReactNative.removeAttribute('key');
1653
+
1654
+ expect(spy).toHaveBeenCalled();
1655
+ spy.mockRestore();
1656
+ });
1657
+
1658
+ it('DdSdkReactNative.addAttributes reaches the native spec via the wrapper', async () => {
1659
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'addAttributes');
1660
+
1661
+ await DdSdkReactNative.addAttributes({ key: 'value' });
1662
+
1663
+ expect(spy).toHaveBeenCalled();
1664
+ spy.mockRestore();
1665
+ });
1666
+
1667
+ it('DdSdkReactNative.removeAttributes reaches the native spec via the wrapper', async () => {
1668
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'removeAttributes');
1669
+
1670
+ await DdSdkReactNative.removeAttributes(['key']);
1671
+
1672
+ expect(spy).toHaveBeenCalled();
1673
+ spy.mockRestore();
1674
+ });
1675
+
1676
+ it('DdSdkReactNative.setUserInfo reaches the native spec via the wrapper', async () => {
1677
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'setUserInfo');
1678
+
1679
+ await DdSdkReactNative.setUserInfo({ id: 'user-id' });
1680
+
1681
+ expect(spy).toHaveBeenCalled();
1682
+ spy.mockRestore();
1683
+ });
1684
+
1685
+ it('DdSdkReactNative.clearUserInfo reaches the native spec via the wrapper', async () => {
1686
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'clearUserInfo');
1687
+
1688
+ await DdSdkReactNative.clearUserInfo();
1689
+
1690
+ expect(spy).toHaveBeenCalled();
1691
+ spy.mockRestore();
1692
+ });
1693
+
1694
+ it('DdSdkReactNative.addUserExtraInfo reaches the native spec via the wrapper', async () => {
1695
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'addUserExtraInfo');
1696
+
1697
+ await DdSdkReactNative.addUserExtraInfo({ role: 'admin' });
1698
+
1699
+ expect(spy).toHaveBeenCalled();
1700
+ spy.mockRestore();
1701
+ });
1702
+
1703
+ it('DdSdkReactNative.setAccountInfo reaches the native spec via the wrapper', async () => {
1704
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'setAccountInfo');
1705
+
1706
+ await DdSdkReactNative.setAccountInfo({ id: 'account-id' });
1707
+
1708
+ expect(spy).toHaveBeenCalled();
1709
+ spy.mockRestore();
1710
+ });
1711
+
1712
+ it('DdSdkReactNative.clearAccountInfo reaches the native spec via the wrapper', async () => {
1713
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'clearAccountInfo');
1714
+
1715
+ await DdSdkReactNative.clearAccountInfo();
1716
+
1717
+ expect(spy).toHaveBeenCalled();
1718
+ spy.mockRestore();
1719
+ });
1720
+
1721
+ it('DdSdkReactNative.addAccountExtraInfo reaches the native spec via the wrapper', async () => {
1722
+ // addAccountExtraInfo bails out early unless an account ID is set.
1723
+ await DdSdkReactNative.setAccountInfo({ id: 'account-id' });
1724
+ const spy = jest.spyOn(
1725
+ DdSdkWrapper.prototype,
1726
+ 'addAccountExtraInfo'
1727
+ );
1728
+
1729
+ await DdSdkReactNative.addAccountExtraInfo({ tier: 'premium' });
1730
+
1731
+ expect(spy).toHaveBeenCalled();
1732
+ spy.mockRestore();
1733
+ });
1734
+
1735
+ it('DdSdkReactNative.setTrackingConsent reaches the native spec via the wrapper', async () => {
1736
+ const spy = jest.spyOn(
1737
+ DdSdkWrapper.prototype,
1738
+ 'setTrackingConsent'
1739
+ );
1740
+
1741
+ await DdSdkReactNative.setTrackingConsent(TrackingConsent.GRANTED);
1742
+
1743
+ expect(spy).toHaveBeenCalled();
1744
+ spy.mockRestore();
1745
+ });
1746
+
1747
+ it('DdSdkReactNative.clearAllData reaches the native spec via the wrapper', async () => {
1748
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'clearAllData');
1749
+
1750
+ await DdSdkReactNative.clearAllData();
1751
+
1752
+ expect(spy).toHaveBeenCalled();
1753
+ spy.mockRestore();
1754
+ });
1755
+ });
1503
1756
  });
@@ -65,6 +65,8 @@ describe('DdSdkReactNativeConfiguration', () => {
65
65
  "longTaskThresholdMs": 0,
66
66
  "nativeCrashReportEnabled": false,
67
67
  "nativeInteractionTracking": false,
68
+ "nativeIosResourceTracking": undefined,
69
+ "nativeIosResourceTrackingDisallowList": undefined,
68
70
  "nativeLongTaskThresholdMs": 200,
69
71
  "nativeViewTracking": false,
70
72
  "resourceEventMapper": null,
@@ -134,6 +136,10 @@ describe('DdSdkReactNativeConfiguration', () => {
134
136
  nativeLongTaskThresholdMs: 345,
135
137
  nativeViewTracking: true,
136
138
  nativeInteractionTracking: true,
139
+ nativeIosResourceTracking: true,
140
+ nativeIosResourceTrackingDisallowList: [
141
+ 'https://3p.example.com/*'
142
+ ],
137
143
  longTaskThresholdMs: 567,
138
144
  trackFrustrations: true,
139
145
  trackNonFatalAnrs: true,
@@ -210,6 +216,10 @@ describe('DdSdkReactNativeConfiguration', () => {
210
216
  "longTaskThresholdMs": 567,
211
217
  "nativeCrashReportEnabled": true,
212
218
  "nativeInteractionTracking": true,
219
+ "nativeIosResourceTracking": true,
220
+ "nativeIosResourceTrackingDisallowList": [
221
+ "https://3p.example.com/*",
222
+ ],
213
223
  "nativeLongTaskThresholdMs": 345,
214
224
  "nativeViewTracking": true,
215
225
  "resourceEventMapper": [Function],
@@ -314,6 +324,8 @@ describe('DdSdkReactNativeConfiguration', () => {
314
324
  "longTaskThresholdMs": false,
315
325
  "nativeCrashReportEnabled": false,
316
326
  "nativeInteractionTracking": false,
327
+ "nativeIosResourceTracking": undefined,
328
+ "nativeIosResourceTrackingDisallowList": undefined,
317
329
  "nativeLongTaskThresholdMs": 0,
318
330
  "nativeViewTracking": false,
319
331
  "resourceEventMapper": null,
@@ -21,7 +21,7 @@ import React from 'react';
21
21
  import type { DdNativeRumType } from '../../../nativeModulesTypes';
22
22
  import { DdRumUserInteractionTracking } from '../../../rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';
23
23
  import { BufferSingleton } from '../../../sdk/DatadogProvider/Buffer/BufferSingleton';
24
- import { NativeDdSdk } from '../../../sdk/DdSdkInternal';
24
+ import NativeDdSdkSpec from '../../../specs/NativeDdSdk';
25
25
 
26
26
  const styles = StyleSheet.create({
27
27
  button: {
@@ -467,7 +467,7 @@ describe('startTracking', () => {
467
467
  jest.setMock('react/jsx-runtime', {});
468
468
  DdRumUserInteractionTracking.startTracking({});
469
469
  expect(DdRumUserInteractionTracking['isTracking']).toBe(true);
470
- expect(NativeDdSdk.telemetryDebug).toBeCalledWith(
470
+ expect(NativeDdSdkSpec.telemetryDebug).toBeCalledWith(
471
471
  'React jsx runtime does not export new jsx transform'
472
472
  );
473
473
  });
@@ -477,7 +477,7 @@ describe('startTracking', () => {
477
477
 
478
478
  DdRumUserInteractionTracking.startTracking({});
479
479
  expect(DdRumUserInteractionTracking['isTracking']).toBe(true);
480
- expect(NativeDdSdk.telemetryDebug).toBeCalledWith(
480
+ expect(NativeDdSdkSpec.telemetryDebug).toBeCalledWith(
481
481
  'React version does not support new jsx transform'
482
482
  );
483
483
  });
@@ -208,7 +208,12 @@ export const getJSONConfiguration = (
208
208
  telemetrySampleRate:
209
209
  configuration.rumConfiguration.telemetrySampleRate,
210
210
  nativeInteractionTracking:
211
- configuration.rumConfiguration.nativeInteractionTracking
211
+ configuration.rumConfiguration.nativeInteractionTracking,
212
+ nativeIosResourceTracking:
213
+ configuration.rumConfiguration.nativeIosResourceTracking,
214
+ nativeIosResourceTrackingDisallowList:
215
+ configuration.rumConfiguration
216
+ .nativeIosResourceTrackingDisallowList
212
217
  }
213
218
  }),
214
219
  ...(configuration.traceConfiguration !== undefined && {
@@ -46,6 +46,8 @@ export interface JsonConfiguration extends CoreConfigurationOptions {
46
46
  nativeLongTaskThresholdMs?: number;
47
47
  nativeViewTracking?: boolean;
48
48
  nativeInteractionTracking?: boolean;
49
+ nativeIosResourceTracking?: boolean;
50
+ nativeIosResourceTrackingDisallowList?: string[];
49
51
  customEndpoint?: string;
50
52
  sessionSampleRate?: number;
51
53
  resourceTraceSampleRate?: number;
@@ -59,6 +59,10 @@ describe('FileBasedConfiguration', () => {
59
59
  "longTaskThresholdMs": 44,
60
60
  "nativeCrashReportEnabled": true,
61
61
  "nativeInteractionTracking": true,
62
+ "nativeIosResourceTracking": true,
63
+ "nativeIosResourceTrackingDisallowList": [
64
+ "https://3p.example.com/*",
65
+ ],
62
66
  "nativeLongTaskThresholdMs": 789,
63
67
  "nativeViewTracking": true,
64
68
  "resourceEventMapper": null,
@@ -172,6 +176,8 @@ describe('FileBasedConfiguration', () => {
172
176
  "longTaskThresholdMs": 44,
173
177
  "nativeCrashReportEnabled": false,
174
178
  "nativeInteractionTracking": false,
179
+ "nativeIosResourceTracking": undefined,
180
+ "nativeIosResourceTrackingDisallowList": undefined,
175
181
  "nativeLongTaskThresholdMs": 200,
176
182
  "nativeViewTracking": false,
177
183
  "resourceEventMapper": null,
@@ -237,6 +243,8 @@ describe('FileBasedConfiguration', () => {
237
243
  "longTaskThresholdMs": 0,
238
244
  "nativeCrashReportEnabled": false,
239
245
  "nativeInteractionTracking": false,
246
+ "nativeIosResourceTracking": undefined,
247
+ "nativeIosResourceTrackingDisallowList": undefined,
240
248
  "nativeLongTaskThresholdMs": 200,
241
249
  "nativeViewTracking": false,
242
250
  "resourceEventMapper": null,
@@ -267,6 +275,77 @@ describe('FileBasedConfiguration', () => {
267
275
  `);
268
276
  });
269
277
 
278
+ it('leaves nativeIosResourceTracking undefined when not set', () => {
279
+ const config = new FileBasedConfiguration({
280
+ configuration: {
281
+ env: 'fake-env',
282
+ clientToken: 'fake-client-token',
283
+ rumConfiguration: {
284
+ applicationId: 'fake-app-id'
285
+ }
286
+ }
287
+ });
288
+ expect(config.rumConfiguration).toHaveProperty(
289
+ 'nativeIosResourceTracking',
290
+ undefined
291
+ );
292
+ });
293
+
294
+ it.each([true, false])(
295
+ 'passes nativeIosResourceTracking through when set to %s',
296
+ value => {
297
+ const config = new FileBasedConfiguration({
298
+ configuration: {
299
+ env: 'fake-env',
300
+ clientToken: 'fake-client-token',
301
+ rumConfiguration: {
302
+ applicationId: 'fake-app-id',
303
+ nativeIosResourceTracking: value
304
+ }
305
+ }
306
+ });
307
+ expect(config.rumConfiguration?.nativeIosResourceTracking).toBe(
308
+ value
309
+ );
310
+ }
311
+ );
312
+
313
+ it('leaves nativeIosResourceTrackingDisallowList undefined when not set', () => {
314
+ const config = new FileBasedConfiguration({
315
+ configuration: {
316
+ env: 'fake-env',
317
+ clientToken: 'fake-client-token',
318
+ rumConfiguration: {
319
+ applicationId: 'fake-app-id'
320
+ }
321
+ }
322
+ });
323
+ expect(config.rumConfiguration).toHaveProperty(
324
+ 'nativeIosResourceTrackingDisallowList',
325
+ undefined
326
+ );
327
+ });
328
+
329
+ it('passes nativeIosResourceTrackingDisallowList through when set', () => {
330
+ const disallowList = [
331
+ 'https://3p.example.com/*',
332
+ 'https://cdn.example.com/a'
333
+ ];
334
+ const config = new FileBasedConfiguration({
335
+ configuration: {
336
+ env: 'fake-env',
337
+ clientToken: 'fake-client-token',
338
+ rumConfiguration: {
339
+ applicationId: 'fake-app-id',
340
+ nativeIosResourceTrackingDisallowList: disallowList
341
+ }
342
+ }
343
+ });
344
+ expect(
345
+ config.rumConfiguration?.nativeIosResourceTrackingDisallowList
346
+ ).toEqual(disallowList);
347
+ });
348
+
270
349
  it('applies event mappers to configuration when provided', () => {
271
350
  const actionEventMapper = () => null;
272
351
  const errorEventMapper = () => null;
@@ -28,6 +28,8 @@
28
28
  "initialResourceThreshold": 456,
29
29
  "nativeViewTracking": true,
30
30
  "nativeInteractionTracking": true,
31
+ "nativeIosResourceTracking": true,
32
+ "nativeIosResourceTrackingDisallowList": ["https://3p.example.com/*"],
31
33
  "nativeLongTaskThresholdMs": 789,
32
34
  "nativeCrashReportEnabled": true,
33
35
  "trackBackgroundEvents": true,
@@ -28,6 +28,8 @@ export type AutoInstrumentationConfiguration = {
28
28
  readonly nativeCrashReportEnabled?: boolean;
29
29
  readonly nativeLongTaskThresholdMs?: number;
30
30
  readonly nativeViewTracking?: boolean;
31
+ readonly nativeIosResourceTracking?: boolean;
32
+ readonly nativeIosResourceTrackingDisallowList?: string[];
31
33
  readonly actionEventMapper?: ActionEventMapper | null;
32
34
  readonly errorEventMapper?: ErrorEventMapper | null;
33
35
  readonly resourceEventMapper?: ResourceEventMapper | null;
@@ -53,6 +55,8 @@ export type AutoInstrumentationParameters = {
53
55
  readonly nativeCrashReportEnabled?: boolean;
54
56
  readonly nativeLongTaskThresholdMs?: number;
55
57
  readonly nativeViewTracking?: boolean;
58
+ readonly nativeIosResourceTracking?: boolean;
59
+ readonly nativeIosResourceTrackingDisallowList?: string[];
56
60
  readonly actionEventMapper: ActionEventMapper | null;
57
61
  readonly errorEventMapper: ErrorEventMapper | null;
58
62
  readonly resourceEventMapper: ResourceEventMapper | null;
@@ -117,6 +121,11 @@ export const addDefaultValuesToAutoInstrumentationConfiguration = (
117
121
  nativeViewTracking:
118
122
  features.rumConfiguration.nativeViewTracking ??
119
123
  RUM_DEFAULTS.nativeViewTracking,
124
+ // No default on purpose: undefined means legacy iOS behavior
125
+ nativeIosResourceTracking:
126
+ features.rumConfiguration.nativeIosResourceTracking,
127
+ nativeIosResourceTrackingDisallowList:
128
+ features.rumConfiguration.nativeIosResourceTrackingDisallowList,
120
129
  firstPartyHosts:
121
130
  features.rumConfiguration.firstPartyHosts ||
122
131
  RUM_DEFAULTS.getFirstPartyHosts()
@@ -36,6 +36,8 @@ export type PartialInitializationConfiguration = {
36
36
  readonly nativeCrashReportEnabled?: boolean;
37
37
  readonly nativeViewTracking?: boolean;
38
38
  readonly nativeInteractionTracking?: boolean;
39
+ readonly nativeIosResourceTracking?: boolean;
40
+ readonly nativeIosResourceTrackingDisallowList?: string[];
39
41
  readonly longTaskThresholdMs?: number | false;
40
42
  readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;
41
43
  readonly trackFrustrations?: boolean;
@@ -26,6 +26,8 @@ const DEFAULTS = {
26
26
  nativeCrashReportEnabled: false,
27
27
  nativeInteractionTracking: false,
28
28
  nativeLongTaskThresholdMs: 200,
29
+ nativeIosResourceTracking: undefined,
30
+ nativeIosResourceTrackingDisallowList: undefined,
29
31
  nativeViewTracking: false,
30
32
  resourceEventMapper: null,
31
33
  resourceTraceSampleRate: 100.0,
@@ -85,6 +87,14 @@ export class RumConfiguration implements RumConfigurationType {
85
87
  public nativeLongTaskThresholdMs: number =
86
88
  DEFAULTS.nativeLongTaskThresholdMs;
87
89
 
90
+ // Native Resource Tracking (iOS only); undefined means legacy behavior
91
+ public nativeIosResourceTracking?: boolean =
92
+ DEFAULTS.nativeIosResourceTracking;
93
+
94
+ // URL patterns excluded from native iOS resource tracking; undefined means [] on iOS
95
+ public nativeIosResourceTrackingDisallowList?: string[] =
96
+ DEFAULTS.nativeIosResourceTrackingDisallowList;
97
+
88
98
  // Native View Tracking enabled
89
99
  public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;
90
100