@datadog/mobile-react-native 2.3.1 → 2.3.2

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.
@@ -6,33 +6,90 @@
6
6
 
7
7
  package com.datadog.reactnative
8
8
 
9
+ import android.util.Log
10
+ import com.facebook.react.bridge.ReadableArray
11
+ import com.facebook.react.bridge.ReadableMap
12
+ import com.facebook.react.bridge.ReadableType
13
+ import com.facebook.react.bridge.WritableArray
14
+ import com.facebook.react.bridge.WritableMap
9
15
  import com.facebook.react.bridge.WritableNativeArray
10
16
  import com.facebook.react.bridge.WritableNativeMap
11
17
 
12
- internal fun List<*>.toWritableArray(): WritableNativeArray {
13
- val list = WritableNativeArray()
18
+ /**
19
+ * Converts the [List] to a [WritableNativeArray].
20
+ */
21
+ internal fun List<*>.toWritableArray(): WritableArray {
22
+ return this.toWritableArray(
23
+ createWritableMap = { WritableNativeMap() },
24
+ createWritableArray = { WritableNativeArray() }
25
+ )
26
+ }
27
+
28
+ /**
29
+ * Converts the [List] to a [WritableArray].
30
+ * @param createWritableMap a function to provide a concrete instance of new WritableMap(s)
31
+ * @param createWritableArray a function to provide a concrete instance of new WritableArray(s)
32
+ */
33
+ internal fun List<*>.toWritableArray(
34
+ createWritableMap: () -> WritableMap,
35
+ createWritableArray: () -> WritableArray
36
+ ): WritableArray {
37
+ val writableArray = createWritableArray()
38
+
14
39
  for (it in iterator()) {
15
- @Suppress("NotImplementedDeclaration")
16
40
  when (it) {
17
- null -> list.pushNull()
18
- is Int -> list.pushInt(it)
19
- is Long -> list.pushDouble(it.toDouble())
20
- is Float -> list.pushDouble(it.toDouble())
21
- is Double -> list.pushDouble(it)
22
- is String -> list.pushString(it)
23
- is List<*> -> list.pushArray(it.toWritableArray())
24
- is Map<*, *> -> list.pushMap(it.toWritableMap())
25
- else -> TODO()
41
+ null -> writableArray.pushNull()
42
+ is Int -> writableArray.pushInt(it)
43
+ is Long -> writableArray.pushDouble(it.toDouble())
44
+ is Float -> writableArray.pushDouble(it.toDouble())
45
+ is Double -> writableArray.pushDouble(it)
46
+ is String -> writableArray.pushString(it)
47
+ is Boolean -> writableArray.pushBoolean(it)
48
+ is List<*> -> writableArray.pushArray(
49
+ it.toWritableArray(
50
+ createWritableMap,
51
+ createWritableArray
52
+ )
53
+ )
54
+ is Map<*, *> -> writableArray.pushMap(
55
+ it.toWritableMap(
56
+ createWritableMap,
57
+ createWritableArray
58
+ )
59
+ )
60
+ else -> Log.e(
61
+ javaClass.simpleName,
62
+ "toWritableArray(): Unhandled type ${it.javaClass.simpleName} has been ignored"
63
+ )
26
64
  }
27
65
  }
28
- return list
66
+
67
+ return writableArray
68
+ }
69
+
70
+ /**
71
+ * Converts the [Map] to a [WritableNativeMap].
72
+ */
73
+ internal fun Map<*, *>.toWritableMap(): WritableMap {
74
+ return this.toWritableMap(
75
+ createWritableMap = { WritableNativeMap() },
76
+ createWritableArray = { WritableNativeArray() }
77
+ )
29
78
  }
30
79
 
31
- internal fun Map<*, *>.toWritableMap(): WritableNativeMap {
32
- val map = WritableNativeMap()
33
- for ((k,v) in iterator()) {
80
+ /**
81
+ * Converts the [Map] to a [WritableMap].
82
+ * @param createWritableMap a function to provide a concrete instance for WritableMap(s)
83
+ * @param createWritableArray a function to provide a concrete instance for WritableArray(s)
84
+ */
85
+ internal fun Map<*, *>.toWritableMap(
86
+ createWritableMap: () -> WritableMap,
87
+ createWritableArray: () -> WritableArray
88
+ ): WritableMap {
89
+ val map = createWritableMap()
90
+
91
+ for ((k, v) in iterator()) {
34
92
  val key = (k as? String) ?: k.toString()
35
- @Suppress("NotImplementedDeclaration")
36
93
  when (v) {
37
94
  null -> map.putNull(key)
38
95
  is Int -> map.putInt(key, v)
@@ -40,10 +97,110 @@ internal fun Map<*, *>.toWritableMap(): WritableNativeMap {
40
97
  is Float -> map.putDouble(key, v.toDouble())
41
98
  is Double -> map.putDouble(key, v)
42
99
  is String -> map.putString(key, v)
43
- is List<*> -> map.putArray(key, v.toWritableArray())
44
- is Map<*, *> -> map.putMap(key, v.toWritableMap())
45
- else -> TODO()
100
+ is Boolean -> map.putBoolean(key, v)
101
+ is List<*> -> map.putArray(
102
+ key,
103
+ v.toWritableArray(
104
+ createWritableMap,
105
+ createWritableArray
106
+ )
107
+ )
108
+ is Map<*, *> -> map.putMap(
109
+ key,
110
+ v.toWritableMap(
111
+ createWritableMap,
112
+ createWritableArray
113
+ )
114
+ )
115
+ else -> Log.e(
116
+ javaClass.simpleName,
117
+ "toWritableMap(): Unhandled type ${v.javaClass.simpleName} has been ignored"
118
+ )
46
119
  }
47
120
  }
121
+
48
122
  return map
49
123
  }
124
+
125
+ /**
126
+ * Recursively converts the [ReadableMap] to a [Map] which only contains Kotlin stdlib objects,
127
+ * such as [List], [Map] and the raw types.
128
+ */
129
+ internal fun ReadableMap.toMap(): Map<String, Any> {
130
+ val map = this.toHashMap()
131
+ val iterator = map.keys.iterator()
132
+
133
+ fun updateMap(key: String, value: Any?) {
134
+ if (value != null) {
135
+ map[key] = value
136
+ } else {
137
+ map.remove(key)
138
+ Log.e(
139
+ javaClass.simpleName,
140
+ "toMap(): Cannot convert nested object for key: $key"
141
+ )
142
+ }
143
+ }
144
+
145
+ while (iterator.hasNext()) {
146
+ val key = iterator.next()
147
+ try {
148
+ when (val type = getType(key)) {
149
+ ReadableType.Map -> updateMap(key, getMap(key)?.toMap())
150
+ ReadableType.Array -> updateMap(key, getArray(key)?.toList())
151
+ ReadableType.Null, ReadableType.Boolean, ReadableType.Number, ReadableType.String -> {}
152
+ else -> {
153
+ map.remove(key)
154
+ Log.e(
155
+ javaClass.simpleName,
156
+ "toMap(): Skipping unhandled type [${type.name}] for key: $key"
157
+ )
158
+ }
159
+ }
160
+ } catch (err: IllegalArgumentException) {
161
+ map.remove(key)
162
+ Log.e(
163
+ javaClass.simpleName,
164
+ "toMap(): Could not convert object for key: $key",
165
+ err
166
+ )
167
+ }
168
+ }
169
+
170
+ return map
171
+ }
172
+
173
+ /**
174
+ * Recursively converts the [ReadableArray] to a [List] which only contains Kotlin stdlib objects,
175
+ * such as [List], [Map] and the raw types.
176
+ * or [List], instead of [ReadableMap] and [ReadableArray] respectively).
177
+ */
178
+ internal fun ReadableArray.toList(): List<*> {
179
+ val list = mutableListOf<Any?>()
180
+ for (i in 0 until size()) {
181
+ // ReadableArray throws a null pointer exception if getMap(i) or getArray(i) returns null
182
+ @Suppress("TooGenericExceptionCaught")
183
+ try {
184
+ when (val type = getType(i)) {
185
+ ReadableType.Null -> list.add(null)
186
+ ReadableType.Boolean -> list.add(getBoolean(i))
187
+ ReadableType.Number -> list.add(getDouble(i))
188
+ ReadableType.String -> list.add(getString(i))
189
+ ReadableType.Map -> list.add(getMap(i).toMap())
190
+ ReadableType.Array -> list.add(getArray(i).toList())
191
+ else -> Log.e(
192
+ javaClass.simpleName,
193
+ "toList(): Unhandled ReadableType: ${type.name}."
194
+ )
195
+ }
196
+ } catch (err: NullPointerException) {
197
+ Log.e(
198
+ javaClass.simpleName,
199
+ "toList(): Could not convert object at index: $i.",
200
+ err
201
+ )
202
+ }
203
+ }
204
+
205
+ return list
206
+ }
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  @file:Suppress("TooManyFunctions")
8
+
8
9
  package com.datadog.reactnative
9
10
 
10
11
  import android.util.Log
@@ -94,13 +95,27 @@ internal fun ReadableMap.asProxyConfig(): Pair<Proxy, ProxyAuthenticator?>? {
94
95
  }
95
96
 
96
97
  internal fun ReadableArray.asFirstPartyHosts(): Map<String, Set<TracingHeaderType>> {
97
- val firstPartyHosts = this.toArrayList() as List<ReadableMap>
98
- return firstPartyHosts.mapNotNull<ReadableMap, JSONFirstPartyHost> {
99
- val match = it.getString("match")
100
- val propagatorTypes = it.getArray("propagatorTypes")
101
- if (match != null && propagatorTypes != null) {
102
- JSONFirstPartyHost(match, propagatorTypes.toArrayList() as List<String>)
103
- } else null
98
+ return this.toList().mapNotNull {
99
+ if (it == null) {
100
+ null
101
+ } else if (it !is Map<*, *>) {
102
+ Log.e(
103
+ javaClass.simpleName,
104
+ "Ignoring $it (${it.javaClass.simpleName}) because it is not of type Map"
105
+ )
106
+ null
107
+ } else {
108
+ val match = it["match"] as? String
109
+
110
+ @Suppress("UNCHECKED_CAST")
111
+ val propagatorTypes = it["propagatorTypes"] as? List<String>
112
+
113
+ if (match != null && propagatorTypes != null) {
114
+ JSONFirstPartyHost(match, propagatorTypes)
115
+ } else {
116
+ null
117
+ }
118
+ }
104
119
  }.asFirstPartyHosts()
105
120
  }
106
121
 
@@ -239,7 +254,13 @@ internal fun CustomEndpoints.toReadableMap(): ReadableMap {
239
254
  return map
240
255
  }
241
256
 
242
- private fun buildProxyConfig(type: String, address: String, port: Int, username: String?, password: String?): Pair<Proxy, ProxyAuthenticator?>? {
257
+ private fun buildProxyConfig(
258
+ type: String,
259
+ address: String,
260
+ port: Int,
261
+ username: String?,
262
+ password: String?
263
+ ): Pair<Proxy, ProxyAuthenticator?>? {
243
264
  val proxyType = when (type.lowercase(Locale.US)) {
244
265
  "http", "https" -> Proxy.Type.HTTP
245
266
  "socks" -> Proxy.Type.SOCKS
@@ -250,11 +271,7 @@ private fun buildProxyConfig(type: String, address: String, port: Int, username:
250
271
  )
251
272
  null
252
273
  }
253
- }
254
-
255
- if (proxyType == null) {
256
- return null
257
- }
274
+ } ?: return null
258
275
 
259
276
  val proxy = Proxy(proxyType, InetSocketAddress(address, port))
260
277
 
@@ -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.3.1"
10
+ internal const val SDK_VERSION = "2.3.2"
@@ -0,0 +1,382 @@
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.datadog.tools.unit.keys
10
+ import com.datadog.tools.unit.toReadableArray
11
+ import com.datadog.tools.unit.toReadableMap
12
+ import com.facebook.react.bridge.JavaOnlyArray
13
+ import com.facebook.react.bridge.JavaOnlyMap
14
+ import com.facebook.react.bridge.WritableArray
15
+ import com.facebook.react.bridge.WritableMap
16
+ import org.assertj.core.api.Assertions.assertThat
17
+ import org.junit.jupiter.api.Test
18
+
19
+ internal class DdSdkBridgeExtTest {
20
+ // Default providers for toWritableArray and toWritableMap
21
+ private val createWritableMap = { JavaOnlyMap() }
22
+ private val createWritableArray = { JavaOnlyArray() }
23
+
24
+ @Test
25
+ fun `M do a proper conversion W toWritableArray { all types of supported values }`() {
26
+ // Given
27
+ val array = getTestArray()
28
+ val nestedTestMap = getTestMap()
29
+ val nestedTestArray = getTestArray()
30
+
31
+ array.add(nestedTestMap) // Nested map
32
+ array.add(nestedTestArray) // Nested array
33
+
34
+ // When
35
+ val writableArray = array.toWritableArray(createWritableMap, createWritableArray)
36
+
37
+ // Then
38
+ assertThat(writableArray.size()).isEqualTo(array.size)
39
+ testWritableArray(writableArray)
40
+
41
+ val nestedMap = writableArray.getMap(array.size - 2)
42
+ assertThat(nestedMap).isInstanceOf(WritableMap::class.java)
43
+ assertThat(nestedMap.keys()).hasSameSizeAs(nestedTestMap.keys)
44
+ testWritableMap(nestedMap as WritableMap)
45
+
46
+ val nestedArray = writableArray.getArray(array.size - 1)
47
+ assertThat(nestedArray).isInstanceOf(WritableArray::class.java)
48
+ assertThat(nestedArray.size()).isEqualTo(nestedTestArray.size)
49
+ testWritableArray(nestedArray as WritableArray)
50
+ }
51
+
52
+ @Test
53
+ fun `M do a proper conversion W toWritableMap { raw and nested values }`() {
54
+ // Given
55
+ val map = getTestMap()
56
+ val nestedTestMap = getTestMap()
57
+ val nestedTestArray = getTestArray()
58
+
59
+ map["map"] = nestedTestMap
60
+ map["array"] = nestedTestArray
61
+
62
+ // When
63
+ val writableMap = map.toWritableMap(createWritableMap, createWritableArray)
64
+
65
+ // Then
66
+ testWritableMap(writableMap)
67
+
68
+ val nestedMap = writableMap.getMap("map")
69
+ assertThat(nestedMap).isNotNull()
70
+ assertThat(nestedMap).isInstanceOf(WritableMap::class.java)
71
+ assertThat(nestedMap!!.keys()).hasSameSizeAs(nestedTestMap.keys)
72
+ testWritableMap(nestedMap as WritableMap)
73
+
74
+ val nestedArray = writableMap.getArray("array")
75
+ assertThat(nestedArray).isNotNull()
76
+ assertThat(nestedArray).isInstanceOf(WritableArray::class.java)
77
+ assertThat(nestedArray!!.size()).isEqualTo(nestedTestArray.size)
78
+ testWritableArray(nestedArray as WritableArray)
79
+ }
80
+
81
+ @Test
82
+ fun `M do a proper conversion W toMap { 1-level JavaOnlyMap }`() {
83
+ // Given
84
+ val writableMap = getTestWritableMap()
85
+
86
+ // When
87
+ val map = writableMap.toMap()
88
+
89
+ // Then
90
+ testMap(map)
91
+ assertThat(map).isEqualTo(writableMap.toHashMap())
92
+ }
93
+
94
+ @Test
95
+ fun `M do a proper conversion W toMap { nested JavaOnlyMap }`() {
96
+ // Given
97
+ val writableMap = getTestWritableMap()
98
+ val nestedTestMap = getTestWritableMap()
99
+
100
+ writableMap.putMap("map", nestedTestMap)
101
+
102
+ // When
103
+ val map = writableMap.toMap()
104
+
105
+ // Then
106
+ assertThat(map).isNotNull()
107
+ assertThat(map).hasSameSizeAs(writableMap.keys())
108
+ testMap(map)
109
+
110
+ val nestedMap = map["map"]
111
+ assertThat(nestedMap).isNotNull()
112
+ assertThat(nestedMap).isInstanceOf(Map::class.java)
113
+ assertThat((nestedMap as Map<*, *>)).hasSameSizeAs(nestedTestMap.keys())
114
+ testMap(nestedMap)
115
+ }
116
+
117
+ @Test
118
+ fun `M do a proper conversion W toMap { nested JavaOnlyArray }`() {
119
+ // Given
120
+ val writableMap = getTestWritableMap()
121
+ val nestedTestArray = getTestWritableArray()
122
+
123
+ writableMap.putArray("array", nestedTestArray)
124
+
125
+ // When
126
+ val map = writableMap.toMap()
127
+
128
+ // Then
129
+ assertThat(map).isNotNull()
130
+ assertThat(map).hasSameSizeAs(writableMap.keys())
131
+ testMap(map)
132
+
133
+ val nestedArray = map["array"]
134
+ assertThat(nestedArray).isNotNull()
135
+ assertThat(nestedArray).isInstanceOf(List::class.java)
136
+ assertThat(nestedArray as List<*>).hasSize(nestedTestArray.size())
137
+ testArray(nestedArray)
138
+ }
139
+
140
+ @Test
141
+ fun `M do a proper conversion W toMap { nested JavaOnlyMap and JavaOnlyArray }`() {
142
+ // Given
143
+ val writableMap = getTestWritableMap()
144
+ val nestedTestMap = getTestWritableMap()
145
+ val nestedTestArray = getTestWritableArray()
146
+
147
+ writableMap.putMap("map", nestedTestMap)
148
+ writableMap.putArray("array", nestedTestArray)
149
+
150
+ // When
151
+ val map = writableMap.toMap()
152
+
153
+ // Then
154
+ assertThat((map as Map<*, *>)).hasSameSizeAs(writableMap.keys())
155
+ testMap(map)
156
+
157
+ val nestedMap = map["map"]
158
+ assertThat((nestedMap as Map<*, *>)).hasSameSizeAs(nestedTestMap.keys())
159
+ assertThat(nestedMap).isNotNull()
160
+ assertThat(nestedMap).isInstanceOf(Map::class.java)
161
+ testMap(nestedMap)
162
+
163
+ val nestedArray = map["array"]
164
+ assertThat(nestedArray).isNotNull()
165
+ assertThat(nestedArray).isInstanceOf(List::class.java)
166
+ assertThat((nestedArray as List<*>)).hasSize(nestedTestArray.size())
167
+ testArray(nestedArray)
168
+ }
169
+
170
+ @Test
171
+ fun `M do a proper conversion W toList { with raw types only }`() {
172
+ // Given
173
+ val writableArray = getTestWritableArray()
174
+
175
+ // When
176
+ val array = writableArray.toList()
177
+
178
+ // Then
179
+ assertThat(array).isNotNull()
180
+ assertThat(array).hasSize(writableArray.size())
181
+ testArray(array)
182
+ }
183
+
184
+ @Test
185
+ fun `M do a proper conversion W toList { with nested objects }`() {
186
+ // Given
187
+ val writableArray = getTestWritableArray()
188
+ val nestedTestMap = getTestWritableMap()
189
+ val nestedTestArray = getTestWritableArray()
190
+
191
+ writableArray.pushMap(nestedTestMap)
192
+ writableArray.pushArray(nestedTestArray)
193
+
194
+ // When
195
+ val array = writableArray.toList()
196
+
197
+ // Then
198
+ assertThat(array).isNotNull()
199
+ assertThat(array).hasSize(writableArray.size())
200
+ testArray(array)
201
+
202
+ val nestedMap = array[array.size - 2]
203
+ assertThat(nestedMap).isInstanceOf(Map::class.java)
204
+ assertThat((nestedMap as Map<*, *>)).hasSameSizeAs(nestedTestMap.keys())
205
+ testMap(nestedMap)
206
+
207
+ val nestedArray = array[array.size - 1]
208
+ assertThat(nestedArray).isInstanceOf(List::class.java)
209
+ assertThat((nestedArray as List<*>)).hasSize(nestedTestArray.size())
210
+ testArray(nestedArray)
211
+ }
212
+
213
+ @Test
214
+ fun `M do a proper conversion and not throw W toMap { malformed nested map }`() {
215
+ // Given
216
+ val readableMap =
217
+ mapOf(
218
+ "map" to mapOf("test" to "test") // NOT a ReadableMap
219
+ ).toReadableMap()
220
+
221
+ // When
222
+ val map = readableMap.toMap()
223
+
224
+ // Then
225
+ assertThat(map).isEmpty()
226
+ }
227
+
228
+ @Test
229
+ fun `M do a proper conversion and not throw W toList { malformed nested array }`() {
230
+ // Given
231
+ val readableArray =
232
+ listOf(
233
+ mapOf("test" to "test"), // NOT a ReadableMap
234
+ listOf(null, true, 1.23, "test") // NOT a ReadableArray
235
+ ).toReadableArray()
236
+
237
+ // When
238
+ val list = readableArray.toList()
239
+
240
+ // Then
241
+ assertThat(list).isEmpty()
242
+ }
243
+
244
+ private fun getTestMap(): MutableMap<String, Any?> = mutableMapOf(
245
+ "null" to null,
246
+ "int" to 1,
247
+ "long" to 2L,
248
+ "float" to 3.0f,
249
+ "double" to 4.0,
250
+ "string" to "test",
251
+ "boolean" to true
252
+ )
253
+
254
+ private fun getTestWritableMap(): JavaOnlyMap = JavaOnlyMap.of(
255
+ "null",
256
+ null,
257
+ "int",
258
+ 1,
259
+ "long",
260
+ 2L,
261
+ "float",
262
+ 3.0f,
263
+ "double",
264
+ 4.0,
265
+ "string",
266
+ "test",
267
+ "boolean",
268
+ true
269
+ )
270
+
271
+ // Long type is not handled in JavaOnlyArray getType() in RN 0.71.10
272
+ // https://github.com/facebook/react-native/pull/43158
273
+ private fun getTestArray(): MutableList<Any?> = mutableListOf(
274
+ null,
275
+ 1,
276
+ 2.0f,
277
+ 3.0,
278
+ "test",
279
+ true
280
+ )
281
+
282
+ // Long type is not handled in JavaOnlyArray getType() in RN 0.71.10
283
+ // https://github.com/facebook/react-native/pull/43158
284
+ private fun getTestWritableArray(): WritableArray = JavaOnlyArray.from(
285
+ listOf(
286
+ null,
287
+ 1,
288
+ 2.0f,
289
+ 3.0,
290
+ "test",
291
+ true
292
+ )
293
+ )
294
+
295
+ private fun testWritableArray(array: WritableArray) {
296
+ assertThat(array.getDynamic(0).isNull).isTrue()
297
+
298
+ assertThat(array.getInt(1)).isInstanceOf(java.lang.Integer::class.java)
299
+ assertThat(array.getInt(1)).isEqualTo(1)
300
+
301
+ assertThat(array.getDouble(2)).isInstanceOf(java.lang.Double::class.java)
302
+ assertThat(array.getDouble(2)).isEqualTo(2.0)
303
+
304
+ assertThat(array.getDouble(3)).isInstanceOf(java.lang.Double::class.java)
305
+ assertThat(array.getDouble(3)).isEqualTo(3.0)
306
+
307
+ assertThat(array.getString(4)).isInstanceOf(java.lang.String::class.java)
308
+ assertThat(array.getString(4)).isEqualTo("test")
309
+
310
+ assertThat(array.getBoolean(5)).isInstanceOf(java.lang.Boolean::class.java)
311
+ assertThat(array.getBoolean(5)).isTrue()
312
+ }
313
+
314
+ private fun testWritableMap(map: WritableMap) {
315
+ assertThat(map.getDynamic("null").isNull).isTrue()
316
+
317
+ assertThat(map.getInt("int")).isInstanceOf(java.lang.Integer::class.java)
318
+ assertThat(map.getInt("int")).isEqualTo(1)
319
+
320
+ assertThat(map.getDouble("long")).isInstanceOf(java.lang.Double::class.java)
321
+ assertThat(map.getDouble("long")).isEqualTo(2.0)
322
+
323
+ assertThat(map.getDouble("float")).isInstanceOf(java.lang.Double::class.java)
324
+ assertThat(map.getDouble("float")).isEqualTo(3.0)
325
+
326
+ assertThat(map.getDouble("double")).isInstanceOf(java.lang.Double::class.java)
327
+ assertThat(map.getDouble("double")).isEqualTo(4.0)
328
+
329
+ assertThat(map.getString("string")).isInstanceOf(java.lang.String::class.java)
330
+ assertThat(map.getString("string")).isEqualTo("test")
331
+
332
+ assertThat(map.getBoolean("boolean")).isInstanceOf(java.lang.Boolean::class.java)
333
+ assertThat(map.getBoolean("boolean")).isTrue()
334
+ }
335
+
336
+ private fun testArray(array: List<*>) {
337
+ val iterator = array.iterator()
338
+ assertThat(iterator.next()).isNull()
339
+
340
+ assertThat(iterator.next())
341
+ .isInstanceOf(java.lang.Double::class.java)
342
+ .isEqualTo(1.0)
343
+
344
+ assertThat(iterator.next())
345
+ .isInstanceOf(java.lang.Double::class.java)
346
+ .isEqualTo(2.0)
347
+
348
+ assertThat(iterator.next())
349
+ .isInstanceOf(java.lang.Double::class.java)
350
+ .isEqualTo(3.0)
351
+
352
+ assertThat(iterator.next())
353
+ .isInstanceOf(java.lang.String::class.java)
354
+ .isEqualTo("test")
355
+
356
+ assertThat(iterator.next())
357
+ .isInstanceOf(java.lang.Boolean::class.java)
358
+ .isEqualTo(true)
359
+ }
360
+
361
+ private fun testMap(map: Map<*, *>) {
362
+ assertThat(map["null"]).isNull()
363
+
364
+ assertThat(map["int"]).isInstanceOf(java.lang.Double::class.java)
365
+ assertThat(map["int"]).isEqualTo(1.0)
366
+
367
+ assertThat(map["long"]).isInstanceOf(java.lang.Double::class.java)
368
+ assertThat(map["long"]).isEqualTo(2.0)
369
+
370
+ assertThat(map["float"]).isInstanceOf(java.lang.Double::class.java)
371
+ assertThat(map["float"]).isEqualTo(3.0)
372
+
373
+ assertThat(map["double"]).isInstanceOf(java.lang.Double::class.java)
374
+ assertThat(map["double"]).isEqualTo(4.0)
375
+
376
+ assertThat(map["string"]).isInstanceOf(java.lang.String::class.java)
377
+ assertThat(map["string"]).isEqualTo("test")
378
+
379
+ assertThat(map["boolean"]).isInstanceOf(java.lang.Boolean::class.java)
380
+ assertThat(map["boolean"] as Boolean).isTrue()
381
+ }
382
+ }
@@ -51,3 +51,12 @@ fun Set<*>.toReadableArray(): ReadableArray {
51
51
  // this FB implementation is not backed by Android-specific .so library, so ok for unit tests
52
52
  return JavaOnlyArray.from(this.toList())
53
53
  }
54
+
55
+ fun ReadableMap.keys(): List<String> {
56
+ val keys = mutableListOf<String>()
57
+ val iterator = this.keySetIterator()
58
+ while (iterator.hasNextKey()) {
59
+ keys.add(iterator.nextKey())
60
+ }
61
+ return keys
62
+ }
@@ -25,6 +25,7 @@ internal final class JSRefreshRateMonitor: RefreshRateMonitor {
25
25
  }
26
26
 
27
27
  public func startMonitoring(jsQueue: DispatchQueueType, frameTimeCallback: @escaping frame_time_callback) {
28
+ self.refreshRateListener.stop()
28
29
  self.refreshRateListener = JSRefreshRateListener(jsQueue: jsQueue, frameTimeCallback: frameTimeCallback)
29
30
  self.refreshRateListener.start()
30
31
  }
@@ -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.3.1"
10
+ let SdkVersion = "2.3.2"
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // generated by genversion
8
- const version = '2.3.1';
8
+ const version = '2.3.2';
9
9
  exports.version = version;
10
10
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.3.1';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.3.2';\n"]}
@@ -1,3 +1,3 @@
1
1
  // generated by genversion
2
- export const version = '2.3.1';
2
+ export const version = '2.3.2';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.3.1';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.3.2';\n"]}
@@ -1 +1 @@
1
- export declare const version = "2.3.1";
1
+ export declare const version = "2.3.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -97,5 +97,5 @@
97
97
  "javaPackageName": "com.datadog.reactnative"
98
98
  }
99
99
  },
100
- "gitHead": "5908b74a76a4046ed2e6993560eb616a6500cdf7"
100
+ "gitHead": "c3047c9cb200b1c178431b6f8214e1c7ea3c59c9"
101
101
  }
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '2.3.1';
2
+ export const version = '2.3.2';