@datadog/mobile-react-native 3.9.0 → 3.11.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 (144) hide show
  1. package/DatadogSDKReactNative.podspec +7 -7
  2. package/android/build.gradle +9 -8
  3. package/android/src/main/kotlin/com/datadog/reactnative/DdFlagsImplementation.kt +6 -3
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +10 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +16 -8
  6. package/android/src/main/kotlin/com/datadog/reactnative/FrameRateProvider.kt +11 -6
  7. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  8. package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +10 -0
  9. package/android/src/oldarchCommon/kotlin/com/datadog/reactnative/DdRum.kt +10 -0
  10. package/android/src/test/kotlin/com/datadog/reactnative/DdFlagsImplementationTest.kt +19 -0
  11. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +9 -0
  12. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +131 -0
  13. package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +3 -3
  14. package/datadog-configuration.schema.json +11 -0
  15. package/ios/Sources/DdRum.mm +13 -1
  16. package/ios/Sources/DdRumImplementation.swift +6 -0
  17. package/ios/Sources/DdSdkConfiguration.swift +13 -0
  18. package/ios/Sources/DdSdkImplementation.swift +4 -3
  19. package/ios/Sources/DdSdkNativeInitialization.swift +26 -8
  20. package/ios/Sources/JSRefreshRateListener.swift +6 -2
  21. package/ios/Sources/RNDdSdkConfiguration.swift +9 -0
  22. package/ios/Sources/SdkVersion.swift +1 -1
  23. package/jest/mock.js +3 -0
  24. package/lib/commonjs/DdSdkReactNative.js +1 -1
  25. package/lib/commonjs/config/FileBasedConfiguration.js +3 -1
  26. package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
  27. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +3 -0
  28. package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  29. package/lib/commonjs/config/features/RumConfiguration.js +8 -0
  30. package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
  31. package/lib/commonjs/flags/FlagsClient.js +81 -8
  32. package/lib/commonjs/flags/FlagsClient.js.map +1 -1
  33. package/lib/commonjs/flags/configuration/precomputed.js +2 -3
  34. package/lib/commonjs/flags/configuration/precomputed.js.map +1 -1
  35. package/lib/commonjs/flags/internal.js.map +1 -1
  36. package/lib/commonjs/rum/DdRum.js +4 -0
  37. package/lib/commonjs/rum/DdRum.js.map +1 -1
  38. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +2 -2
  39. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -1
  40. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +1 -1
  41. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
  42. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +7 -1
  43. package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -1
  44. package/lib/commonjs/rum/types.js.map +1 -1
  45. package/lib/commonjs/sdk/AccountInfoSingleton/AccountInfoSingleton.js +1 -0
  46. package/lib/commonjs/sdk/AccountInfoSingleton/AccountInfoSingleton.js.map +1 -1
  47. package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.js +1 -0
  48. package/lib/commonjs/sdk/UserInfoSingleton/UserInfoSingleton.js.map +1 -1
  49. package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
  50. package/lib/commonjs/version.js +1 -1
  51. package/lib/commonjs/version.js.map +1 -1
  52. package/lib/module/DdSdkReactNative.js +1 -1
  53. package/lib/module/config/FileBasedConfiguration.js +3 -1
  54. package/lib/module/config/FileBasedConfiguration.js.map +1 -1
  55. package/lib/module/config/async/AutoInstrumentationConfiguration.js +3 -0
  56. package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
  57. package/lib/module/config/features/RumConfiguration.js +8 -0
  58. package/lib/module/config/features/RumConfiguration.js.map +1 -1
  59. package/lib/module/flags/FlagsClient.js +81 -8
  60. package/lib/module/flags/FlagsClient.js.map +1 -1
  61. package/lib/module/flags/configuration/precomputed.js +2 -3
  62. package/lib/module/flags/configuration/precomputed.js.map +1 -1
  63. package/lib/module/flags/internal.js.map +1 -1
  64. package/lib/module/rum/DdRum.js +4 -0
  65. package/lib/module/rum/DdRum.js.map +1 -1
  66. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +3 -3
  67. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -1
  68. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +2 -2
  69. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
  70. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +5 -0
  71. package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -1
  72. package/lib/module/rum/types.js.map +1 -1
  73. package/lib/module/sdk/AccountInfoSingleton/AccountInfoSingleton.js +2 -1
  74. package/lib/module/sdk/AccountInfoSingleton/AccountInfoSingleton.js.map +1 -1
  75. package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.js +2 -1
  76. package/lib/module/sdk/UserInfoSingleton/UserInfoSingleton.js.map +1 -1
  77. package/lib/module/specs/NativeDdRum.js.map +1 -1
  78. package/lib/module/version.js +1 -1
  79. package/lib/module/version.js.map +1 -1
  80. package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -1
  81. package/lib/typescript/config/FileBasedConfiguration.type.d.ts +2 -0
  82. package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
  83. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +4 -0
  84. package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
  85. package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts +2 -0
  86. package/lib/typescript/config/async/PartialInitializationConfiguration.d.ts.map +1 -1
  87. package/lib/typescript/config/features/RumConfiguration.d.ts +4 -0
  88. package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
  89. package/lib/typescript/config/features/RumConfiguration.type.d.ts +21 -0
  90. package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
  91. package/lib/typescript/config/features/RumConfigurationNative.d.ts +2 -0
  92. package/lib/typescript/config/features/RumConfigurationNative.d.ts.map +1 -1
  93. package/lib/typescript/flags/FlagsClient.d.ts +38 -1
  94. package/lib/typescript/flags/FlagsClient.d.ts.map +1 -1
  95. package/lib/typescript/flags/internal.d.ts +1 -0
  96. package/lib/typescript/flags/internal.d.ts.map +1 -1
  97. package/lib/typescript/flags/types.d.ts +1 -1
  98. package/lib/typescript/flags/types.d.ts.map +1 -1
  99. package/lib/typescript/rum/DdRum.d.ts +1 -0
  100. package/lib/typescript/rum/DdRum.d.ts.map +1 -1
  101. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts +2 -0
  102. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts.map +1 -1
  103. package/lib/typescript/rum/types.d.ts +6 -0
  104. package/lib/typescript/rum/types.d.ts.map +1 -1
  105. package/lib/typescript/sdk/AccountInfoSingleton/AccountInfoSingleton.d.ts.map +1 -1
  106. package/lib/typescript/sdk/UserInfoSingleton/UserInfoSingleton.d.ts.map +1 -1
  107. package/lib/typescript/specs/NativeDdRum.d.ts +6 -0
  108. package/lib/typescript/specs/NativeDdRum.d.ts.map +1 -1
  109. package/lib/typescript/version.d.ts +1 -1
  110. package/lib/typescript/version.d.ts.map +1 -1
  111. package/package.json +2 -2
  112. package/src/DdSdkReactNative.tsx +1 -1
  113. package/src/__tests__/DdSdkReactNative.test.tsx +133 -0
  114. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +12 -0
  115. package/src/config/FileBasedConfiguration.ts +6 -1
  116. package/src/config/FileBasedConfiguration.type.ts +2 -0
  117. package/src/config/__tests__/FileBasedConfiguration.test.ts +79 -0
  118. package/src/config/__tests__/__fixtures__/configuration-all-fields.json +2 -0
  119. package/src/config/async/AutoInstrumentationConfiguration.ts +9 -0
  120. package/src/config/async/PartialInitializationConfiguration.ts +2 -0
  121. package/src/config/features/RumConfiguration.ts +10 -0
  122. package/src/config/features/RumConfiguration.type.ts +23 -0
  123. package/src/config/features/RumConfigurationNative.ts +2 -0
  124. package/src/flags/FlagsClient.ts +128 -19
  125. package/src/flags/__tests__/FlagsClient.test.ts +167 -0
  126. package/src/flags/configuration/precomputed.ts +2 -3
  127. package/src/flags/internal.ts +2 -0
  128. package/src/flags/types.ts +2 -0
  129. package/src/rum/DdRum.ts +10 -0
  130. package/src/rum/__tests__/DdRum.test.ts +10 -0
  131. package/src/rum/instrumentation/interactionTracking/__tests__/DdBabelInteractionTracking.test.ts +104 -1
  132. package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.ts +3 -3
  133. package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/__tests__/FetchProxy.test.ts +29 -0
  134. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +2 -2
  135. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +40 -0
  136. package/src/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.ts +9 -0
  137. package/src/rum/types.ts +7 -0
  138. package/src/sdk/AccountInfoSingleton/AccountInfoSingleton.ts +2 -1
  139. package/src/sdk/AccountInfoSingleton/__tests__/AccountInfoSingleton.test.ts +59 -0
  140. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +165 -0
  141. package/src/sdk/UserInfoSingleton/UserInfoSingleton.ts +2 -1
  142. package/src/sdk/UserInfoSingleton/__tests__/UserInfoSingleton.test.ts +55 -0
  143. package/src/specs/NativeDdRum.ts +7 -0
  144. package/src/version.ts +1 -1
