@datadog/mobile-react-native 2.4.3 → 2.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 (91) hide show
  1. package/DatadogSDKReactNative.podspec +8 -6
  2. package/android/build.gradle +9 -5
  3. package/android/gradle.properties +1 -1
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkBridgeExt.kt +12 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +5 -2
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +5 -2
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +15 -1
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +5 -0
  9. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkSynthetics.kt +12 -0
  10. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  11. package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +19 -0
  12. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +19 -0
  13. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkBridgeExtTest.kt +28 -0
  14. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +17 -0
  15. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +2 -0
  16. package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +4 -0
  17. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +2 -1
  18. package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +55 -55
  19. package/datadog-configuration.schema.json +8 -0
  20. package/ios/Sources/DdSdkConfiguration.swift +5 -1
  21. package/ios/Sources/DdSdkNativeInitialization.swift +1 -0
  22. package/ios/Sources/RNDdSdkConfiguration.swift +6 -2
  23. package/ios/Sources/SdkVersion.swift +1 -1
  24. package/jest/mock.js +4 -0
  25. package/lib/commonjs/DdSdkReactNative.js +22 -1
  26. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  27. package/lib/commonjs/DdSdkReactNativeConfiguration.js +22 -0
  28. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  29. package/lib/commonjs/logs/DdLogs.js +11 -9
  30. package/lib/commonjs/logs/DdLogs.js.map +1 -1
  31. package/lib/commonjs/rum/DdRum.js +7 -0
  32. package/lib/commonjs/rum/DdRum.js.map +1 -1
  33. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +1 -1
  34. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  35. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +8 -2
  36. package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
  37. package/lib/commonjs/rum/types.js.map +1 -1
  38. package/lib/commonjs/types.js +4 -1
  39. package/lib/commonjs/types.js.map +1 -1
  40. package/lib/commonjs/version.js +1 -1
  41. package/lib/module/DdSdkReactNative.js +22 -1
  42. package/lib/module/DdSdkReactNative.js.map +1 -1
  43. package/lib/module/DdSdkReactNativeConfiguration.js +22 -0
  44. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  45. package/lib/module/logs/DdLogs.js +11 -9
  46. package/lib/module/logs/DdLogs.js.map +1 -1
  47. package/lib/module/rum/DdRum.js +7 -0
  48. package/lib/module/rum/DdRum.js.map +1 -1
  49. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +1 -1
  50. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  51. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +8 -2
  52. package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
  53. package/lib/module/rum/types.js.map +1 -1
  54. package/lib/module/types.js +4 -1
  55. package/lib/module/types.js.map +1 -1
  56. package/lib/module/version.js +1 -1
  57. package/lib/typescript/DdSdkReactNative.d.ts +7 -0
  58. package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
  59. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +22 -0
  60. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts.map +1 -1
  61. package/lib/typescript/logs/DdLogs.d.ts.map +1 -1
  62. package/lib/typescript/logs/types.d.ts +8 -4
  63. package/lib/typescript/logs/types.d.ts.map +1 -1
  64. package/lib/typescript/rum/DdRum.d.ts +2 -0
  65. package/lib/typescript/rum/DdRum.d.ts.map +1 -1
  66. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts.map +1 -1
  67. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts.map +1 -1
  68. package/lib/typescript/rum/types.d.ts +6 -0
  69. package/lib/typescript/rum/types.d.ts.map +1 -1
  70. package/lib/typescript/types.d.ts +9 -1
  71. package/lib/typescript/types.d.ts.map +1 -1
  72. package/lib/typescript/version.d.ts +1 -1
  73. package/package.json +2 -2
  74. package/src/DdSdkReactNative.tsx +31 -1
  75. package/src/DdSdkReactNativeConfiguration.tsx +24 -0
  76. package/src/__tests__/DdSdkReactNative.test.tsx +34 -0
  77. package/src/__tests__/mock.test.ts +1 -0
  78. package/src/logs/DdLogs.ts +21 -13
  79. package/src/logs/__tests__/DdLogs.test.ts +147 -0
  80. package/src/logs/__tests__/eventMapper.test.ts +37 -0
  81. package/src/logs/types.ts +8 -4
  82. package/src/rum/DdRum.ts +12 -0
  83. package/src/rum/__tests__/DdRum.test.ts +16 -0
  84. package/src/rum/instrumentation/DdRumErrorTracking.tsx +12 -4
  85. package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/distributedTracing.test.ts +1 -1
  86. package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +9 -2
  87. package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +4 -7
  88. package/src/rum/types.ts +8 -0
  89. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +5 -0
  90. package/src/types.tsx +10 -1
  91. package/src/version.ts +1 -1
