@datadog/mobile-react-native 3.3.0 → 3.5.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 (112) hide show
  1. package/DatadogSDKReactNative.podspec +7 -7
  2. package/android/build.gradle +7 -7
  3. package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +4 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +13 -5
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +14 -6
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkSessionStartedListener.kt +93 -22
  7. package/android/src/main/kotlin/com/datadog/reactnative/FrameRateProvider.kt +16 -8
  8. package/android/src/main/kotlin/com/datadog/reactnative/JsThreadExecutor.kt +27 -0
  9. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  10. package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +5 -1
  11. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +5 -1
  12. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +9 -1
  13. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +68 -0
  14. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkSessionStartedListenerTest.kt +38 -1
  15. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +63 -5
  16. package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +25 -0
  17. package/android/src/test/kotlin/com/datadog/tools/unit/TestJsThreadExecutor.kt +16 -0
  18. package/ios/Sources/DdRum.mm +6 -4
  19. package/ios/Sources/DdRumImplementation.swift +82 -7
  20. package/ios/Sources/DdSdkNativeInitialization.swift +24 -17
  21. package/ios/Sources/DdSdkSessionStartedListener.swift +28 -1
  22. package/ios/Sources/RNDdSdkConfiguration.swift +2 -0
  23. package/ios/Sources/RNViewResolution.swift +88 -0
  24. package/ios/Sources/RUMMonitorInternalProtocol.swift +8 -0
  25. package/ios/Sources/SdkVersion.swift +1 -1
  26. package/lib/commonjs/DdSdkReactNative.js +25 -21
  27. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  28. package/lib/commonjs/config/DatadogProviderConfiguration.js +3 -1
  29. package/lib/commonjs/config/DatadogProviderConfiguration.js.map +1 -1
  30. package/lib/commonjs/metro/debugIdResolver.js +5 -3
  31. package/lib/commonjs/metro/debugIdResolver.js.map +1 -1
  32. package/lib/commonjs/metro/plugin/metroSerializer.js +4 -3
  33. package/lib/commonjs/metro/plugin/metroSerializer.js.map +1 -1
  34. package/lib/commonjs/rum/DdRum.js +14 -1
  35. package/lib/commonjs/rum/DdRum.js.map +1 -1
  36. package/lib/commonjs/rum/eventMappers/actionEventMapper.js.map +1 -1
  37. package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +1 -1
  38. package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
  39. package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js +6 -1
  40. package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
  41. package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.js +13 -1
  42. package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.js.map +1 -1
  43. package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
  44. package/lib/commonjs/types.js.map +1 -1
  45. package/lib/commonjs/version.js +1 -1
  46. package/lib/module/DdSdkReactNative.js +25 -21
  47. package/lib/module/DdSdkReactNative.js.map +1 -1
  48. package/lib/module/config/DatadogProviderConfiguration.js +3 -1
  49. package/lib/module/config/DatadogProviderConfiguration.js.map +1 -1
  50. package/lib/module/metro/debugIdResolver.js +5 -3
  51. package/lib/module/metro/debugIdResolver.js.map +1 -1
  52. package/lib/module/metro/plugin/metroSerializer.js +4 -3
  53. package/lib/module/metro/plugin/metroSerializer.js.map +1 -1
  54. package/lib/module/rum/DdRum.js +14 -1
  55. package/lib/module/rum/DdRum.js.map +1 -1
  56. package/lib/module/rum/eventMappers/actionEventMapper.js.map +1 -1
  57. package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +1 -1
  58. package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
  59. package/lib/module/sdk/AttributesEncoding/defaultEncoders.js +6 -1
  60. package/lib/module/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
  61. package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.js +13 -1
  62. package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.js.map +1 -1
  63. package/lib/module/specs/NativeDdRum.js.map +1 -1
  64. package/lib/module/types.js.map +1 -1
  65. package/lib/module/version.js +1 -1
  66. package/lib/typescript/DdSdkReactNative.d.ts +6 -9
  67. package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
  68. package/lib/typescript/config/DatadogProviderConfiguration.d.ts +3 -1
  69. package/lib/typescript/config/DatadogProviderConfiguration.d.ts.map +1 -1
  70. package/lib/typescript/metro/debugIdResolver.d.ts.map +1 -1
  71. package/lib/typescript/metro/plugin/metroSerializer.d.ts +1 -1
  72. package/lib/typescript/metro/plugin/metroSerializer.d.ts.map +1 -1
  73. package/lib/typescript/nativeModulesTypes.d.ts +2 -1
  74. package/lib/typescript/nativeModulesTypes.d.ts.map +1 -1
  75. package/lib/typescript/rum/DdRum.d.ts.map +1 -1
  76. package/lib/typescript/rum/eventMappers/actionEventMapper.d.ts +1 -0
  77. package/lib/typescript/rum/eventMappers/actionEventMapper.d.ts.map +1 -1
  78. package/lib/typescript/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts.map +1 -1
  79. package/lib/typescript/sdk/AttributesEncoding/defaultEncoders.d.ts.map +1 -1
  80. package/lib/typescript/sdk/UserInfoSingleton/UserInfoSingleton.d.ts +4 -1
  81. package/lib/typescript/sdk/UserInfoSingleton/UserInfoSingleton.d.ts.map +1 -1
  82. package/lib/typescript/sdk/UserInfoSingleton/types.d.ts +1 -1
  83. package/lib/typescript/sdk/UserInfoSingleton/types.d.ts.map +1 -1
  84. package/lib/typescript/specs/NativeDdRum.d.ts +2 -1
  85. package/lib/typescript/specs/NativeDdRum.d.ts.map +1 -1
  86. package/lib/typescript/types.d.ts +8 -7
  87. package/lib/typescript/types.d.ts.map +1 -1
  88. package/lib/typescript/version.d.ts +1 -1
  89. package/package.json +2 -2
  90. package/src/DdSdkReactNative.tsx +35 -31
  91. package/src/__tests__/DdSdkReactNative.test.tsx +22 -3
  92. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +8 -0
  93. package/src/config/DatadogProviderConfiguration.ts +3 -1
  94. package/src/metro/__tests__/metro.test.ts +13 -0
  95. package/src/metro/debugIdResolver.ts +7 -3
  96. package/src/metro/plugin/metroSerializer.ts +11 -3
  97. package/src/nativeModulesTypes.ts +2 -0
  98. package/src/rum/DdRum.ts +25 -0
  99. package/src/rum/__tests__/DdRum.test.ts +33 -0
  100. package/src/rum/eventMappers/actionEventMapper.ts +1 -0
  101. package/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.ts +2 -1
  102. package/src/rum/instrumentation/interactionTracking/__tests__/DdBabelInteractionTracking.test.ts +28 -0
  103. package/src/sdk/AttributesEncoding/__tests__/defaultEncoders.test.ts +25 -1
  104. package/src/sdk/AttributesEncoding/defaultEncoders.ts +11 -1
  105. package/src/sdk/DatadogProvider/__tests__/__utils__/renderWithProvider.tsx +24 -7
  106. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +19 -15
  107. package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +85 -54
  108. package/src/sdk/UserInfoSingleton/UserInfoSingleton.ts +15 -2
  109. package/src/sdk/UserInfoSingleton/types.ts +1 -1
  110. package/src/specs/NativeDdRum.ts +2 -0
  111. package/src/types.tsx +6 -7
  112. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"UserInfoSingleton.d.ts","sourceRoot":"","sources":["../../../../src/sdk/UserInfoSingleton/UserInfoSingleton.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,cAAM,gBAAgB;IAClB,OAAO,CAAC,QAAQ,CAAmC;IAEnD,WAAW,aAAc,QAAQ,UAG/B;IAEF,WAAW,QAAO,QAAQ,GAAG,SAAS,CAEpC;IAEF,aAAa,aAEX;CACL;AAED,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAA0B;IAEzD,MAAM,CAAC,WAAW,QAAO,gBAAgB,CAEvC;IAEF,MAAM,CAAC,KAAK,aAEV;CACL"}