@@ -19,15 +19,15 @@ Pod::Spec.new do |s|
19
19
  s.dependency "React-Core"
20
20
 
21
21
  # /!\ Remember to keep the versions in sync with DatadogSDKReactNativeSessionReplay.podspec
22
- s.dependency 'DatadogCore', '3.16.0'
23
- s.dependency 'DatadogLogs', '3.16.0'
24
- s.dependency 'DatadogTrace', '3.16.0'
25
- s.dependency 'DatadogRUM', '3.16.0'
26
- s.dependency 'DatadogCrashReporting', '3.16.0'
27
- s.dependency 'DatadogFlags', '3.16.0'
22
+ s.dependency 'DatadogCore', '3.16.1'
23
+ s.dependency 'DatadogLogs', '3.16.1'
24
+ s.dependency 'DatadogTrace', '3.16.1'
25
+ s.dependency 'DatadogRUM', '3.16.1'
26
+ s.dependency 'DatadogCrashReporting', '3.16.1'
27
+ s.dependency 'DatadogFlags', '3.16.1'
28
28
 
29
29
  # DatadogWebViewTracking is not available for tvOS
30
- s.ios.dependency 'DatadogWebViewTracking', '3.16.0'
30
+ s.ios.dependency 'DatadogWebViewTracking', '3.16.1'
31
31
 
32
32
  s.test_spec 'Tests' do |test_spec|
33
33
  test_spec.source_files = 'ios/Tests/**/*.{swift,json}'
