@datadog/mobile-react-native 2.1.1 → 2.3.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.
- package/DatadogSDKReactNative.podspec +8 -7
- package/android/build.gradle +5 -4
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +2 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +11 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt +5 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +3 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +64 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +164 -4
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +6 -354
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +351 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +5 -3
- package/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt +10 -0
- package/android/src/main/kotlin/com/datadog/reactnative/JSONFileReader.kt +20 -0
- package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +4 -1
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +10 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +3 -2
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +5 -2
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +3 -2
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkConfigurationTest.kt +196 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +181 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +12 -271
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +10 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +28 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +24 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ActionEventForgeryFactory.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +9 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ResourceEventForgeryFactory.kt +1 -1
- package/android/src/test/resources/input/complete-configuration.json +48 -0
- package/android/src/test/resources/input/malformed-configuration.json +5 -0
- package/android/src/test/resources/input/minimal-configuration.json +8 -0
- package/datadog-configuration.gradle +57 -0
- package/datadog-configuration.schema.json +200 -0
- package/ios/Sources/DatadogSDKWrapper.swift +22 -19
- package/ios/Sources/DdLogsImplementation.swift +14 -0
- package/ios/Sources/DdSdk.h +2 -0
- package/ios/Sources/DdSdk.mm +6 -1
- package/ios/Sources/DdSdkConfiguration.swift +47 -56
- package/ios/Sources/DdSdkImplementation.swift +10 -279
- package/ios/Sources/DdSdkNativeInitialization.swift +218 -0
- package/ios/Sources/DdTraceImplementation.swift +3 -1
- package/ios/Sources/GlobalState.swift +1 -1
- package/ios/Sources/JSONFileReader.swift +28 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +227 -9
- package/ios/Sources/SdkVersion.swift +10 -0
- package/lib/commonjs/DdSdkReactNative.js +24 -66
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -4
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/ProxyConfiguration.js +15 -2
- package/lib/commonjs/ProxyConfiguration.js.map +1 -1
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +2 -2
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/DatadogProvider.js.map +1 -1
- package/lib/commonjs/sdk/FileBasedConfiguration/FileBasedConfiguration.js +214 -0
- package/lib/commonjs/sdk/FileBasedConfiguration/FileBasedConfiguration.js.map +1 -0
- package/lib/commonjs/types.js +10 -2
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +23 -65
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +22 -4
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/ProxyConfiguration.js +15 -2
- package/lib/module/ProxyConfiguration.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +2 -2
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/DatadogProvider.js.map +1 -1
- package/lib/module/sdk/FileBasedConfiguration/FileBasedConfiguration.js +197 -0
- package/lib/module/sdk/FileBasedConfiguration/FileBasedConfiguration.js.map +1 -0
- package/lib/module/types.js +10 -2
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +0 -9
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +43 -3
- package/lib/typescript/ProxyConfiguration.d.ts +4 -12
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/nativeModulesTypes.d.ts +2 -2
- package/lib/typescript/sdk/DatadogProvider/DatadogProvider.d.ts +2 -1
- package/lib/typescript/sdk/FileBasedConfiguration/FileBasedConfiguration.d.ts +31 -0
- package/lib/typescript/types.d.ts +29 -3
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +7 -4
- package/src/DdSdkReactNative.tsx +58 -101
- package/src/DdSdkReactNativeConfiguration.tsx +26 -7
- package/src/ProxyConfiguration.tsx +17 -3
- package/src/__tests__/DdSdkReactNative.test.tsx +134 -112
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +19 -10
- package/src/__tests__/mock.test.ts +0 -9
- package/src/index.tsx +2 -0
- package/src/nativeModulesTypes.ts +1 -1
- package/src/sdk/DatadogProvider/DatadogProvider.tsx +3 -1
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +12 -5
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +1 -2
- package/src/sdk/FileBasedConfiguration/FileBasedConfiguration.ts +235 -0
- package/src/sdk/FileBasedConfiguration/__tests__/FileBasedConfiguration.test.ts +245 -0
- package/src/sdk/FileBasedConfiguration/__tests__/__fixtures__/configuration-all-fields.json +22 -0
- package/src/sdk/FileBasedConfiguration/__tests__/__fixtures__/malformed-configuration.json +5 -0
- package/src/types.tsx +21 -2
- package/src/version.ts +1 -1
|
@@ -7,32 +7,14 @@
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
9
|
import android.content.Context
|
|
10
|
-
import android.content.pm.PackageManager
|
|
11
10
|
import android.util.Log
|
|
12
11
|
import android.view.Choreographer
|
|
13
|
-
import com.datadog.android.DatadogSite
|
|
14
|
-
import com.datadog.android.core.configuration.BatchSize
|
|
15
|
-
import com.datadog.android.core.configuration.Configuration
|
|
16
|
-
import com.datadog.android.core.configuration.UploadFrequency
|
|
17
|
-
import com.datadog.android.event.EventMapper
|
|
18
|
-
import com.datadog.android.log.LogsConfiguration
|
|
19
12
|
import com.datadog.android.privacy.TrackingConsent
|
|
20
13
|
import com.datadog.android.rum.configuration.VitalsUpdateFrequency
|
|
21
|
-
import com.datadog.android.rum.RumConfiguration
|
|
22
14
|
import com.datadog.android.rum.RumPerformanceMetric
|
|
23
|
-
import com.datadog.android.rum._RumInternalProxy
|
|
24
|
-
import com.datadog.android.rum.model.ActionEvent
|
|
25
|
-
import com.datadog.android.rum.model.ResourceEvent
|
|
26
|
-
import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy
|
|
27
|
-
import com.datadog.android.telemetry.model.TelemetryConfigurationEvent
|
|
28
|
-
import com.datadog.android.trace.TraceConfiguration
|
|
29
|
-
import com.datadog.android.trace.TracingHeaderType
|
|
30
15
|
import com.facebook.react.bridge.Promise
|
|
31
16
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
32
|
-
import com.facebook.react.bridge.ReadableArray
|
|
33
17
|
import com.facebook.react.bridge.ReadableMap
|
|
34
|
-
import java.net.InetSocketAddress
|
|
35
|
-
import java.net.Proxy
|
|
36
18
|
import java.util.Locale
|
|
37
19
|
import java.util.concurrent.TimeUnit
|
|
38
20
|
import java.util.concurrent.atomic.AtomicBoolean
|
|
@@ -54,23 +36,10 @@ class DdSdkImplementation(
|
|
|
54
36
|
*/
|
|
55
37
|
fun initialize(configuration: ReadableMap, promise: Promise) {
|
|
56
38
|
val ddSdkConfiguration = configuration.asDdSdkConfiguration()
|
|
57
|
-
val sdkConfiguration = buildSdkConfiguration(ddSdkConfiguration)
|
|
58
|
-
val rumConfiguration = buildRumConfiguration(ddSdkConfiguration)
|
|
59
|
-
val logsConfiguration = buildLogsConfiguration(ddSdkConfiguration)
|
|
60
|
-
val traceConfiguration = buildTraceConfiguration(ddSdkConfiguration)
|
|
61
|
-
val trackingConsent = buildTrackingConsent(ddSdkConfiguration.trackingConsent)
|
|
62
39
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
datadog.initialize(appContext, sdkConfiguration, trackingConsent)
|
|
66
|
-
|
|
67
|
-
datadog.enableRum(rumConfiguration)
|
|
40
|
+
val nativeInitialization = DdSdkNativeInitialization(appContext, datadog)
|
|
41
|
+
nativeInitialization.initialize(ddSdkConfiguration)
|
|
68
42
|
monitorJsRefreshRate(ddSdkConfiguration)
|
|
69
|
-
|
|
70
|
-
datadog.enableTrace(traceConfiguration)
|
|
71
|
-
|
|
72
|
-
datadog.enableLogs(logsConfiguration)
|
|
73
|
-
|
|
74
43
|
initialized.set(true)
|
|
75
44
|
|
|
76
45
|
promise.resolve(null)
|
|
@@ -154,240 +123,6 @@ class DdSdkImplementation(
|
|
|
154
123
|
|
|
155
124
|
// region Internal
|
|
156
125
|
|
|
157
|
-
private fun configureSdkVerbosity(configuration: DdSdkConfiguration) {
|
|
158
|
-
val verbosityConfig = configuration.additionalConfig?.get(DD_SDK_VERBOSITY) as? String
|
|
159
|
-
val verbosity =
|
|
160
|
-
when (verbosityConfig?.lowercase(Locale.US)) {
|
|
161
|
-
"debug" -> Log.DEBUG
|
|
162
|
-
"info" -> Log.INFO
|
|
163
|
-
"warn" -> Log.WARN
|
|
164
|
-
"error" -> Log.ERROR
|
|
165
|
-
else -> null
|
|
166
|
-
}
|
|
167
|
-
if (verbosity != null) {
|
|
168
|
-
datadog.setVerbosity(verbosity)
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private fun getDefaultAppVersion(): String {
|
|
173
|
-
val packageName = appContext.packageName
|
|
174
|
-
val packageInfo =
|
|
175
|
-
try {
|
|
176
|
-
appContext.packageManager.getPackageInfo(packageName, 0)
|
|
177
|
-
} catch (e: PackageManager.NameNotFoundException) {
|
|
178
|
-
datadog.telemetryError(e.message ?: PACKAGE_INFO_NOT_FOUND_ERROR_MESSAGE, e)
|
|
179
|
-
return DEFAULT_APP_VERSION
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return packageInfo?.let {
|
|
183
|
-
// we need to use the deprecated method because getLongVersionCode method is only
|
|
184
|
-
// available from API 28 and above
|
|
185
|
-
@Suppress("DEPRECATION")
|
|
186
|
-
it.versionName ?: it.versionCode.toString()
|
|
187
|
-
}
|
|
188
|
-
?: DEFAULT_APP_VERSION
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
@Suppress("ComplexMethod", "LongMethod", "UnsafeCallOnNullableType")
|
|
192
|
-
private fun buildRumConfiguration(configuration: DdSdkConfiguration): RumConfiguration {
|
|
193
|
-
val configBuilder =
|
|
194
|
-
RumConfiguration.Builder(
|
|
195
|
-
applicationId = configuration.applicationId
|
|
196
|
-
)
|
|
197
|
-
if (configuration.sampleRate != null) {
|
|
198
|
-
configBuilder.setSessionSampleRate(configuration.sampleRate.toFloat())
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
configBuilder.trackFrustrations(configuration.trackFrustrations ?: true)
|
|
202
|
-
configBuilder.trackBackgroundEvents(configuration.trackBackgroundEvents ?: false)
|
|
203
|
-
|
|
204
|
-
configBuilder.setVitalsUpdateFrequency(
|
|
205
|
-
buildVitalUpdateFrequency(configuration.vitalsUpdateFrequency)
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
val telemetrySampleRate = (configuration.telemetrySampleRate as? Number)?.toFloat()
|
|
209
|
-
telemetrySampleRate?.let { configBuilder.setTelemetrySampleRate(it) }
|
|
210
|
-
|
|
211
|
-
val longTask = (configuration.nativeLongTaskThresholdMs as? Number)?.toLong()
|
|
212
|
-
if (longTask != null) {
|
|
213
|
-
configBuilder.trackLongTasks(longTask)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
val viewTracking = configuration.additionalConfig?.get(DD_NATIVE_VIEW_TRACKING) as? Boolean
|
|
217
|
-
if (viewTracking == true) {
|
|
218
|
-
// Use sensible default
|
|
219
|
-
configBuilder.useViewTrackingStrategy(ActivityViewTrackingStrategy(false))
|
|
220
|
-
} else {
|
|
221
|
-
configBuilder.useViewTrackingStrategy(NoOpViewTrackingStrategy)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
val interactionTracking =
|
|
225
|
-
configuration.additionalConfig?.get(DD_NATIVE_INTERACTION_TRACKING) as? Boolean
|
|
226
|
-
if (interactionTracking == false) {
|
|
227
|
-
configBuilder.disableUserInteractionTracking()
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
configBuilder.setResourceEventMapper(
|
|
231
|
-
object : EventMapper<ResourceEvent> {
|
|
232
|
-
override fun map(event: ResourceEvent): ResourceEvent? {
|
|
233
|
-
if (event.context?.additionalProperties?.containsKey(DD_DROP_RESOURCE) ==
|
|
234
|
-
true
|
|
235
|
-
) {
|
|
236
|
-
return null
|
|
237
|
-
}
|
|
238
|
-
return event
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
)
|
|
242
|
-
|
|
243
|
-
configBuilder.setActionEventMapper(
|
|
244
|
-
object : EventMapper<ActionEvent> {
|
|
245
|
-
override fun map(event: ActionEvent): ActionEvent? {
|
|
246
|
-
if (event.context?.additionalProperties?.containsKey(DD_DROP_ACTION) == true
|
|
247
|
-
) {
|
|
248
|
-
return null
|
|
249
|
-
}
|
|
250
|
-
return event
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
_RumInternalProxy.setTelemetryConfigurationEventMapper(
|
|
256
|
-
configBuilder,
|
|
257
|
-
object : EventMapper<TelemetryConfigurationEvent> {
|
|
258
|
-
override fun map(
|
|
259
|
-
event: TelemetryConfigurationEvent
|
|
260
|
-
): TelemetryConfigurationEvent? {
|
|
261
|
-
event.telemetry.configuration.trackNativeErrors =
|
|
262
|
-
configuration.nativeCrashReportEnabled
|
|
263
|
-
// trackCrossPlatformLongTasks will be deprecated for trackLongTask
|
|
264
|
-
event.telemetry.configuration.trackCrossPlatformLongTasks =
|
|
265
|
-
configuration.longTaskThresholdMs != 0.0
|
|
266
|
-
event.telemetry.configuration.trackLongTask =
|
|
267
|
-
configuration.longTaskThresholdMs != 0.0
|
|
268
|
-
event.telemetry.configuration.trackNativeLongTasks =
|
|
269
|
-
configuration.nativeLongTaskThresholdMs != 0.0
|
|
270
|
-
|
|
271
|
-
event.telemetry.configuration.initializationType =
|
|
272
|
-
configuration.configurationForTelemetry?.initializationType
|
|
273
|
-
event.telemetry.configuration.trackInteractions =
|
|
274
|
-
configuration.configurationForTelemetry?.trackInteractions
|
|
275
|
-
event.telemetry.configuration.trackErrors =
|
|
276
|
-
configuration.configurationForTelemetry?.trackErrors
|
|
277
|
-
event.telemetry.configuration.trackResources =
|
|
278
|
-
configuration.configurationForTelemetry?.trackNetworkRequests
|
|
279
|
-
event.telemetry.configuration.trackNetworkRequests =
|
|
280
|
-
configuration.configurationForTelemetry?.trackNetworkRequests
|
|
281
|
-
event.telemetry.configuration.reactVersion =
|
|
282
|
-
configuration.configurationForTelemetry?.reactVersion
|
|
283
|
-
event.telemetry.configuration.reactNativeVersion =
|
|
284
|
-
configuration.configurationForTelemetry?.reactNativeVersion
|
|
285
|
-
|
|
286
|
-
return event
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
)
|
|
290
|
-
|
|
291
|
-
configuration.customEndpoints?.rum?.let {
|
|
292
|
-
configBuilder.useCustomEndpoint(it)
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return configBuilder.build()
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
private fun buildLogsConfiguration(configuration: DdSdkConfiguration): LogsConfiguration {
|
|
299
|
-
val configBuilder = LogsConfiguration.Builder()
|
|
300
|
-
configuration.customEndpoints?.logs?.let {
|
|
301
|
-
configBuilder.useCustomEndpoint(it)
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return configBuilder.build()
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
private fun buildTraceConfiguration(configuration: DdSdkConfiguration): TraceConfiguration {
|
|
308
|
-
val configBuilder = TraceConfiguration.Builder()
|
|
309
|
-
configuration.customEndpoints?.trace?.let {
|
|
310
|
-
configBuilder.useCustomEndpoint(it)
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
return configBuilder.build()
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
private fun buildFirstPartyHosts(
|
|
317
|
-
firstPartyHosts: List<ReadableMap>
|
|
318
|
-
): Map<String, Set<TracingHeaderType>> {
|
|
319
|
-
/**
|
|
320
|
-
* Adapts the data format from the React Native SDK configuration to match with the Android
|
|
321
|
-
* SDK configuration. For example:
|
|
322
|
-
*
|
|
323
|
-
* RN config: [{ match: "example.com", propagatorTypes: [DATADOG, B3] }] Android config: {
|
|
324
|
-
* "example.com": [DATADOG, B3] }
|
|
325
|
-
*/
|
|
326
|
-
val firstPartyHostsWithHeaderTypes = mutableMapOf<String, MutableSet<TracingHeaderType>>()
|
|
327
|
-
|
|
328
|
-
for (it in firstPartyHosts) {
|
|
329
|
-
val match = it.getString("match")
|
|
330
|
-
val propagatorTypes = it.getArray("propagatorTypes")?.asTracingHeaderTypes()
|
|
331
|
-
if (match != null && propagatorTypes != null && propagatorTypes.isNotEmpty()) {
|
|
332
|
-
val hostMatch = firstPartyHostsWithHeaderTypes[match]
|
|
333
|
-
if (hostMatch != null) {
|
|
334
|
-
hostMatch.addAll(propagatorTypes)
|
|
335
|
-
} else {
|
|
336
|
-
firstPartyHostsWithHeaderTypes[match] = propagatorTypes.toMutableSet()
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
return firstPartyHostsWithHeaderTypes
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
private fun buildSdkConfiguration(configuration: DdSdkConfiguration): Configuration {
|
|
345
|
-
val serviceName = configuration.additionalConfig?.get(DD_SERVICE_NAME) as? String
|
|
346
|
-
val configBuilder = Configuration.Builder(
|
|
347
|
-
clientToken = configuration.clientToken,
|
|
348
|
-
env = configuration.env,
|
|
349
|
-
variant = "",
|
|
350
|
-
service = serviceName
|
|
351
|
-
)
|
|
352
|
-
|
|
353
|
-
val additionalConfig = configuration.additionalConfig?.toMutableMap()
|
|
354
|
-
val versionSuffix = configuration.additionalConfig?.get(DD_VERSION_SUFFIX) as? String
|
|
355
|
-
if (versionSuffix != null && additionalConfig != null) {
|
|
356
|
-
val defaultVersion = getDefaultAppVersion()
|
|
357
|
-
additionalConfig.put(DD_VERSION, defaultVersion + versionSuffix)
|
|
358
|
-
}
|
|
359
|
-
configBuilder.setAdditionalConfiguration(
|
|
360
|
-
additionalConfig?.filterValues { it != null }?.mapValues {
|
|
361
|
-
it.value
|
|
362
|
-
} as Map<String, Any>? ?: emptyMap()
|
|
363
|
-
)
|
|
364
|
-
|
|
365
|
-
configBuilder.setCrashReportsEnabled(configuration.nativeCrashReportEnabled ?: false)
|
|
366
|
-
configBuilder.useSite(buildSite(configuration.site))
|
|
367
|
-
configBuilder.setUploadFrequency(
|
|
368
|
-
buildUploadFrequency(configuration.uploadFrequency)
|
|
369
|
-
)
|
|
370
|
-
configBuilder.setBatchSize(
|
|
371
|
-
buildBatchSize(configuration.batchSize)
|
|
372
|
-
)
|
|
373
|
-
|
|
374
|
-
buildProxyConfiguration(configuration)?.let { (proxy, authenticator) ->
|
|
375
|
-
configBuilder.setProxy(proxy, authenticator)
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
@Suppress("UNCHECKED_CAST")
|
|
379
|
-
val firstPartyHosts =
|
|
380
|
-
(configuration.additionalConfig?.get(DD_FIRST_PARTY_HOSTS) as? ReadableArray)
|
|
381
|
-
?.toArrayList() as?
|
|
382
|
-
List<ReadableMap>
|
|
383
|
-
if (firstPartyHosts != null) {
|
|
384
|
-
val firstPartyHostsWithHeaderTypes = buildFirstPartyHosts(firstPartyHosts)
|
|
385
|
-
configBuilder.setFirstPartyHostsWithHeaderType(firstPartyHostsWithHeaderTypes)
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return configBuilder.build()
|
|
389
|
-
}
|
|
390
|
-
|
|
391
126
|
internal fun buildTrackingConsent(trackingConsent: String?): TrackingConsent {
|
|
392
127
|
return when (trackingConsent?.lowercase(Locale.US)) {
|
|
393
128
|
"pending" -> TrackingConsent.PENDING
|
|
@@ -397,68 +132,13 @@ class DdSdkImplementation(
|
|
|
397
132
|
Log.w(
|
|
398
133
|
DdSdk::class.java.canonicalName,
|
|
399
134
|
"Unknown consent given: $trackingConsent, " +
|
|
400
|
-
|
|
135
|
+
"using ${TrackingConsent.PENDING} as default"
|
|
401
136
|
)
|
|
402
137
|
TrackingConsent.PENDING
|
|
403
138
|
}
|
|
404
139
|
}
|
|
405
140
|
}
|
|
406
141
|
|
|
407
|
-
internal fun buildProxyConfiguration(
|
|
408
|
-
configuration: DdSdkConfiguration
|
|
409
|
-
): Pair<Proxy, ProxyAuthenticator?>? {
|
|
410
|
-
val additionalConfig = configuration.additionalConfig ?: return null
|
|
411
|
-
|
|
412
|
-
val address = additionalConfig[DD_PROXY_ADDRESS] as? String
|
|
413
|
-
val port = (additionalConfig[DD_PROXY_PORT] as? Number)?.toInt()
|
|
414
|
-
val type =
|
|
415
|
-
(additionalConfig[DD_PROXY_TYPE] as? String)?.let {
|
|
416
|
-
when (it.lowercase(Locale.US)) {
|
|
417
|
-
"http", "https" -> Proxy.Type.HTTP
|
|
418
|
-
"socks" -> Proxy.Type.SOCKS
|
|
419
|
-
else -> {
|
|
420
|
-
Log.w(
|
|
421
|
-
DdSdk::class.java.canonicalName,
|
|
422
|
-
"Unknown proxy type given: $it, skipping proxy configuration."
|
|
423
|
-
)
|
|
424
|
-
null
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
val proxy =
|
|
430
|
-
if (address != null && port != null && type != null) {
|
|
431
|
-
Proxy(type, InetSocketAddress(address, port))
|
|
432
|
-
} else {
|
|
433
|
-
return null
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
val username = additionalConfig[DD_PROXY_USERNAME] as? String
|
|
437
|
-
val password = additionalConfig[DD_PROXY_PASSWORD] as? String
|
|
438
|
-
|
|
439
|
-
val authenticator =
|
|
440
|
-
if (username != null && password != null) {
|
|
441
|
-
ProxyAuthenticator(username, password)
|
|
442
|
-
} else {
|
|
443
|
-
null
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
return Pair(proxy, authenticator)
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
private fun buildSite(site: String?): DatadogSite {
|
|
450
|
-
val siteLower = site?.lowercase(Locale.US)
|
|
451
|
-
return when (siteLower) {
|
|
452
|
-
"us1", "us" -> DatadogSite.US1
|
|
453
|
-
"eu1", "eu" -> DatadogSite.EU1
|
|
454
|
-
"us3" -> DatadogSite.US3
|
|
455
|
-
"us5" -> DatadogSite.US5
|
|
456
|
-
"us1_fed", "gov" -> DatadogSite.US1_FED
|
|
457
|
-
"ap1" -> DatadogSite.AP1
|
|
458
|
-
else -> DatadogSite.US1
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
142
|
private fun buildVitalUpdateFrequency(vitalsUpdateFrequency: String?): VitalsUpdateFrequency {
|
|
463
143
|
val vitalUpdateFrequencyLower = vitalsUpdateFrequency?.lowercase(Locale.US)
|
|
464
144
|
return when (vitalUpdateFrequencyLower) {
|
|
@@ -470,24 +150,6 @@ class DdSdkImplementation(
|
|
|
470
150
|
}
|
|
471
151
|
}
|
|
472
152
|
|
|
473
|
-
private fun buildUploadFrequency(uploadFrequency: String?): UploadFrequency {
|
|
474
|
-
return when (uploadFrequency?.lowercase(Locale.US)) {
|
|
475
|
-
"rare" -> UploadFrequency.RARE
|
|
476
|
-
"average" -> UploadFrequency.AVERAGE
|
|
477
|
-
"frequent" -> UploadFrequency.FREQUENT
|
|
478
|
-
else -> UploadFrequency.AVERAGE
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
private fun buildBatchSize(batchSize: String?): BatchSize {
|
|
483
|
-
return when (batchSize?.lowercase(Locale.US)) {
|
|
484
|
-
"small" -> BatchSize.SMALL
|
|
485
|
-
"medium" -> BatchSize.MEDIUM
|
|
486
|
-
"large" -> BatchSize.LARGE
|
|
487
|
-
else -> BatchSize.MEDIUM
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
153
|
private fun handlePostFrameCallbackError(e: IllegalStateException) {
|
|
492
154
|
datadog.telemetryError(e.message ?: MONITOR_JS_ERROR_MESSAGE, e)
|
|
493
155
|
}
|
|
@@ -515,7 +177,7 @@ class DdSdkImplementation(
|
|
|
515
177
|
): ((Double) -> Unit)? {
|
|
516
178
|
val jsRefreshRateMonitoringEnabled =
|
|
517
179
|
buildVitalUpdateFrequency(ddSdkConfiguration.vitalsUpdateFrequency) !=
|
|
518
|
-
|
|
180
|
+
VitalsUpdateFrequency.NEVER
|
|
519
181
|
val jsLongTasksMonitoringEnabled = ddSdkConfiguration.longTaskThresholdMs != 0.0
|
|
520
182
|
|
|
521
183
|
if (!jsLongTasksMonitoringEnabled && !jsRefreshRateMonitoringEnabled) {
|
|
@@ -531,8 +193,8 @@ class DdSdkImplementation(
|
|
|
531
193
|
if (jsLongTasksMonitoringEnabled &&
|
|
532
194
|
it >
|
|
533
195
|
TimeUnit.MILLISECONDS.toNanos(
|
|
534
|
-
|
|
535
|
-
|
|
196
|
+
ddSdkConfiguration.longTaskThresholdMs?.toLong() ?: 0L
|
|
197
|
+
)
|
|
536
198
|
) {
|
|
537
199
|
datadog.getRumMonitor()._getInternal()?.addLongTask(it.toLong(), "javascript")
|
|
538
200
|
}
|
|
@@ -543,18 +205,8 @@ class DdSdkImplementation(
|
|
|
543
205
|
|
|
544
206
|
companion object {
|
|
545
207
|
internal const val DEFAULT_APP_VERSION = "?"
|
|
546
|
-
internal const val DD_NATIVE_VIEW_TRACKING = "_dd.native_view_tracking"
|
|
547
|
-
internal const val DD_NATIVE_INTERACTION_TRACKING = "_dd.native_interaction_tracking"
|
|
548
|
-
internal const val DD_SDK_VERBOSITY = "_dd.sdk_verbosity"
|
|
549
|
-
internal const val DD_SERVICE_NAME = "_dd.service_name"
|
|
550
|
-
internal const val DD_FIRST_PARTY_HOSTS = "_dd.first_party_hosts"
|
|
551
208
|
internal const val DD_VERSION = "_dd.version"
|
|
552
209
|
internal const val DD_VERSION_SUFFIX = "_dd.version_suffix"
|
|
553
|
-
internal const val DD_PROXY_ADDRESS = "_dd.proxy.address"
|
|
554
|
-
internal const val DD_PROXY_PORT = "_dd.proxy.port"
|
|
555
|
-
internal const val DD_PROXY_TYPE = "_dd.proxy.type"
|
|
556
|
-
internal const val DD_PROXY_USERNAME = "_dd.proxy.username"
|
|
557
|
-
internal const val DD_PROXY_PASSWORD = "_dd.proxy.password"
|
|
558
210
|
internal const val DD_DROP_RESOURCE = "_dd.resource.drop_resource"
|
|
559
211
|
internal const val DD_DROP_ACTION = "_dd.action.drop_action"
|
|
560
212
|
internal const val MONITOR_JS_ERROR_MESSAGE = "Error monitoring JS refresh rate"
|