1
+ {"version":3,"file":"UserInfoSingleton.d.ts","sourceRoot":"","sources":["../../../../src/sdk/UserInfoSingleton/UserInfoSingleton.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,cAAM,gBAAgB;IAClB,OAAO,CAAC,QAAQ,CAAmC;IAEnD,WAAW,aAAc,QAAQ,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,UAMhD;IAEF,gBAAgB,cAAe,OAAO,MAAM,EAAE,OAAO,CAAC,UAQpD;IAEF,WAAW,QAAO,QAAQ,GAAG,SAAS,CAEpC;IAEF,aAAa,aAEX;CACL;AAED,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAA0B;IAEzD,MAAM,CAAC,WAAW,QAAO,gBAAgB,CAEvC;IAEF,MAAM,CAAC,KAAK,aAEV;CACL"}
@@ -1,5 +1,5 @@
1
1
  export type UserInfo = {
2
- readonly id: string;
2
+ readonly id?: string;
3
3
  readonly name?: string;
4
4
  readonly email?: string;
5
5
  readonly extraInfo?: Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/sdk/UserInfoSingleton/types.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChD,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/sdk/UserInfoSingleton/types.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG;IACnB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChD,CAAC"}
@@ -39,10 +39,11 @@ export interface Spec extends TurboModule {
39
39
  * Add a RUM Action.
40
40
  * @param type: The action type (tap, scroll, swipe, back, custom).
41
41
  * @param name: The action name.
42
+ * @param touch: The native touch data for tap actions, or null for other action types.
42
43
  * @param context: The additional context to send.
43
44
  * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
44
45
  */
45
- addAction(type: string, name: string, context: Object, timestampMs: number): Promise<void>;
46
+ addAction(type: string, name: string, touch: Object | null, context: Object, timestampMs: number): Promise<void>;
46
47
  /**
47
48
  * Start tracking a RUM Resource.
48
49
  * @param key: The resource unique key identifier.
@@ -1 +1 @@
1
- {"version":3,"file":"NativeDdRum.d.ts","sourceRoot":"","sources":["../../../src/specs/NativeDdRum.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD;;GAEG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IACrC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,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B;;;;;OAKG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErE;;OAEG;IACH,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEnD;;;;;OAKG;IACH,qBAAqB,CACjB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;;OAMG;IACH,uBAAuB,CACnB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;;;OAOG;IACH,oBAAoB,CAChB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB;;AAGD,wBAAsD"}
@@ -33,13 +33,14 @@ export type DdSdkType = {
33
33
  */
34
34
  removeAttributes(keys: string[]): Promise<void>;
35
35
  /**
36
- * Sets the user information.
37
- * @param id: A unique user identifier (relevant to your business domain)
38
- * @param name: The user name or alias.
39
- * @param email: The user email.
40
- * @param extraInfo: Additional information.
36
+ * Sets the user information. Requires a user ID — setting user properties
37
+ * like name or email implies a known user, so an ID must be provided.
38
+ * To add custom attributes without setting a user ID, use {@link addUserExtraInfo} instead.
39
+ * @param userInfo: The user object (id is required, name, email and extraInfo are optional).
41
40
  */
42
- setUserInfo(userInfo: UserInfo): Promise<void>;
41
+ setUserInfo(userInfo: UserInfo & {
42
+ id: string;
43
+ }): Promise<void>;
43
44
  /**
44
45
  * Clears the user information.
45
46
  */
@@ -91,7 +92,7 @@ export type DdTraceType = {
91
92
  finishSpan(spanId: string, context?: object, timestampMs?: number): Promise<void>;
92
93
  };
93
94
  export type UserInfo = {
94
- id: string;
95
+ id?: string;
95
96
  name?: string;
96
97
  email?: string;
97
98
  extraInfo?: object;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAE1F,OAAO,CAAC,MAAM,CAAC;IAEX,IAAI,8BAA8B,EAAE,OAAO,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACpB;;;OAGG;IACH,UAAU,CAAC,aAAa,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnE;;;;OAIG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD;;;OAGG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD;;;;;;OAMG;IACH,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/B;;;OAGG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;;;;OAKG;IACH,cAAc,C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MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5D,MAAM,MAAM,QAAQ,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAE9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,QAAQ,GAAG,IAAI,CAAC;AAGrE,oBAAY,WAAW;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;CACpB;AAED,oBAAY,uBAAuB;IAC/B,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,KAAK,UAAU;CAClB"}
@@ -1,2 +1,2 @@
1
- export declare const version = "3.3.0";
1
+ export declare const version = "3.5.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.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -118,5 +118,5 @@
118
118
  "dependencies": {
119
119
  "big-integer": "^1.6.52"
120
120
  },
121
- "gitHead": "050502227beb4dd48ea3442bd5aa3eb89c85ee19"
121
+ "gitHead": "aaad2111194cfb651230f8c7089d681674a12c81"
122
122
  }
@@ -41,6 +41,7 @@ import { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';
41
41
  import { NativeDdSdk } from './sdk/DdSdkInternal';
42
42
  import { GlobalState } from './sdk/GlobalState/GlobalState';
43
43
  import { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';
44
+ import type { UserInfo } from './sdk/UserInfoSingleton/types';
44
45
  import { adaptLongTaskThreshold } from './utils/longTasksUtils';
45
46
  import { version as sdkVersion } from './version';
46
47
 
@@ -123,10 +124,26 @@ export class DdSdkReactNative {
123
124
  });
124
125
  }
125
126
  if (configuration.initializationMode === InitializationMode.ASYNC) {
126
- return InteractionManager.runAfterInteractions(() => {
127
- return DdSdkReactNative.initializeNativeSDK(configuration, {
127
+ const initNative = () =>
128
+ DdSdkReactNative.initializeNativeSDK(configuration, {
128
129
  initializationModeForTelemetry: 'ASYNC'
129
130
  });
131
+
132
+ // We rely on requestIdleCallback for RN >= 0.76 to make sure that the SDK initialization
133
+ // happens after rendering has finished
134
+ if ((globalThis as Record<string, unknown>).requestIdleCallback) {
135
+ return new Promise<void>((resolve, reject) => {
136
+ ((globalThis as unknown) as {
137
+ requestIdleCallback: (cb: () => void) => void;
138
+ }).requestIdleCallback(() => {
139
+ initNative().then(resolve, reject);
140
+ });
141
+ });
142
+ }
143
+
144
+ // On RN below 0.76 we use runAfterInteractions, which initializes the SDK after animations are done
145
+ return InteractionManager.runAfterInteractions(() => {
146
+ return initNative();
130
147
  });
131
148
  }
132
149
  // TODO: Remove when DdSdkReactNativeConfiguration is deprecated
@@ -235,19 +252,23 @@ export class DdSdkReactNative {
235
252
  };
236
253
 
237
254
  /**
238
- * Sets the user information.
239
- * @param id: A mandatory unique user identifier (relevant to your business domain).
240
- * @param name: The user name or alias.
241
- * @param email: The user email.
242
- * @param extraInfo: Additional information.
255
+ * Sets the user information. Requires a user ID — setting user properties
256
+ * like name or email implies a known user, so an ID must be provided.
257
+ * To add custom attributes without setting a user ID, use {@link addUserExtraInfo} instead.
258
+ * @param userInfo: The user object (id is required, name, email and extraInfo are optional).
243
259
  * @returns a Promise.
244
260
  */
245
- static setUserInfo = async (userInfo: {
246
- id: string;
247
- name?: string;
248
- email?: string;
249
- extraInfo?: Record<string, unknown>;
250
- }): Promise<void> => {
261
+ static setUserInfo = async (
262
+ userInfo: UserInfo & { id: string }
263
+ ): Promise<void> => {
264
+ if (typeof userInfo.id !== 'string' || userInfo.id.length === 0) {
265
+ InternalLog.log(
266
+ 'setUserInfo requires a valid user ID. Please provide a non-empty string as the id field.',
267
+ SdkVerbosity.WARN
268
+ );
269
+ return;
270
+ }
271
+
251
272
  InternalLog.log(
252
273
  `Setting user ${JSON.stringify(userInfo)}`,
253
274
  SdkVerbosity.DEBUG
@@ -280,25 +301,8 @@ export class DdSdkReactNative {
280
301
  SdkVerbosity.DEBUG
281
302
  );
282
303
 
283
- const userInfo = UserInfoSingleton.getInstance().getUserInfo();
284
- if (!userInfo) {
285
- InternalLog.log(
286
- 'Skipped adding User Extra Info: User Info is currently undefined. A user ID must be set before adding extra info. Please call setUserInfo() first.',
287
- SdkVerbosity.WARN
288
- );
289
-
290
- return;
291
- }
292
- const updatedUserInfo = {
293
- ...userInfo,
294
- extraInfo: {
295
- ...userInfo.extraInfo,
296
- ...extraUserInfo
297
- }
298
- };
299
-
300
304
  await NativeDdSdk.addUserExtraInfo(extraUserInfo);
301
- UserInfoSingleton.getInstance().setUserInfo(updatedUserInfo);
305
+ UserInfoSingleton.getInstance().addUserExtraInfo(extraUserInfo);
302
306
  };
303
307
 
304
308
  /**
@@ -885,6 +885,7 @@ describe('DdSdkReactNative', () => {
885
885
  expect(NativeModules.DdRum.addAction).toHaveBeenCalledWith(
886
886
  'CUSTOM',
887
887
  'Click on button',
888
+ null,
888
889
  {
889
890
  body: 'content'
890
891
  },
@@ -1297,6 +1298,24 @@ describe('DdSdkReactNative', () => {
1297
1298
  }
1298
1299
  });
1299
1300
  });
1301
+
1302
+ it('calls SDK method when addUserExtraInfo without prior setUserInfo', async () => {
1303
+ // GIVEN
1304
+ const extraInfo = { testId: 'abc123' };
1305
+
1306
+ // WHEN
1307
+ await DdSdkReactNative.addUserExtraInfo(extraInfo);
1308
+
1309
+ // THEN
1310
+ expect(NativeDdSdk.addUserExtraInfo).toHaveBeenCalledWith(
1311
+ extraInfo
1312
+ );
1313
+ expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual({
1314
+ extraInfo: {
1315
+ testId: 'abc123'
1316
+ }
1317
+ });
1318
+ });
1300
1319
  });
1301
1320
 
1302
1321
  describe('clearUserInfo', () => {
@@ -1319,9 +1338,9 @@ describe('DdSdkReactNative', () => {
1319
1338
  // THEN
1320
1339
  expect(NativeDdSdk.clearUserInfo).toHaveBeenCalledTimes(1);
1321
1340
  expect(NativeDdSdk.setUserInfo).toHaveBeenCalled();
1322
- expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual(
1323
- undefined
1324
- );
1341
+ expect(
1342
+ UserInfoSingleton.getInstance().getUserInfo()
1343
+ ).toBeUndefined();
1325
1344
  });
1326
1345
  });
1327
1346
 
@@ -73,6 +73,7 @@ it('M intercept and send a RUM event W onPress { Button component }', async () =
73
73
  expect(DdRum.addAction).toBeCalledWith(
74
74
  'TAP',
75
75
  'click_me_button',
76
+ null,
76
77
  expect.anything(),
77
78
  expect.anything()
78
79
  );
@@ -105,6 +106,7 @@ it('M intercept and send a RUM event with elementType W onPress { Button compone
105
106
  expect(DdRum.addAction).toBeCalledWith(
106
107
  'TAP',
107
108
  'test_element_type',
109
+ null,
108
110
  expect.anything(),
109
111
  expect.anything()
110
112
  );
@@ -136,6 +138,7 @@ it('M intercept and send a RUM event W onPress { custom action name prop used }'
136
138
  expect(DdRum.addAction).toBeCalledWith(
137
139
  'TAP',
138
140
  'click_me_test_ID',
141
+ null,
139
142
  expect.anything(),
140
143
  expect.anything()
141
144
  );
@@ -166,6 +169,7 @@ it('M intercept only once W startTracking { called multiple times }', async () =
166
169
  expect(DdRum.addAction).toBeCalledWith(
167
170
  'TAP',
168
171
  'click_me_button',
172
+ null,
169
173
  expect.anything(),
170
174
  expect.anything()
171
175
  );
@@ -196,6 +200,7 @@ it('M intercept and send a RUM event W onPress { TouchableOpacity component }',
196
200
  expect(DdRum.addAction).toBeCalledWith(
197
201
  'TAP',
198
202
  'click_me_button',
203
+ null,
199
204
  expect.anything(),
200
205
  expect.anything()
201
206
  );
@@ -228,6 +233,7 @@ it('M intercept and send a RUM event W onPress { TouchableHighlight component }'
228
233
  expect(DdRum.addAction).toBeCalledWith(
229
234
  'TAP',
230
235
  'click_me_button',
236
+ null,
231
237
  expect.anything(),
232
238
  expect.anything()
233
239
  );
@@ -260,6 +266,7 @@ it('M intercept and send a RUM event W onPress { TouchableNativeFeedback compone
260
266
  expect(DdRum.addAction).toBeCalledWith(
261
267
  'TAP',
262
268
  'click_me_button',
269
+ null,
263
270
  expect.anything(),
264
271
  expect.anything()
265
272
  );
@@ -292,6 +299,7 @@ it('M intercept and send a RUM event W onPress { TouchableWithoutFeedback compon
292
299
  expect(DdRum.addAction).toBeCalledWith(
293
300
  'TAP',
294
301
  'click_me_button',
302
+ null,
295
303
  expect.anything(),
296
304
  expect.anything()
297
305
  );
@@ -11,7 +11,9 @@ import { InitializationMode } from './types';
11
11
  */
12
12
  export class DatadogProviderConfiguration extends CoreConfiguration {
13
13
  /**
14
- * If set to ASYNC, the initialization will be delayed until all animations are completed.
14
+ * If set to ASYNC, the native initialization will run when the
15
+ * main thread is idle (via `requestIdleCallback` on RN >= 0.76, or
16
+ * `InteractionManager.runAfterInteractions` on earlier versions)
15
17
  */
16
18
  public initializationMode: InitializationMode = InitializationMode.SYNC;
17
19
  }
@@ -32,6 +32,19 @@ describe('Datadog Metro Plugin', () => {
32
32
  });
33
33
 
34
34
  describe('Datadog Metro Serializer', () => {
35
+ test('skips debug ID injection for web platform builds', async () => {
36
+ const serializer = createDatadogMetroSerializer();
37
+ const args = mockSerializerArgsForEmptyModule();
38
+ // Set platform to 'web'
39
+ (args[2] as any).transformOptions.platform = 'web';
40
+
41
+ const bundle = await serializer(...args);
42
+ const { code } = await convertSerializerOutput(bundle);
43
+ // Web builds should not contain debug ID injection
44
+ expect(code).not.toContain('debugId');
45
+ expect(code).not.toContain('_datadogDebugIds');
46
+ });
47
+
35
48
  test('generates bundle and source map with UUID v5 Debug ID', async () => {
36
49
  const codeSnippetHash = createHash('md5');
37
50
  codeSnippetHash.update(DEBUG_ID_CODE_SNIPPET);
@@ -14,10 +14,14 @@ function loadDebugId() {
14
14
  if (typeof globalThis === 'undefined') {
15
15
  return;
16
16
  }
17
+
18
+ const shouldWarn = process.env.NODE_ENV !== 'test' && __DEV__ !== true;
17
19
  try {
18
20
  const debugIds = (globalThis as any)._datadogDebugIds;
19
- if (!debugIds || Object.keys(debugIds).length === 0) {
20
- if (process.env.NODE_ENV !== 'test') {
21
+ const hasDebugId = debugIds && Object.keys(debugIds).length > 0;
22
+
23
+ if (!hasDebugId) {
24
+ if (shouldWarn) {
21
25
  console.warn(
22
26
  '[Datadog SDK] Debug ID not found. Are you using @datadog/mobile-react-native/metro config?'
23
27
  );
@@ -27,7 +31,7 @@ function loadDebugId() {
27
31
 
28
32
  debugId = debugIds[Object.keys(debugIds)[0]];
29
33
  } catch (error) {
30
- if (process.env.NODE_ENV !== 'test') {
34
+ if (shouldWarn) {
31
35
  console.warn(
32
36
  '[Datadog SDK] Error while retrieving Debug ID. Are you using @datadog/mobile-react-native/metro config?'
33
37
  );
@@ -45,8 +45,11 @@ export const createDatadogMetroSerializer = (
45
45
  ): DatadogMetroSerializer => {
46
46
  const serializer = customSerializer || createDefaultMetroSerializer();
47
47
  return async (entryPoint, preModules, graph, options) => {
48
- // Skip for hot reload mode
49
- if ((graph.transformOptions as any).hot) {
48
+ // Skip for hot reload mode and web builds
49
+ if (
50
+ (graph.transformOptions as any).hot ||
51
+ graph.transformOptions.platform === 'web'
52
+ ) {
50
53
  return serializer(entryPoint, preModules, graph, options);
51
54
  }
52
55
 
@@ -158,6 +161,7 @@ export const createDatadogBundleCallback = (
158
161
  * Adds Debug ID module for runtime injection, used for Expo.
159
162
  */
160
163
  export function unstable_beforeAssetSerializationPlugin({
164
+ graph,
161
165
  premodules,
162
166
  debugId
163
167
  }: {
@@ -165,7 +169,11 @@ export function unstable_beforeAssetSerializationPlugin({
165
169
  premodules: Module[];
166
170
  debugId?: string;
167
171
  }): Module[] {
168
- if (!debugId || checkIfDebugIdModuleExists(premodules)) {
172
+ if (
173
+ graph.transformOptions.platform === 'web' ||
174
+ !debugId ||
175
+ checkIfDebugIdModuleExists(premodules)
176
+ ) {
169
177
  return premodules;
170
178
  }
171
179
  return [...addDebugIdModule(premodules, createDebugIdModule(debugId))];
@@ -95,12 +95,14 @@ export interface DdNativeRumType extends NativeDdRum {
95
95
  * Add a RUM Action.
96
96
  * @param type: The action type (tap, scroll, swipe, back, custom).
97
97
  * @param name: The action name.
98
+ * @param touch: The native touch data for tap actions, or null for other action types.
98
99
  * @param context: The additional context to send.
99
100
  * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
100
101
  */
101
102
  addAction(
102
103
  type: ActionType,
103
104
  name: string,
105
+ touch: object | null,
104
106
  context: object,
105
107
  timestampMs: number
106
108
  ): Promise<void>;
package/src/rum/DdRum.ts CHANGED
@@ -52,6 +52,30 @@ const RUM_MODULE = 'com.datadog.reactnative.rum';
52
52
 
53
53
  const generateEmptyPromise = () => new Promise<void>(resolve => resolve());
54
54
 
55
+ type TouchData = {
56
+ reactTag: number;
57
+ x: number;
58
+ y: number;
59
+ pageX: number;
60
+ pageY: number;
61
+ };
62
+
63
+ const touchDataFromEvent = (
64
+ event?: GestureResponderEvent
65
+ ): TouchData | null => {
66
+ const nativeEvent = event?.nativeEvent;
67
+ if (!nativeEvent) {
68
+ return null;
69
+ }
70
+ return {
71
+ reactTag: Number(nativeEvent.target),
72
+ x: nativeEvent.locationX,
73
+ y: nativeEvent.locationY,
74
+ pageX: nativeEvent.pageX,
75
+ pageY: nativeEvent.pageY
76
+ };
77
+ };
78
+
55
79
  class DdRumWrapper implements DdRumType {
56
80
  // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
57
81
  private nativeRum: DdNativeRumType = require('../specs/NativeDdRum')
@@ -215,6 +239,7 @@ class DdRumWrapper implements DdRumType {
215
239
  this.nativeRum.addAction(
216
240
  mappedEvent.type,
217
241
  mappedEvent.name,
242
+ touchDataFromEvent(mappedEvent.actionContext),
218
243
  encodeAttributes(mappedEvent.context),
219
244
  mappedEvent.timestampMs
220
245
  )
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import { NativeModules } from 'react-native';
9
+ import type { GestureResponderEvent } from 'react-native';
9
10
 
10
11
  import { InternalLog } from '../../InternalLog';
11
12
  import { SdkVerbosity } from '../../config/types';
@@ -1285,6 +1286,7 @@ describe('DdRum', () => {
1285
1286
  expect(NativeModules.DdRum.addAction).toHaveBeenCalledWith(
1286
1287
  expect.anything(),
1287
1288
  expect.anything(),
1289
+ null,
1288
1290
  context,
1289
1291
  expect.anything()
1290
1292
  );
@@ -1303,6 +1305,7 @@ describe('DdRum', () => {
1303
1305
  expect(NativeModules.DdRum.addAction).toHaveBeenCalledWith(
1304
1306
  expect.anything(),
1305
1307
  expect.anything(),
1308
+ null,
1306
1309
  {},
1307
1310
  expect.anything()
1308
1311
  );
@@ -1321,6 +1324,7 @@ describe('DdRum', () => {
1321
1324
  expect(NativeModules.DdRum.addAction).toHaveBeenCalledWith(
1322
1325
  expect.anything(),
1323
1326
  expect.anything(),
1327
+ null,
1324
1328
  { context },
1325
1329
  expect.anything()
1326
1330
  );
@@ -1704,6 +1708,34 @@ describe('DdRum', () => {
1704
1708
  });
1705
1709
 
1706
1710
  describe('DdRum.addAction', () => {
1711
+ it('passes touch data from GestureResponderEvent to native module', async () => {
1712
+ const event = ({
1713
+ nativeEvent: {
1714
+ target: 42,
1715
+ locationX: 10,
1716
+ locationY: 20,
1717
+ pageX: 100,
1718
+ pageY: 200
1719
+ }
1720
+ } as unknown) as GestureResponderEvent;
1721
+
1722
+ await DdRum.addAction(
1723
+ RumActionType.TAP,
1724
+ 'tap button',
1725
+ {},
1726
+ undefined,
1727
+ event
1728
+ );
1729
+
1730
+ expect(NativeModules.DdRum.addAction).toHaveBeenCalledWith(
1731
+ 'TAP',
1732
+ 'tap button',
1733
+ { reactTag: 42, x: 10, y: 20, pageX: 100, pageY: 200 },
1734
+ {},
1735
+ expect.anything()
1736
+ );
1737
+ });
1738
+
1707
1739
  it('registers event mapper and maps action', async () => {
1708
1740
  const actionEventMapper: ActionEventMapper = action => {
1709
1741
  action.context = { frustration: true };
@@ -1720,6 +1752,7 @@ describe('DdRum', () => {
1720
1752
  expect(NativeModules.DdRum.addAction).toHaveBeenCalledWith(
1721
1753
  'CUSTOM',
1722
1754
  'Click on button',
1755
+ null,
1723
1756
  {
1724
1757
  frustration: true
1725
1758
  },
@@ -25,6 +25,7 @@ type NativeAction = {
25
25
  name: string;
26
26
  context: object;
27
27
  timestampMs: number;
28
+ actionContext?: GestureResponderEvent;
28
29
  };
29
30
 
30
31
  export type ActionEventMapper = (event: ActionEvent) => ActionEvent | null;
@@ -142,7 +142,8 @@ class BabelInteractionTracking {
142
142
  action,
143
143
  targetName,
144
144
  { '__dd.action_source': ActionSource.BABEL },
145
- this.timeProvider.now()
145
+ this.timeProvider.now(),
146
+ args[0]
146
147
  )
147
148
  .catch(e => {
148
149
  if (e instanceof Error) {
@@ -66,4 +66,32 @@ describe('DdBabelInteractionTracking.wrapRumAction', () => {
66
66
  expect(func).toHaveBeenCalledWith('arg1', 'arg2');
67
67
  expect(result).toBe('result');
68
68
  });
69
+
70
+ it('should forward the first handler argument as actionContext to DdRum.addAction', () => {
71
+ const mockAddAction = jest.fn().mockResolvedValue(undefined);
72
+ DdBabelInteractionTracking.config = { trackInteractions: true };
73
+ DdBabelInteractionTracking.attachRumInstance({
74
+ addAction: mockAddAction
75
+ } as any);
76
+
77
+ const func = jest.fn();
78
+ const wrapped = DdBabelInteractionTracking.wrapRumAction(
79
+ func,
80
+ RumActionType.TAP,
81
+ mockTargetObject
82
+ );
83
+
84
+ const event = {
85
+ nativeEvent: { target: 42, locationX: 10, locationY: 20 }
86
+ };
87
+ wrapped(event);
88
+
89
+ expect(mockAddAction).toHaveBeenCalledWith(
90
+ RumActionType.TAP,
91
+ expect.any(String),
92
+ expect.anything(),
93
+ expect.any(Number),
94
+ event
95
+ );
96
+ });
69
97
  });
@@ -123,12 +123,36 @@ describe('default encoders', () => {
123
123
  expect(result).toHaveProperty('componentStack');
124
124
  });
125
125
 
126
+ it('does not cause infinite recursion', () => {
127
+ const error = new Error('stack overflow test');
128
+ errorEncoder.encode(error);
129
+ expect(warn).not.toHaveBeenCalledWith(
130
+ expect.stringContaining('Encoder error')
131
+ );
132
+ });
133
+
134
+ it('does not cause infinite recursion with nested Error cause', () => {
135
+ const inner = new Error('inner');
136
+ const outer: any = new Error('outer');
137
+ outer.cause = inner;
138
+ errorEncoder.encode(outer);
139
+ expect(warn).not.toHaveBeenCalledWith(
140
+ expect.stringContaining('Encoder error')
141
+ );
142
+ });
143
+
126
144
  it('encodes error with cause', () => {
127
145
  const cause = new Error('inner');
128
146
  const err: any = new Error('outer');
129
147
  err.cause = cause;
130
148
  const result = errorEncoder.encode(err) as Record<string, any>;
131
- expect(result.cause).toBe(cause);
149
+ expect(result.cause).toEqual(
150
+ expect.objectContaining({
151
+ name: 'Error',
152
+ message: 'inner'
153
+ })
154
+ );
155
+ expect(result.cause.stack).toContain('Error: inner');
132
156
  });
133
157
  });
134
158
 
@@ -77,7 +77,17 @@ export const errorEncoder: AttributeEncoder<any> = {
77
77
  ...DdSdk.attributeEncoders,
78
78
  ...builtInEncoders
79
79
  ];
80
- encodeAttributesInPlace(e, extraAttributes, [], allEncoders);
80
+
81
+ // We encode each enumerable property individually to avoid potential infinite recursion issues
82
+ // such as those caused by having nested errors
83
+ for (const [key, val] of Object.entries(e)) {
84
+ encodeAttributesInPlace(
85
+ val,
86
+ extraAttributes,
87
+ [key],
88
+ allEncoders
89
+ );
90
+ }
81
91
  }
82
92
 
83
93
  // Remove fields that are duplicated in the dedicated fields below