@@ -213,7 +213,7 @@ dependencies {
213
213
  // This breaks builds if the React Native target is below 0.76.0. as it relies on Gradle 8.5.0.
214
214
  // To avoid this, we enforce 1.0.0-beta01 on RN < 0.76.0
215
215
  if (reactNativeMinorVersion < 76) {
216
- implementation("com.datadoghq:dd-sdk-android-rum:3.13.1") {
216
+ implementation("com.datadoghq:dd-sdk-android-rum:3.15.0") {
217
217
  exclude group: "androidx.metrics", module: "metrics-performance"
218
218
  }
219
219
  implementation "androidx.metrics:metrics-performance:1.0.0-beta01"
@@ -233,14 +233,15 @@ dependencies {
233
233
  }
234
234
  }
235
235
  } else {
236
- implementation "com.datadoghq:dd-sdk-android-rum:3.13.1"
236
+ implementation "com.datadoghq:dd-sdk-android-rum:3.15.0"
237
237
  }
238
- implementation "com.datadoghq:dd-sdk-android-logs:3.13.1"
239
- implementation "com.datadoghq:dd-sdk-android-trace:3.13.1"
240
- implementation "com.datadoghq:dd-sdk-android-webview:3.13.1"
241
- implementation "com.datadoghq:dd-sdk-android-ndk:3.13.1"
242
- implementation "com.datadoghq:dd-sdk-android-flags:3.13.1"
243
- implementation "com.datadoghq:dd-sdk-android-internal:3.13.1"
238
+ implementation "com.datadoghq:dd-sdk-android-logs:3.15.0"
239
+ implementation "com.datadoghq:dd-sdk-android-trace:3.15.0"
240
+ implementation "com.datadoghq:dd-sdk-android-webview:3.15.0"
241
+ implementation "com.datadoghq:dd-sdk-android-ndk:3.15.0"
242
+ implementation "com.datadoghq:dd-sdk-android-flags:3.15.0"
243
+ implementation "com.datadoghq:dd-sdk-android-internal:3.15.0"
244
+ implementation "com.datadoghq:dd-sdk-android-rum-prelaunch:3.15.0"
244
245
  implementation "com.google.code.gson:gson:2.11.0"
245
246
  testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
246
247
  testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
@@ -169,14 +169,17 @@ private fun buildFlagsConfiguration(configuration: Map<String, Any?>): FlagsConf
169
169
  }.build()
170
170
  }
171
171
 
