@datadog/mobile-react-native 2.4.2 → 2.4.4
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 -6
- package/android/build.gradle +9 -5
- package/android/gradle.properties +1 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkBridgeExt.kt +12 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +5 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +5 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +15 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +5 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkSynthetics.kt +12 -0
- package/android/src/main/kotlin/com/datadog/reactnative/FrameRateProvider.kt +5 -5
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +19 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +19 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkBridgeExtTest.kt +28 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +28 -23
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +2 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +4 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +2 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +55 -55
- package/datadog-configuration.schema.json +8 -0
- package/ios/Sources/DdSdkConfiguration.swift +5 -1
- package/ios/Sources/DdSdkNativeInitialization.swift +1 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +6 -2
- package/ios/Sources/SdkVersion.swift +1 -1
- package/jest/mock.js +3 -0
- package/lib/commonjs/DdSdkReactNative.js +22 -1
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +22 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +11 -9
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/types.js +3 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +22 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +22 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/logs/DdLogs.js +11 -9
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/types.js +3 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +7 -0
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +22 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts.map +1 -1
- package/lib/typescript/logs/DdLogs.d.ts.map +1 -1
- package/lib/typescript/logs/types.d.ts +8 -4
- package/lib/typescript/logs/types.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +8 -1
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +30 -1
- package/src/DdSdkReactNativeConfiguration.tsx +24 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +34 -0
- package/src/__tests__/mock.test.ts +1 -0
- package/src/logs/DdLogs.ts +21 -13
- package/src/logs/__tests__/DdLogs.test.ts +147 -0
- package/src/logs/__tests__/eventMapper.test.ts +37 -0
- package/src/logs/types.ts +8 -4
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +12 -4
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +4 -0
- package/src/types.tsx +9 -1
- package/src/version.ts +1 -1
|
@@ -19,12 +19,14 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
20
|
|
|
21
21
|
# /!\ Remember to keep the versions in sync with DatadogSDKReactNativeSessionReplay.podspec
|
|
22
|
-
s.dependency 'DatadogCore', '~> 2.
|
|
23
|
-
s.dependency 'DatadogLogs', '~> 2.
|
|
24
|
-
s.dependency 'DatadogTrace', '~> 2.
|
|
25
|
-
s.dependency 'DatadogRUM', '~> 2.
|
|
26
|
-
s.dependency 'DatadogCrashReporting', '~> 2.
|
|
27
|
-
|
|
22
|
+
s.dependency 'DatadogCore', '~> 2.18.0'
|
|
23
|
+
s.dependency 'DatadogLogs', '~> 2.18.0'
|
|
24
|
+
s.dependency 'DatadogTrace', '~> 2.18.0'
|
|
25
|
+
s.dependency 'DatadogRUM', '~> 2.18.0'
|
|
26
|
+
s.dependency 'DatadogCrashReporting', '~> 2.18.0'
|
|
27
|
+
|
|
28
|
+
# DatadogWebViewTracking is not available for tvOS
|
|
29
|
+
s.ios.dependency 'DatadogWebViewTracking', '~> 2.18.0'
|
|
28
30
|
|
|
29
31
|
s.test_spec 'Tests' do |test_spec|
|
|
30
32
|
test_spec.source_files = 'ios/Tests/**/*.{swift,json}'
|
package/android/build.gradle
CHANGED
|
@@ -12,7 +12,7 @@ buildscript {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
dependencies {
|
|
15
|
-
classpath 'com.android.tools.build:gradle:7.
|
|
15
|
+
classpath 'com.android.tools.build:gradle:7.3.1'
|
|
16
16
|
// noinspection DifferentKotlinGradleVersion
|
|
17
17
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
18
18
|
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1"
|
|
@@ -98,15 +98,19 @@ def getExtOrIntegerDefault(name) {
|
|
|
98
98
|
android {
|
|
99
99
|
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
100
100
|
buildToolsVersion getExtOrDefault('buildToolsVersion')
|
|
101
|
+
|
|
101
102
|
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
103
|
+
|
|
102
104
|
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
|
|
103
105
|
namespace = "com.datadog.reactnative"
|
|
104
106
|
}
|
|
107
|
+
|
|
105
108
|
if (agpVersion.tokenize('.')[0].toInteger() >= 8) {
|
|
106
109
|
buildFeatures {
|
|
107
110
|
buildConfig = true
|
|
108
111
|
}
|
|
109
112
|
}
|
|
113
|
+
|
|
110
114
|
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
|
|
111
115
|
compileOptions {
|
|
112
116
|
sourceCompatibility JavaVersion.VERSION_11
|
|
@@ -188,10 +192,10 @@ dependencies {
|
|
|
188
192
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
189
193
|
compileOnly "com.squareup.okhttp3:okhttp:3.12.13"
|
|
190
194
|
|
|
191
|
-
implementation "com.datadoghq:dd-sdk-android-rum:2.
|
|
192
|
-
implementation "com.datadoghq:dd-sdk-android-logs:2.
|
|
193
|
-
implementation "com.datadoghq:dd-sdk-android-trace:2.
|
|
194
|
-
implementation "com.datadoghq:dd-sdk-android-webview:2.
|
|
195
|
+
implementation "com.datadoghq:dd-sdk-android-rum:2.14.0"
|
|
196
|
+
implementation "com.datadoghq:dd-sdk-android-logs:2.14.0"
|
|
197
|
+
implementation "com.datadoghq:dd-sdk-android-trace:2.14.0"
|
|
198
|
+
implementation "com.datadoghq:dd-sdk-android-webview:2.14.0"
|
|
195
199
|
implementation "com.google.code.gson:gson:2.10.0"
|
|
196
200
|
testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
|
|
197
201
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
|
|
@@ -215,3 +215,15 @@ internal fun ReadableArray.toList(): List<*> {
|
|
|
215
215
|
|
|
216
216
|
return list
|
|
217
217
|
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Returns the boolean for the given key, or null if the entry is
|
|
221
|
+
* not in the map.
|
|
222
|
+
*/
|
|
223
|
+
internal fun ReadableMap.getBooleanOrNull(key: String): Boolean? {
|
|
224
|
+
return if (hasKey(key)) {
|
|
225
|
+
getBoolean(key)
|
|
226
|
+
} else {
|
|
227
|
+
null
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -37,6 +37,7 @@ import java.net.Proxy
|
|
|
37
37
|
* @param firstPartyHosts List of backend hosts to enable tracing with.
|
|
38
38
|
* @param bundleLogsWithRum Enables RUM correlation with logs.
|
|
39
39
|
* @param bundleLogsWithTraces Enables Traces correlation with logs.
|
|
40
|
+
* @param trackNonFatalAnrs Enables tracking of non-fatal ANRs on Android.
|
|
40
41
|
*/
|
|
41
42
|
data class DdSdkConfiguration(
|
|
42
43
|
val clientToken: String,
|
|
@@ -64,7 +65,8 @@ data class DdSdkConfiguration(
|
|
|
64
65
|
val serviceName: String? = null,
|
|
65
66
|
val firstPartyHosts: Map<String, Set<TracingHeaderType>>? = null,
|
|
66
67
|
val bundleLogsWithRum: Boolean? = null,
|
|
67
|
-
val bundleLogsWithTraces: Boolean? = null
|
|
68
|
+
val bundleLogsWithTraces: Boolean? = null,
|
|
69
|
+
val trackNonFatalAnrs: Boolean? = null
|
|
68
70
|
)
|
|
69
71
|
|
|
70
72
|
internal data class JSONConfigurationFile(
|
|
@@ -95,7 +97,8 @@ internal data class JSONDdSdkConfiguration(
|
|
|
95
97
|
val serviceName: String? = null,
|
|
96
98
|
val firstPartyHosts: List<JSONFirstPartyHost>? = null,
|
|
97
99
|
val bundleLogsWithRum: Boolean? = null,
|
|
98
|
-
val bundleLogsWithTraces: Boolean? = null
|
|
100
|
+
val bundleLogsWithTraces: Boolean? = null,
|
|
101
|
+
val trackNonFatalAnrs: Boolean? = null
|
|
99
102
|
)
|
|
100
103
|
|
|
101
104
|
internal data class JSONProxyConfiguration(
|
|
@@ -46,7 +46,8 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
46
46
|
serviceName = getString("serviceName"),
|
|
47
47
|
firstPartyHosts = getArray("firstPartyHosts")?.asFirstPartyHosts(),
|
|
48
48
|
bundleLogsWithRum = getBoolean("bundleLogsWithRum"),
|
|
49
|
-
bundleLogsWithTraces = getBoolean("bundleLogsWithTraces")
|
|
49
|
+
bundleLogsWithTraces = getBoolean("bundleLogsWithTraces"),
|
|
50
|
+
trackNonFatalAnrs = getBooleanOrNull("trackNonFatalAnrs")
|
|
50
51
|
)
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -169,7 +170,8 @@ internal fun JSONDdSdkConfiguration.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
169
170
|
this.serviceName,
|
|
170
171
|
this.firstPartyHosts?.asFirstPartyHosts(),
|
|
171
172
|
this.bundleLogsWithRum ?: DefaultConfiguration.bundleLogsWithRum,
|
|
172
|
-
this.bundleLogsWithTraces ?: DefaultConfiguration.bundleLogsWithTraces
|
|
173
|
+
this.bundleLogsWithTraces ?: DefaultConfiguration.bundleLogsWithTraces,
|
|
174
|
+
this.trackNonFatalAnrs
|
|
173
175
|
)
|
|
174
176
|
}
|
|
175
177
|
|
|
@@ -231,6 +233,7 @@ internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
|
|
|
231
233
|
uploadFrequency?.let { map.putString("uploadFrequency", it) }
|
|
232
234
|
batchSize?.let { map.putString("batchSize", it) }
|
|
233
235
|
trackBackgroundEvents?.let { map.putBoolean("trackBackgroundEvents", it) }
|
|
236
|
+
trackNonFatalAnrs?.let { map.putBoolean("trackNonFatalAnrs", it) }
|
|
234
237
|
additionalConfig?.let { map.putMap("additionalConfig", it.toWritableMap()) }
|
|
235
238
|
return map
|
|
236
239
|
}
|
|
@@ -9,8 +9,9 @@ package com.datadog.reactnative
|
|
|
9
9
|
import android.content.Context
|
|
10
10
|
import android.util.Log
|
|
11
11
|
import com.datadog.android.privacy.TrackingConsent
|
|
12
|
-
import com.datadog.android.rum.
|
|
12
|
+
import com.datadog.android.rum.GlobalRumMonitor
|
|
13
13
|
import com.datadog.android.rum.RumPerformanceMetric
|
|
14
|
+
import com.datadog.android.rum.configuration.VitalsUpdateFrequency
|
|
14
15
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
15
16
|
import com.facebook.react.bridge.Promise
|
|
16
17
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -57,6 +58,8 @@ class DdSdkImplementation(
|
|
|
57
58
|
}
|
|
58
59
|
})
|
|
59
60
|
|
|
61
|
+
configureSynthetics()
|
|
62
|
+
|
|
60
63
|
initialized.set(true)
|
|
61
64
|
|
|
62
65
|
promise.resolve(null)
|
|
@@ -156,6 +159,17 @@ class DdSdkImplementation(
|
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
|
|
162
|
+
private fun configureSynthetics() {
|
|
163
|
+
if (DdSdkSynthetics.testId.isNullOrBlank() || DdSdkSynthetics.resultId.isNullOrBlank()) {
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
datadog.getRumMonitor()._getInternal()?.setSyntheticsAttribute(
|
|
168
|
+
DdSdkSynthetics.testId,
|
|
169
|
+
DdSdkSynthetics.resultId
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
159
173
|
private fun buildVitalUpdateFrequency(vitalsUpdateFrequency: String?): VitalsUpdateFrequency {
|
|
160
174
|
val vitalUpdateFrequencyLower = vitalsUpdateFrequency?.lowercase(Locale.US)
|
|
161
175
|
return when (vitalUpdateFrequencyLower) {
|
|
@@ -96,6 +96,7 @@ class DdSdkNativeInitialization internal constructor(
|
|
|
96
96
|
?: DdSdkImplementation.DEFAULT_APP_VERSION
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
@Suppress("ComplexMethod")
|
|
99
100
|
private fun buildRumConfiguration(configuration: DdSdkConfiguration): RumConfiguration {
|
|
100
101
|
val configBuilder =
|
|
101
102
|
RumConfiguration.Builder(
|
|
@@ -196,6 +197,10 @@ class DdSdkNativeInitialization internal constructor(
|
|
|
196
197
|
configBuilder.useCustomEndpoint(it)
|
|
197
198
|
}
|
|
198
199
|
|
|
200
|
+
configuration.trackNonFatalAnrs?.let {
|
|
201
|
+
configBuilder.trackNonFatalAnrs(it)
|
|
202
|
+
}
|
|
203
|
+
|
|
199
204
|
return configBuilder.build()
|
|
200
205
|
}
|
|
201
206
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
package com.datadog.reactnative
|
|
8
|
+
|
|
9
|
+
internal object DdSdkSynthetics {
|
|
10
|
+
var testId: String? = null
|
|
11
|
+
var resultId: String? = null
|
|
12
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import android.view.Choreographer
|
|
10
10
|
|
|
11
11
|
internal class FrameRateProvider(
|
|
12
12
|
reactFrameRateCallback: ((Double) -> Unit),
|
|
@@ -30,9 +30,9 @@ internal class FrameRateProvider(
|
|
|
30
30
|
internal class FpsFrameCallback(
|
|
31
31
|
private val reactFrameRateCallback: ((Double) -> Unit),
|
|
32
32
|
private val uiThreadExecutor: UiThreadExecutor
|
|
33
|
-
) :
|
|
33
|
+
) : Choreographer.FrameCallback {
|
|
34
34
|
|
|
35
|
-
private var choreographer:
|
|
35
|
+
private var choreographer: Choreographer? = null
|
|
36
36
|
private var lastFrameTime = -1L
|
|
37
37
|
|
|
38
38
|
override fun doFrame(time: Long) {
|
|
@@ -45,14 +45,14 @@ internal class FpsFrameCallback(
|
|
|
45
45
|
|
|
46
46
|
fun start() {
|
|
47
47
|
uiThreadExecutor.runOnUiThread {
|
|
48
|
-
choreographer =
|
|
48
|
+
choreographer = Choreographer.getInstance()
|
|
49
49
|
choreographer?.postFrameCallback(this@FpsFrameCallback)
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
fun stop() {
|
|
54
54
|
uiThreadExecutor.runOnUiThread {
|
|
55
|
-
choreographer =
|
|
55
|
+
choreographer = Choreographer.getInstance()
|
|
56
56
|
choreographer?.removeFrameCallback(this@FpsFrameCallback)
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
|
+
import android.app.Activity
|
|
10
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
9
11
|
import com.facebook.react.bridge.Promise
|
|
10
12
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
13
|
import com.facebook.react.bridge.ReactMethod
|
|
@@ -21,6 +23,23 @@ class DdSdk(
|
|
|
21
23
|
|
|
22
24
|
override fun getName(): String = DdSdkImplementation.NAME
|
|
23
25
|
|
|
26
|
+
init {
|
|
27
|
+
reactContext.addLifecycleEventListener(object : LifecycleEventListener {
|
|
28
|
+
override fun onHostResume() {
|
|
29
|
+
val currentActivity: Activity? = currentActivity
|
|
30
|
+
if (currentActivity != null) {
|
|
31
|
+
val intent = currentActivity.intent
|
|
32
|
+
val extras = intent.extras
|
|
33
|
+
DdSdkSynthetics.testId = extras?.getString("_dd.synthetics.test_id")
|
|
34
|
+
DdSdkSynthetics.resultId = extras?.getString("_dd.synthetics.result_id")
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override fun onHostPause() {}
|
|
39
|
+
override fun onHostDestroy() {}
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
24
43
|
/**
|
|
25
44
|
* Initializes Datadog's features.
|
|
26
45
|
* @param configuration The configuration to use.
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
|
+
import android.app.Activity
|
|
10
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
9
11
|
import com.facebook.react.bridge.Promise
|
|
10
12
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
13
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
@@ -22,6 +24,23 @@ class DdSdk(
|
|
|
22
24
|
|
|
23
25
|
override fun getName(): String = DdSdkImplementation.NAME
|
|
24
26
|
|
|
27
|
+
init {
|
|
28
|
+
reactContext.addLifecycleEventListener(object : LifecycleEventListener {
|
|
29
|
+
override fun onHostResume() {
|
|
30
|
+
val currentActivity: Activity? = currentActivity
|
|
31
|
+
if (currentActivity != null) {
|
|
32
|
+
val intent = currentActivity.intent
|
|
33
|
+
val extras = intent.extras
|
|
34
|
+
DdSdkSynthetics.testId = extras?.getString("_dd.synthetics.test_id")
|
|
35
|
+
DdSdkSynthetics.resultId = extras?.getString("_dd.synthetics.result_id")
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
override fun onHostPause() {}
|
|
40
|
+
override fun onHostDestroy() {}
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
25
44
|
/**
|
|
26
45
|
* Initializes Datadog's features.
|
|
27
46
|
* @param configuration The configuration to use.
|
|
@@ -241,6 +241,34 @@ internal class DdSdkBridgeExtTest {
|
|
|
241
241
|
assertThat(list).isEmpty()
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
@Test
|
|
245
|
+
fun `M returns a boolean W getBooleanOrNull { entry in the map }`() {
|
|
246
|
+
// Given
|
|
247
|
+
val readableMap = mapOf(
|
|
248
|
+
"testKey" to true
|
|
249
|
+
).toReadableMap()
|
|
250
|
+
|
|
251
|
+
// When
|
|
252
|
+
val value = readableMap.getBooleanOrNull("testKey")
|
|
253
|
+
|
|
254
|
+
// Then
|
|
255
|
+
assertThat(value).isTrue()
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
@Test
|
|
259
|
+
fun `M returns null W getBooleanOrNull { entry not in the map }`() {
|
|
260
|
+
// Given
|
|
261
|
+
val readableMap = mapOf(
|
|
262
|
+
"dummy" to false
|
|
263
|
+
).toReadableMap()
|
|
264
|
+
|
|
265
|
+
// When
|
|
266
|
+
val value = readableMap.getBooleanOrNull("testKey")
|
|
267
|
+
|
|
268
|
+
// Then
|
|
269
|
+
assertThat(value).isNull()
|
|
270
|
+
}
|
|
271
|
+
|
|
244
272
|
private fun getTestMap(): MutableMap<String, Any?> = mutableMapOf(
|
|
245
273
|
"null" to null,
|
|
246
274
|
"int" to 1,
|
|
@@ -38,7 +38,6 @@ import com.datadog.tools.unit.toReadableMap
|
|
|
38
38
|
import com.facebook.react.bridge.Promise
|
|
39
39
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
40
40
|
import com.facebook.react.bridge.ReadableMap
|
|
41
|
-
import com.facebook.react.modules.core.ChoreographerCompat
|
|
42
41
|
import fr.xgouchet.elmyr.Forge
|
|
43
42
|
import fr.xgouchet.elmyr.annotation.AdvancedForgery
|
|
44
43
|
import fr.xgouchet.elmyr.annotation.BoolForgery
|
|
@@ -81,13 +80,6 @@ import org.mockito.kotlin.verifyNoInteractions
|
|
|
81
80
|
import org.mockito.kotlin.whenever
|
|
82
81
|
import org.mockito.quality.Strictness
|
|
83
82
|
|
|
84
|
-
fun mockChoreographerCompatInstance(mock: ChoreographerCompat = mock()) {
|
|
85
|
-
ChoreographerCompat::class.java.setStaticValue(
|
|
86
|
-
"sInstance",
|
|
87
|
-
mock
|
|
88
|
-
)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
83
|
fun mockChoreographerInstance(mock: Choreographer = mock()) {
|
|
92
84
|
Choreographer::class.java.setStaticValue(
|
|
93
85
|
"sThreadInstance",
|
|
@@ -135,9 +127,6 @@ internal class DdSdkTest {
|
|
|
135
127
|
@Mock
|
|
136
128
|
lateinit var mockChoreographer: Choreographer
|
|
137
129
|
|
|
138
|
-
@Mock
|
|
139
|
-
lateinit var mockChoreographerCompat: ChoreographerCompat
|
|
140
|
-
|
|
141
130
|
@BeforeEach
|
|
142
131
|
fun `set up`() {
|
|
143
132
|
val mockLooper = mock<Looper>()
|
|
@@ -148,10 +137,8 @@ internal class DdSdkTest {
|
|
|
148
137
|
whenever(mockRumMonitor._getInternal()) doReturn mockRumInternalProxy
|
|
149
138
|
|
|
150
139
|
doNothing().whenever(mockChoreographer).postFrameCallback(any())
|
|
151
|
-
doNothing().whenever(mockChoreographerCompat).postFrameCallback(any())
|
|
152
140
|
|
|
153
141
|
mockChoreographerInstance(mockChoreographer)
|
|
154
|
-
mockChoreographerCompatInstance(mockChoreographerCompat)
|
|
155
142
|
|
|
156
143
|
whenever(mockReactContext.applicationContext) doReturn mockContext
|
|
157
144
|
whenever(mockContext.packageName) doReturn "packageName"
|
|
@@ -1581,8 +1568,9 @@ internal class DdSdkTest {
|
|
|
1581
1568
|
.hasField("featureConfiguration") {
|
|
1582
1569
|
it.hasFieldEqualTo("vitalsMonitorUpdateFrequency", VitalsUpdateFrequency.RARE)
|
|
1583
1570
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1571
|
+
|
|
1572
|
+
argumentCaptor<Choreographer.FrameCallback> {
|
|
1573
|
+
verify(mockChoreographer).postFrameCallback(capture())
|
|
1586
1574
|
assertThat(firstValue).isInstanceOf(FpsFrameCallback::class.java)
|
|
1587
1575
|
}
|
|
1588
1576
|
}
|
|
@@ -1592,7 +1580,7 @@ internal class DdSdkTest {
|
|
|
1592
1580
|
@Forgery configuration: DdSdkConfiguration
|
|
1593
1581
|
) {
|
|
1594
1582
|
// Given
|
|
1595
|
-
doThrow(IllegalStateException()).whenever(
|
|
1583
|
+
doThrow(IllegalStateException()).whenever(mockChoreographer).postFrameCallback(any())
|
|
1596
1584
|
val bridgeConfiguration = configuration.copy(
|
|
1597
1585
|
vitalsUpdateFrequency = "NEVER",
|
|
1598
1586
|
longTaskThresholdMs = 0.0
|
|
@@ -1620,7 +1608,7 @@ internal class DdSdkTest {
|
|
|
1620
1608
|
.hasField("featureConfiguration") {
|
|
1621
1609
|
it.hasFieldEqualTo("vitalsMonitorUpdateFrequency", VitalsUpdateFrequency.NEVER)
|
|
1622
1610
|
}
|
|
1623
|
-
verifyNoInteractions(
|
|
1611
|
+
verifyNoInteractions(mockChoreographer)
|
|
1624
1612
|
}
|
|
1625
1613
|
|
|
1626
1614
|
@Test
|
|
@@ -1660,8 +1648,8 @@ internal class DdSdkTest {
|
|
|
1660
1648
|
.hasField("featureConfiguration") {
|
|
1661
1649
|
it.hasFieldEqualTo("vitalsMonitorUpdateFrequency", VitalsUpdateFrequency.AVERAGE)
|
|
1662
1650
|
}
|
|
1663
|
-
argumentCaptor<
|
|
1664
|
-
verify(
|
|
1651
|
+
argumentCaptor<Choreographer.FrameCallback> {
|
|
1652
|
+
verify(mockChoreographer).postFrameCallback(capture())
|
|
1665
1653
|
assertThat(firstValue).isInstanceOf(FpsFrameCallback::class.java)
|
|
1666
1654
|
|
|
1667
1655
|
// When
|
|
@@ -1698,8 +1686,8 @@ internal class DdSdkTest {
|
|
|
1698
1686
|
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
1699
1687
|
|
|
1700
1688
|
// Then
|
|
1701
|
-
argumentCaptor<
|
|
1702
|
-
verify(
|
|
1689
|
+
argumentCaptor<Choreographer.FrameCallback> {
|
|
1690
|
+
verify(mockChoreographer).postFrameCallback(capture())
|
|
1703
1691
|
|
|
1704
1692
|
// When
|
|
1705
1693
|
firstValue.doFrame(timestampNs)
|
|
@@ -1735,8 +1723,8 @@ internal class DdSdkTest {
|
|
|
1735
1723
|
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
1736
1724
|
|
|
1737
1725
|
// Then
|
|
1738
|
-
argumentCaptor<
|
|
1739
|
-
verify(
|
|
1726
|
+
argumentCaptor<Choreographer.FrameCallback> {
|
|
1727
|
+
verify(mockChoreographer).postFrameCallback(capture())
|
|
1740
1728
|
|
|
1741
1729
|
// When
|
|
1742
1730
|
firstValue.doFrame(timestampNs)
|
|
@@ -2305,6 +2293,23 @@ internal class DdSdkTest {
|
|
|
2305
2293
|
.hasFieldEqualTo("customEndpointUrl", customTraceEndpoint)
|
|
2306
2294
|
}
|
|
2307
2295
|
|
|
2296
|
+
@Test
|
|
2297
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {synthethics attributes}`() {
|
|
2298
|
+
// Given
|
|
2299
|
+
fakeConfiguration = fakeConfiguration.copy(nativeCrashReportEnabled = false, site = null)
|
|
2300
|
+
DdSdkSynthetics.testId = "unit-test-test-id"
|
|
2301
|
+
DdSdkSynthetics.resultId = "unit-test-result-id"
|
|
2302
|
+
|
|
2303
|
+
// When
|
|
2304
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
2305
|
+
|
|
2306
|
+
// Then
|
|
2307
|
+
verify(mockRumInternalProxy).setSyntheticsAttribute(
|
|
2308
|
+
"unit-test-test-id",
|
|
2309
|
+
"unit-test-result-id"
|
|
2310
|
+
)
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2308
2313
|
@Test
|
|
2309
2314
|
fun `𝕄 clear all data 𝕎 clearAllData()`() {
|
|
2310
2315
|
// When
|
|
@@ -99,6 +99,8 @@ fun DdSdkConfiguration.toReadableJavaOnlyMap(): ReadableMap {
|
|
|
99
99
|
map.put("bundleLogsWithRum", bundleLogsWithRum)
|
|
100
100
|
map.put("bundleLogsWithTraces", bundleLogsWithTraces)
|
|
101
101
|
|
|
102
|
+
trackNonFatalAnrs?.let { map.put("trackNonFatalAnrs", it) }
|
|
103
|
+
|
|
102
104
|
return map.toReadableMap()
|
|
103
105
|
}
|
|
104
106
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.tools.unit
|
|
8
8
|
|
|
9
|
+
import com.datadog.android.rum.ExperimentalRumApi
|
|
9
10
|
import com.datadog.android.rum.RumActionType
|
|
10
11
|
import com.datadog.android.rum.RumErrorSource
|
|
11
12
|
import com.datadog.android.rum.RumMonitor
|
|
@@ -48,6 +49,9 @@ class MockRumMonitor : RumMonitor {
|
|
|
48
49
|
|
|
49
50
|
override fun addTiming(name: String) {}
|
|
50
51
|
|
|
52
|
+
@ExperimentalRumApi
|
|
53
|
+
override fun addViewLoadingTime(overwrite: Boolean) {}
|
|
54
|
+
|
|
51
55
|
override fun clearAttributes() {}
|
|
52
56
|
|
|
53
57
|
override fun getAttributes(): Map<String, Any?> {
|
package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt
CHANGED
|
@@ -79,7 +79,8 @@ class DdSdkConfigurationForgeryFactory : ForgeryFactory<DdSdkConfiguration> {
|
|
|
79
79
|
serviceName = forge.aNullable { forge.anAlphabeticalString() },
|
|
80
80
|
firstPartyHosts = null,
|
|
81
81
|
bundleLogsWithRum = forge.aBool(),
|
|
82
|
-
bundleLogsWithTraces = forge.aBool()
|
|
82
|
+
bundleLogsWithTraces = forge.aBool(),
|
|
83
|
+
trackNonFatalAnrs = forge.aBool()
|
|
83
84
|
)
|
|
84
85
|
}
|
|
85
86
|
}
|