@@ -19,12 +19,14 @@ 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', '~> 2.14.1'
23
- s.dependency 'DatadogLogs', '~> 2.14.1'
24
- s.dependency 'DatadogTrace', '~> 2.14.1'
25
- s.dependency 'DatadogRUM', '~> 2.14.1'
26
- s.dependency 'DatadogCrashReporting', '~> 2.14.1'
27
- s.dependency 'DatadogWebViewTracking', '~> 2.14.1'
22
+ s.dependency 'DatadogCore', '~> 2.18.0'
23
+ s.dependency 'DatadogLogs', '~> 2.18.0'
24
+ s.dependency 'DatadogTrace', '~> 2.18.0'
25
+ s.dependency 'DatadogRUM', '~> 2.18.0'
26
+ s.dependency 'DatadogCrashReporting', '~> 2.18.0'
27
+
28
+ # DatadogWebViewTracking is not available for tvOS
29
+ s.ios.dependency 'DatadogWebViewTracking', '~> 2.18.0'
28
30
 
29
31
  s.test_spec 'Tests' do |test_spec|
30
32
  test_spec.source_files = 'ios/Tests/**/*.{swift,json}'
@@ -12,7 +12,7 @@ buildscript {
12
12
  }
13
13
 
14
14
  dependencies {
15
- classpath 'com.android.tools.build:gradle:7.2.2'
15
+ classpath 'com.android.tools.build:gradle:7.3.1'
16
16
  // noinspection DifferentKotlinGradleVersion
17
17
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
18
18
  classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1"
@@ -98,15 +98,19 @@ def getExtOrIntegerDefault(name) {
98
98
  android {
99
99
  compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
100
100
  buildToolsVersion getExtOrDefault('buildToolsVersion')
101
+
101
102
  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
103
+
102
104
  if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
103
105
  namespace = "com.datadog.reactnative"
104
106
  }
107
+
105
108
  if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
106
109
  buildFeatures {
107
110
  buildConfig = true
108
111
  }
109
112
  }
113
+
110
114
  if (agpVersion.tokenize('.')[0].toInteger() < 8) {
111
115
  compileOptions {
112
116
  sourceCompatibility JavaVersion.VERSION_11
@@ -188,10 +192,10 @@ dependencies {
188
192
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
189
193
  compileOnly "com.squareup.okhttp3:okhttp:3.12.13"
190
194
 
191
- implementation "com.datadoghq:dd-sdk-android-rum:2.11.0"
192
- implementation "com.datadoghq:dd-sdk-android-logs:2.11.0"
193
- implementation "com.datadoghq:dd-sdk-android-trace:2.11.0"
194
- implementation "com.datadoghq:dd-sdk-android-webview:2.11.0"
195
+ implementation "com.datadoghq:dd-sdk-android-rum:2.16.1"
196
+ implementation "com.datadoghq:dd-sdk-android-logs:2.16.1"
197
+ implementation "com.datadoghq:dd-sdk-android-trace:2.16.1"
198
+ implementation "com.datadoghq:dd-sdk-android-webview:2.16.1"
195
199
  implementation "com.google.code.gson:gson:2.10.0"
196
200
  testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
197
201
  testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
@@ -1,4 +1,4 @@
1
- DdSdkReactNative_kotlinVersion=1.7.21
1
+ DdSdkReactNative_kotlinVersion=1.8.21
2
2
  DdSdkReactNative_compileSdkVersion=33
3
3
  DdSdkReactNative_buildToolsVersion=33.0.0
4
4
  DdSdkReactNative_targetSdkVersion=33
@@ -215,3 +215,15 @@ internal fun ReadableArray.toList(): List<*> {
215
215
 
216
216
  return list
217
217
  }
218
+
219
+ /**
220
+ * Returns the boolean for the given key, or null if the entry is
221
+ * not in the map.
222
+ */
223
+ internal fun ReadableMap.getBooleanOrNull(key: String): Boolean? {
224
+ return if (hasKey(key)) {
225
+ getBoolean(key)
226
+ } else {
227
+ null
228
+ }
229
+ }
@@ -37,6 +37,7 @@ import java.net.Proxy
37
37
  * @param firstPartyHosts List of backend hosts to enable tracing with.
38
38
  * @param bundleLogsWithRum Enables RUM correlation with logs.
39
39
  * @param bundleLogsWithTraces Enables Traces correlation with logs.
40
+ * @param trackNonFatalAnrs Enables tracking of non-fatal ANRs on Android.
40
41
  */
41
42
  data class DdSdkConfiguration(
42
43
  val clientToken: String,
@@ -64,7 +65,8 @@ data class DdSdkConfiguration(
64
65
  val serviceName: String? = null,
65
66
  val firstPartyHosts: Map<String, Set<TracingHeaderType>>? = null,
66
67
  val bundleLogsWithRum: Boolean? = null,
67
- val bundleLogsWithTraces: Boolean? = null
68
+ val bundleLogsWithTraces: Boolean? = null,
69
+ val trackNonFatalAnrs: Boolean? = null
68
70
  )
69
71
 
70
72
  internal data class JSONConfigurationFile(
@@ -95,7 +97,8 @@ internal data class JSONDdSdkConfiguration(
95
97
  val serviceName: String? = null,
96
98
  val firstPartyHosts: List<JSONFirstPartyHost>? = null,
97
99
  val bundleLogsWithRum: Boolean? = null,
98
- val bundleLogsWithTraces: Boolean? = null
100
+ val bundleLogsWithTraces: Boolean? = null,
101
+ val trackNonFatalAnrs: Boolean? = null
99
102
  )
100
103
 
101
104
  internal data class JSONProxyConfiguration(
@@ -46,7 +46,8 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
46
46
  serviceName = getString("serviceName"),
47
47
  firstPartyHosts = getArray("firstPartyHosts")?.asFirstPartyHosts(),
48
48
  bundleLogsWithRum = getBoolean("bundleLogsWithRum"),
49
- bundleLogsWithTraces = getBoolean("bundleLogsWithTraces")
49
+ bundleLogsWithTraces = getBoolean("bundleLogsWithTraces"),
50
+ trackNonFatalAnrs = getBooleanOrNull("trackNonFatalAnrs")
50
51
  )
51
52
  }
52
53
 
@@ -169,7 +170,8 @@ internal fun JSONDdSdkConfiguration.asDdSdkConfiguration(): DdSdkConfiguration {
169
170
  this.serviceName,
170
171
  this.firstPartyHosts?.asFirstPartyHosts(),
171
172
  this.bundleLogsWithRum ?: DefaultConfiguration.bundleLogsWithRum,
172
- this.bundleLogsWithTraces ?: DefaultConfiguration.bundleLogsWithTraces
173
+ this.bundleLogsWithTraces ?: DefaultConfiguration.bundleLogsWithTraces,
174
+ this.trackNonFatalAnrs
173
175
  )
174
176
  }
175
177
 
@@ -231,6 +233,7 @@ internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
231
233
  uploadFrequency?.let { map.putString("uploadFrequency", it) }
232
234
  batchSize?.let { map.putString("batchSize", it) }
233
235
  trackBackgroundEvents?.let { map.putBoolean("trackBackgroundEvents", it) }
236
+ trackNonFatalAnrs?.let { map.putBoolean("trackNonFatalAnrs", it) }
234
237
  additionalConfig?.let { map.putMap("additionalConfig", it.toWritableMap()) }
235
238
  return map
236
239
  }
@@ -9,8 +9,9 @@ package com.datadog.reactnative
9
9
  import android.content.Context
10
10
  import android.util.Log
11
11
  import com.datadog.android.privacy.TrackingConsent
12
- import com.datadog.android.rum.configuration.VitalsUpdateFrequency
12
+ import com.datadog.android.rum.GlobalRumMonitor
13
13
  import com.datadog.android.rum.RumPerformanceMetric
14
+ import com.datadog.android.rum.configuration.VitalsUpdateFrequency
14
15
  import com.facebook.react.bridge.LifecycleEventListener
15
16
  import com.facebook.react.bridge.Promise
16
17
  import com.facebook.react.bridge.ReactApplicationContext
@@ -57,6 +58,8 @@ class DdSdkImplementation(
57
58
  }
58
59
  })
59
60
 
61
+ configureSynthetics()
62
+
60
63
  initialized.set(true)
61
64
 
62
65
  promise.resolve(null)
@@ -156,6 +159,17 @@ class DdSdkImplementation(
156
159
  }
157
160
  }