172
- private fun buildEvaluationContext(
172
+ internal fun buildEvaluationContext(
173
173
  targetingKey: String,
174
174
  attributes: ReadableMap,
175
175
  ): EvaluationContext {
176
176
  val parsed = mutableMapOf<String, String>()
177
177
 
178
- for ((key, value) in attributes.entryIterator) {
179
- parsed[key] = value.toString()
178
+ // JS null attributes arrive as null; the native context only holds strings, so omit them.
179
+ for ((key, value) in attributes.toHashMap()) {
180
+ if (value != null) {
181
+ parsed[key] = value.toString()
182
+ }
180
183
  }
181
184
 
182
185
  return EvaluationContext(targetingKey, parsed)
@@ -327,6 +327,16 @@ class DdRumImplementation internal constructor(
327
327
  promise.resolve(null)
328
328
  }
329
329
 
330
+ /**
331
+ * This method can be used to mark the moment in time when the UI of the app is considered fully displayed.
332
+ * The duration between the application launch and this moment of time will be shown as TTFD (time to full display)
333
+ * in the RUM session explorer. Only the first call to this method will have any effect for a given RUM session.
334
+ */
335
+ fun reportAppFullyDisplayed(promise: Promise) {
336
+ datadog.getRumMonitor().reportAppFullyDisplayed()
337
+ promise.resolve(null)
338
+ }
339
+
330
340
  /**
331
341
  * Stops the current RUM Session.
332
342
  */
@@ -331,7 +331,14 @@ class DdSdkImplementation(
331
331
  ddSdkConfiguration: DdSdkConfiguration
332
332
  ): FrameRateProvider? {
333
333
  val frameTimeCallback = buildFrameTimeCallback(ddSdkConfiguration) ?: return null
334
- val frameRateProvider = FrameRateProvider(frameTimeCallback, jsThreadExecutor)
334
+ // Before API 30 every Display.refreshRate read is an IPC, so use the max refresh rate there
335
+ val display = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
336
+ (appContext.getSystemService(Context.DISPLAY_SERVICE) as? DisplayManager)
337
+ ?.getDisplay(Display.DEFAULT_DISPLAY)
338
+ } else {
339
+ null
340
+ }
341
+ val frameRateProvider = FrameRateProvider(frameTimeCallback, jsThreadExecutor, display)
335
342
  frameRateProvider.start()
336
343
 
337
344
  return frameRateProvider
@@ -340,7 +347,7 @@ class DdSdkImplementation(
340
347
  @Suppress("CyclomaticComplexMethod")
341
348
  private fun buildFrameTimeCallback(
342
349
  ddSdkConfiguration: DdSdkConfiguration
343
- ): ((Double) -> Unit)? {
350
+ ): ((Double, Double?) -> Unit)? {
344
351
  val jsRefreshRateMonitoringEnabled =
345
352
  ddSdkConfiguration.rumConfiguration != null &&
346
353
  buildVitalUpdateFrequency(ddSdkConfiguration.rumConfiguration.vitalsUpdateFrequency) !=
@@ -351,20 +358,21 @@ class DdSdkImplementation(
351
358
  return null
352
359
  }
353
360
 
354
- return {
355
- if (jsRefreshRateMonitoringEnabled && it > 0.0) {
356
- val normalizedFrameTimeSeconds = normalizeFrameTime(it, appContext)
361
+ return { frameTime, displayFps ->
362
+ if (jsRefreshRateMonitoringEnabled && frameTime > 0.0) {
363
+ val normalizedFrameTimeSeconds =
364
+ normalizeFrameTime(frameTime, appContext, deviceDisplayFps = displayFps)
357
365
  datadog.getRumMonitor()
358
366
  ._getInternal()
359
367
  ?.updatePerformanceMetric(RumPerformanceMetric.JS_FRAME_TIME, normalizedFrameTimeSeconds)
360
368
  }
361
369
  if (jsLongTasksMonitoringEnabled &&
362
- it >
370
+ frameTime >
363
371
  TimeUnit.MILLISECONDS.toNanos(
364
372
  ddSdkConfiguration.rumConfiguration?.longTaskThresholdMs?.toLong() ?: 0L
365
373
  )
366
374
  ) {
367
- datadog.getRumMonitor()._getInternal()?.addLongTask(it.toLong(), "javascript")
375
+ datadog.getRumMonitor()._getInternal()?.addLongTask(frameTime.toLong(), "javascript")
368
376
  }
369
377
  }
370
378
  }
@@ -374,7 +382,7 @@ class DdSdkImplementation(
374
382
  * @param frameTimeSeconds: the frame time to normalize. In seconds.
375
383
  * @param context: The current app context
376
384
  * @param fpsBudget: The maximum fps under which the frame Time will be normalized [0-fpsBudget]. Defaults to 60Hz.
377
- * @param deviceDisplayFps: The maximum fps supported by the device. If not provided it will be set from the value obtained from the app context.
385
+ * @param deviceDisplayFps: The refresh rate the display is currently running at. If not provided it will be set from the maximum value obtained from the app context.
378
386
  */
379
387
  @Suppress("CyclomaticComplexMethod")
380
388
  fun normalizeFrameTime(
@@ -7,14 +7,17 @@
7
7
  package com.datadog.reactnative
8
8
 
9
9
  import android.view.Choreographer
10
+ import android.view.Display
10
11
 
11
12
  internal class FrameRateProvider(
12
- reactFrameRateCallback: ((Double) -> Unit),
13
- jsThreadExecutor: JsThreadExecutor
13
+ reactFrameRateCallback: ((Double, Double?) -> Unit),
14
+ jsThreadExecutor: JsThreadExecutor,
15
+ display: Display?
14
16
  ) {
15
17
  private val frameCallback: FpsFrameCallback = FpsFrameCallback(
16
18
  reactFrameRateCallback,
17
- jsThreadExecutor
19
+ jsThreadExecutor,
20
+ display
18
21
  )
19
22
 
20
23
  fun start() {
@@ -28,8 +31,9 @@ internal class FrameRateProvider(
28
31
  }
29
32
 
30
33
  internal class FpsFrameCallback(
31
- private val reactFrameRateCallback: ((Double) -> Unit),
32
- private val jsThreadExecutor: JsThreadExecutor
34
+ private val reactFrameRateCallback: ((Double, Double?) -> Unit),
35
+ private val jsThreadExecutor: JsThreadExecutor,
36
+ private val display: Display?
33
37
  ) : Choreographer.FrameCallback {
34
38
 
35
39
  private var choreographer: Choreographer? = null
@@ -37,7 +41,8 @@ internal class FpsFrameCallback(
37
41
 
38
42
  override fun doFrame(time: Long) {
39
43
  if (lastFrameTime != -1L) {
40
- reactFrameRateCallback((time - lastFrameTime).toDouble())
44
+ // Refresh rate the display is currently running at
45
+ reactFrameRateCallback((time - lastFrameTime).toDouble(), display?.refreshRate?.toDouble())
41
46
  }
42
47
  lastFrameTime = time
43
48
  choreographer?.postFrameCallback(this)
@@ -7,4 +7,4 @@
7
7
  package com.datadog.reactnative
8
8
 
9
9
  // This is automatically updated by the update-version.sh script
10
- internal const val SDK_VERSION = "3.9.0"
10
+ internal const val SDK_VERSION = "3.11.0"
@@ -276,6 +276,16 @@ class DdRum(
276
276
  implementation.addViewLoadingTime(overwrite, promise)
277
277
  }
278
278
 
279
+ /**
280
+ * This method can be used to mark the moment in time when the UI of the app is considered fully displayed.
281
+ * The duration between the application launch and this moment of time will be shown as TTFD (time to full display)
282
+ * in the RUM session explorer. Only the first call to this method will have any effect for a given RUM session.
283
+ */
284
+ @ReactMethod
285
+ override fun reportAppFullyDisplayed(promise: Promise) {
286
+ implementation.reportAppFullyDisplayed(promise)
287
+ }
288
+
279
289
  /**
280
290
  * Stops the current RUM Session.
281
291
  */
@@ -258,6 +258,16 @@ class DdRum(
258
258
  implementation.addViewLoadingTime(overwrite, promise)
259
259
  }
260
260
 
261
+ /**
262
+ * This method can be used to mark the moment in time when the UI of the app is considered fully displayed.
263
+ * The duration between the application launch and this moment of time will be shown as TTFD (time to full display)
264
+ * in the RUM session explorer. Only the first call to this method will have any effect for a given RUM session.
265
+ */
266
+ @ReactMethod
267
+ fun reportAppFullyDisplayed(promise: Promise) {
268
+ implementation.reportAppFullyDisplayed(promise)
269
+ }
270
+
261
271
  /**
262
272
  * Stops the current RUM Session.
263
273
  */
@@ -12,6 +12,7 @@ import com.datadog.android.flags.Flags
12
12
  import com.datadog.android.flags.FlagsConfiguration
13
13
  import com.datadog.tools.unit.toReadableMap
14
14
  import com.facebook.react.bridge.Promise
15
+ import org.assertj.core.api.Assertions.assertThat
15
16
  import org.junit.jupiter.api.Test
16
17
  import org.junit.jupiter.api.extension.ExtendWith
17
18
  import org.junit.jupiter.api.extension.Extensions
@@ -74,4 +75,22 @@ internal class DdFlagsImplementationTest {
74
75
  datadogMock.close()
75
76
  }
76
77
  }
78
+
79
+ @Test
80
+ fun `M omit null attributes W buildEvaluationContext()`() {
81
+ // Given
82
+ val attributes = mapOf(
83
+ "country" to "US",
84
+ "age" to 42,
85
+ "size" to null
86
+ ).toReadableMap()
87
+
88
+ // When
89
+ val context = buildEvaluationContext("user", attributes)
90
+
91
+ // Then
92
+ assertThat(context.targetingKey).isEqualTo("user")
93
+ assertThat(context.attributes).containsOnlyKeys("country", "age")
94
+ assertThat(context.attributes["country"]).isEqualTo("US")
95
+ }
77
96
  }
@@ -557,6 +557,15 @@ internal class DdRumTest {
557
557
  verify(mockRumMonitor).addViewLoadingTime(overwrite)
558
558
  }
559
559
 
560
+ @Test
561
+ fun `M call reportAppFullyDisplayed w reportAppFullyDisplayed()`() {
562
+ // When
563
+ testedDdRum.reportAppFullyDisplayed(mockPromise)
564
+
565
+ // Then
566
+ verify(mockRumMonitor).reportAppFullyDisplayed()
567
+ }
568
+
560
569
  @Test
561
570
  fun `M call stopSession W stopSession()`() {
562
571
  // When
@@ -9,6 +9,7 @@ package com.datadog.reactnative
9
9
  import android.content.Context
10
10
  import android.content.pm.PackageInfo
11
11
  import android.hardware.display.DisplayManager
12
+ import android.os.Build
12
13
  import android.os.Looper
13
14
  import android.util.Log
14
15
  import android.view.Choreographer
@@ -3670,6 +3671,136 @@ internal class DdSdkTest {
3670
3671
  verify(mockDisplay, times(1)).supportedModes
3671
3672
  }
3672
3673
 
3674
+ @Test
3675
+ fun `𝕄 normalize JS frame time with the display's current refresh rate 𝕎 doFrame()`(
3676
+ @Forgery configuration: DdSdkConfiguration
3677
+ ) {
3678
+ // Given
3679
+ val rumConfiguration = configuration.rumConfiguration?.copy(
3680
+ vitalsUpdateFrequency = "AVERAGE",
3681
+ longTaskThresholdMs = 0.0
3682
+ )
3683
+ val bridgeConfiguration = configuration.copy(rumConfiguration = rumConfiguration)
3684
+ val mockDisplayManager = mock<DisplayManager>()
3685
+ val mockDisplay = mock<Display>()
3686
+ whenever(mockContext.getSystemService(Context.DISPLAY_SERVICE)) doReturn mockDisplayManager
3687
+ whenever(mockDisplayManager.getDisplay(Display.DEFAULT_DISPLAY)) doReturn mockDisplay
3688
+ val originalSdkInt = Build.VERSION.SDK_INT
3689
+ Build.VERSION::class.java.setStaticValue("SDK_INT", Build.VERSION_CODES.R)
3690
+
3691
+ val rumMock = org.mockito.Mockito.mockStatic(Rum::class.java)
3692
+ val traceMock = org.mockito.Mockito.mockStatic(Trace::class.java)
3693
+ val logsMock = org.mockito.Mockito.mockStatic(Logs::class.java)
3694
+
3695
+ try {
3696
+ rumMock.`when`<Unit> { Rum.enable(any(), any()) }.then { }
3697
+ logsMock.`when`<Unit> { Logs.enable(any(), any()) }.then { }
3698
+ traceMock.`when`<Unit> { Trace.enable(any(), any()) }.then { }
3699
+
3700
+ // When
3701
+ testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
3702
+
3703
+ // Then
3704
+ argumentCaptor<Choreographer.FrameCallback> {
3705
+ verify(mockChoreographer).postFrameCallback(capture())
3706
+ var timestampNs = 0L
3707
+ firstValue.doFrame(timestampNs)
3708
+
3709
+ // 120 fps, display running at 120Hz -> Normalized to 60fps
3710
+ whenever(mockDisplay.refreshRate) doReturn 120f
3711
+ timestampNs += 8_333_333L
3712
+ firstValue.doFrame(timestampNs)
3713
+ verify(mockRumInternalProxy).updatePerformanceMetric(
3714
+ RumPerformanceMetric.JS_FRAME_TIME,
3715
+ 16_666_666.0
3716
+ )
3717
+
3718
+ // 60 fps, display running at 120Hz -> Normalized to 30fps
3719
+ timestampNs += 16_666_667L
3720
+ firstValue.doFrame(timestampNs)
3721
+ verify(mockRumInternalProxy).updatePerformanceMetric(
3722
+ RumPerformanceMetric.JS_FRAME_TIME,
3723
+ 33_333_334.0
3724
+ )
3725
+
3726
+ // 60 fps, display running at 60Hz -> Normalized to 60fps
3727
+ whenever(mockDisplay.refreshRate) doReturn 60f
3728
+ timestampNs += 16_666_667L
3729
+ firstValue.doFrame(timestampNs)
3730
+ verify(mockRumInternalProxy).updatePerformanceMetric(
3731
+ RumPerformanceMetric.JS_FRAME_TIME,
3732
+ 16_666_667.0
3733
+ )
3734
+
3735
+ // 30 fps, display running at 60Hz -> Normalized to 30fps
3736
+ timestampNs += 33_333_333L
3737
+ firstValue.doFrame(timestampNs)
3738
+ verify(mockRumInternalProxy).updatePerformanceMetric(
3739
+ RumPerformanceMetric.JS_FRAME_TIME,
3740
+ 33_333_333.0
3741
+ )
3742
+ }
3743
+ } finally {
3744
+ Build.VERSION::class.java.setStaticValue("SDK_INT", originalSdkInt)
3745
+ rumMock.close()
3746
+ logsMock.close()
3747
+ traceMock.close()
3748
+ }
3749
+ }
3750
+
3751
+ @Test
3752
+ fun `𝕄 normalize JS frame time with the max refresh rate 𝕎 doFrame() {API below 30}`(
3753
+ @Forgery configuration: DdSdkConfiguration
3754
+ ) {
3755
+ // Given
3756
+ val rumConfiguration = configuration.rumConfiguration?.copy(
3757
+ vitalsUpdateFrequency = "AVERAGE",
3758
+ longTaskThresholdMs = 0.0
3759
+ )
3760
+ val bridgeConfiguration = configuration.copy(rumConfiguration = rumConfiguration)
3761
+ val mockDisplayManager = mock<DisplayManager>()
3762
+ val mockDisplay = mock<Display>()
3763
+ val mockDisplayMode = mock<Display.Mode>()
3764
+ whenever(mockContext.getSystemService(Context.DISPLAY_SERVICE)) doReturn mockDisplayManager
3765
+ whenever(mockDisplayManager.getDisplay(Display.DEFAULT_DISPLAY)) doReturn mockDisplay
3766
+ whenever(mockDisplayMode.refreshRate) doReturn 120f
3767
+ whenever(mockDisplay.supportedModes) doReturn arrayOf(mockDisplayMode)
3768
+ val originalSdkInt = Build.VERSION.SDK_INT
3769
+ Build.VERSION::class.java.setStaticValue("SDK_INT", Build.VERSION_CODES.Q)
3770
+
3771
+ val rumMock = org.mockito.Mockito.mockStatic(Rum::class.java)
3772
+ val traceMock = org.mockito.Mockito.mockStatic(Trace::class.java)
3773
+ val logsMock = org.mockito.Mockito.mockStatic(Logs::class.java)
3774
+
3775
+ try {
3776
+ rumMock.`when`<Unit> { Rum.enable(any(), any()) }.then { }
3777
+ logsMock.`when`<Unit> { Logs.enable(any(), any()) }.then { }
3778
+ traceMock.`when`<Unit> { Trace.enable(any(), any()) }.then { }
3779
+
3780
+ // When
3781
+ testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
3782
+
3783
+ // Then
3784
+ argumentCaptor<Choreographer.FrameCallback> {
3785
+ verify(mockChoreographer).postFrameCallback(capture())
3786
+ firstValue.doFrame(0L)
3787
+
3788
+ // 60 fps, 120Hz capable display -> Normalized with the max refresh rate to 30fps
3789
+ firstValue.doFrame(16_666_667L)
3790
+ verify(mockRumInternalProxy).updatePerformanceMetric(
3791
+ RumPerformanceMetric.JS_FRAME_TIME,
3792
+ 33_333_334.0
3793
+ )
3794
+ verify(mockDisplay, never()).refreshRate
3795
+ }
3796
+ } finally {
3797
+ Build.VERSION::class.java.setStaticValue("SDK_INT", originalSdkInt)
3798
+ rumMock.close()
3799
+ logsMock.close()
3800
+ traceMock.close()
3801
+ }
3802
+ }
3803
+
3673
3804
  // endregion
3674
3805
 
3675
3806
  // region Internal
@@ -63,6 +63,9 @@ class MockRumMonitor : RumMonitor {
63
63
  @ExperimentalRumApi
64
64
  override fun addViewLoadingTime(overwrite: Boolean) {}
65
65
 
66
+ @ExperimentalRumApi
67
+ override fun reportAppFullyDisplayed() {}
68
+
66
69
  override fun getCurrentSessionId(callback: (String?) -> Unit) {}
67
70
 
68
71
  override fun addViewAttributes(attributes: Map<String, Any?>) {}
@@ -172,7 +175,4 @@ class MockRumMonitor : RumMonitor {
172
175
  failureReason: OperationFailureReason,
173
176
  attributes: Map<String, Any?>
174
177
  ) {}
175
-
176
- @ExperimentalRumApi
177
- override fun reportAppFullyDisplayed() {}
178
178
  }
@@ -211,6 +211,17 @@
211
211
  "description": "Enables native interaction tracking.",
212
212
  "type": "boolean"
213
213
  },
214
+ "nativeIosResourceTracking": {
215
+ "description": "Controls automatic native network (URLSession) resource tracking. iOS only: has no effect on Android. If not set (default): legacy behavior, enables iOS network tracking if `firstPartyHosts` is defined. `true`: enables iOS network tracking (with trace headers for `firstPartyHosts`, if defined). `false`: disables iOS network tracking.",
216
+ "type": "boolean"
217
+ },
218
+ "nativeIosResourceTrackingDisallowList": {
219
+ "description": "URL patterns excluded from automatic native iOS network (URLSession) resource tracking. Patterns are matched against the full URL: plain strings match exactly, `*` matches any characters. Patterns without any literal characters (e.g. `\"*\"`) are ignored. Matching requests also get no trace headers injected and no APM span. Only takes effect when native iOS resource tracking is enabled (see `nativeIosResourceTracking`); it never enables tracking by itself. If set while tracking is disabled, the native SDK logs a warning (subject to `verbosity`). iOS only: has no effect on Android. Default: []",
220
+ "type": "array",
221
+ "items": {
222
+ "type": "string"
223
+ }
224
+ },
214
225
  "nativeCrashReportEnabled": {
215
226
  "description": "Enables crash reporting for native platforms (iOS, Android). Default `false`.",
216
227
  "type": "boolean"
@@ -145,7 +145,15 @@ RCT_REMAP_METHOD(addViewLoadingTime, withOverwrite:(BOOL)overwrite
145
145
  [self addViewLoadingTime:overwrite resolve:resolve reject:reject];
146
146
  }
147
147
 
148
- RCT_REMAP_METHOD(stopSession, withResolve:(RCTPromiseResolveBlock)resolve
148
+ RCT_EXPORT_METHOD(reportAppFullyDisplayed:
149
+ (RCTPromiseResolveBlock)resolve
150
+ withRejecter:(RCTPromiseRejectBlock)reject)
151
+ {
152
+ [self reportAppFullyDisplayed: resolve reject:reject];
153
+ }
154
+
155
+ RCT_EXPORT_METHOD(stopSession:
156
+ (RCTPromiseResolveBlock)resolve
149
157
  withRejecter:(RCTPromiseRejectBlock)reject)
150
158
  {
151
159
  [self stopSession:resolve reject:reject];
@@ -262,6 +270,10 @@ RCT_REMAP_METHOD(failFeatureOperation,
262
270
  [self.ddRumImplementation addViewLoadingTimeWithOverwrite:overwrite resolve:resolve reject:reject];
263
271
  }
264
272
 
273
+ - (void)reportAppFullyDisplayed:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
274
+ [self.ddRumImplementation reportAppFullyDisplayedWithResolve:resolve reject: reject];
275
+ }
276
+
265
277
  - (void)startAction:(NSString *)type name:(NSString *)name context:(NSDictionary *)context timestampMs:(double)timestampMs resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
266
278
  [self.ddRumImplementation startActionWithType:type name:name context:context timestampMs:timestampMs resolve:resolve reject:reject];
267
279
  }
@@ -262,6 +262,12 @@ public class DdRumImplementation: NSObject {
262
262
  resolve(nil)
263
263
  }
264
264
 
265
+ @objc
266
+ public func reportAppFullyDisplayed(resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
267
+ nativeRUM.reportAppFullyDisplayed()
268
+ resolve(nil)
269
+ }
270
+
265
271
  @objc
266
272
  public func stopSession(resolve: @escaping RCTPromiseResolve, reject: @escaping RCTPromiseReject) -> Void {
267
273
  nativeRUM.stopSession()
@@ -95,6 +95,13 @@ public class DdSdkConfiguration: NSObject {
95
95
  /// - nativeLongTaskThresholdMs: The threshold for reporting native long tasks in milliseconds.
96
96
  /// - nativeViewTracking: Enables tracking of native iOS/Android UI views.
97
97
  /// - nativeInteractionTracking: Enables tracking of native UI interactions.
98
+ /// - nativeIosResourceTracking: Controls automatic URLSession resource tracking (iOS only).
99
+ /// `nil` (default): legacy behavior, tracking enabled iff `firstPartyHosts` is non-nil.
100
+ /// `true`: tracking always enabled (trace headers for `firstPartyHosts`, if non-nil).
101
+ /// `false`: tracking disabled.
102
+ /// - nativeIosResourceTrackingDisallowList: URL patterns excluded from automatic URLSession resource tracking
103
+ /// (iOS only). Passed to `RUM.Configuration.URLSessionTracking.disallowList`; only effective when
104
+ /// URLSession tracking is enabled. Default: `[]`.
98
105
  /// - firstPartyHosts: List of backend hosts considered first-party for network tracing.
99
106
  /// - appHangThreshold: Threshold in seconds for reporting non-fatal app hangs (iOS only).
100
107
  /// - trackWatchdogTerminations: Whether the SDK should track application terminations
@@ -115,6 +122,8 @@ public class RumConfiguration: NSObject {
115
122
  public var nativeLongTaskThresholdMs: Double? = nil
116
123
  public var nativeViewTracking: Bool? = nil
117
124
  public var nativeInteractionTracking: Bool? = nil
125
+ public var nativeIosResourceTracking: Bool? = nil
126
+ public var nativeIosResourceTrackingDisallowList: [String] = []
118
127
  public var firstPartyHosts: [String: Set<TracingHeaderType>]? = nil
119
128
  public var appHangThreshold: Double? = nil
120
129
  public var trackWatchdogTerminations: Bool
@@ -135,6 +144,8 @@ public class RumConfiguration: NSObject {
135
144
  nativeLongTaskThresholdMs: Double? = nil,
136
145
  nativeViewTracking: Bool?,
137
146
  nativeInteractionTracking: Bool?,
147
+ nativeIosResourceTracking: Bool? = nil,
148
+ nativeIosResourceTrackingDisallowList: [String] = [],
138
149
  firstPartyHosts: [String: Set<TracingHeaderType>]?,
139
150
  appHangThreshold: Double?,
140
151
  trackWatchdogTerminations: Bool,
@@ -154,6 +165,8 @@ public class RumConfiguration: NSObject {
154
165
  self.nativeLongTaskThresholdMs = nativeLongTaskThresholdMs
155
166
  self.nativeViewTracking = nativeViewTracking
156
167
  self.nativeInteractionTracking = nativeInteractionTracking
168
+ self.nativeIosResourceTracking = nativeIosResourceTracking
169
+ self.nativeIosResourceTrackingDisallowList = nativeIosResourceTrackingDisallowList
157
170
  self.firstPartyHosts = firstPartyHosts
158
171
  self.appHangThreshold = appHangThreshold
159
172
  self.trackWatchdogTerminations = trackWatchdogTerminations
@@ -309,7 +309,7 @@ public class DdSdkImplementation: NSObject {
309
309
  }
310
310
  }
311
311
 
312
- func buildFrameTimeCallback(sdkConfiguration: DdSdkConfiguration) -> ((Double) -> Void)? {
312
+ func buildFrameTimeCallback(sdkConfiguration: DdSdkConfiguration) -> ((Double, Double) -> Void)? {
313
313
  let jsRefreshRateMonitoringEnabled =
314
314
  sdkConfiguration.rumConfiguration != nil
315
315
  && sdkConfiguration.rumConfiguration?.vitalsUpdateFrequency != nil
@@ -321,7 +321,7 @@ public class DdSdkImplementation: NSObject {
321
321
  return nil
322
322
  }
323
323
 
324
- func frameTimeCallback(frameTime: Double) {
324
+ func frameTimeCallback(frameTime: Double, displayFps: Double) {
325
325
  // These checks happen before dispatching because they are quick and less overhead than the dispatch itself.
326
326
  let shouldRecordFrameTime = jsRefreshRateMonitoringEnabled && frameTime > 0
327
327
  let shouldRecordLongTask =
@@ -338,7 +338,8 @@ public class DdSdkImplementation: NSObject {
338
338
  sharedQueue.async {
339
339
  if shouldRecordFrameTime {
340
340
  let normalizedFrameTimeSeconds =
341
- DdSdkImplementation.normalizeFrameTimeForDeviceRefreshRate(frameTime)
341
+ DdSdkImplementation.normalizeFrameTimeForDeviceRefreshRate(
342
+ frameTime, deviceDisplayFps: displayFps)
342
343
  rumMonitorInternal.updatePerformanceMetric(
343
344
  at: now, metric: .jsFrameTimeSeconds, value: normalizedFrameTimeSeconds,
344
345
  attributes: [:])
@@ -168,22 +168,40 @@ public class DdSdkNativeInitialization: NSObject {
168
168
  uiKitActionsPredicate = DefaultUIKitRUMActionsPredicate()
169
169
  }
170
170
 
171
- var urlSessionTracking: RUM.Configuration.URLSessionTracking? = nil
171
+ // `nativeIosResourceTracking` (iOS only):
172
+ // - nil (default): legacy behavior, tracking enabled iff `firstPartyHosts` is non-nil.
173
+ // - true: tracking always enabled (trace headers only if `firstPartyHosts` is non-nil).
174
+ // - false: tracking disabled.
175
+ // `nativeIosResourceTrackingDisallowList` is applied only when tracking is enabled; it never enables it.
176
+ var firstPartyHostsTracing: RUM.Configuration.URLSessionTracking.FirstPartyHostsTracing? = nil
172
177
  if let firstPartyHosts = rumConfig.firstPartyHosts {
178
+ firstPartyHostsTracing = .traceWithHeaders(
179
+ hostsWithHeaders: firstPartyHosts,
180
+ sampleRate: Float(
181
+ configuration.rumConfiguration?.resourceTraceSampleRate
182
+ ?? DefaultConfiguration.resourceTraceSampleRate)
183
+ )
184
+ }
185
+ let shouldTrackURLSession = rumConfig.nativeIosResourceTracking ?? (rumConfig.firstPartyHosts != nil)
186
+
187
+ var urlSessionTracking: RUM.Configuration.URLSessionTracking? = nil
188
+ if shouldTrackURLSession {
173
189
  urlSessionTracking = RUM.Configuration.URLSessionTracking(
174
- firstPartyHostsTracing: .traceWithHeaders(
175
- hostsWithHeaders: firstPartyHosts,
176
- sampleRate: Float(
177
- configuration.rumConfiguration?.resourceTraceSampleRate
178
- ?? DefaultConfiguration.resourceTraceSampleRate)
179
- ),
190
+ firstPartyHostsTracing: firstPartyHostsTracing,
180
191
  resourceAttributesProvider: { request, _, _, _ in
181
192
  let trackedBy = request.value(forHTTPHeaderField: InternalConfigurationAttributes.trackedByHeaderKey)
182
193
  if trackedBy == InternalConfigurationAttributes.trackedByHeaderValue {
183
194
  return [InternalConfigurationAttributes.dropResource: true]
184
195
  }
185
196
  return nil
186
- }
197
+ },
198
+ disallowList: rumConfig.nativeIosResourceTrackingDisallowList
199
+ )
200
+ } else if !rumConfig.nativeIosResourceTrackingDisallowList.isEmpty {
201
+ DD.logger.warn(
202
+ "nativeIosResourceTrackingDisallowList is set but native iOS resource tracking is disabled "
203
+ + "(nativeIosResourceTracking is false, or unset with no firstPartyHosts). "
204
+ + "The disallow list will be ignored."
187
205
  )
188
206
  }
189
207