@datadog/mobile-react-native 2.6.4 → 2.6.5
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 +6 -6
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +17 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +26 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +5 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +7 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +38 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +7 -0
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +28 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +19 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +2 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +226 -4
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +6 -0
- package/android/src/test/resources/input/complete-configuration.json +2 -1
- package/datadog-configuration.schema.json +4 -0
- package/ios/Sources/DdSdk.mm +22 -0
- package/ios/Sources/DdSdkConfiguration.swift +5 -1
- package/ios/Sources/DdSdkImplementation.swift +29 -0
- package/ios/Sources/DdSdkNativeInitialization.swift +6 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +7 -3
- package/ios/Sources/SdkVersion.swift +1 -1
- package/jest/mock.js +3 -0
- package/lib/commonjs/DdSdkReactNative.js +24 -4
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +34 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +9 -16
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +33 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +2 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/commonjs/rum/sessionId/sessionIdHelper.js +67 -0
- package/lib/commonjs/rum/sessionId/sessionIdHelper.js.map +1 -0
- package/lib/commonjs/rum/types.js +5 -0
- package/lib/commonjs/rum/types.js.map +1 -1
- package/lib/commonjs/sdk/EventEmitter/EventEmitter.js +51 -0
- package/lib/commonjs/sdk/EventEmitter/EventEmitter.js.map +1 -0
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
- package/lib/commonjs/types.js +4 -2
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +24 -4
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +34 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/rum/DdRum.js +9 -16
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js +33 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/TracingIdentifier.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +2 -2
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/module/rum/sessionId/sessionIdHelper.js +56 -0
- package/lib/module/rum/sessionId/sessionIdHelper.js.map +1 -0
- package/lib/module/rum/types.js +5 -0
- package/lib/module/rum/types.js.map +1 -1
- package/lib/module/sdk/EventEmitter/EventEmitter.js +43 -0
- package/lib/module/sdk/EventEmitter/EventEmitter.js.map +1 -0
- package/lib/module/specs/NativeDdSdk.js.map +1 -1
- package/lib/module/types.js +4 -2
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +17 -2
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +8 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts.map +1 -1
- package/lib/typescript/rum/DdRum.d.ts +0 -1
- package/lib/typescript/rum/DdRum.d.ts.map +1 -1
- package/lib/typescript/rum/sessionId/sessionIdHelper.d.ts +26 -0
- package/lib/typescript/rum/sessionId/sessionIdHelper.d.ts.map +1 -0
- package/lib/typescript/sdk/EventEmitter/EventEmitter.d.ts +12 -0
- package/lib/typescript/sdk/EventEmitter/EventEmitter.d.ts.map +1 -0
- package/lib/typescript/sdk/UserInfoSingleton/types.d.ts +3 -2
- package/lib/typescript/sdk/UserInfoSingleton/types.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdSdk.d.ts +11 -0
- package/lib/typescript/specs/NativeDdSdk.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +22 -5
- 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 +40 -5
- package/src/DdSdkReactNativeConfiguration.tsx +9 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +101 -12
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
- package/src/rum/DdRum.ts +13 -21
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +1 -1
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +2 -2
- package/src/rum/sessionId/__tests__/sessionIdHelper.test.ts +162 -0
- package/src/rum/sessionId/sessionIdHelper.ts +59 -0
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +1 -0
- package/src/sdk/EventEmitter/EventEmitter.ts +55 -0
- package/src/sdk/EventEmitter/__tests__/EventEmitter.test.ts +181 -0
- package/src/sdk/UserInfoSingleton/types.ts +5 -2
- package/src/specs/NativeDdSdk.ts +13 -0
- package/src/types.tsx +23 -5
- package/src/version.ts +1 -1
|
@@ -19,14 +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.
|
|
22
|
+
s.dependency 'DatadogCore', '~> 2.25.0'
|
|
23
|
+
s.dependency 'DatadogLogs', '~> 2.25.0'
|
|
24
|
+
s.dependency 'DatadogTrace', '~> 2.25.0'
|
|
25
|
+
s.dependency 'DatadogRUM', '~> 2.25.0'
|
|
26
|
+
s.dependency 'DatadogCrashReporting', '~> 2.25.0'
|
|
27
27
|
|
|
28
28
|
# DatadogWebViewTracking is not available for tvOS
|
|
29
|
-
s.ios.dependency 'DatadogWebViewTracking', '~> 2.
|
|
29
|
+
s.ios.dependency 'DatadogWebViewTracking', '~> 2.25.0'
|
|
30
30
|
|
|
31
31
|
s.test_spec 'Tests' do |test_spec|
|
|
32
32
|
test_spec.source_files = 'ios/Tests/**/*.{swift,json}'
|
|
@@ -121,7 +121,8 @@ internal class DatadogSDKWrapper : DatadogWrapper {
|
|
|
121
121
|
Trace.enable(configuration, DatadogSDKWrapperStorage.getSdkCore())
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
@Deprecated("Use setUserInfo instead; the user ID is now required.")
|
|
125
|
+
override fun setUser(
|
|
125
126
|
id: String?,
|
|
126
127
|
name: String?,
|
|
127
128
|
email: String?,
|
|
@@ -130,6 +131,21 @@ internal class DatadogSDKWrapper : DatadogWrapper {
|
|
|
130
131
|
Datadog.setUserInfo(id, name, email, extraInfo)
|
|
131
132
|
}
|
|
132
133
|
|
|
134
|
+
override fun setUserInfo(
|
|
135
|
+
id: String,
|
|
136
|
+
name: String?,
|
|
137
|
+
email: String?,
|
|
138
|
+
extraInfo: Map<String, Any?>
|
|
139
|
+
) {
|
|
140
|
+
Datadog.setUserInfo(id, name, email, extraInfo)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
override fun addUserExtraInfo(
|
|
144
|
+
extraInfo: Map<String, Any?>
|
|
145
|
+
) {
|
|
146
|
+
Datadog.addUserProperties(extraInfo)
|
|
147
|
+
}
|
|
148
|
+
|
|
133
149
|
override fun addRumGlobalAttributes(attributes: Map<String, Any?>) {
|
|
134
150
|
val rumMonitor = this.getRumMonitor()
|
|
135
151
|
for (attribute in attributes) {
|
|
@@ -98,13 +98,38 @@ interface DatadogWrapper {
|
|
|
98
98
|
* @param extraInfo additional information. An extra information can be
|
|
99
99
|
* nested up to 8 levels deep. Keys using more than 8 levels will be sanitized by SDK.
|
|
100
100
|
*/
|
|
101
|
-
|
|
101
|
+
@Deprecated("Use setUserInfo instead; the user ID is now required.")
|
|
102
|
+
fun setUser(
|
|
102
103
|
id: String?,
|
|
103
104
|
name: String?,
|
|
104
105
|
email: String?,
|
|
105
106
|
extraInfo: Map<String, Any?>
|
|
106
107
|
)
|
|
107
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Sets the user information.
|
|
111
|
+
*
|
|
112
|
+
* @param id a unique user identifier (relevant to your business domain)
|
|
113
|
+
* @param name (nullable) the user name or alias
|
|
114
|
+
* @param email (nullable) the user email
|
|
115
|
+
* @param extraInfo additional information. An extra information can be
|
|
116
|
+
* nested up to 8 levels deep. Keys using more than 8 levels will be sanitized by SDK.
|
|
117
|
+
*/
|
|
118
|
+
fun setUserInfo(
|
|
119
|
+
id: String,
|
|
120
|
+
name: String?,
|
|
121
|
+
email: String?,
|
|
122
|
+
extraInfo: Map<String, Any?>
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Sets the user information.
|
|
127
|
+
* @param extraUserInfo: The additional information. (To set the id, name or email please user setUserInfo).
|
|
128
|
+
*/
|
|
129
|
+
fun addUserExtraInfo(
|
|
130
|
+
extraInfo: Map<String, Any?>
|
|
131
|
+
)
|
|
132
|
+
|
|
108
133
|
/**
|
|
109
134
|
* Adds global attributes.
|
|
110
135
|
*
|
|
@@ -42,6 +42,7 @@ import java.net.Proxy
|
|
|
42
42
|
* @param bundleLogsWithTraces Enables Traces correlation with logs.
|
|
43
43
|
* @param trackNonFatalAnrs Enables tracking of non-fatal ANRs on Android.
|
|
44
44
|
* @param batchProcessingLevel The preferred number of batches of data that will be sent in a single upload (can be 'LOW', 'MEDIUM' (default), 'HIGH')
|
|
45
|
+
* @param initialResourceThreshold "The amount of time after a view starts where a Resource should be considered when calculating Time to Network-Settled (TNS)"
|
|
45
46
|
*/
|
|
46
47
|
data class DdSdkConfiguration(
|
|
47
48
|
val clientToken: String,
|
|
@@ -71,7 +72,8 @@ data class DdSdkConfiguration(
|
|
|
71
72
|
val bundleLogsWithRum: Boolean? = null,
|
|
72
73
|
val bundleLogsWithTraces: Boolean? = null,
|
|
73
74
|
val trackNonFatalAnrs: Boolean? = null,
|
|
74
|
-
val batchProcessingLevel: String? = null
|
|
75
|
+
val batchProcessingLevel: String? = null,
|
|
76
|
+
val initialResourceThreshold: Double? = null
|
|
75
77
|
)
|
|
76
78
|
|
|
77
79
|
internal data class JSONConfigurationFile(
|
|
@@ -104,7 +106,8 @@ internal data class JSONDdSdkConfiguration(
|
|
|
104
106
|
val bundleLogsWithRum: Boolean? = null,
|
|
105
107
|
val bundleLogsWithTraces: Boolean? = null,
|
|
106
108
|
val trackNonFatalAnrs: Boolean? = null,
|
|
107
|
-
val batchProcessingLevel: String? = null
|
|
109
|
+
val batchProcessingLevel: String? = null,
|
|
110
|
+
val initialResourceThreshold: Double? = null
|
|
108
111
|
)
|
|
109
112
|
|
|
110
113
|
internal data class JSONProxyConfiguration(
|
|
@@ -48,7 +48,8 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
48
48
|
bundleLogsWithRum = getBoolean("bundleLogsWithRum"),
|
|
49
49
|
bundleLogsWithTraces = getBoolean("bundleLogsWithTraces"),
|
|
50
50
|
trackNonFatalAnrs = getBooleanOrNull("trackNonFatalAnrs"),
|
|
51
|
-
batchProcessingLevel = getString("batchProcessingLevel")
|
|
51
|
+
batchProcessingLevel = getString("batchProcessingLevel"),
|
|
52
|
+
initialResourceThreshold = getDouble("initialResourceThreshold")
|
|
52
53
|
)
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -138,6 +139,7 @@ internal object DefaultConfiguration {
|
|
|
138
139
|
const val trackBackgroundEvents = false
|
|
139
140
|
const val bundleLogsWithRum = true
|
|
140
141
|
const val bundleLogsWithTraces = true
|
|
142
|
+
const val initialResourceThreshold = 0.1
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
@Suppress("ComplexMethod")
|
|
@@ -172,7 +174,9 @@ internal fun JSONDdSdkConfiguration.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
172
174
|
this.firstPartyHosts?.asFirstPartyHosts(),
|
|
173
175
|
this.bundleLogsWithRum ?: DefaultConfiguration.bundleLogsWithRum,
|
|
174
176
|
this.bundleLogsWithTraces ?: DefaultConfiguration.bundleLogsWithTraces,
|
|
175
|
-
this.trackNonFatalAnrs
|
|
177
|
+
this.trackNonFatalAnrs,
|
|
178
|
+
this.batchProcessingLevel,
|
|
179
|
+
this.initialResourceThreshold ?: DefaultConfiguration.initialResourceThreshold
|
|
176
180
|
)
|
|
177
181
|
}
|
|
178
182
|
|
|
@@ -236,6 +240,7 @@ internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
|
|
|
236
240
|
trackBackgroundEvents?.let { map.putBoolean("trackBackgroundEvents", it) }
|
|
237
241
|
trackNonFatalAnrs?.let { map.putBoolean("trackNonFatalAnrs", it) }
|
|
238
242
|
additionalConfig?.let { map.putMap("additionalConfig", it.toWritableMap()) }
|
|
243
|
+
initialResourceThreshold?.let { map.putDouble("initialResourceThreshold", it)}
|
|
239
244
|
return map
|
|
240
245
|
}
|
|
241
246
|
|
|
@@ -82,12 +82,49 @@ class DdSdkImplementation(
|
|
|
82
82
|
* @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom
|
|
83
83
|
* attribute).
|
|
84
84
|
*/
|
|
85
|
+
@Deprecated("Use setUserInfo instead; the user ID is now required.")
|
|
85
86
|
fun setUser(user: ReadableMap, promise: Promise) {
|
|
86
87
|
val extraInfo = user.toHashMap().toMutableMap()
|
|
87
88
|
val id = extraInfo.remove("id")?.toString()
|
|
88
89
|
val name = extraInfo.remove("name")?.toString()
|
|
89
90
|
val email = extraInfo.remove("email")?.toString()
|
|
90
|
-
datadog.
|
|
91
|
+
datadog.setUser(id, name, email, extraInfo)
|
|
92
|
+
promise.resolve(null)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Set the user information.
|
|
97
|
+
* @param userInfo The user object (use builtin attributes: 'id', 'email', 'name', and any custom
|
|
98
|
+
* attribute inside 'extraInfo').
|
|
99
|
+
*/
|
|
100
|
+
fun setUserInfo(userInfo: ReadableMap, promise: Promise) {
|
|
101
|
+
val userInfoMap = userInfo.toHashMap().toMutableMap()
|
|
102
|
+
val id = userInfoMap["id"] as? String
|
|
103
|
+
val name = userInfoMap["name"] as? String
|
|
104
|
+
val email = userInfoMap["email"] as? String
|
|
105
|
+
val extraInfo = (userInfoMap["extraInfo"] as? Map<*, *>)?.filterKeys { it is String }
|
|
106
|
+
?.mapKeys { it.key as String }
|
|
107
|
+
?.mapValues { it.value } ?: emptyMap()
|
|
108
|
+
|
|
109
|
+
if (id != null) {
|
|
110
|
+
datadog.setUserInfo(id, name, email, extraInfo)
|
|
111
|
+
} else {
|
|
112
|
+
datadog.setUser(null, name, email, extraInfo)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
promise.resolve(null)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Sets the user information.
|
|
120
|
+
* @param userExtraInfo: The additional information. (To set the id, name or email please user setUserInfo).
|
|
121
|
+
*/
|
|
122
|
+
fun addUserExtraInfo(
|
|
123
|
+
userExtraInfo: ReadableMap, promise: Promise
|
|
124
|
+
) {
|
|
125
|
+
val extraInfoMap = userExtraInfo.toHashMap().toMutableMap()
|
|
126
|
+
|
|
127
|
+
datadog.addUserExtraInfo(extraInfoMap)
|
|
91
128
|
promise.resolve(null)
|
|
92
129
|
}
|
|
93
130
|
|
|
@@ -21,6 +21,7 @@ import com.datadog.android.rum.RumConfiguration
|
|
|
21
21
|
import com.datadog.android.rum.RumSessionListener
|
|
22
22
|
import com.datadog.android.rum._RumInternalProxy
|
|
23
23
|
import com.datadog.android.rum.configuration.VitalsUpdateFrequency
|
|
24
|
+
import com.datadog.android.rum.metric.networksettled.TimeBasedInitialResourceIdentifier
|
|
24
25
|
import com.datadog.android.rum.model.ActionEvent
|
|
25
26
|
import com.datadog.android.rum.model.ResourceEvent
|
|
26
27
|
import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy
|
|
@@ -31,6 +32,7 @@ import com.facebook.react.bridge.WritableNativeMap
|
|
|
31
32
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
32
33
|
import com.google.gson.Gson
|
|
33
34
|
import java.util.Locale
|
|
35
|
+
import kotlin.time.Duration.Companion.seconds
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Initializes the Android Datadog SDK.
|
|
@@ -215,6 +217,11 @@ class DdSdkNativeInitialization internal constructor(
|
|
|
215
217
|
}
|
|
216
218
|
)
|
|
217
219
|
|
|
220
|
+
configuration.initialResourceThreshold?.let {
|
|
221
|
+
val milliseconds = it.seconds.inWholeMilliseconds
|
|
222
|
+
configBuilder.setInitialResourceIdentifier(TimeBasedInitialResourceIdentifier(milliseconds))
|
|
223
|
+
}
|
|
224
|
+
|
|
218
225
|
return configBuilder.build()
|
|
219
226
|
}
|
|
220
227
|
|
|
@@ -64,11 +64,31 @@ class DdSdk(
|
|
|
64
64
|
* @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom
|
|
65
65
|
* attribute).
|
|
66
66
|
*/
|
|
67
|
+
@Deprecated("Use setUserInfo instead; the user ID is now required.")
|
|
67
68
|
@ReactMethod
|
|
68
69
|
override fun setUser(user: ReadableMap, promise: Promise) {
|
|
69
70
|
implementation.setUser(user, promise)
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Set the user information.
|
|
75
|
+
* @param user The user object (use builtin attributes: 'id', 'email', 'name', and any custom
|
|
76
|
+
* attribute inside 'extraInfo').
|
|
77
|
+
*/
|
|
78
|
+
@ReactMethod
|
|
79
|
+
override fun setUserInfo(user: ReadableMap, promise: Promise) {
|
|
80
|
+
implementation.setUserInfo(user, promise)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Sets the user information.
|
|
85
|
+
* @param extraUserInfo: The additional information. (To set the id, name or email please user setUserInfo).
|
|
86
|
+
*/
|
|
87
|
+
@ReactMethod
|
|
88
|
+
override fun addUserExtraInfo(extraInfo: ReadableMap, promise: Promise) {
|
|
89
|
+
implementation.addUserExtraInfo(extraInfo, promise)
|
|
90
|
+
}
|
|
91
|
+
|
|
72
92
|
/**
|
|
73
93
|
* Set the tracking consent regarding the data collection.
|
|
74
94
|
* @param trackingConsent Consent, which can take one of the following values: 'pending',
|
|
@@ -115,4 +135,12 @@ class DdSdk(
|
|
|
115
135
|
override fun clearAllData(promise: Promise) {
|
|
116
136
|
implementation.clearAllData(promise)
|
|
117
137
|
}
|
|
138
|
+
|
|
139
|
+
override fun addListener(eventType: String?) {
|
|
140
|
+
// No-op
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
override fun removeListeners(count: Double) {
|
|
144
|
+
// No-op
|
|
145
|
+
}
|
|
118
146
|
}
|
|
@@ -65,11 +65,30 @@ class DdSdk(
|
|
|
65
65
|
* @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom
|
|
66
66
|
* attribute).
|
|
67
67
|
*/
|
|
68
|
+
@Deprecated("Use setUserInfo instead; the user ID is now required.")
|
|
68
69
|
@ReactMethod
|
|
69
70
|
fun setUser(user: ReadableMap, promise: Promise) {
|
|
70
71
|
implementation.setUser(user, promise)
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Set the user information.
|
|
76
|
+
* @param user The user object (use builtin attributes: 'id', 'email', 'name', and any custom * attribute inside 'extraInfo').
|
|
77
|
+
*/
|
|
78
|
+
@ReactMethod
|
|
79
|
+
fun setUserInfo(user: ReadableMap, promise: Promise) {
|
|
80
|
+
implementation.setUserInfo(user, promise)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Sets the user information.
|
|
85
|
+
* @param extraUserInfo: The additional information. (To set the id, name or email please user setUserInfo).
|
|
86
|
+
*/
|
|
87
|
+
@ReactMethod
|
|
88
|
+
fun addUserExtraInfo(extraInfo: ReadableMap, promise: Promise) {
|
|
89
|
+
implementation.addUserExtraInfo(extraInfo, promise)
|
|
90
|
+
}
|
|
91
|
+
|
|
73
92
|
/**
|
|
74
93
|
* Set the tracking consent regarding the data collection.
|
|
75
94
|
* @param trackingConsent Consent, which can take one of the following values: 'pending',
|
|
@@ -121,6 +121,7 @@ internal class DdSdkNativeInitializationTest {
|
|
|
121
121
|
assertThat(configuration.firstPartyHosts?.get("example.com").toString()).isEqualTo(
|
|
122
122
|
"[B3MULTI, TRACECONTEXT]"
|
|
123
123
|
)
|
|
124
|
+
assertThat(configuration.initialResourceThreshold).isEqualTo(0.5)
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
@Test
|
|
@@ -161,6 +162,7 @@ internal class DdSdkNativeInitializationTest {
|
|
|
161
162
|
assertThat(configuration.serviceName).isNull()
|
|
162
163
|
assertThat(configuration.proxyConfig).isNull()
|
|
163
164
|
assertThat(configuration.firstPartyHosts).isNull()
|
|
165
|
+
assertThat(configuration.initialResourceThreshold).isEqualTo(0.1)
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
@Test
|
|
@@ -22,6 +22,7 @@ import com.datadog.android.rum.RumConfiguration
|
|
|
22
22
|
import com.datadog.android.rum.RumPerformanceMetric
|
|
23
23
|
import com.datadog.android.rum._RumInternalProxy
|
|
24
24
|
import com.datadog.android.rum.configuration.VitalsUpdateFrequency
|
|
25
|
+
import com.datadog.android.rum.metric.networksettled.TimeBasedInitialResourceIdentifier
|
|
25
26
|
import com.datadog.android.rum.model.ActionEvent
|
|
26
27
|
import com.datadog.android.rum.model.ResourceEvent
|
|
27
28
|
import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy
|
|
@@ -42,6 +43,7 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
42
43
|
import fr.xgouchet.elmyr.Forge
|
|
43
44
|
import fr.xgouchet.elmyr.annotation.AdvancedForgery
|
|
44
45
|
import fr.xgouchet.elmyr.annotation.BoolForgery
|
|
46
|
+
import fr.xgouchet.elmyr.annotation.DoubleForgery
|
|
45
47
|
import fr.xgouchet.elmyr.annotation.Forgery
|
|
46
48
|
import fr.xgouchet.elmyr.annotation.IntForgery
|
|
47
49
|
import fr.xgouchet.elmyr.annotation.LongForgery
|
|
@@ -52,6 +54,7 @@ import fr.xgouchet.elmyr.junit5.ForgeConfiguration
|
|
|
52
54
|
import fr.xgouchet.elmyr.junit5.ForgeExtension
|
|
53
55
|
import java.util.Locale
|
|
54
56
|
import java.util.stream.Stream
|
|
57
|
+
import kotlin.time.Duration.Companion.seconds
|
|
55
58
|
import org.assertj.core.api.Assertions.assertThat
|
|
56
59
|
import org.junit.jupiter.api.AfterEach
|
|
57
60
|
import org.junit.jupiter.api.BeforeEach
|
|
@@ -72,6 +75,7 @@ import org.mockito.kotlin.doReturn
|
|
|
72
75
|
import org.mockito.kotlin.doThrow
|
|
73
76
|
import org.mockito.kotlin.eq
|
|
74
77
|
import org.mockito.kotlin.inOrder
|
|
78
|
+
import org.mockito.kotlin.isNotNull
|
|
75
79
|
import org.mockito.kotlin.isNull
|
|
76
80
|
import org.mockito.kotlin.mock
|
|
77
81
|
import org.mockito.kotlin.never
|
|
@@ -1784,6 +1788,80 @@ internal class DdSdkTest {
|
|
|
1784
1788
|
|
|
1785
1789
|
// endregion
|
|
1786
1790
|
|
|
1791
|
+
// region initial resource threshold TNS
|
|
1792
|
+
|
|
1793
|
+
@Test
|
|
1794
|
+
fun `𝕄 initialize W initialize() { initialResourceThreshold is null }`(
|
|
1795
|
+
@Forgery configuration: DdSdkConfiguration
|
|
1796
|
+
) {
|
|
1797
|
+
// Given
|
|
1798
|
+
val sdkConfigCaptor = argumentCaptor<Configuration>()
|
|
1799
|
+
val rumConfigCaptor = argumentCaptor<RumConfiguration>()
|
|
1800
|
+
val logsConfigCaptor = argumentCaptor<LogsConfiguration>()
|
|
1801
|
+
val traceConfigCaptor = argumentCaptor<TraceConfiguration>()
|
|
1802
|
+
val defaultTimeBasedIdentifier = TimeBasedInitialResourceIdentifier(100)
|
|
1803
|
+
|
|
1804
|
+
// When
|
|
1805
|
+
testedBridgeSdk.initialize(configuration.toReadableJavaOnlyMap(), mockPromise)
|
|
1806
|
+
|
|
1807
|
+
// Then
|
|
1808
|
+
inOrder(mockDatadog) {
|
|
1809
|
+
verify(mockDatadog).initialize(
|
|
1810
|
+
same(mockContext),
|
|
1811
|
+
sdkConfigCaptor.capture(),
|
|
1812
|
+
any()
|
|
1813
|
+
)
|
|
1814
|
+
verify(mockDatadog).enableRum(rumConfigCaptor.capture())
|
|
1815
|
+
verify(mockDatadog).enableTrace(traceConfigCaptor.capture())
|
|
1816
|
+
verify(mockDatadog).enableLogs(logsConfigCaptor.capture())
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
assertThat(rumConfigCaptor.firstValue)
|
|
1820
|
+
.hasField("featureConfiguration") {
|
|
1821
|
+
it.hasFieldEqualTo("initialResourceIdentifier", defaultTimeBasedIdentifier)
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
@Test
|
|
1826
|
+
fun `𝕄 initialize W initialize() { initialResourceThreshold is not null}`(
|
|
1827
|
+
@DoubleForgery(min = 0.1, max = 5.0) thresholdInSeconds: Double,
|
|
1828
|
+
@Forgery configuration: DdSdkConfiguration
|
|
1829
|
+
) {
|
|
1830
|
+
// Given
|
|
1831
|
+
val bridgeConfiguration = configuration.copy(
|
|
1832
|
+
initialResourceThreshold = thresholdInSeconds
|
|
1833
|
+
)
|
|
1834
|
+
val sdkConfigCaptor = argumentCaptor<Configuration>()
|
|
1835
|
+
val rumConfigCaptor = argumentCaptor<RumConfiguration>()
|
|
1836
|
+
val logsConfigCaptor = argumentCaptor<LogsConfiguration>()
|
|
1837
|
+
val traceConfigCaptor = argumentCaptor<TraceConfiguration>()
|
|
1838
|
+
val timeBasedIdentifier = TimeBasedInitialResourceIdentifier(
|
|
1839
|
+
thresholdInSeconds.seconds.inWholeMilliseconds
|
|
1840
|
+
)
|
|
1841
|
+
|
|
1842
|
+
// When
|
|
1843
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
1844
|
+
|
|
1845
|
+
// Then
|
|
1846
|
+
inOrder(mockDatadog) {
|
|
1847
|
+
verify(mockDatadog).initialize(
|
|
1848
|
+
same(mockContext),
|
|
1849
|
+
sdkConfigCaptor.capture(),
|
|
1850
|
+
any()
|
|
1851
|
+
)
|
|
1852
|
+
verify(mockDatadog).enableRum(rumConfigCaptor.capture())
|
|
1853
|
+
verify(mockDatadog).enableTrace(traceConfigCaptor.capture())
|
|
1854
|
+
verify(mockDatadog).enableLogs(logsConfigCaptor.capture())
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
assertThat(rumConfigCaptor.firstValue)
|
|
1858
|
+
.hasField("featureConfiguration") {
|
|
1859
|
+
it.hasFieldEqualTo("initialResourceIdentifier", timeBasedIdentifier)
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
// endregion
|
|
1864
|
+
|
|
1787
1865
|
// region version suffix
|
|
1788
1866
|
|
|
1789
1867
|
@Test
|
|
@@ -2064,7 +2142,7 @@ internal class DdSdkTest {
|
|
|
2064
2142
|
// Then
|
|
2065
2143
|
argumentCaptor<Map<String, Any?>> {
|
|
2066
2144
|
verify(mockDatadog)
|
|
2067
|
-
.
|
|
2145
|
+
.setUser(
|
|
2068
2146
|
isNull(),
|
|
2069
2147
|
isNull(),
|
|
2070
2148
|
isNull(),
|
|
@@ -2096,7 +2174,7 @@ internal class DdSdkTest {
|
|
|
2096
2174
|
// Then
|
|
2097
2175
|
argumentCaptor<Map<String, Any?>> {
|
|
2098
2176
|
verify(mockDatadog)
|
|
2099
|
-
.
|
|
2177
|
+
.setUser(
|
|
2100
2178
|
eq(id),
|
|
2101
2179
|
isNull(),
|
|
2102
2180
|
isNull(),
|
|
@@ -2128,7 +2206,7 @@ internal class DdSdkTest {
|
|
|
2128
2206
|
// Then
|
|
2129
2207
|
argumentCaptor<Map<String, Any?>> {
|
|
2130
2208
|
verify(mockDatadog)
|
|
2131
|
-
.
|
|
2209
|
+
.setUser(
|
|
2132
2210
|
isNull(),
|
|
2133
2211
|
eq(name),
|
|
2134
2212
|
isNull(),
|
|
@@ -2160,7 +2238,7 @@ internal class DdSdkTest {
|
|
|
2160
2238
|
// Then
|
|
2161
2239
|
argumentCaptor<Map<String, Any?>> {
|
|
2162
2240
|
verify(mockDatadog)
|
|
2163
|
-
.
|
|
2241
|
+
.setUser(
|
|
2164
2242
|
isNull(),
|
|
2165
2243
|
isNull(),
|
|
2166
2244
|
eq(email),
|
|
@@ -2193,6 +2271,127 @@ internal class DdSdkTest {
|
|
|
2193
2271
|
// When
|
|
2194
2272
|
testedBridgeSdk.setUser(user.toReadableMap(), mockPromise)
|
|
2195
2273
|
|
|
2274
|
+
// Then
|
|
2275
|
+
argumentCaptor<Map<String, Any?>> {
|
|
2276
|
+
verify(mockDatadog)
|
|
2277
|
+
.setUser(
|
|
2278
|
+
eq(id),
|
|
2279
|
+
eq(name),
|
|
2280
|
+
eq(email),
|
|
2281
|
+
capture()
|
|
2282
|
+
)
|
|
2283
|
+
|
|
2284
|
+
assertThat(firstValue)
|
|
2285
|
+
.containsAllEntriesOf(extraInfo)
|
|
2286
|
+
.hasSize(extraInfo.size)
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
@Test
|
|
2291
|
+
fun `𝕄 set native user info 𝕎 setUserInfo() {with id}`(
|
|
2292
|
+
@StringForgery id: String
|
|
2293
|
+
) {
|
|
2294
|
+
// Given
|
|
2295
|
+
val userInfo = mapOf(
|
|
2296
|
+
"id" to id
|
|
2297
|
+
)
|
|
2298
|
+
|
|
2299
|
+
// When
|
|
2300
|
+
testedBridgeSdk.setUserInfo(userInfo.toReadableMap(), mockPromise)
|
|
2301
|
+
|
|
2302
|
+
// Then
|
|
2303
|
+
argumentCaptor<Map<String, Any?>> {
|
|
2304
|
+
verify(mockDatadog)
|
|
2305
|
+
.setUserInfo(
|
|
2306
|
+
eq(id),
|
|
2307
|
+
isNull(),
|
|
2308
|
+
isNull(),
|
|
2309
|
+
capture()
|
|
2310
|
+
)
|
|
2311
|
+
|
|
2312
|
+
assertThat(firstValue).isEmpty()
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
@Test
|
|
2317
|
+
fun `𝕄 set native user info 𝕎 setUserInfo() {with id and name}`(
|
|
2318
|
+
@StringForgery id: String,
|
|
2319
|
+
@StringForgery name: String
|
|
2320
|
+
) {
|
|
2321
|
+
// Given
|
|
2322
|
+
val userInfo = mapOf(
|
|
2323
|
+
"id" to id,
|
|
2324
|
+
"name" to name
|
|
2325
|
+
)
|
|
2326
|
+
|
|
2327
|
+
// When
|
|
2328
|
+
testedBridgeSdk.setUserInfo(userInfo.toReadableMap(), mockPromise)
|
|
2329
|
+
|
|
2330
|
+
// Then
|
|
2331
|
+
argumentCaptor<Map<String, Any?>> {
|
|
2332
|
+
verify(mockDatadog)
|
|
2333
|
+
.setUserInfo(
|
|
2334
|
+
eq(id),
|
|
2335
|
+
eq(name),
|
|
2336
|
+
isNull(),
|
|
2337
|
+
capture()
|
|
2338
|
+
)
|
|
2339
|
+
|
|
2340
|
+
assertThat(firstValue).isEmpty()
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
@Test
|
|
2345
|
+
fun `𝕄 set native user info 𝕎 setUserInfo() {with id, name and email}`(
|
|
2346
|
+
@StringForgery id: String,
|
|
2347
|
+
@StringForgery name: String,
|
|
2348
|
+
@StringForgery(regex = "\\w+@\\w+\\.[a-z]{3}") email: String
|
|
2349
|
+
) {
|
|
2350
|
+
// Given
|
|
2351
|
+
val userInfo = mapOf(
|
|
2352
|
+
"id" to id,
|
|
2353
|
+
"name" to name,
|
|
2354
|
+
"email" to email
|
|
2355
|
+
)
|
|
2356
|
+
|
|
2357
|
+
// When
|
|
2358
|
+
testedBridgeSdk.setUserInfo(userInfo.toReadableMap(), mockPromise)
|
|
2359
|
+
|
|
2360
|
+
// Then
|
|
2361
|
+
argumentCaptor<Map<String, Any?>> {
|
|
2362
|
+
verify(mockDatadog)
|
|
2363
|
+
.setUserInfo(
|
|
2364
|
+
eq(id),
|
|
2365
|
+
eq(name),
|
|
2366
|
+
eq(email),
|
|
2367
|
+
capture()
|
|
2368
|
+
)
|
|
2369
|
+
|
|
2370
|
+
assertThat(firstValue).isEmpty()
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
@Test
|
|
2375
|
+
fun `𝕄 set native user info 𝕎 setUserInfo() {with id, name, email and extraInfo}`(
|
|
2376
|
+
@StringForgery id: String,
|
|
2377
|
+
@StringForgery name: String,
|
|
2378
|
+
@StringForgery(regex = "\\w+@\\w+\\.[a-z]{3}") email: String,
|
|
2379
|
+
@MapForgery(
|
|
2380
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
2381
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
2382
|
+
) extraInfo: Map<String, String>
|
|
2383
|
+
) {
|
|
2384
|
+
// Given
|
|
2385
|
+
val userInfo = mapOf(
|
|
2386
|
+
"id" to id,
|
|
2387
|
+
"name" to name,
|
|
2388
|
+
"email" to email,
|
|
2389
|
+
"extraInfo" to extraInfo
|
|
2390
|
+
)
|
|
2391
|
+
|
|
2392
|
+
// When
|
|
2393
|
+
testedBridgeSdk.setUserInfo(userInfo.toReadableMap(), mockPromise)
|
|
2394
|
+
|
|
2196
2395
|
// Then
|
|
2197
2396
|
argumentCaptor<Map<String, Any?>> {
|
|
2198
2397
|
verify(mockDatadog)
|
|
@@ -2209,6 +2408,29 @@ internal class DdSdkTest {
|
|
|
2209
2408
|
}
|
|
2210
2409
|
}
|
|
2211
2410
|
|
|
2411
|
+
@Test
|
|
2412
|
+
fun `𝕄 add native extra user info 𝕎 addUserExtraInfo() {with userExtraInfo}`(
|
|
2413
|
+
@MapForgery(
|
|
2414
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
2415
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
2416
|
+
) userExtraInfo: Map<String, String>
|
|
2417
|
+
) {
|
|
2418
|
+
// When
|
|
2419
|
+
testedBridgeSdk.addUserExtraInfo(userExtraInfo.toReadableMap(), mockPromise)
|
|
2420
|
+
|
|
2421
|
+
// Then
|
|
2422
|
+
argumentCaptor<Map<String, Any?>> {
|
|
2423
|
+
verify(mockDatadog)
|
|
2424
|
+
.addUserExtraInfo(
|
|
2425
|
+
capture()
|
|
2426
|
+
)
|
|
2427
|
+
|
|
2428
|
+
assertThat(firstValue)
|
|
2429
|
+
.containsAllEntriesOf(userExtraInfo)
|
|
2430
|
+
.hasSize(userExtraInfo.size)
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2212
2434
|
@Test
|
|
2213
2435
|
fun `𝕄 set RUM attributes 𝕎 setAttributes`(
|
|
2214
2436
|
@MapForgery(
|
|
@@ -108,6 +108,12 @@ fun DdSdkConfiguration.toReadableJavaOnlyMap(): ReadableMap {
|
|
|
108
108
|
map["batchProcessingLevel"] = BatchProcessingLevel.MEDIUM.toString()
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
if (initialResourceThreshold != null) {
|
|
112
|
+
map.put("initialResourceThreshold", initialResourceThreshold)
|
|
113
|
+
} else {
|
|
114
|
+
map.put("initialResourceThreshold", 0.1f)
|
|
115
|
+
}
|
|
116
|
+
|
|
111
117
|
return map.toReadableMap()
|
|
112
118
|
}
|
|
113
119
|
|
|
@@ -241,6 +241,10 @@
|
|
|
241
241
|
"trackNonFatalAnrs": {
|
|
242
242
|
"description": "Enables tracking of non-fatal ANRs on Android.",
|
|
243
243
|
"type": "boolean"
|
|
244
|
+
},
|
|
245
|
+
"initialResourceThreshold" : {
|
|
246
|
+
"description": "The amount of time after a view starts where a Resource should be considered when calculating Time to Network-Settled (TNS)",
|
|
247
|
+
"type": "number"
|
|
244
248
|
}
|
|
245
249
|
},
|
|
246
250
|
"required": [
|