158
161
 
162
+ private fun configureSynthetics() {
163
+ if (DdSdkSynthetics.testId.isNullOrBlank() || DdSdkSynthetics.resultId.isNullOrBlank()) {
164
+ return
165
+ }
166
+
167
+ datadog.getRumMonitor()._getInternal()?.setSyntheticsAttribute(
168
+ DdSdkSynthetics.testId,
169
+ DdSdkSynthetics.resultId
170
+ )
171
+ }
172
+
159
173
  private fun buildVitalUpdateFrequency(vitalsUpdateFrequency: String?): VitalsUpdateFrequency {
160
174
  val vitalUpdateFrequencyLower = vitalsUpdateFrequency?.lowercase(Locale.US)
161
175
  return when (vitalUpdateFrequencyLower) {
@@ -96,6 +96,7 @@ class DdSdkNativeInitialization internal constructor(
96
96
  ?: DdSdkImplementation.DEFAULT_APP_VERSION
97
97
  }
98
98
 
99
+ @Suppress("ComplexMethod")
99
100
  private fun buildRumConfiguration(configuration: DdSdkConfiguration): RumConfiguration {
100
101
  val configBuilder =
101
102
  RumConfiguration.Builder(
@@ -196,6 +197,10 @@ class DdSdkNativeInitialization internal constructor(
196
197
  configBuilder.useCustomEndpoint(it)
197
198
  }
198
199
 
200
+ configuration.trackNonFatalAnrs?.let {
201
+ configBuilder.trackNonFatalAnrs(it)
202
+ }
203
+
199
204
  return configBuilder.build()
200
205
  }
201
206
 
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ package com.datadog.reactnative
8
+
9
+ internal object DdSdkSynthetics {
10
+ var testId: String? = null
11
+ var resultId: String? = null
12
+ }
@@ -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 = "2.4.3"
10
+ internal const val SDK_VERSION = "2.5.0"
@@ -6,6 +6,8 @@
6
6
 
7
7
  package com.datadog.reactnative
8
8
 
9
+ import android.app.Activity
10
+ import com.facebook.react.bridge.LifecycleEventListener
9
11
  import com.facebook.react.bridge.Promise
10
12
  import com.facebook.react.bridge.ReactApplicationContext
11
13
  import com.facebook.react.bridge.ReactMethod
@@ -21,6 +23,23 @@ class DdSdk(
21
23
 
22
24
  override fun getName(): String = DdSdkImplementation.NAME
23
25
 
26
+ init {
27
+ reactContext.addLifecycleEventListener(object : LifecycleEventListener {
28
+ override fun onHostResume() {
29
+ val currentActivity: Activity? = currentActivity
30
+ if (currentActivity != null) {
31
+ val intent = currentActivity.intent
32
+ val extras = intent.extras
33
+ DdSdkSynthetics.testId = extras?.getString("_dd.synthetics.test_id")
34
+ DdSdkSynthetics.resultId = extras?.getString("_dd.synthetics.result_id")
35
+ }
36
+ }
37
+
38
+ override fun onHostPause() {}
39
+ override fun onHostDestroy() {}
40
+ })
41
+ }
42
+
24
43
  /**
25
44
  * Initializes Datadog's features.
26
45
  * @param configuration The configuration to use.
@@ -6,6 +6,8 @@
6
6
 
7
7
  package com.datadog.reactnative
8
8
 
9
+ import android.app.Activity
10
+ import com.facebook.react.bridge.LifecycleEventListener
9
11
  import com.facebook.react.bridge.Promise
10
12
  import com.facebook.react.bridge.ReactApplicationContext
11
13
  import com.facebook.react.bridge.ReactContextBaseJavaModule
@@ -22,6 +24,23 @@ class DdSdk(
22
24
 
23
25
  override fun getName(): String = DdSdkImplementation.NAME
24
26
 
27
+ init {
28
+ reactContext.addLifecycleEventListener(object : LifecycleEventListener {
29
+ override fun onHostResume() {
30
+ val currentActivity: Activity? = currentActivity
31
+ if (currentActivity != null) {
32
+ val intent = currentActivity.intent
33
+ val extras = intent.extras
34
+ DdSdkSynthetics.testId = extras?.getString("_dd.synthetics.test_id")
35
+ DdSdkSynthetics.resultId = extras?.getString("_dd.synthetics.result_id")
36
+ }
37
+ }
38
+
39
+ override fun onHostPause() {}
40
+ override fun onHostDestroy() {}
41
+ })
42
+ }
43
+
25
44
  /**
26
45
  * Initializes Datadog's features.
27
46
  * @param configuration The configuration to use.
@@ -241,6 +241,34 @@ internal class DdSdkBridgeExtTest {
241
241
  assertThat(list).isEmpty()
242
242
  }
243
243
 
244
+ @Test
245
+ fun `M returns a boolean W getBooleanOrNull { entry in the map }`() {
246
+ // Given
247
+ val readableMap = mapOf(
248
+ "testKey" to true
249
+ ).toReadableMap()
250
+
251
+ // When
252
+ val value = readableMap.getBooleanOrNull("testKey")
253
+
254
+ // Then
255
+ assertThat(value).isTrue()
256
+ }
257
+
258
+ @Test
259
+ fun `M returns null W getBooleanOrNull { entry not in the map }`() {
260
+ // Given
261
+ val readableMap = mapOf(
262
+ "dummy" to false
263
+ ).toReadableMap()
264
+
265
+ // When
266
+ val value = readableMap.getBooleanOrNull("testKey")
267
+
268
+ // Then
269
+ assertThat(value).isNull()
270
+ }
271
+
244
272
  private fun getTestMap(): MutableMap<String, Any?> = mutableMapOf(
245
273
  "null" to null,
246
274
  "int" to 1,
@@ -2293,6 +2293,23 @@ internal class DdSdkTest {
2293
2293
  .hasFieldEqualTo("customEndpointUrl", customTraceEndpoint)
2294
2294
  }
2295
2295
 
2296
+ @Test
2297
+ fun `𝕄 initialize native SDK 𝕎 initialize() {synthethics attributes}`() {
2298
+ // Given
2299
+ fakeConfiguration = fakeConfiguration.copy(nativeCrashReportEnabled = false, site = null)
2300
+ DdSdkSynthetics.testId = "unit-test-test-id"
2301
+ DdSdkSynthetics.resultId = "unit-test-result-id"
2302
+
2303
+ // When
2304
+ testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
2305
+
2306
+ // Then
2307
+ verify(mockRumInternalProxy).setSyntheticsAttribute(
2308
+ "unit-test-test-id",
2309
+ "unit-test-result-id"
2310
+ )
2311
+ }
2312
+
2296
2313
  @Test
2297
2314
  fun `𝕄 clear all data 𝕎 clearAllData()`() {
2298
2315
  // When
@@ -99,6 +99,8 @@ fun DdSdkConfiguration.toReadableJavaOnlyMap(): ReadableMap {
99
99
  map.put("bundleLogsWithRum", bundleLogsWithRum)
100
100
  map.put("bundleLogsWithTraces", bundleLogsWithTraces)
101
101
 
102
+ trackNonFatalAnrs?.let { map.put("trackNonFatalAnrs", it) }
103
+
102
104
  return map.toReadableMap()
103
105
  }
104
106
 
@@ -6,6 +6,7 @@
6
6
 
7
7
  package com.datadog.tools.unit
8
8
 
9
+ import com.datadog.android.rum.ExperimentalRumApi
9
10
  import com.datadog.android.rum.RumActionType
10
11
  import com.datadog.android.rum.RumErrorSource
11
12
  import com.datadog.android.rum.RumMonitor
@@ -48,6 +49,9 @@ class MockRumMonitor : RumMonitor {
48
49
 
49
50
  override fun addTiming(name: String) {}
50
51
 
52
+ @ExperimentalRumApi
53
+ override fun addViewLoadingTime(overwrite: Boolean) {}
54
+
51
55
  override fun clearAttributes() {}
52
56
 
53
57
  override fun getAttributes(): Map<String, Any?> {
@@ -79,7 +79,8 @@ class DdSdkConfigurationForgeryFactory : ForgeryFactory<DdSdkConfiguration> {
79
79
  serviceName = forge.aNullable { forge.anAlphabeticalString() },
80
80
  firstPartyHosts = null,
81
81
  bundleLogsWithRum = forge.aBool(),
82
- bundleLogsWithTraces = forge.aBool()
82
+ bundleLogsWithTraces = forge.aBool(),
83
+ trackNonFatalAnrs = forge.aBool()
83
84
  )
84
85
  }
85
86
  }
@@ -45,78 +45,78 @@ internal class TelemetryConfigurationEventForgeryFactory :
45
45
  dd = TelemetryConfigurationEvent.Dd(),
46
46
  telemetry = TelemetryConfigurationEvent.Telemetry(
47
47
  configuration = TelemetryConfigurationEvent.Configuration(
48
- forge.aNullable { aLong() },
49
- forge.aNullable { aLong() },
50
- forge.aNullable { aLong() },
51
- forge.aNullable { aLong() },
52
- forge.aNullable { aLong() },
53
- forge.aNullable {
48
+ sessionSampleRate = forge.aNullable { aLong() },
49
+ telemetrySampleRate = forge.aNullable { aLong() },
50
+ telemetryConfigurationSampleRate = forge.aNullable { aLong() },
51
+ telemetryUsageSampleRate = forge.aNullable { aLong() },
52
+ traceSampleRate = forge.aNullable { aLong() },
53
+ traceContextInjection = forge.aNullable {
54
54
  aValueFrom(
55
55
  TelemetryConfigurationEvent.TraceContextInjection::class.java
56
56
  )
57
57
  },
58
- forge.aNullable { aLong() },
59
- forge.aNullable { aLong() },
60
- forge.aNullable { aLong() },
61
- forge.aNullable {
58
+ premiumSampleRate = forge.aNullable { aLong() },
59
+ replaySampleRate = forge.aNullable { aLong() },
60
+ sessionReplaySampleRate = forge.aNullable { aLong() },
61
+ trackingConsent = forge.aNullable {
62
62
  aValueFrom(
63
63
  TelemetryConfigurationEvent.TrackingConsent::class.java
64
64
  )
65
65
  },
66
- forge.aNullable { aBool() },
67
- forge.aNullable { aBool() },
68
- forge.aNullable { aBool() },
69
- forge.aNullable { aBool() },
70
- forge.aNullable { aBool() },
71
- forge.aNullable { aBool() },
72
- forge.aNullable { aBool() },
73
- forge.aNullable { aBool() },
74
- forge.aNullable { aBool() },
75
- forge.aNullable { aBool() },
76
- forge.aNullable { aBool() },
77
- forge.aNullable { aBool() },
78
- forge.aNullable { aBool() },
79
- forge.aNullable { aString() },
80
- forge.aNullable { aBool() },
81
- forge.aNullable { aBool() },
82
- forge.aNullable {
66
+ startSessionReplayRecordingManually = forge.aNullable { aBool() },
67
+ useProxy = forge.aNullable { aBool() },
68
+ useBeforeSend = forge.aNullable { aBool() },
69
+ silentMultipleInit = forge.aNullable { aBool() },
70
+ trackSessionAcrossSubdomains = forge.aNullable { aBool() },
71
+ trackResources = forge.aNullable { aBool() },
72
+ trackLongTask = forge.aNullable { aBool() },
73
+ useCrossSiteSessionCookie = forge.aNullable { aBool() },
74
+ usePartitionedCrossSiteSessionCookie = forge.aNullable { aBool() },
75
+ useSecureSessionCookie = forge.aNullable { aBool() },
76
+ allowFallbackToLocalStorage = forge.aNullable { aBool() },
77
+ storeContextsAcrossPages = forge.aNullable { aBool() },
78
+ allowUntrustedEvents = forge.aNullable { aBool() },
79
+ actionNameAttribute = forge.aNullable { aString() },
80
+ useAllowedTracingOrigins = forge.aNullable { aBool() },
81
+ useAllowedTracingUrls = forge.aNullable { aBool() },
82
+ selectedTracingPropagators = forge.aNullable {
83
83
  aList {
84
84
  aValueFrom(
85
85
  TelemetryConfigurationEvent.SelectedTracingPropagator::class.java
86
86
  )
87
87
  }
88
88
  },
89
- forge.aNullable { aString() },
90
- forge.aNullable { aBool() },
91
- forge.aNullable { aBool() },
92
- forge.aNullable { aBool() },
93
- forge.aNullable { aBool() },
94
- forge.aNullable { aBool() },
89
+ defaultPrivacyLevel = forge.aNullable { aString() },
90
+ enablePrivacyForActionName = forge.aNullable { aBool() },
91
+ useExcludedActivityUrls = forge.aNullable { aBool() },
92
+ useWorkerUrl = forge.aNullable { aBool() },
93
+ compressIntakeRequests = forge.aNullable { aBool() },
94
+ trackFrustrations = forge.aNullable { aBool() },
95
95
 
96
- forge.aNullable { aBool() },
97
- forge.aNullable { aBool() },
98
- forge.aNullable { aBool() },
99
- forge.aNullable { aBool() },
100
- forge.aNullable { aList { aString() } },
101
- forge.aNullable { aList { aString() } },
102
- forge.aNullable { aBool() },
103
- forge.aNullable {
96
+ trackViewsManually = forge.aNullable { aBool() },
97
+ trackInteractions = forge.aNullable { aBool() },
98
+ trackUserInteractions = forge.aNullable { aBool() },
99
+ forwardErrorsToLogs = forge.aNullable { aBool() },
100
+ forwardConsoleLogs = forge.aNullable { aList { aString() } },
101
+ forwardReports = forge.aNullable { aList { aString() } },
102
+ useLocalEncryption = forge.aNullable { aBool() },
103
+ viewTrackingStrategy = forge.aNullable {
104
104
  aValueFrom(TelemetryConfigurationEvent.ViewTrackingStrategy::class.java)
105
105
  },
106
- forge.aNullable { aBool() },
107
- forge.aNullable { aLong() },
108
- forge.aNullable { aBool() },
109
- forge.aNullable { aBool() },
110
- forge.aNullable { aBool() },
111
- forge.aNullable { aBool() },
112
- forge.aNullable { aBool() },
113
- forge.aNullable { aBool() },
114
- forge.aNullable { aBool() },
115
- forge.aNullable { aBool() },
116
- forge.aNullable { aString() },
117
- forge.aNullable { aBool() },
118
- forge.aNullable { aLong() },
119
- forge.aNullable { aLong() }
106
+ trackBackgroundEvents = forge.aNullable { aBool() },
107
+ mobileVitalsUpdatePeriod = forge.aNullable { aLong() },
108
+ trackErrors = forge.aNullable { aBool() },
109
+ trackNetworkRequests = forge.aNullable { aBool() },
110
+ useTracing = forge.aNullable { aBool() },
111
+ trackNativeViews = forge.aNullable { aBool() },
112
+ trackNativeErrors = forge.aNullable { aBool() },
113
+ trackNativeLongTasks = forge.aNullable { aBool() },
114
+ trackCrossPlatformLongTasks = forge.aNullable { aBool() },
115
+ useFirstPartyHosts = forge.aNullable { aBool() },
116
+ initializationType = forge.aNullable { aString() },
117
+ trackFlutterPerformance = forge.aNullable { aBool() },
118
+ batchSize = forge.aNullable { aLong() },
119
+ batchUploadFrequency = forge.aNullable { aLong() }
120
120
  )
121
121
  )
122
122
  )
@@ -233,6 +233,14 @@
233
233
  "bundleLogsWithTraces": {
234
234
  "description": "Enables Traces correlation with logs.",
235
235
  "type": "boolean"
236
+ },
237
+ "appHangThreshold": {
238
+ "description": "The app hang threshold in seconds for non-fatal app hangs on iOS.",
239
+ "type": "number"
240
+ },
241
+ "trackNonFatalAnrs": {
242
+ "description": "Enables tracking of non-fatal ANRs on Android.",
243
+ "type": "boolean"
236
244
  }
237
245
  },
238
246
  "required": [
@@ -38,6 +38,7 @@ import DatadogRUM
38
38
  - firstPartyHosts: List of backend hosts to enable tracing with.
39
39
  - bundleLogsWithRum: Correlates logs with RUM.
40
40
  - bundleLogsWithTraces: Correlates logs with traces.
41
+ - appHangThreshold: The threshold for non-fatal app hangs reporting in seconds.
41
42
  */
42
43
  @objc(DdSdkConfiguration)
43
44
  public class DdSdkConfiguration: NSObject {
@@ -68,6 +69,7 @@ public class DdSdkConfiguration: NSObject {
68
69
  public var resourceTracingSamplingRate: Double? = nil
69
70
  public var bundleLogsWithRum: Bool
70
71
  public var bundleLogsWithTraces: Bool
72
+ public var appHangThreshold: Double? = nil
71
73
 
72
74
  public init(
73
75
  clientToken: String,
@@ -96,7 +98,8 @@ public class DdSdkConfiguration: NSObject {
96
98
  firstPartyHosts: [String: Set<TracingHeaderType>]?,
97
99
  resourceTracingSamplingRate: Double?,
98
100
  bundleLogsWithRum: Bool,
99
- bundleLogsWithTraces: Bool
101
+ bundleLogsWithTraces: Bool,
102
+ appHangThreshold: Double?
100
103
  ) {
101
104
  self.clientToken = clientToken
102
105
  self.env = env
@@ -125,6 +128,7 @@ public class DdSdkConfiguration: NSObject {
125
128
  self.resourceTracingSamplingRate = resourceTracingSamplingRate
126
129
  self.bundleLogsWithRum = bundleLogsWithRum
127
130
  self.bundleLogsWithTraces = bundleLogsWithTraces
131
+ self.appHangThreshold = appHangThreshold
128
132
  }
129
133
  }
130
134
 
@@ -159,6 +159,7 @@ public class DdSdkNativeInitialization: NSObject {
159
159
  trackFrustrations: configuration.trackFrustrations ?? true,
160
160
  trackBackgroundEvents: configuration.trackBackgroundEvents ?? false,
161
161
  longTaskThreshold: longTaskThreshold,
162
+ appHangThreshold: configuration.appHangThreshold,
162
163
  vitalsUpdateFrequency: configuration.vitalsUpdateFrequency,
163
164
  resourceEventMapper: { resourceEvent in
164
165
  if resourceEvent.context?.contextInfo[InternalConfigurationAttributes.dropResource] != nil {
@@ -39,6 +39,7 @@ extension NSDictionary {
39
39
  let resourceTracingSamplingRate = object(forKey: "resourceTracingSamplingRate") as? Double
40
40
  let bundleLogsWithRum = object(forKey: "bundleLogsWithRum") as? Bool
41
41
  let bundleLogsWithTraces = object(forKey: "bundleLogsWithTraces") as? Bool
42
+ let appHangThreshold = object(forKey: "appHangThreshold") as? Double
42
43
 
43
44
  return DdSdkConfiguration(
44
45
  clientToken: (clientToken != nil) ? clientToken! : String(),
@@ -67,7 +68,8 @@ extension NSDictionary {
67
68
  firstPartyHosts: firstPartyHosts?.asFirstPartyHosts(),
68
69
  resourceTracingSamplingRate: resourceTracingSamplingRate,
69
70
  bundleLogsWithRum: bundleLogsWithRum ?? DefaultConfiguration.bundleLogsWithRum,
70
- bundleLogsWithTraces: bundleLogsWithTraces ?? DefaultConfiguration.bundleLogsWithTraces
71
+ bundleLogsWithTraces: bundleLogsWithTraces ?? DefaultConfiguration.bundleLogsWithTraces,
72
+ appHangThreshold: appHangThreshold
71
73
  )
72
74
  }
73
75
 
@@ -231,6 +233,7 @@ extension Dictionary where Key == String, Value == AnyObject {
231
233
  let resourceTracingSamplingRate = configuration["resourceTracingSamplingRate"] as? Double
232
234
  let bundleLogsWithRum = configuration["bundleLogsWithRum"] as? Bool
233
235
  let bundleLogsWithTraces = configuration["bundleLogsWithTraces"] as? Bool
236
+ let appHangThreshold = configuration["appHangThreshold"] as? Double
234
237
 
235
238
  return DdSdkConfiguration(
236
239
  clientToken: clientToken ?? String(),
@@ -262,7 +265,8 @@ extension Dictionary where Key == String, Value == AnyObject {
262
265
  firstPartyHosts: firstPartyHosts?.asFirstPartyHosts() ?? DefaultConfiguration.firstPartyHosts,
263
266
  resourceTracingSamplingRate: resourceTracingSamplingRate ?? DefaultConfiguration.resourceTracingSamplingRate,
264
267
  bundleLogsWithRum: bundleLogsWithRum ?? DefaultConfiguration.bundleLogsWithRum,
265
- bundleLogsWithTraces: bundleLogsWithTraces ?? DefaultConfiguration.bundleLogsWithTraces
268
+ bundleLogsWithTraces: bundleLogsWithTraces ?? DefaultConfiguration.bundleLogsWithTraces,
269
+ appHangThreshold: appHangThreshold
266
270
  )
267
271
  }
268
272
  }
@@ -7,4 +7,4 @@
7
7
  import Foundation
8
8
 
9
9
  // This is automatically updated by the update-version.sh script
10
- let SdkVersion = "2.4.3"
10
+ let SdkVersion = "2.5.0"
package/jest/mock.js CHANGED
@@ -30,6 +30,9 @@ module.exports = {
30
30
  setUser: jest
31
31
  .fn()
32
32
  .mockImplementation(() => new Promise(resolve => resolve())),
33
+ addUserExtraInfo: jest
34
+ .fn()
35
+ .mockImplementation(() => new Promise(resolve => resolve())),
33
36
  setAttributes: jest
34
37
  .fn()
35
38
  .mockImplementation(() => new Promise(resolve => resolve())),
@@ -95,6 +98,7 @@ module.exports = {
95
98
  stopResource: jest
96
99
  .fn()
97
100
  .mockImplementation(() => new Promise(resolve => resolve())),
101
+ generateUUID: jest.fn().mockImplementation(() => 'fakeUUID'),
98
102
  addError: jest
99
103
  .fn()
100
104
  .mockImplementation(() => new Promise(resolve => resolve())),