@datadog/mobile-react-native 3.0.3 → 3.1.1

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 (93) hide show
  1. package/DatadogSDKReactNative.podspec +10 -9
  2. package/android/build.gradle +10 -8
  3. package/android/src/main/kotlin/com/datadog/reactnative/DdFlagsImplementation.kt +237 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkBridgeExt.kt +262 -78
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +3 -3
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +18 -18
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +3 -2
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -1
  9. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  10. package/android/src/newarch/kotlin/com/datadog/reactnative/DdFlags.kt +66 -0
  11. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdFlags.kt +63 -0
  12. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkBridgeExtTest.kt +242 -0
  13. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +4 -2
  14. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +6 -3
  15. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +3 -4
  16. package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +38 -0
  17. package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +3 -0
  18. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +1 -1
  19. package/android/src/test/resources/input/complete-configuration.json +10 -10
  20. package/ios/Sources/DatadogSDKReactNative.h +2 -0
  21. package/ios/Sources/DdFlags.h +24 -0
  22. package/ios/Sources/DdFlags.mm +83 -0
  23. package/ios/Sources/DdFlagsImplementation.swift +263 -0
  24. package/ios/Sources/DdSdkConfiguration.swift +4 -4
  25. package/ios/Sources/DdSdkNativeInitialization.swift +2 -2
  26. package/ios/Sources/RNDdSdkConfiguration.swift +11 -9
  27. package/ios/Sources/SdkVersion.swift +1 -1
  28. package/lib/commonjs/InternalLog.js +9 -7
  29. package/lib/commonjs/InternalLog.js.map +1 -1
  30. package/lib/commonjs/flags/DdFlags.js +51 -0
  31. package/lib/commonjs/flags/DdFlags.js.map +1 -0
  32. package/lib/commonjs/flags/FlagsClient.js +218 -0
  33. package/lib/commonjs/flags/FlagsClient.js.map +1 -0
  34. package/lib/commonjs/flags/internal.js +40 -0
  35. package/lib/commonjs/flags/internal.js.map +1 -0
  36. package/lib/commonjs/flags/types.js +6 -0
  37. package/lib/commonjs/flags/types.js.map +1 -0
  38. package/lib/commonjs/index.js +7 -0
  39. package/lib/commonjs/index.js.map +1 -1
  40. package/lib/commonjs/sdk/DatadogProvider/Buffer/BufferSingleton.js +10 -8
  41. package/lib/commonjs/sdk/DatadogProvider/Buffer/BufferSingleton.js.map +1 -1
  42. package/lib/commonjs/specs/NativeDdFlags.js +19 -0
  43. package/lib/commonjs/specs/NativeDdFlags.js.map +1 -0
  44. package/lib/commonjs/version.js +1 -1
  45. package/lib/module/InternalLog.js +9 -6
  46. package/lib/module/InternalLog.js.map +1 -1
  47. package/lib/module/flags/DdFlags.js +45 -0
  48. package/lib/module/flags/DdFlags.js.map +1 -0
  49. package/lib/module/flags/FlagsClient.js +211 -0
  50. package/lib/module/flags/FlagsClient.js.map +1 -0
  51. package/lib/module/flags/internal.js +33 -0
  52. package/lib/module/flags/internal.js.map +1 -0
  53. package/lib/module/flags/types.js +2 -0
  54. package/lib/module/flags/types.js.map +1 -0
  55. package/lib/module/index.js +2 -1
  56. package/lib/module/index.js.map +1 -1
  57. package/lib/module/sdk/DatadogProvider/Buffer/BufferSingleton.js +10 -7
  58. package/lib/module/sdk/DatadogProvider/Buffer/BufferSingleton.js.map +1 -1
  59. package/lib/module/specs/NativeDdFlags.js +17 -0
  60. package/lib/module/specs/NativeDdFlags.js.map +1 -0
  61. package/lib/module/version.js +1 -1
  62. package/lib/typescript/InternalLog.d.ts +6 -4
  63. package/lib/typescript/InternalLog.d.ts.map +1 -1
  64. package/lib/typescript/flags/DdFlags.d.ts +3 -0
  65. package/lib/typescript/flags/DdFlags.d.ts.map +1 -0
  66. package/lib/typescript/flags/FlagsClient.d.ts +114 -0
  67. package/lib/typescript/flags/FlagsClient.d.ts.map +1 -0
  68. package/lib/typescript/flags/internal.d.ts +14 -0
  69. package/lib/typescript/flags/internal.d.ts.map +1 -0
  70. package/lib/typescript/flags/types.d.ts +202 -0
  71. package/lib/typescript/flags/types.d.ts.map +1 -0
  72. package/lib/typescript/index.d.ts +5 -2
  73. package/lib/typescript/index.d.ts.map +1 -1
  74. package/lib/typescript/nativeModulesTypes.d.ts +5 -0
  75. package/lib/typescript/nativeModulesTypes.d.ts.map +1 -1
  76. package/lib/typescript/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -5
  77. package/lib/typescript/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts.map +1 -1
  78. package/lib/typescript/specs/NativeDdFlags.d.ts +15 -0
  79. package/lib/typescript/specs/NativeDdFlags.d.ts.map +1 -0
  80. package/lib/typescript/version.d.ts +1 -1
  81. package/package.json +2 -2
  82. package/src/InternalLog.tsx +14 -6
  83. package/src/flags/DdFlags.ts +59 -0
  84. package/src/flags/FlagsClient.ts +266 -0
  85. package/src/flags/__tests__/DdFlags.test.ts +65 -0
  86. package/src/flags/__tests__/FlagsClient.test.ts +320 -0
  87. package/src/flags/internal.ts +63 -0
  88. package/src/flags/types.ts +215 -0
  89. package/src/index.tsx +15 -1
  90. package/src/nativeModulesTypes.ts +6 -0
  91. package/src/sdk/DatadogProvider/Buffer/BufferSingleton.ts +16 -7
  92. package/src/specs/NativeDdFlags.ts +35 -0
  93. package/src/version.ts +1 -1
