@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.
- package/DatadogSDKReactNative.podspec +10 -9
- package/android/build.gradle +10 -8
- package/android/src/main/kotlin/com/datadog/reactnative/DdFlagsImplementation.kt +237 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkBridgeExt.kt +262 -78
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +3 -3
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +18 -18
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +3 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -1
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdFlags.kt +66 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdFlags.kt +63 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkBridgeExtTest.kt +242 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +4 -2
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +6 -3
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +3 -4
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +38 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +3 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +1 -1
- package/android/src/test/resources/input/complete-configuration.json +10 -10
- package/ios/Sources/DatadogSDKReactNative.h +2 -0
- package/ios/Sources/DdFlags.h +24 -0
- package/ios/Sources/DdFlags.mm +83 -0
- package/ios/Sources/DdFlagsImplementation.swift +263 -0
- package/ios/Sources/DdSdkConfiguration.swift +4 -4
- package/ios/Sources/DdSdkNativeInitialization.swift +2 -2
- package/ios/Sources/RNDdSdkConfiguration.swift +11 -9
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/InternalLog.js +9 -7
- package/lib/commonjs/InternalLog.js.map +1 -1
- package/lib/commonjs/flags/DdFlags.js +51 -0
- package/lib/commonjs/flags/DdFlags.js.map +1 -0
- package/lib/commonjs/flags/FlagsClient.js +218 -0
- package/lib/commonjs/flags/FlagsClient.js.map +1 -0
- package/lib/commonjs/flags/internal.js +40 -0
- package/lib/commonjs/flags/internal.js.map +1 -0
- package/lib/commonjs/flags/types.js +6 -0
- package/lib/commonjs/flags/types.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BufferSingleton.js +10 -8
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BufferSingleton.js.map +1 -1
- package/lib/commonjs/specs/NativeDdFlags.js +19 -0
- package/lib/commonjs/specs/NativeDdFlags.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/module/InternalLog.js +9 -6
- package/lib/module/InternalLog.js.map +1 -1
- package/lib/module/flags/DdFlags.js +45 -0
- package/lib/module/flags/DdFlags.js.map +1 -0
- package/lib/module/flags/FlagsClient.js +211 -0
- package/lib/module/flags/FlagsClient.js.map +1 -0
- package/lib/module/flags/internal.js +33 -0
- package/lib/module/flags/internal.js.map +1 -0
- package/lib/module/flags/types.js +2 -0
- package/lib/module/flags/types.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BufferSingleton.js +10 -7
- package/lib/module/sdk/DatadogProvider/Buffer/BufferSingleton.js.map +1 -1
- package/lib/module/specs/NativeDdFlags.js +17 -0
- package/lib/module/specs/NativeDdFlags.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/InternalLog.d.ts +6 -4
- package/lib/typescript/InternalLog.d.ts.map +1 -1
- package/lib/typescript/flags/DdFlags.d.ts +3 -0
- package/lib/typescript/flags/DdFlags.d.ts.map +1 -0
- package/lib/typescript/flags/FlagsClient.d.ts +114 -0
- package/lib/typescript/flags/FlagsClient.d.ts.map +1 -0
- package/lib/typescript/flags/internal.d.ts +14 -0
- package/lib/typescript/flags/internal.d.ts.map +1 -0
- package/lib/typescript/flags/types.d.ts +202 -0
- package/lib/typescript/flags/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/nativeModulesTypes.d.ts +5 -0
- package/lib/typescript/nativeModulesTypes.d.ts.map +1 -1
- package/lib/typescript/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -5
- package/lib/typescript/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdFlags.d.ts +15 -0
- package/lib/typescript/specs/NativeDdFlags.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/InternalLog.tsx +14 -6
- package/src/flags/DdFlags.ts +59 -0
- package/src/flags/FlagsClient.ts +266 -0
- package/src/flags/__tests__/DdFlags.test.ts +65 -0
- package/src/flags/__tests__/FlagsClient.test.ts +320 -0
- package/src/flags/internal.ts +63 -0
- package/src/flags/types.ts +215 -0
- package/src/index.tsx +15 -1
- package/src/nativeModulesTypes.ts +6 -0
- package/src/sdk/DatadogProvider/Buffer/BufferSingleton.ts +16 -7
- package/src/specs/NativeDdFlags.ts +35 -0
- package/src/version.ts +1 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
|
+
@file:Suppress("TooManyFunctions")
|
|
6
7
|
|
|
7
8
|
package com.datadog.reactnative
|
|
8
9
|
|
|
@@ -15,53 +16,84 @@ import com.facebook.react.bridge.WritableArray
|
|
|
15
16
|
import com.facebook.react.bridge.WritableMap
|
|
16
17
|
import com.facebook.react.bridge.WritableNativeArray
|
|
17
18
|
import com.facebook.react.bridge.WritableNativeMap
|
|
19
|
+
import org.json.JSONArray
|
|
20
|
+
import org.json.JSONObject
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
23
|
* Converts the [List] to a [WritableNativeArray].
|
|
21
24
|
*/
|
|
22
|
-
internal fun List<*>.toWritableArray(): WritableArray
|
|
23
|
-
|
|
25
|
+
internal fun List<*>.toWritableArray(): WritableArray =
|
|
26
|
+
this.toWritableArray(
|
|
24
27
|
createWritableMap = { WritableNativeMap() },
|
|
25
|
-
createWritableArray = { WritableNativeArray() }
|
|
28
|
+
createWritableArray = { WritableNativeArray() },
|
|
26
29
|
)
|
|
27
|
-
}
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* Converts the [List] to a [WritableArray].
|
|
31
33
|
* @param createWritableMap a function to provide a concrete instance of new WritableMap(s)
|
|
32
34
|
* @param createWritableArray a function to provide a concrete instance of new WritableArray(s)
|
|
33
35
|
*/
|
|
36
|
+
@Suppress("CyclomaticComplexMethod")
|
|
34
37
|
internal fun List<*>.toWritableArray(
|
|
35
38
|
createWritableMap: () -> WritableMap,
|
|
36
|
-
createWritableArray: () -> WritableArray
|
|
39
|
+
createWritableArray: () -> WritableArray,
|
|
37
40
|
): WritableArray {
|
|
38
41
|
val writableArray = createWritableArray()
|
|
39
42
|
|
|
40
43
|
for (it in iterator()) {
|
|
41
44
|
when (it) {
|
|
42
|
-
null ->
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
is
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
null -> {
|
|
46
|
+
writableArray.pushNull()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
is Int -> {
|
|
50
|
+
writableArray.pushInt(it)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
is Long -> {
|
|
54
|
+
writableArray.pushDouble(it.toDouble())
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
is Float -> {
|
|
58
|
+
writableArray.pushDouble(it.toDouble())
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
is Double -> {
|
|
62
|
+
writableArray.pushDouble(it)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
is String -> {
|
|
66
|
+
writableArray.pushString(it)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
is Boolean -> {
|
|
70
|
+
writableArray.pushBoolean(it)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
is List<*> -> {
|
|
74
|
+
writableArray.pushArray(
|
|
75
|
+
it.toWritableArray(
|
|
76
|
+
createWritableMap,
|
|
77
|
+
createWritableArray,
|
|
78
|
+
),
|
|
53
79
|
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
is Map<*, *> -> {
|
|
83
|
+
writableArray.pushMap(
|
|
84
|
+
it.toWritableMap(
|
|
85
|
+
createWritableMap,
|
|
86
|
+
createWritableArray,
|
|
87
|
+
),
|
|
59
88
|
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
else -> {
|
|
92
|
+
Log.e(
|
|
93
|
+
javaClass.simpleName,
|
|
94
|
+
"toWritableArray(): Unhandled type ${it.javaClass.simpleName} has been ignored",
|
|
95
|
+
)
|
|
96
|
+
}
|
|
65
97
|
}
|
|
66
98
|
}
|
|
67
99
|
|
|
@@ -71,52 +103,81 @@ internal fun List<*>.toWritableArray(
|
|
|
71
103
|
/**
|
|
72
104
|
* Converts the [Map] to a [WritableNativeMap].
|
|
73
105
|
*/
|
|
74
|
-
internal fun Map<*, *>.toWritableMap(): WritableMap
|
|
75
|
-
|
|
106
|
+
internal fun Map<*, *>.toWritableMap(): WritableMap =
|
|
107
|
+
this.toWritableMap(
|
|
76
108
|
createWritableMap = { WritableNativeMap() },
|
|
77
|
-
createWritableArray = { WritableNativeArray() }
|
|
109
|
+
createWritableArray = { WritableNativeArray() },
|
|
78
110
|
)
|
|
79
|
-
}
|
|
80
111
|
|
|
81
112
|
/**
|
|
82
113
|
* Converts the [Map] to a [WritableMap].
|
|
83
114
|
* @param createWritableMap a function to provide a concrete instance for WritableMap(s)
|
|
84
115
|
* @param createWritableArray a function to provide a concrete instance for WritableArray(s)
|
|
85
116
|
*/
|
|
117
|
+
@Suppress("CyclomaticComplexMethod")
|
|
86
118
|
internal fun Map<*, *>.toWritableMap(
|
|
87
119
|
createWritableMap: () -> WritableMap,
|
|
88
|
-
createWritableArray: () -> WritableArray
|
|
120
|
+
createWritableArray: () -> WritableArray,
|
|
89
121
|
): WritableMap {
|
|
90
122
|
val map = createWritableMap()
|
|
91
123
|
|
|
92
124
|
for ((k, v) in iterator()) {
|
|
93
125
|
val key = (k as? String) ?: k.toString()
|
|
94
126
|
when (v) {
|
|
95
|
-
null ->
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
is
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
v.
|
|
105
|
-
|
|
106
|
-
|
|
127
|
+
null -> {
|
|
128
|
+
map.putNull(key)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
is Int -> {
|
|
132
|
+
map.putInt(key, v)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
is Long -> {
|
|
136
|
+
map.putDouble(key, v.toDouble())
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
is Float -> {
|
|
140
|
+
map.putDouble(key, v.toDouble())
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
is Double -> {
|
|
144
|
+
map.putDouble(key, v)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
is String -> {
|
|
148
|
+
map.putString(key, v)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
is Boolean -> {
|
|
152
|
+
map.putBoolean(key, v)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
is List<*> -> {
|
|
156
|
+
map.putArray(
|
|
157
|
+
key,
|
|
158
|
+
v.toWritableArray(
|
|
159
|
+
createWritableMap,
|
|
160
|
+
createWritableArray,
|
|
161
|
+
),
|
|
107
162
|
)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
is Map<*, *> -> {
|
|
166
|
+
map.putMap(
|
|
167
|
+
key,
|
|
168
|
+
v.toWritableMap(
|
|
169
|
+
createWritableMap,
|
|
170
|
+
createWritableArray,
|
|
171
|
+
),
|
|
114
172
|
)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
else -> {
|
|
176
|
+
Log.e(
|
|
177
|
+
javaClass.simpleName,
|
|
178
|
+
"toWritableMap(): Unhandled type ${v.javaClass.simpleName} has been ignored",
|
|
179
|
+
)
|
|
180
|
+
}
|
|
120
181
|
}
|
|
121
182
|
}
|
|
122
183
|
|
|
@@ -128,20 +189,25 @@ internal fun Map<*, *>.toWritableMap(
|
|
|
128
189
|
* such as [List], [Map] and the raw types.
|
|
129
190
|
*/
|
|
130
191
|
internal fun ReadableMap.toMap(): Map<String, Any> {
|
|
131
|
-
val map =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
192
|
+
val map =
|
|
193
|
+
this
|
|
194
|
+
.toHashMap()
|
|
195
|
+
.filterValues { it != null }
|
|
196
|
+
.mapValues { it.value!! }
|
|
197
|
+
.toMap(HashMap())
|
|
135
198
|
val iterator = map.keys.iterator()
|
|
136
199
|
|
|
137
|
-
fun updateMap(
|
|
200
|
+
fun updateMap(
|
|
201
|
+
key: String,
|
|
202
|
+
value: Any?,
|
|
203
|
+
) {
|
|
138
204
|
if (value != null) {
|
|
139
205
|
map[key] = value
|
|
140
206
|
} else {
|
|
141
207
|
map.remove(key)
|
|
142
208
|
Log.e(
|
|
143
209
|
javaClass.simpleName,
|
|
144
|
-
"toMap(): Cannot convert nested object for key: $key"
|
|
210
|
+
"toMap(): Cannot convert nested object for key: $key",
|
|
145
211
|
)
|
|
146
212
|
}
|
|
147
213
|
}
|
|
@@ -150,14 +216,21 @@ internal fun ReadableMap.toMap(): Map<String, Any> {
|
|
|
150
216
|
val key = iterator.next()
|
|
151
217
|
try {
|
|
152
218
|
when (val type = getType(key)) {
|
|
153
|
-
ReadableType.Map ->
|
|
154
|
-
|
|
219
|
+
ReadableType.Map -> {
|
|
220
|
+
updateMap(key, getMap(key)?.toMap())
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
ReadableType.Array -> {
|
|
224
|
+
updateMap(key, getArray(key)?.toList())
|
|
225
|
+
}
|
|
226
|
+
|
|
155
227
|
ReadableType.Null, ReadableType.Boolean, ReadableType.Number, ReadableType.String -> {}
|
|
228
|
+
|
|
156
229
|
else -> {
|
|
157
230
|
map.remove(key)
|
|
158
231
|
Log.e(
|
|
159
232
|
javaClass.simpleName,
|
|
160
|
-
"toMap(): Skipping unhandled type [${type.name}] for key: $key"
|
|
233
|
+
"toMap(): Skipping unhandled type [${type.name}] for key: $key",
|
|
161
234
|
)
|
|
162
235
|
}
|
|
163
236
|
}
|
|
@@ -166,7 +239,7 @@ internal fun ReadableMap.toMap(): Map<String, Any> {
|
|
|
166
239
|
Log.e(
|
|
167
240
|
javaClass.simpleName,
|
|
168
241
|
"toMap(): Could not convert object for key: $key",
|
|
169
|
-
err
|
|
242
|
+
err,
|
|
170
243
|
)
|
|
171
244
|
}
|
|
172
245
|
}
|
|
@@ -179,6 +252,7 @@ internal fun ReadableMap.toMap(): Map<String, Any> {
|
|
|
179
252
|
* such as [List], [Map] and the raw types.
|
|
180
253
|
* or [List], instead of [ReadableMap] and [ReadableArray] respectively).
|
|
181
254
|
*/
|
|
255
|
+
@Suppress("CyclomaticComplexMethod")
|
|
182
256
|
internal fun ReadableArray.toList(): List<*> {
|
|
183
257
|
val list = mutableListOf<Any?>()
|
|
184
258
|
for (i in 0 until size()) {
|
|
@@ -186,32 +260,48 @@ internal fun ReadableArray.toList(): List<*> {
|
|
|
186
260
|
@Suppress("TooGenericExceptionCaught")
|
|
187
261
|
try {
|
|
188
262
|
when (val type = getType(i)) {
|
|
189
|
-
ReadableType.Null ->
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
263
|
+
ReadableType.Null -> {
|
|
264
|
+
list.add(null)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
ReadableType.Boolean -> {
|
|
268
|
+
list.add(getBoolean(i))
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
ReadableType.Number -> {
|
|
272
|
+
list.add(getDouble(i))
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
ReadableType.String -> {
|
|
276
|
+
list.add(getString(i))
|
|
277
|
+
}
|
|
278
|
+
|
|
193
279
|
ReadableType.Map -> {
|
|
194
280
|
// getMap() return type is nullable in previous RN versions
|
|
195
281
|
@Suppress("USELESS_ELVIS")
|
|
196
282
|
val readableMap = getMap(i) ?: Arguments.createMap()
|
|
197
283
|
list.add(readableMap.toMap())
|
|
198
284
|
}
|
|
285
|
+
|
|
199
286
|
ReadableType.Array -> {
|
|
200
287
|
// getArray() return type is nullable in previous RN versions
|
|
201
288
|
@Suppress("USELESS_ELVIS")
|
|
202
289
|
val readableArray = getArray(i) ?: Arguments.createArray()
|
|
203
290
|
list.add(readableArray.toList())
|
|
204
291
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
292
|
+
|
|
293
|
+
else -> {
|
|
294
|
+
Log.e(
|
|
295
|
+
javaClass.simpleName,
|
|
296
|
+
"toList(): Unhandled ReadableType: ${type.name}.",
|
|
297
|
+
)
|
|
298
|
+
}
|
|
209
299
|
}
|
|
210
300
|
} catch (err: NullPointerException) {
|
|
211
301
|
Log.e(
|
|
212
302
|
javaClass.simpleName,
|
|
213
303
|
"toList(): Could not convert object at index: $i.",
|
|
214
|
-
err
|
|
304
|
+
err,
|
|
215
305
|
)
|
|
216
306
|
}
|
|
217
307
|
}
|
|
@@ -223,22 +313,116 @@ internal fun ReadableArray.toList(): List<*> {
|
|
|
223
313
|
* Returns the boolean for the given key, or null if the entry is
|
|
224
314
|
* not in the map.
|
|
225
315
|
*/
|
|
226
|
-
internal fun ReadableMap.getBooleanOrNull(key: String): Boolean?
|
|
227
|
-
|
|
316
|
+
internal fun ReadableMap.getBooleanOrNull(key: String): Boolean? =
|
|
317
|
+
if (hasKey(key)) {
|
|
228
318
|
getBoolean(key)
|
|
229
319
|
} else {
|
|
230
320
|
null
|
|
231
321
|
}
|
|
232
|
-
}
|
|
233
322
|
|
|
234
323
|
/**
|
|
235
324
|
* Returns the double for the given key, or null if the entry is
|
|
236
325
|
* not in the map.
|
|
237
326
|
*/
|
|
238
|
-
internal fun ReadableMap.getDoubleOrNull(key: String): Double?
|
|
239
|
-
|
|
327
|
+
internal fun ReadableMap.getDoubleOrNull(key: String): Double? =
|
|
328
|
+
if (hasKey(key)) {
|
|
240
329
|
getDouble(key)
|
|
241
330
|
} else {
|
|
242
331
|
null
|
|
243
332
|
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Converts a [JSONObject] to a [WritableMap].
|
|
336
|
+
*/
|
|
337
|
+
internal fun JSONObject.toWritableMap(): WritableMap = this.toMap().toWritableMap()
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Converts a [JSONObject] to a [Map].
|
|
341
|
+
*/
|
|
342
|
+
internal fun JSONObject.toMap(): Map<String, Any?> {
|
|
343
|
+
val map = mutableMapOf<String, Any?>()
|
|
344
|
+
val keys = this.keys()
|
|
345
|
+
|
|
346
|
+
while (keys.hasNext()) {
|
|
347
|
+
val key = keys.next()
|
|
348
|
+
val value = this.opt(key)
|
|
349
|
+
|
|
350
|
+
map[key] =
|
|
351
|
+
when (value) {
|
|
352
|
+
null, JSONObject.NULL -> null
|
|
353
|
+
is JSONObject -> value.toMap()
|
|
354
|
+
is JSONArray -> value.toList()
|
|
355
|
+
else -> value
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return map
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Converts a [JSONArray] to a [List].
|
|
364
|
+
*/
|
|
365
|
+
internal fun JSONArray.toList(): List<Any?> {
|
|
366
|
+
val list = mutableListOf<Any?>()
|
|
367
|
+
|
|
368
|
+
for (i in 0 until this.length()) {
|
|
369
|
+
val value = this.opt(i)
|
|
370
|
+
|
|
371
|
+
list.add(
|
|
372
|
+
when (value) {
|
|
373
|
+
null, JSONObject.NULL -> null
|
|
374
|
+
is JSONObject -> value.toMap()
|
|
375
|
+
is JSONArray -> value.toList()
|
|
376
|
+
else -> value
|
|
377
|
+
},
|
|
378
|
+
)
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return list
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Converts a [ReadableMap] to a [JSONObject].
|
|
386
|
+
*/
|
|
387
|
+
internal fun ReadableMap.toJSONObject(): JSONObject = this.toMap().toJSONObject()
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Converts a [Map] to a [JSONObject].
|
|
391
|
+
*/
|
|
392
|
+
@Suppress("UNCHECKED_CAST")
|
|
393
|
+
internal fun Map<String, Any>.toJSONObject(): JSONObject {
|
|
394
|
+
val jsonObject = JSONObject()
|
|
395
|
+
|
|
396
|
+
for ((key, value) in this) {
|
|
397
|
+
jsonObject.put(
|
|
398
|
+
key,
|
|
399
|
+
when (value) {
|
|
400
|
+
is Map<*, *> -> (value as Map<String, Any>).toJSONObject()
|
|
401
|
+
is List<*> -> value.toJSONArray()
|
|
402
|
+
else -> value
|
|
403
|
+
},
|
|
404
|
+
)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return jsonObject
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Converts a [List] to a [JSONArray].
|
|
412
|
+
*/
|
|
413
|
+
@Suppress("UNCHECKED_CAST")
|
|
414
|
+
internal fun List<*>.toJSONArray(): JSONArray {
|
|
415
|
+
val jsonArray = JSONArray()
|
|
416
|
+
|
|
417
|
+
for (value in this) {
|
|
418
|
+
jsonArray.put(
|
|
419
|
+
when (value) {
|
|
420
|
+
is Map<*, *> -> (value as Map<String, Any>).toJSONObject()
|
|
421
|
+
is List<*> -> value.toJSONArray()
|
|
422
|
+
else -> value
|
|
423
|
+
},
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return jsonArray
|
|
244
428
|
}
|
|
@@ -24,7 +24,6 @@ import java.net.Proxy
|
|
|
24
24
|
* @param batchSize The preferred size for uploaded batches of data (can be 'SMALL', 'MEDIUM' (default), 'LARGE')
|
|
25
25
|
* @param batchProcessingLevel The preferred number of batches of data that will be sent in a single upload (can be 'LOW', 'MEDIUM' (default), 'HIGH')
|
|
26
26
|
* @param proxyConfiguration Configuration for proxying SDK data.
|
|
27
|
-
* @param firstPartyHosts List of backend hosts to enable tracing with.
|
|
28
27
|
* @param rumConfiguration Configuration for the RUM feature module, including RUM application ID and RUM-specific options.
|
|
29
28
|
* @param logsConfiguration Configuration for the Logs feature module.
|
|
30
29
|
* @param traceConfiguration Configuration for the Traces (APM) feature module.
|
|
@@ -42,7 +41,6 @@ data class DdSdkConfiguration(
|
|
|
42
41
|
val batchSize: String? = null,
|
|
43
42
|
val batchProcessingLevel: String? = null,
|
|
44
43
|
val proxyConfiguration: Pair<Proxy, ProxyAuthenticator?>? = null,
|
|
45
|
-
val firstPartyHosts: Map<String, Set<TracingHeaderType>>? = null,
|
|
46
44
|
val rumConfiguration: RumConfiguration? = null,
|
|
47
45
|
val logsConfiguration: LogsConfiguration? = null,
|
|
48
46
|
val traceConfiguration: TraceConfiguration? = null,
|
|
@@ -63,6 +61,7 @@ data class DdSdkConfiguration(
|
|
|
63
61
|
* @param nativeLongTaskThresholdMs The threshold for native long tasks reporting in milliseconds.
|
|
64
62
|
* @param nativeViewTracking Enables/Disables tracking RUM Views on the native level.
|
|
65
63
|
* @param nativeInteractionTracking Enables/Disables tracking RUM Actions on the native level.
|
|
64
|
+
* @param firstPartyHosts List of backend hosts to enable tracing with.
|
|
66
65
|
* @param trackNonFatalAnrs Enables tracking of non-fatal ANRs on Android.
|
|
67
66
|
* @param initialResourceThreshold The amount of time after a view starts where a Resource should be considered when calculating Time to Network-Settled (TNS).
|
|
68
67
|
* @param telemetrySampleRate The sample rate (between 0 and 100) of telemetry events.
|
|
@@ -80,6 +79,7 @@ data class RumConfiguration(
|
|
|
80
79
|
val nativeLongTaskThresholdMs: Double? = null,
|
|
81
80
|
val nativeViewTracking: Boolean? = null,
|
|
82
81
|
val nativeInteractionTracking: Boolean? = null,
|
|
82
|
+
val firstPartyHosts: Map<String, Set<TracingHeaderType>>? = null,
|
|
83
83
|
val trackNonFatalAnrs: Boolean? = null,
|
|
84
84
|
val initialResourceThreshold: Double? = null,
|
|
85
85
|
val telemetrySampleRate: Double? = null,
|
|
@@ -127,7 +127,6 @@ internal data class JSONDdSdkConfiguration(
|
|
|
127
127
|
val version: String? = null,
|
|
128
128
|
val versionSuffix: String? = null,
|
|
129
129
|
val site: String? = null,
|
|
130
|
-
val firstPartyHosts: List<JSONFirstPartyHost>? = null,
|
|
131
130
|
val rumConfiguration: JSONRumConfiguration? = null,
|
|
132
131
|
val logsConfiguration: JSONLogsConfiguration? = null,
|
|
133
132
|
val traceConfiguration: JSONTraceConfiguration? = null
|
|
@@ -140,6 +139,7 @@ internal data class JSONRumConfiguration(
|
|
|
140
139
|
val trackResources: Boolean? = null,
|
|
141
140
|
val trackErrors: Boolean? = null,
|
|
142
141
|
val actionNameAttribute: String? = null,
|
|
142
|
+
val firstPartyHosts: List<JSONFirstPartyHost>? = null,
|
|
143
143
|
val appHangThreshold: Double? = null,
|
|
144
144
|
val initialResourceThreshold: Double? = null,
|
|
145
145
|
|
|
@@ -41,6 +41,7 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
41
41
|
nativeLongTaskThresholdMs = rm.getDoubleOrNull("nativeLongTaskThresholdMs"),
|
|
42
42
|
nativeViewTracking = rm.getBooleanOrNull("nativeViewTracking"),
|
|
43
43
|
nativeInteractionTracking = rm.getBooleanOrNull("nativeInteractionTracking"),
|
|
44
|
+
firstPartyHosts = rm.getArray("firstPartyHosts")?.asFirstPartyHosts(),
|
|
44
45
|
trackNonFatalAnrs = rm.getBooleanOrNull("trackNonFatalAnrs"),
|
|
45
46
|
initialResourceThreshold = rm.getDoubleOrNull("initialResourceThreshold"),
|
|
46
47
|
telemetrySampleRate = rm.getDoubleOrNull("telemetrySampleRate"),
|
|
@@ -77,7 +78,6 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
77
78
|
batchSize = getString("batchSize"),
|
|
78
79
|
batchProcessingLevel = getString("batchProcessingLevel"),
|
|
79
80
|
proxyConfiguration = getMap("proxyConfiguration")?.asProxyConfig(),
|
|
80
|
-
firstPartyHosts = getArray("firstPartyHosts")?.asFirstPartyHosts(),
|
|
81
81
|
rumConfiguration = rumConfiguration,
|
|
82
82
|
logsConfiguration = logsConfiguration,
|
|
83
83
|
traceConfiguration = traceConfiguration,
|
|
@@ -182,6 +182,7 @@ internal fun JSONDdSdkConfiguration.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
182
182
|
nativeLongTaskThresholdMs = rum.nativeLongTaskThresholdMs ?: DefaultConfiguration.nativeLongTaskThresholdMs,
|
|
183
183
|
nativeViewTracking = rum.nativeViewTracking ?: DefaultConfiguration.nativeViewTracking,
|
|
184
184
|
nativeInteractionTracking = rum.nativeInteractionTracking ?: DefaultConfiguration.nativeInteractionTracking,
|
|
185
|
+
firstPartyHosts = rum.firstPartyHosts?.asFirstPartyHosts(),
|
|
185
186
|
trackNonFatalAnrs = rum.trackNonFatalAnrs,
|
|
186
187
|
initialResourceThreshold = rum.initialResourceThreshold ?: DefaultConfiguration.initialResourceThreshold,
|
|
187
188
|
telemetrySampleRate = rum.telemetrySampleRate?.toDouble()
|
|
@@ -220,7 +221,6 @@ internal fun JSONDdSdkConfiguration.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
220
221
|
batchSize = this.batchSize?: DefaultConfiguration.batchSize,
|
|
221
222
|
batchProcessingLevel = this.batchProcessingLevel,
|
|
222
223
|
proxyConfiguration = this.proxyConfiguration?.asProxyConfig(),
|
|
223
|
-
firstPartyHosts = this.firstPartyHosts?.asFirstPartyHosts(),
|
|
224
224
|
rumConfiguration = rumConfiguration,
|
|
225
225
|
logsConfiguration = logsConfiguration,
|
|
226
226
|
traceConfiguration = traceConfiguration,
|
|
@@ -269,7 +269,7 @@ internal fun List<String>.asTracingHeaderTypes(): Set<TracingHeaderType> {
|
|
|
269
269
|
}.toSet()
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
@Suppress("LongMethod", "CyclomaticComplexMethod")
|
|
272
|
+
@Suppress("LongMethod", "CyclomaticComplexMethod", "NestedBlockDepth")
|
|
273
273
|
internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
|
|
274
274
|
val map = WritableNativeMap()
|
|
275
275
|
|
|
@@ -300,25 +300,11 @@ internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
|
|
|
300
300
|
)
|
|
301
301
|
map.putMap("proxyConfiguration", proxyMap)
|
|
302
302
|
}
|
|
303
|
-
firstPartyHosts?.let { hosts ->
|
|
304
|
-
val hostsArray = WritableNativeArray()
|
|
305
|
-
hosts.forEach { (match, types) ->
|
|
306
|
-
val hostMap = WritableNativeMap()
|
|
307
|
-
hostMap.putString("match", match)
|
|
308
|
-
val propagatorsArray = WritableNativeArray()
|
|
309
|
-
types.forEach { type ->
|
|
310
|
-
propagatorsArray.pushString(type.toString())
|
|
311
|
-
}
|
|
312
|
-
hostMap.putArray("propagatorTypes", propagatorsArray)
|
|
313
|
-
hostsArray.pushMap(hostMap)
|
|
314
|
-
}
|
|
315
|
-
map.putArray("firstPartyHosts", hostsArray)
|
|
316
|
-
}
|
|
317
303
|
rumConfiguration?.let { rum ->
|
|
318
304
|
val rumMap = WritableNativeMap()
|
|
319
305
|
rumMap.putString("applicationId", rum.applicationId)
|
|
320
306
|
rum.trackFrustrations?.let { rumMap.putBoolean("trackFrustrations", it) }
|
|
321
|
-
rum.longTaskThresholdMs?.let {
|
|
307
|
+
rum.longTaskThresholdMs?.let { rumMap.putDouble("longTaskThresholdMs", it) }
|
|
322
308
|
rum.sessionSampleRate?.let { rumMap.putDouble("sessionSampleRate", it) }
|
|
323
309
|
rum.resourceTraceSampleRate?.let { rumMap.putDouble("resourceTraceSampleRate", it) }
|
|
324
310
|
rum.vitalsUpdateFrequency?.let { rumMap.putString("vitalsUpdateFrequency", it) }
|
|
@@ -328,6 +314,20 @@ internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
|
|
|
328
314
|
rum.nativeViewTracking?.let { rumMap.putBoolean("nativeViewTracking", it) }
|
|
329
315
|
rum.nativeInteractionTracking?.let { rumMap.putBoolean("nativeInteractionTracking", it) }
|
|
330
316
|
rum.trackNonFatalAnrs?.let { rumMap.putBoolean("trackNonFatalAnrs", it) }
|
|
317
|
+
rum.firstPartyHosts?.let { hosts ->
|
|
318
|
+
val hostsArray = WritableNativeArray()
|
|
319
|
+
hosts.forEach { (match, types) ->
|
|
320
|
+
val hostMap = WritableNativeMap()
|
|
321
|
+
hostMap.putString("match", match)
|
|
322
|
+
val propagatorsArray = WritableNativeArray()
|
|
323
|
+
types.forEach { type ->
|
|
324
|
+
propagatorsArray.pushString(type.toString())
|
|
325
|
+
}
|
|
326
|
+
hostMap.putArray("propagatorTypes", propagatorsArray)
|
|
327
|
+
hostsArray.pushMap(hostMap)
|
|
328
|
+
}
|
|
329
|
+
rumMap.putArray("firstPartyHosts", hostsArray)
|
|
330
|
+
}
|
|
331
331
|
rum.initialResourceThreshold?.let { rumMap.putDouble("initialResourceThreshold", it) }
|
|
332
332
|
rum.telemetrySampleRate?.let { rumMap.putDouble("telemetrySampleRate", it) }
|
|
333
333
|
rum.customEndpoint?.let { rumMap.putString("customEndpoint", it) }
|
|
@@ -306,8 +306,9 @@ class DdSdkNativeInitialization internal constructor(
|
|
|
306
306
|
configBuilder.setProxy(proxy, authenticator)
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
|
|
310
|
-
|
|
309
|
+
val firstPartyHosts = configuration.rumConfiguration?.firstPartyHosts
|
|
310
|
+
if (firstPartyHosts != null) {
|
|
311
|
+
configBuilder.setFirstPartyHostsWithHeaderType(firstPartyHosts)
|
|
311
312
|
}
|
|
312
313
|
|
|
313
314
|
configBuilder.setBatchProcessingLevel(buildBatchProcessingLevel(configuration.batchProcessingLevel))
|
|
@@ -25,6 +25,7 @@ class DdSdkReactNativePackage : TurboReactPackage() {
|
|
|
25
25
|
DdRumImplementation.NAME -> DdRum(reactContext, sdkWrapper)
|
|
26
26
|
DdTraceImplementation.NAME -> DdTrace(reactContext)
|
|
27
27
|
DdLogsImplementation.NAME -> DdLogs(reactContext, sdkWrapper)
|
|
28
|
+
DdFlagsImplementation.NAME -> DdFlags(reactContext)
|
|
28
29
|
else -> null
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -36,7 +37,8 @@ class DdSdkReactNativePackage : TurboReactPackage() {
|
|
|
36
37
|
DdSdkImplementation.NAME,
|
|
37
38
|
DdRumImplementation.NAME,
|
|
38
39
|
DdTraceImplementation.NAME,
|
|
39
|
-
DdLogsImplementation.NAME
|
|
40
|
+
DdLogsImplementation.NAME,
|
|
41
|
+
DdFlagsImplementation.NAME
|
|
40
42
|
).associateWith {
|
|
41
43
|
ReactModuleInfo(
|
|
42
44
|
it,
|