@datadog/mobile-react-native 3.7.0 → 3.9.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 (98) hide show
  1. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  2. package/ios/Sources/DdFlagsImplementation.swift +3 -4
  3. package/ios/Sources/DdLogsImplementation.swift +8 -8
  4. package/ios/Sources/DdRumImplementation.swift +25 -25
  5. package/ios/Sources/DdSdkImplementation.swift +20 -21
  6. package/ios/Sources/DdTraceImplementation.swift +2 -2
  7. package/ios/Sources/RCTPromiseTypes.swift +18 -0
  8. package/ios/Sources/SdkVersion.swift +1 -1
  9. package/lib/commonjs/DdSdkReactNative.js +15 -15
  10. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  11. package/lib/commonjs/flags/internal.js +9 -1
  12. package/lib/commonjs/flags/internal.js.map +1 -1
  13. package/lib/commonjs/flags/rumIntegration.js +104 -0
  14. package/lib/commonjs/flags/rumIntegration.js.map +1 -0
  15. package/lib/commonjs/index.js +7 -0
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/rum/DdRum.js +2 -2
  18. package/lib/commonjs/rum/DdRum.js.map +1 -1
  19. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +3 -3
  20. package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  21. package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js +1 -1
  22. package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
  23. package/lib/commonjs/sdk/AttributesEncoding/helpers.js +3 -3
  24. package/lib/commonjs/sdk/AttributesEncoding/helpers.js.map +1 -1
  25. package/lib/commonjs/sdk/AttributesEncoding/utils.js +8 -0
  26. package/lib/commonjs/sdk/AttributesEncoding/utils.js.map +1 -1
  27. package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
  28. package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
  29. package/lib/commonjs/sdk/DdSdkInternal.js +22 -22
  30. package/lib/commonjs/sdk/DdSdkInternal.js.map +1 -1
  31. package/lib/commonjs/sdk/EventMappers/EventMapper.js +2 -2
  32. package/lib/commonjs/sdk/EventMappers/EventMapper.js.map +1 -1
  33. package/lib/commonjs/utils/time-provider/TimeProvider.js +4 -1
  34. package/lib/commonjs/utils/time-provider/TimeProvider.js.map +1 -1
  35. package/lib/commonjs/version.js +1 -1
  36. package/lib/module/DdSdkReactNative.js +15 -15
  37. package/lib/module/DdSdkReactNative.js.map +1 -1
  38. package/lib/module/flags/internal.js +9 -1
  39. package/lib/module/flags/internal.js.map +1 -1
  40. package/lib/module/flags/rumIntegration.js +97 -0
  41. package/lib/module/flags/rumIntegration.js.map +1 -0
  42. package/lib/module/index.js +2 -1
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/module/rum/DdRum.js +2 -2
  45. package/lib/module/rum/DdRum.js.map +1 -1
  46. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +3 -3
  47. package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
  48. package/lib/module/sdk/AttributesEncoding/defaultEncoders.js +2 -2
  49. package/lib/module/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
  50. package/lib/module/sdk/AttributesEncoding/helpers.js +4 -4
  51. package/lib/module/sdk/AttributesEncoding/helpers.js.map +1 -1
  52. package/lib/module/sdk/AttributesEncoding/utils.js +7 -0
  53. package/lib/module/sdk/AttributesEncoding/utils.js.map +1 -1
  54. package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
  55. package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
  56. package/lib/module/sdk/DdSdkInternal.js +21 -22
  57. package/lib/module/sdk/DdSdkInternal.js.map +1 -1
  58. package/lib/module/sdk/EventMappers/EventMapper.js +2 -2
  59. package/lib/module/sdk/EventMappers/EventMapper.js.map +1 -1
  60. package/lib/module/utils/time-provider/TimeProvider.js +4 -1
  61. package/lib/module/utils/time-provider/TimeProvider.js.map +1 -1
  62. package/lib/module/version.js +1 -1
  63. package/lib/typescript/flags/internal.d.ts.map +1 -1
  64. package/lib/typescript/flags/rumIntegration.d.ts +14 -0
  65. package/lib/typescript/flags/rumIntegration.d.ts.map +1 -0
  66. package/lib/typescript/index.d.ts +2 -1
  67. package/lib/typescript/index.d.ts.map +1 -1
  68. package/lib/typescript/sdk/AttributesEncoding/defaultEncoders.d.ts.map +1 -1
  69. package/lib/typescript/sdk/AttributesEncoding/utils.d.ts +1 -0
  70. package/lib/typescript/sdk/AttributesEncoding/utils.d.ts.map +1 -1
  71. package/lib/typescript/sdk/DdSdkInternal.d.ts +1 -8
  72. package/lib/typescript/sdk/DdSdkInternal.d.ts.map +1 -1
  73. package/lib/typescript/utils/time-provider/TimeProvider.d.ts.map +1 -1
  74. package/lib/typescript/version.d.ts +1 -1
  75. package/package.json +2 -2
  76. package/src/DdSdkReactNative.tsx +15 -15
  77. package/src/__tests__/DdSdkReactNative.test.tsx +139 -19
  78. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +3 -3
  79. package/src/flags/__tests__/internal.test.ts +39 -0
  80. package/src/flags/__tests__/rumIntegration.test.ts +493 -0
  81. package/src/flags/internal.ts +12 -1
  82. package/src/flags/rumIntegration.ts +140 -0
  83. package/src/index.tsx +3 -1
  84. package/src/rum/DdRum.ts +2 -2
  85. package/src/rum/__tests__/DdRum.test.ts +4 -4
  86. package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +3 -3
  87. package/src/sdk/AttributesEncoding/__tests__/attributesEncoding.test.ts +25 -0
  88. package/src/sdk/AttributesEncoding/defaultEncoders.ts +6 -2
  89. package/src/sdk/AttributesEncoding/helpers.ts +6 -6
  90. package/src/sdk/AttributesEncoding/utils.ts +8 -0
  91. package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +2 -2
  92. package/src/sdk/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +5 -5
  93. package/src/sdk/DdSdkInternal.ts +23 -30
  94. package/src/sdk/EventMappers/EventMapper.ts +2 -2
  95. package/src/sdk/EventMappers/__tests__/EventMapper.test.ts +2 -2
  96. package/src/utils/__tests__/TimeProvider.test.tsx +49 -0
  97. package/src/utils/time-provider/TimeProvider.tsx +10 -1
  98. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DdSdkInternal.d.ts","sourceRoot":"","sources":["../../../src/sdk/DdSdkInternal.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,QAAA,MAAM,WAAW,EAAE,eAAyD,CAAC;AAE7E,MAAM,MAAM,SAAS,GAAG;IACpB,QAAQ,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;IAEpD;;;OAGG;IACH,UAAU,CAAC,aAAa,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE,CAAC;AAEF,qBAAa,YAAa,YAAW,eAAe;IAChD,IAAI,iBAAiB,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAE/C;IACD,OAAO,CAAC,kBAAkB,CAA+B;IAEzD,UAAU,CAAC,aAAa,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlE,YAAY;IAIZ,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1C,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI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AAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1D,gBAAgB,CACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAIhB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,cAAc,CACV,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAIhB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIpC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIpC,+BAA+B,CAC3B,iBAAiB,EAAE,gBAAgB,CAAC,GAAG,CAAC,EAAE;CAIjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"TimeProvider.d.ts","sourceRoot":"","sources":["../../../../src/utils/time-provider/TimeProvider.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IAEpB,IAAI,EAAE,MAAM,CAAC;IAGb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,8BAAsB,YAAY;IAC9B,gFAAgF;IAChF,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;;IAW7B,QAAQ,CAAC,YAAY,IAAI,SAAS;IAElC,GAAG,IAAI,MAAM;CAahB"}