@@ -0,0 +1,66 @@
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
+ import com.facebook.react.bridge.Promise
10
+ import com.facebook.react.bridge.ReactApplicationContext
11
+ import com.facebook.react.bridge.ReactMethod
12
+ import com.facebook.react.bridge.ReadableMap
13
+
14
+ /** The entry point to use Datadog's Flags feature. */
15
+ class DdFlags(
16
+ reactContext: ReactApplicationContext,
17
+ ) : NativeDdFlagsSpec(reactContext) {
18
+ private val implementation = DdFlagsImplementation()
19
+
20
+ override fun getName(): String = DdFlagsImplementation.NAME
21
+
22
+ /**
23
+ * Enable the Flags feature with the provided configuration.
24
+ * @param configuration The configuration for Flags.
25
+ */
26
+ @ReactMethod
27
+ override fun enable(
28
+ configuration: ReadableMap,
29
+ promise: Promise,
30
+ ) {
31
+ implementation.enable(configuration, promise)
32
+ }
33
+
34
+ /**
35
+ * Set the evaluation context for a specific client.
36
+ * @param clientName The name of the client.
37
+ * @param targetingKey The targeting key.
38
+ * @param attributes The attributes for the evaluation context.
39
+ */
40
+ @ReactMethod
41
+ override fun setEvaluationContext(
42
+ clientName: String,
43
+ targetingKey: String,
44
+ attributes: ReadableMap,
45
+ promise: Promise,
46
+ ) {
47
+ implementation.setEvaluationContext(clientName, targetingKey, attributes, promise)
48
+ }
49
+
50
+ /**
51
+ * Track the evaluation of a flag.
52
+ * @param clientName The name of the client.
53
+ * @param key The key of the flag.
54
+ */
55
+ @ReactMethod
56
+ override fun trackEvaluation(
57
+ clientName: String,
58
+ key: String,
59
+ rawFlag: ReadableMap,
60
+ targetingKey: String,
61
+ attributes: ReadableMap,
62
+ promise: Promise,
63
+ ) {
64
+ implementation.trackEvaluation(clientName, key, rawFlag, targetingKey, attributes, promise)
65
+ }
66
+ }
@@ -0,0 +1,63 @@
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
+ import com.facebook.react.bridge.Promise
10
+ import com.facebook.react.bridge.ReactApplicationContext
11
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
12
+ import com.facebook.react.bridge.ReactMethod
13
+ import com.facebook.react.bridge.ReadableMap
14
+
15
+ /** The entry point to use Datadog's Flags feature. */
16
+ class DdFlags(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
17
+
18
+ private val implementation = DdFlagsImplementation()
19
+
20
+ override fun getName(): String = DdFlagsImplementation.NAME
21
+
22
+ /**
23
+ * Enable the Flags feature with the provided configuration.
24
+ * @param configuration The configuration for Flags.
25
+ */
26
+ @ReactMethod
27
+ fun enable(configuration: ReadableMap, promise: Promise) {
28
+ implementation.enable(configuration, promise)
29
+ }
30
+
31
+ /**
32
+ * Set the evaluation context for a specific client.
33
+ * @param clientName The name of the client.
34
+ * @param targetingKey The targeting key.
35
+ * @param attributes The attributes for the evaluation context.
36
+ */
37
+ @ReactMethod
38
+ fun setEvaluationContext(
39
+ clientName: String,
40
+ targetingKey: String,
41
+ attributes: ReadableMap,
42
+ promise: Promise
43
+ ) {
44
+ implementation.setEvaluationContext(clientName, targetingKey, attributes, promise)
45
+ }
46
+
47
+ /**
48
+ * Track the evaluation of a flag.
49
+ * @param clientName The name of the client.
50
+ * @param key The key of the flag.
51
+ */
52
+ @ReactMethod
53
+ fun trackEvaluation(
54
+ clientName: String,
55
+ key: String,
56
+ rawFlag: ReadableMap,
57
+ targetingKey: String,
58
+ attributes: ReadableMap,
59
+ promise: Promise
60
+ ) {
61
+ implementation.trackEvaluation(clientName, key, rawFlag, targetingKey, attributes, promise)
62
+ }
63
+ }
@@ -9,11 +9,14 @@ package com.datadog.reactnative
9
9
  import com.datadog.tools.unit.keys