1
+ {"version":3,"file":"TimeProvider.d.ts","sourceRoot":"","sources":["../../../../src/utils/time-provider/TimeProvider.tsx"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IAEpB,IAAI,EAAE,MAAM,CAAC;IAGb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,8BAAsB,YAAY;IAC9B,gFAAgF;IAChF,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;;IAW7B,QAAQ,CAAC,YAAY,IAAI,SAAS;IAElC,GAAG,IAAI,MAAM;CAoBhB"}
@@ -1,2 +1,2 @@
1
- export declare const version = "3.7.0";
1
+ export declare const version = "3.9.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native",
3
- "version": "3.7.0",
3
+ "version": "3.9.0",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -128,5 +128,5 @@
128
128
  "@datadog/flagging-core": "~2.0.1",
129
129
  "big-integer": "^1.6.52"
130
130
  },
131
- "gitHead": "c9c90f33c7e0fc674dbff0872fa019b01e876c1a"
131
+ "gitHead": "6e8a314dbe755c284d9e882ebf9b03fd008a6967"
132
132
  }
@@ -38,7 +38,7 @@ import { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSinglet
38
38
  import type { Attributes } from './sdk/AttributesSingleton/types';
39
39
  import { registerNativeBridge } from './sdk/DatadogInternalBridge/DdSdkInternalNativeBridge';
40
40
  import { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';
41
- import { NativeDdSdk } from './sdk/DdSdkInternal';
41
+ import { DdSdk } from './sdk/DdSdk';
42
42
  import { GlobalState } from './sdk/GlobalState/GlobalState';
43
43
  import { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';
44
44
  import type { UserInfo } from './sdk/UserInfoSingleton/types';
@@ -86,7 +86,7 @@ export class DdSdkReactNative {
86
86
  SdkVerbosity.WARN
87
87
  );
88
88
  if (!__DEV__) {
89
- NativeDdSdk.telemetryDebug(
89
+ DdSdk.telemetryDebug(
90
90
  'RN SDK was already initialized in javascript'
91
91
  );
92
92
  }
@@ -97,7 +97,7 @@ export class DdSdkReactNative {
97
97
 
98
98
  registerNativeBridge();
99
99
 
100
- await NativeDdSdk.initialize(
100
+ await DdSdk.initialize(
101
101
  DdSdkReactNative.buildConfiguration(configuration, params)
102
102
  );
103
103
 
@@ -218,7 +218,7 @@ export class DdSdkReactNative {
218
218
  `Adding attribute ${JSON.stringify(value)} for key ${key}`,
219
219
  SdkVerbosity.DEBUG
220
220
  );
221
- await NativeDdSdk.addAttribute(key, { value });
221
+ await DdSdk.addAttribute(key, { value });
222
222
  AttributesSingleton.getInstance().addAttribute(key, value);
223
223
  };
224
224
 
@@ -231,7 +231,7 @@ export class DdSdkReactNative {
231
231
  `Removing attribute for key ${key}`,
232
232
  SdkVerbosity.DEBUG
233
233
  );
234
- await NativeDdSdk.removeAttribute(key);
234
+ await DdSdk.removeAttribute(key);
235
235
  AttributesSingleton.getInstance().removeAttribute(key);
236
236
  };
237
237
 
@@ -245,7 +245,7 @@ export class DdSdkReactNative {
245
245
  `Adding attributes ${JSON.stringify(attributes)}`,
246
246
  SdkVerbosity.DEBUG
247
247
  );
248
- await NativeDdSdk.addAttributes(attributes);
248
+ await DdSdk.addAttributes(attributes);
249
249
  AttributesSingleton.getInstance().addAttributes(attributes);
250
250
  };
251
251
 
@@ -258,7 +258,7 @@ export class DdSdkReactNative {
258
258
  `Removing attributes for keys ${JSON.stringify(keys)}`,
259
259
  SdkVerbosity.DEBUG
260
260
  );
261
- await NativeDdSdk.removeAttributes(keys);
261
+ await DdSdk.removeAttributes(keys);
262
262
  AttributesSingleton.getInstance().removeAttributes(keys);
263
263
  };
264
264
 
@@ -285,7 +285,7 @@ export class DdSdkReactNative {
285
285
  SdkVerbosity.DEBUG
286
286
  );
287
287
 
288
- await NativeDdSdk.setUserInfo(userInfo);
288
+ await DdSdk.setUserInfo(userInfo);
289
289
  UserInfoSingleton.getInstance().setUserInfo(userInfo);
290
290
  };
291
291
 
@@ -295,7 +295,7 @@ export class DdSdkReactNative {
295
295
  */
296
296
  static clearUserInfo = async (): Promise<void> => {
297
297
  InternalLog.log('Clearing user info', SdkVerbosity.DEBUG);
298
- await NativeDdSdk.clearUserInfo();
298
+ await DdSdk.clearUserInfo();
299
299
  UserInfoSingleton.getInstance().clearUserInfo();
300
300
  };
301
301
 
@@ -312,7 +312,7 @@ export class DdSdkReactNative {
312
312
  SdkVerbosity.DEBUG
313
313
  );
314
314
 
315
- await NativeDdSdk.addUserExtraInfo(extraUserInfo);
315
+ await DdSdk.addUserExtraInfo(extraUserInfo);
316
316
  UserInfoSingleton.getInstance().addUserExtraInfo(extraUserInfo);
317
317
  };
318
318
 
@@ -333,7 +333,7 @@ export class DdSdkReactNative {
333
333
  SdkVerbosity.DEBUG
334
334
  );
335
335
 
336
- await NativeDdSdk.setAccountInfo(accountInfo);
336
+ await DdSdk.setAccountInfo(accountInfo);
337
337
  AccountInfoSingleton.getInstance().setAccountInfo(accountInfo);
338
338
  };
339
339
 
@@ -343,7 +343,7 @@ export class DdSdkReactNative {
343
343
  */
344
344
  static clearAccountInfo = async (): Promise<void> => {
345
345
  InternalLog.log('Clearing account info', SdkVerbosity.DEBUG);
346
- await NativeDdSdk.clearAccountInfo();
346
+ await DdSdk.clearAccountInfo();
347
347
  AccountInfoSingleton.getInstance().clearAccountInfo();
348
348
  };
349
349
 
@@ -375,7 +375,7 @@ export class DdSdkReactNative {
375
375
  ...extraAccountInfo
376
376
  };
377
377
 
378
- await NativeDdSdk.addAccountExtraInfo(extraInfo);
378
+ await DdSdk.addAccountExtraInfo(extraInfo);
379
379
  AccountInfoSingleton.getInstance().addAccountExtraInfo(
380
380
  extraAccountInfo
381
381
  );
@@ -388,7 +388,7 @@ export class DdSdkReactNative {
388
388
  */
389
389
  static setTrackingConsent = (consent: TrackingConsent): Promise<void> => {
390
390
  InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);
391
- return NativeDdSdk.setTrackingConsent(consent);
391
+ return DdSdk.setTrackingConsent(consent);
392
392
  };
393
393
 
394
394
  /**
@@ -397,7 +397,7 @@ export class DdSdkReactNative {
397
397
  */
398
398
  static clearAllData = (): Promise<void> => {
399
399
  InternalLog.log('Clearing all data', SdkVerbosity.DEBUG);
400
- return NativeDdSdk.clearAllData();
400
+ return DdSdk.clearAllData();
401
401
  };
402
402
 
403
403
  private static buildConfiguration = (
@@ -22,9 +22,10 @@ import { DdRumUserInteractionTracking } from '../rum/instrumentation/interaction
22
22
  import { DdRumResourceTracking } from '../rum/instrumentation/resourceTracking/DdRumResourceTracking';
23
23
  import { PropagatorType, RumActionType } from '../rum/types';
24
24
  import { AttributesSingleton } from '../sdk/AttributesSingleton/AttributesSingleton';
25
- import { NativeDdSdk } from '../sdk/DdSdkInternal';
25
+ import { DdSdkWrapper } from '../sdk/DdSdkInternal';
26
26
  import { GlobalState } from '../sdk/GlobalState/GlobalState';
27
27
  import { UserInfoSingleton } from '../sdk/UserInfoSingleton/UserInfoSingleton';
28
+ import NativeDdSdkSpec from '../specs/NativeDdSdk';
28
29
  import type { LogEvent } from '../types';
29
30
  import { ErrorSource } from '../types';
30
31
  import { version as sdkVersion } from '../version';
@@ -1184,8 +1185,8 @@ describe('DdSdkReactNative', () => {
1184
1185
  await DdSdkReactNative.addAttribute(key, value);
1185
1186
 
1186
1187
  // THEN
1187
- expect(NativeDdSdk.addAttribute).toHaveBeenCalledTimes(1);
1188
- expect(NativeDdSdk.addAttribute).toHaveBeenCalledWith(key, {
1188
+ expect(NativeDdSdkSpec.addAttribute).toHaveBeenCalledTimes(1);
1189
+ expect(NativeDdSdkSpec.addAttribute).toHaveBeenCalledWith(key, {
1189
1190
  value
1190
1191
  });
1191
1192
  expect(AttributesSingleton.getInstance().getAttribute(key)).toEqual(
@@ -1205,8 +1206,8 @@ describe('DdSdkReactNative', () => {
1205
1206
  await DdSdkReactNative.removeAttribute(key);
1206
1207
 
1207
1208
  // THEN
1208
- expect(NativeDdSdk.removeAttribute).toHaveBeenCalledTimes(1);
1209
- expect(NativeDdSdk.removeAttribute).toHaveBeenCalledWith(key);
1209
+ expect(NativeDdSdkSpec.removeAttribute).toHaveBeenCalledTimes(1);
1210
+ expect(NativeDdSdkSpec.removeAttribute).toHaveBeenCalledWith(key);
1210
1211
  expect(AttributesSingleton.getInstance().getAttribute(key)).toEqual(
1211
1212
  undefined
1212
1213
  );
@@ -1223,8 +1224,10 @@ describe('DdSdkReactNative', () => {
1223
1224
  await DdSdkReactNative.addAttributes(attributes);
1224
1225
 
1225
1226
  // THEN
1226
- expect(NativeDdSdk.addAttributes).toHaveBeenCalledTimes(1);
1227
- expect(NativeDdSdk.addAttributes).toHaveBeenCalledWith(attributes);
1227
+ expect(NativeDdSdkSpec.addAttributes).toHaveBeenCalledTimes(1);
1228
+ expect(NativeDdSdkSpec.addAttributes).toHaveBeenCalledWith(
1229
+ attributes
1230
+ );
1228
1231
  expect(AttributesSingleton.getInstance().getAttributes()).toEqual({
1229
1232
  foo: 'bar'
1230
1233
  });
@@ -1241,8 +1244,8 @@ describe('DdSdkReactNative', () => {
1241
1244
  await DdSdkReactNative.removeAttributes(['foo', 'baz']);
1242
1245
 
1243
1246
  // THEN
1244
- expect(NativeDdSdk.removeAttributes).toHaveBeenCalledTimes(1);
1245
- expect(NativeDdSdk.removeAttributes).toHaveBeenCalledWith([
1247
+ expect(NativeDdSdkSpec.removeAttributes).toHaveBeenCalledTimes(1);
1248
+ expect(NativeDdSdkSpec.removeAttributes).toHaveBeenCalledWith([
1246
1249
  'foo',
1247
1250
  'baz'
1248
1251
  ]);
@@ -1268,8 +1271,8 @@ describe('DdSdkReactNative', () => {
1268
1271
  await DdSdkReactNative.setUserInfo(userInfo);
1269
1272
 
1270
1273
  // THEN
1271
- expect(NativeDdSdk.setUserInfo).toHaveBeenCalledTimes(1);
1272
- expect(NativeDdSdk.setUserInfo).toHaveBeenCalledWith(userInfo);
1274
+ expect(NativeDdSdkSpec.setUserInfo).toHaveBeenCalledTimes(1);
1275
+ expect(NativeDdSdkSpec.setUserInfo).toHaveBeenCalledWith(userInfo);
1273
1276
  expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual(
1274
1277
  userInfo
1275
1278
  );
@@ -1289,8 +1292,8 @@ describe('DdSdkReactNative', () => {
1289
1292
  await DdSdkReactNative.addUserExtraInfo(extraInfo);
1290
1293
 
1291
1294
  // THEN
1292
- expect(NativeDdSdk.addUserExtraInfo).toHaveBeenCalledTimes(1);
1293
- expect(NativeDdSdk.addUserExtraInfo).toHaveBeenCalledWith(
1295
+ expect(NativeDdSdkSpec.addUserExtraInfo).toHaveBeenCalledTimes(1);
1296
+ expect(NativeDdSdkSpec.addUserExtraInfo).toHaveBeenCalledWith(
1294
1297
  extraInfo
1295
1298
  );
1296
1299
  expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual({
@@ -1310,7 +1313,7 @@ describe('DdSdkReactNative', () => {
1310
1313
  await DdSdkReactNative.addUserExtraInfo(extraInfo);
1311
1314
 
1312
1315
  // THEN
1313
- expect(NativeDdSdk.addUserExtraInfo).toHaveBeenCalledWith(
1316
+ expect(NativeDdSdkSpec.addUserExtraInfo).toHaveBeenCalledWith(
1314
1317
  extraInfo
1315
1318
  );
1316
1319
  expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual({
@@ -1339,8 +1342,8 @@ describe('DdSdkReactNative', () => {
1339
1342
  await DdSdkReactNative.clearUserInfo();
1340
1343
 
1341
1344
  // THEN
1342
- expect(NativeDdSdk.clearUserInfo).toHaveBeenCalledTimes(1);
1343
- expect(NativeDdSdk.setUserInfo).toHaveBeenCalled();
1345
+ expect(NativeDdSdkSpec.clearUserInfo).toHaveBeenCalledTimes(1);
1346
+ expect(NativeDdSdkSpec.setUserInfo).toHaveBeenCalled();
1344
1347
  expect(
1345
1348
  UserInfoSingleton.getInstance().getUserInfo()
1346
1349
  ).toBeUndefined();
@@ -1357,8 +1360,8 @@ describe('DdSdkReactNative', () => {
1357
1360
  DdSdkReactNative.setTrackingConsent(consent);
1358
1361
 
1359
1362
  // THEN
1360
- expect(NativeDdSdk.setTrackingConsent).toHaveBeenCalledTimes(1);
1361
- expect(NativeDdSdk.setTrackingConsent).toHaveBeenCalledWith(
1363
+ expect(NativeDdSdkSpec.setTrackingConsent).toHaveBeenCalledTimes(1);
1364
+ expect(NativeDdSdkSpec.setTrackingConsent).toHaveBeenCalledWith(
1362
1365
  consent
1363
1366
  );
1364
1367
  });
@@ -1370,7 +1373,7 @@ describe('DdSdkReactNative', () => {
1370
1373
  DdSdkReactNative.clearAllData();
1371
1374
 
1372
1375
  // THEN
1373
- expect(NativeDdSdk.clearAllData).toHaveBeenCalledTimes(1);
1376
+ expect(NativeDdSdkSpec.clearAllData).toHaveBeenCalledTimes(1);
1374
1377
  });
1375
1378
  });
1376
1379
 
@@ -1500,4 +1503,121 @@ describe('DdSdkReactNative', () => {
1500
1503
  });
1501
1504
  }
1502
1505
  );
1506
+ describe('routing through DdSdkWrapper', () => {
1507
+ it('DdSdkReactNative.addAttribute reaches the native spec via the wrapper', async () => {
1508
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'addAttribute');
1509
+
1510
+ await DdSdkReactNative.addAttribute('key', 'value');
1511
+
1512
+ expect(spy).toHaveBeenCalled();
1513
+ spy.mockRestore();
1514
+ });
1515
+
1516
+ it('DdSdkReactNative.removeAttribute reaches the native spec via the wrapper', async () => {
1517
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'removeAttribute');
1518
+
1519
+ await DdSdkReactNative.removeAttribute('key');
1520
+
1521
+ expect(spy).toHaveBeenCalled();
1522
+ spy.mockRestore();
1523
+ });
1524
+
1525
+ it('DdSdkReactNative.addAttributes reaches the native spec via the wrapper', async () => {
1526
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'addAttributes');
1527
+
1528
+ await DdSdkReactNative.addAttributes({ key: 'value' });
1529
+
1530
+ expect(spy).toHaveBeenCalled();
1531
+ spy.mockRestore();
1532
+ });
1533
+
1534
+ it('DdSdkReactNative.removeAttributes reaches the native spec via the wrapper', async () => {
1535
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'removeAttributes');
1536
+
1537
+ await DdSdkReactNative.removeAttributes(['key']);
1538
+
1539
+ expect(spy).toHaveBeenCalled();
1540
+ spy.mockRestore();
1541
+ });
1542
+
1543
+ it('DdSdkReactNative.setUserInfo reaches the native spec via the wrapper', async () => {
1544
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'setUserInfo');
1545
+
1546
+ await DdSdkReactNative.setUserInfo({ id: 'user-id' });
1547
+
1548
+ expect(spy).toHaveBeenCalled();
1549
+ spy.mockRestore();
1550
+ });
1551
+
1552
+ it('DdSdkReactNative.clearUserInfo reaches the native spec via the wrapper', async () => {
1553
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'clearUserInfo');
1554
+
1555
+ await DdSdkReactNative.clearUserInfo();
1556
+
1557
+ expect(spy).toHaveBeenCalled();
1558
+ spy.mockRestore();
1559
+ });
1560
+
1561
+ it('DdSdkReactNative.addUserExtraInfo reaches the native spec via the wrapper', async () => {
1562
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'addUserExtraInfo');
1563
+
1564
+ await DdSdkReactNative.addUserExtraInfo({ role: 'admin' });
1565
+
1566
+ expect(spy).toHaveBeenCalled();
1567
+ spy.mockRestore();
1568
+ });
1569
+
1570
+ it('DdSdkReactNative.setAccountInfo reaches the native spec via the wrapper', async () => {
1571
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'setAccountInfo');
1572
+
1573
+ await DdSdkReactNative.setAccountInfo({ id: 'account-id' });
1574
+
1575
+ expect(spy).toHaveBeenCalled();
1576
+ spy.mockRestore();
1577
+ });
1578
+
1579
+ it('DdSdkReactNative.clearAccountInfo reaches the native spec via the wrapper', async () => {
1580
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'clearAccountInfo');
1581
+
1582
+ await DdSdkReactNative.clearAccountInfo();
1583
+
1584
+ expect(spy).toHaveBeenCalled();
1585
+ spy.mockRestore();
1586
+ });
1587
+
1588
+ it('DdSdkReactNative.addAccountExtraInfo reaches the native spec via the wrapper', async () => {
1589
+ // addAccountExtraInfo bails out early unless an account ID is set.
1590
+ await DdSdkReactNative.setAccountInfo({ id: 'account-id' });
1591
+ const spy = jest.spyOn(
1592
+ DdSdkWrapper.prototype,
1593
+ 'addAccountExtraInfo'
1594
+ );
1595
+
1596
+ await DdSdkReactNative.addAccountExtraInfo({ tier: 'premium' });
1597
+
1598
+ expect(spy).toHaveBeenCalled();
1599
+ spy.mockRestore();
1600
+ });
1601
+
1602
+ it('DdSdkReactNative.setTrackingConsent reaches the native spec via the wrapper', async () => {
1603
+ const spy = jest.spyOn(
1604
+ DdSdkWrapper.prototype,
1605
+ 'setTrackingConsent'
1606
+ );
1607
+
1608
+ await DdSdkReactNative.setTrackingConsent(TrackingConsent.GRANTED);
1609
+
1610
+ expect(spy).toHaveBeenCalled();
1611
+ spy.mockRestore();
1612
+ });
1613
+
1614
+ it('DdSdkReactNative.clearAllData reaches the native spec via the wrapper', async () => {
1615
+ const spy = jest.spyOn(DdSdkWrapper.prototype, 'clearAllData');
1616
+
1617
+ await DdSdkReactNative.clearAllData();
1618
+
1619
+ expect(spy).toHaveBeenCalled();
1620
+ spy.mockRestore();
1621
+ });
1622
+ });
1503
1623
  });
@@ -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
  });
@@ -4,6 +4,8 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
+ import { InternalLog } from '../../InternalLog';
8
+ import { SdkVerbosity } from '../../config/types/SdkVerbosity';
7
9
  import { processEvaluationContext } from '../internal';
8
10
 
9
11
  jest.mock('../../InternalLog', () => {
@@ -14,6 +16,43 @@ jest.mock('../../InternalLog', () => {
14
16
  });
15
17
 
16
18
  describe('processEvaluationContext', () => {
19
+ beforeEach(() => {
20
+ jest.clearAllMocks();
21
+ });
22
+
23
+ it.each(['user-1', ''])(
24
+ 'preserves the string targeting key %p without a warning',
25
+ targetingKey => {
26
+ expect(processEvaluationContext({ targetingKey })).toStrictEqual({
27
+ targetingKey,
28
+ attributes: {}
29
+ });
30
+ expect(InternalLog.log).not.toHaveBeenCalled();
31
+ }
32
+ );
33
+
34
+ it.each([42, true, false, null, undefined, {}, []])(
35
+ 'uses the anonymous subject for a non-string final targeting key %p',
36
+ targetingKey => {
37
+ // JavaScript callers can provide values outside the TypeScript contract.
38
+ const context = {
39
+ targetingKey: targetingKey as never,
40
+ attributes: { plan: 'pro' }
41
+ };
42
+
43
+ expect(processEvaluationContext(context)).toStrictEqual({
44
+ targetingKey: '',
45
+ attributes: { plan: 'pro' }
46
+ });
47
+ expect(context.targetingKey).toBe(targetingKey);
48
+ expect(InternalLog.log).toHaveBeenCalledTimes(1);
49
+ expect(InternalLog.log).toHaveBeenCalledWith(
50
+ "The evaluation context targetingKey is not a string. Using the anonymous subject ('') instead.",
51
+ SdkVerbosity.WARN
52
+ );
53
+ }
54
+ );
55
+
17
56
  it('keeps primitive attributes and drops non-primitive ones', () => {
18
57
  expect(
19
58
  processEvaluationContext({