10
10
  import com.datadog.tools.unit.toReadableArray
11
11
  import com.datadog.tools.unit.toReadableMap
12
+ import com.datadog.tools.unit.toReadableMapDeep
12
13
  import com.facebook.react.bridge.JavaOnlyArray
13
14
  import com.facebook.react.bridge.JavaOnlyMap
14
15
  import com.facebook.react.bridge.WritableArray
15
16
  import com.facebook.react.bridge.WritableMap
16
17
  import org.assertj.core.api.Assertions.assertThat
18
+ import org.json.JSONArray
19
+ import org.json.JSONObject
17
20
  import org.junit.jupiter.api.Test
18
21
 
19
22
  internal class DdSdkBridgeExtTest {
@@ -276,6 +279,245 @@ internal class DdSdkBridgeExtTest {
276
279
  assertThat(value).isNull()
277
280
  }
278
281
 
282
+ @Test
283
+ fun `M do a proper conversion W JSONObject toMap { with raw types }`() {
284
+ // Given
285
+ val jsonObject = JSONObject().apply {
286
+ put("null", JSONObject.NULL)
287
+ put("int", 1)
288
+ put("long", 2L)
289
+ put("double", 3.0)
290
+ put("string", "test")
291
+ put("boolean", true)
292
+ }
293
+
294
+ // When
295
+ val map = jsonObject.toMap()
296
+
297
+ // Then
298
+ assertThat(map).hasSize(6)
299
+ assertThat(map["null"]).isNull()
300
+ assertThat(map["int"]).isEqualTo(1)
301
+ assertThat(map["long"]).isEqualTo(2L)
302
+ assertThat(map["double"]).isEqualTo(3.0)
303
+ assertThat(map["string"]).isEqualTo("test")
304
+ assertThat(map["boolean"]).isEqualTo(true)
305
+ }
306
+
307
+ @Test
308
+ fun `M do a proper conversion W JSONObject toMap { with nested objects }`() {
309
+ // Given
310
+ val nestedObject = JSONObject().apply {
311
+ put("nestedKey", "nestedValue")
312
+ }
313
+ val nestedArray = JSONArray().apply {
314
+ put("item1")
315
+ put("item2")
316
+ }
317
+ val jsonObject = JSONObject().apply {
318
+ put("object", nestedObject)
319
+ put("array", nestedArray)
320
+ }
321
+
322
+ // When
323
+ val map = jsonObject.toMap()
324
+
325
+ // Then
326
+ assertThat(map).hasSize(2)
327
+ assertThat(map["object"]).isInstanceOf(Map::class.java)
328
+ assertThat((map["object"] as Map<*, *>)["nestedKey"]).isEqualTo("nestedValue")
329
+ assertThat(map["array"]).isInstanceOf(List::class.java)
330
+ assertThat((map["array"] as List<*>)).hasSize(2)
331
+ assertThat((map["array"] as List<*>)[0]).isEqualTo("item1")
332
+ assertThat((map["array"] as List<*>)[1]).isEqualTo("item2")
333
+ }
334
+
335
+ @Test
336
+ fun `M do a proper conversion W JSONObject toWritableMap { with raw types }`() {
337
+ // Given
338
+ val jsonObject = JSONObject().apply {
339
+ put("int", 1)
340
+ put("double", 2.0)
341
+ put("string", "test")
342
+ put("boolean", true)
343
+ }
344
+
345
+ // When
346
+ // Use the parameterized version to avoid native library requirements in unit tests
347
+ val writableMap = jsonObject.toMap().toWritableMap(createWritableMap, createWritableArray)
348
+
349
+ // Then
350
+ assertThat(writableMap.getInt("int")).isEqualTo(1)
351
+ assertThat(writableMap.getDouble("double")).isEqualTo(2.0)
352
+ assertThat(writableMap.getString("string")).isEqualTo("test")
353
+ assertThat(writableMap.getBoolean("boolean")).isTrue()
354
+ }
355
+
356
+ @Test
357
+ fun `M do a proper conversion W JSONArray toList { with raw types }`() {
358
+ // Given
359
+ val jsonArray = JSONArray().apply {
360
+ put(JSONObject.NULL)
361
+ put(1)
362
+ put(2.0)
363
+ put("test")
364
+ put(true)
365
+ }
366
+
367
+ // When
368
+ val list = jsonArray.toList()
369
+
370
+ // Then
371
+ assertThat(list).hasSize(5)
372
+ assertThat(list[0]).isNull()
373
+ assertThat(list[1]).isEqualTo(1)
374
+ assertThat(list[2]).isEqualTo(2.0)
375
+ assertThat(list[3]).isEqualTo("test")
376
+ assertThat(list[4]).isEqualTo(true)
377
+ }
378
+
379
+ @Test
380
+ fun `M do a proper conversion W JSONArray toList { with nested objects }`() {
381
+ // Given
382
+ val nestedObject = JSONObject().apply {
383
+ put("key", "value")
384
+ }
385
+ val nestedArray = JSONArray().apply {
386
+ put("nested")
387
+ }
388
+ val jsonArray = JSONArray().apply {
389
+ put(nestedObject)
390
+ put(nestedArray)
391
+ }
392
+
393
+ // When
394
+ val list = jsonArray.toList()
395
+
396
+ // Then
397
+ assertThat(list).hasSize(2)
398
+ assertThat(list[0]).isInstanceOf(Map::class.java)
399
+ assertThat((list[0] as Map<*, *>)["key"]).isEqualTo("value")
400
+ assertThat(list[1]).isInstanceOf(List::class.java)
401
+ assertThat((list[1] as List<*>)[0]).isEqualTo("nested")
402
+ }
403
+
404
+ @Test
405
+ fun `M do a proper conversion W ReadableMap toJSONObject { with raw types }`() {
406
+ // Given
407
+ val readableMap = mapOf(
408
+ "int" to 1,
409
+ "double" to 2.0,
410
+ "string" to "test",
411
+ "boolean" to true
412
+ ).toReadableMapDeep()
413
+
414
+ // When
415
+ val jsonObject = readableMap.toJSONObject()
416
+
417
+ // Then
418
+ assertThat(jsonObject.length()).isEqualTo(4)
419
+ assertThat(jsonObject.getInt("int")).isEqualTo(1)
420
+ assertThat(jsonObject.getDouble("double")).isEqualTo(2.0)
421
+ assertThat(jsonObject.getString("string")).isEqualTo("test")
422
+ assertThat(jsonObject.getBoolean("boolean")).isTrue()
423
+ }
424
+
425
+ @Test
426
+ fun `M do a proper conversion W ReadableMap toJSONObject { with nested objects }`() {
427
+ // Given
428
+ val readableMap = mapOf(
429
+ "map" to mapOf("nestedKey" to "nestedValue"),
430
+ "list" to listOf("item1", "item2")
431
+ ).toReadableMapDeep()
432
+
433
+ // When
434
+ val jsonObject = readableMap.toJSONObject()
435
+
436
+ // Then
437
+ assertThat(jsonObject.length()).isEqualTo(2)
438
+ assertThat(jsonObject.getJSONObject("map").getString("nestedKey")).isEqualTo("nestedValue")
439
+ assertThat(jsonObject.getJSONArray("list").length()).isEqualTo(2)
440
+ assertThat(jsonObject.getJSONArray("list").getString(0)).isEqualTo("item1")
441
+ assertThat(jsonObject.getJSONArray("list").getString(1)).isEqualTo("item2")
442
+ }
443
+
444
+ @Test
445
+ fun `M do a proper conversion W Map toJSONObject { with raw types }`() {
446
+ // Given
447
+ val map: Map<String, Any> = mapOf(
448
+ "int" to 1,
449
+ "double" to 2.0,
450
+ "string" to "test",
451
+ "boolean" to true
452
+ )
453
+
454
+ // When
455
+ val jsonObject = map.toJSONObject()
456
+
457
+ // Then
458
+ assertThat(jsonObject.length()).isEqualTo(4)
459
+ assertThat(jsonObject.getInt("int")).isEqualTo(1)
460
+ assertThat(jsonObject.getDouble("double")).isEqualTo(2.0)
461
+ assertThat(jsonObject.getString("string")).isEqualTo("test")
462
+ assertThat(jsonObject.getBoolean("boolean")).isTrue()
463
+ }
464
+
465
+ @Test
466
+ fun `M do a proper conversion W Map toJSONObject { with nested objects }`() {
467
+ // Given
468
+ val map: Map<String, Any> = mapOf(
469
+ "nestedMap" to mapOf("key" to "value"),
470
+ "nestedList" to listOf(1, 2, 3)
471
+ )
472
+
473
+ // When
474
+ val jsonObject = map.toJSONObject()
475
+
476
+ // Then
477
+ assertThat(jsonObject.length()).isEqualTo(2)
478
+ assertThat(jsonObject.getJSONObject("nestedMap").getString("key")).isEqualTo("value")
479
+ assertThat(jsonObject.getJSONArray("nestedList").length()).isEqualTo(3)
480
+ assertThat(jsonObject.getJSONArray("nestedList").getInt(0)).isEqualTo(1)
481
+ assertThat(jsonObject.getJSONArray("nestedList").getInt(1)).isEqualTo(2)
482
+ assertThat(jsonObject.getJSONArray("nestedList").getInt(2)).isEqualTo(3)
483
+ }
484
+
485
+ @Test
486
+ fun `M do a proper conversion W List toJSONArray { with raw types }`() {
487
+ // Given
488
+ val list = listOf(null, 1, 2.0, "test", true)
489
+
490
+ // When
491
+ val jsonArray = list.toJSONArray()
492
+
493
+ // Then
494
+ assertThat(jsonArray.length()).isEqualTo(5)
495
+ assertThat(jsonArray.isNull(0)).isTrue()
496
+ assertThat(jsonArray.getInt(1)).isEqualTo(1)
497
+ assertThat(jsonArray.getDouble(2)).isEqualTo(2.0)
498
+ assertThat(jsonArray.getString(3)).isEqualTo("test")
499
+ assertThat(jsonArray.getBoolean(4)).isTrue()
500
+ }
501
+
502
+ @Test
503
+ fun `M do a proper conversion W List toJSONArray { with nested objects }`() {
504
+ // Given
505
+ val list = listOf(
506
+ mapOf("key" to "value"),
507
+ listOf("nested1", "nested2")
508
+ )
509
+
510
+ // When
511
+ val jsonArray = list.toJSONArray()
512
+
513
+ // Then
514
+ assertThat(jsonArray.length()).isEqualTo(2)
515
+ assertThat(jsonArray.getJSONObject(0).getString("key")).isEqualTo("value")
516
+ assertThat(jsonArray.getJSONArray(1).length()).isEqualTo(2)
517
+ assertThat(jsonArray.getJSONArray(1).getString(0)).isEqualTo("nested1")
518
+ assertThat(jsonArray.getJSONArray(1).getString(1)).isEqualTo("nested2")
519
+ }
520
+
279
521
  private fun getTestMap(): MutableMap<String, Any?> = mutableMapOf(
280
522
  "null" to null,
281
523
  "int" to 1,
@@ -131,7 +131,8 @@ internal class DdSdkNativeInitializationTest {
131
131
  }
132
132
  assertThat(configuration.proxyConfiguration?.second?.username).isEqualTo("proxyusername")
133
133
  assertThat(configuration.proxyConfiguration?.second?.password).isEqualTo("proxypassword")
134
- assertThat(configuration.firstPartyHosts?.get("example.com").toString()).isEqualTo(
134
+ val firstPartyHosts = configuration.rumConfiguration?.firstPartyHosts?.get("example.com")
135
+ assertThat(firstPartyHosts.toString()).isEqualTo(
135
136
  "[B3MULTI, TRACECONTEXT]"
136
137
  )
137
138
  assertThat(configuration.rumConfiguration?.initialResourceThreshold).isEqualTo(0.5)
@@ -155,7 +156,7 @@ internal class DdSdkNativeInitializationTest {
155
156
  assertThat(configuration.verbosity).isNull()
156
157
  assertThat(configuration.service).isNull()
157
158
  assertThat(configuration.proxyConfiguration).isNull()
158
- assertThat(configuration.firstPartyHosts).isNull()
159
+
159
160
  assertThat(configuration.site).isEqualTo("US1")
160
161
  assertThat(configuration.uploadFrequency).isEqualTo("AVERAGE")
161
162
  assertThat(configuration.batchSize).isEqualTo("MEDIUM")
@@ -180,6 +181,7 @@ internal class DdSdkNativeInitializationTest {
180
181
  assertThat(configuration.rumConfiguration?.nativeLongTaskThresholdMs).isEqualTo(200.0)
181
182
  assertThat(configuration.rumConfiguration?.nativeViewTracking).isEqualTo(false)
182
183
  assertThat(configuration.rumConfiguration?.nativeInteractionTracking).isEqualTo(false)
184
+ assertThat(configuration.rumConfiguration?.firstPartyHosts).isNull()
183
185
  assertThat(configuration.logsConfiguration?.customEndpoint).isNull()
184
186
  assertThat(configuration.traceConfiguration?.customEndpoint).isNull()
185
187
  }
@@ -1772,9 +1772,10 @@ internal class DdSdkTest {
1772
1772
  }
1773
1773
 
1774
1774
  // Given
1775
- val bridgeConfiguration = configuration.copy(
1775
+ val rumConfiguration = configuration.rumConfiguration?.copy(
1776
1776
  firstPartyHosts = firstPartyHosts.toReadableArray().asFirstPartyHosts()
1777
1777
  )
1778
+ val bridgeConfiguration = configuration.copy(rumConfiguration = rumConfiguration)
1778
1779
  val sdkConfigCaptor = argumentCaptor<Configuration>()
1779
1780
  val rumConfigCaptor = argumentCaptor<RumConfiguration>()
1780
1781
  val logsConfigCaptor = argumentCaptor<LogsConfiguration>()
@@ -1845,9 +1846,10 @@ internal class DdSdkTest {
1845
1846
  }
1846
1847
 
1847
1848
  // Given
1848
- val bridgeConfiguration = configuration.copy(
1849
+ val rumConfiguration = configuration.rumConfiguration?.copy(
1849
1850
  firstPartyHosts = firstPartyHosts.toReadableArray().asFirstPartyHosts()
1850
1851
  )
1852
+ val bridgeConfiguration = configuration.copy(rumConfiguration = rumConfiguration)
1851
1853
  val sdkConfigCaptor = argumentCaptor<Configuration>()
1852
1854
  val rumConfigCaptor = argumentCaptor<RumConfiguration>()
1853
1855
  val logsConfigCaptor = argumentCaptor<LogsConfiguration>()
@@ -1925,9 +1927,10 @@ internal class DdSdkTest {
1925
1927
  )
1926
1928
 
1927
1929
  // Given
1928
- val bridgeConfiguration = configuration.copy(
1930
+ val rumConfiguration = configuration.rumConfiguration?.copy(
1929
1931
  firstPartyHosts = firstPartyHosts.toReadableArray().asFirstPartyHosts()
1930
1932
  )
1933
+ val bridgeConfiguration = configuration.copy(rumConfiguration = rumConfiguration)
1931
1934
  val sdkConfigCaptor = argumentCaptor<Configuration>()
1932
1935
  val rumConfigCaptor = argumentCaptor<RumConfiguration>()
1933
1936
  val logsConfigCaptor = argumentCaptor<LogsConfiguration>()
@@ -40,10 +40,6 @@ fun DdSdkConfiguration.toReadableJavaOnlyMap(): ReadableMap {
40
40
  map["proxyConfiguration"] = proxyPair.toReadableMap()
41
41
  }
42
42
 
43
- firstPartyHosts?.let {
44
- map["firstPartyHosts"] = it.toFirstPartyHostsReadableArray()
45
- }
46
-
47
43
  additionalConfiguration?.let {
48
44
  map["additionalConfiguration"] = it.toReadableMap()
49
45
  }
@@ -65,6 +61,9 @@ fun DdSdkConfiguration.toReadableJavaOnlyMap(): ReadableMap {
65
61
  rum?.nativeViewTracking?.let { rumMap["nativeViewTracking"] = it }
66
62
  rum?.nativeInteractionTracking?.let { rumMap["nativeInteractionTracking"] = it }
67
63
  rum?.trackNonFatalAnrs?.let { rumMap["trackNonFatalAnrs"] = it }
64
+ rum?.firstPartyHosts?.let {
65
+ rumMap["firstPartyHosts"] = it.toFirstPartyHostsReadableArray()
66
+ }
68
67
  rumMap["initialResourceThreshold"] = rum?.initialResourceThreshold ?: 0.1
69
68
  rumMap["telemetrySampleRate"] = rum?.telemetrySampleRate ?: 20.0
70
69
  rum?.customEndpoint?.let { rumMap["customEndpoint"] = it }
@@ -25,6 +25,28 @@ fun Map<*, *>.toReadableMap(): ReadableMap {
25
25
  return JavaOnlyMap.of(*keysAndValues.toTypedArray())
26
26
  }
27
27
 
28
+ /**
29
+ * Recursively converts the [Map] to a [ReadableMap], including nested maps and lists.
30
+ */
31
+ fun Map<*, *>.toReadableMapDeep(): ReadableMap {
32
+ val keysAndValues = mutableListOf<Any?>()
33
+
34
+ entries.forEach {
35
+ keysAndValues.add(it.key)
36
+ keysAndValues.add(
37
+ when (val value = it.value) {
38
+ is ReadableMap -> value
39
+ is ReadableArray -> value
40
+ is Map<*, *> -> value.toReadableMapDeep()
41
+ is List<*> -> value.toReadableArrayDeep()
42
+ else -> value
43
+ }
44
+ )
45
+ }
46
+
47
+ return JavaOnlyMap.of(*keysAndValues.toTypedArray())
48
+ }
49
+
28
50
  fun Map<String, Set<TracingHeaderType>>.toFirstPartyHostsReadableArray(): ReadableArray {
29
51
  val list = mutableListOf<Any>()
30
52
 
@@ -48,6 +70,22 @@ fun List<*>.toReadableArray(): ReadableArray {
48
70
  return JavaOnlyArray.from(this)
49
71
  }
50
72
 
73
+ /**
74
+ * Recursively converts the [List] to a [ReadableArray], including nested maps and lists.
75
+ */
76
+ fun List<*>.toReadableArrayDeep(): ReadableArray {
77
+ val convertedList = this.map { value ->
78
+ when (value) {
79
+ is ReadableMap -> value
80
+ is ReadableArray -> value
81
+ is Map<*, *> -> value.toReadableMapDeep()
82
+ is List<*> -> value.toReadableArrayDeep()
83
+ else -> value
84
+ }
85
+ }
86
+ return JavaOnlyArray.from(convertedList)
87
+ }
88
+
51
89
  fun Set<*>.toReadableArray(): ReadableArray {
52
90
  // this FB implementation is not backed by Android-specific .so library, so ok for unit tests
53
91
  return JavaOnlyArray.from(this.toList())
@@ -147,4 +147,7 @@ class MockRumMonitor : RumMonitor {
147
147
  failureReason: FailureReason,
148
148
  attributes: Map<String, Any?>
149
149
  ) {}
150
+
151
+ @ExperimentalRumApi
152
+ override fun reportAppFullyDisplayed() {}
150
153
  }
@@ -56,7 +56,6 @@ class DdSdkConfigurationForgeryFactory : ForgeryFactory<DdSdkConfiguration> {
56
56
  )
57
57
  },
58
58
  proxyConfiguration = null,
59
- firstPartyHosts = null,
60
59
  rumConfiguration = RumConfiguration(
61
60
  applicationId = forge.getForgery<UUID>().toString(),
62
61
  trackFrustrations = forge.aNullable { aBool() },
@@ -71,6 +70,7 @@ class DdSdkConfigurationForgeryFactory : ForgeryFactory<DdSdkConfiguration> {
71
70
  nativeLongTaskThresholdMs = forge.aNullable { aDouble(100.0, 5000.0) },
72
71
  nativeViewTracking = forge.aNullable { aBool() },
73
72
  nativeInteractionTracking = forge.aNullable { aBool() },
73
+ firstPartyHosts = null,
74
74
  trackNonFatalAnrs = forge.aNullable { aBool() },
75
75
  initialResourceThreshold = forge.aNullable { aDouble(0.0, 2.0) },
76
76
  telemetrySampleRate = forge.aNullable { aDouble(0.0, 100.0) },
@@ -29,7 +29,16 @@
29
29
  "sessionSampleRate": 80,
30
30
  "resourceTraceSampleRate": 33,
31
31
  "trackBackgroundEvents": true,
32
- "trackFrustrations": false
32
+ "trackFrustrations": false,
33
+ "firstPartyHosts": [
34
+ {
35
+ "match": "example.com",
36
+ "propagatorTypes": [
37
+ "B3MULTI",
38
+ "TRACECONTEXT"
39
+ ]
40
+ }
41
+ ]
33
42
  },
34
43
  "logsConfiguration": {
35
44
  "customEndpoint": "https://logs.example.com"
@@ -37,15 +46,6 @@
37
46
  "traceConfiguration": {
38
47
  "customEndpoint": "https://trace.example.com"
39
48
  },
40
- "firstPartyHosts": [
41
- {
42
- "match": "example.com",
43
- "propagatorTypes": [
44
- "B3MULTI",
45
- "TRACECONTEXT"
46
- ]
47
- }
48
- ],
49
49
  "proxyConfiguration": {
50
50
  "address": "1.1.1.1",
51
51
  "port": 4444,
@@ -6,3 +6,5 @@
6
6
 
7
7
  // This file is imported in the auto-generated DatadogSDKReactNative-Swift.h header file.
8
8
  // Deleting it could result in iOS builds failing.
9
+
10
+ #import <React/RCTBridgeModule.h>
@@ -0,0 +1,24 @@
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
+ #import <Foundation/Foundation.h>
8
+ @class DdFlagsImplementation;
9
+
10
+ #ifdef RCT_NEW_ARCH_ENABLED
11
+
12
+ #import <DdSdkReactNative/DdSdkReactNative.h>
13
+ @interface DdFlags: NSObject <NativeDdFlagsSpec>
14
+
15
+ #else
16
+
17
+ #import <React/RCTBridgeModule.h>
18
+ @interface DdFlags : NSObject <RCTBridgeModule>
19
+
20
+ #endif
21
+
22
+ @property (nonatomic, strong) DdFlagsImplementation* ddFlagsImplementation;
23
+
24
+ @end