@datadog/mobile-react-native 2.6.3 → 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/build.gradle +4 -4
- 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/DdRumImplementation.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 +7 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +39 -3
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +33 -5
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +10 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +28 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +10 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +30 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +9 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +3 -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/DdRum.mm +11 -0
- package/ios/Sources/DdRumImplementation.swift +7 -0
- package/ios/Sources/DdSdk.h +5 -3
- package/ios/Sources/DdSdk.mm +27 -1
- package/ios/Sources/DdSdkConfiguration.swift +5 -1
- package/ios/Sources/DdSdkImplementation.swift +31 -2
- package/ios/Sources/DdSdkNativeInitialization.swift +17 -6
- package/ios/Sources/RNDdSdkConfiguration.swift +7 -3
- package/ios/Sources/SdkVersion.swift +1 -1
- package/jest/mock.js +6 -0
- package/lib/commonjs/DdSdkReactNative.js +24 -4
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +36 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +2 -1
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +19 -3
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.js +2 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.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 +6 -4
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +31 -12
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +9 -8
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.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/NativeDdRum.js.map +1 -1
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
- package/lib/commonjs/types.js +4 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/Timer.js +2 -2
- package/lib/commonjs/utils/Timer.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 +36 -1
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +2 -1
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +19 -3
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.js +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.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 +6 -4
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +30 -11
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +8 -6
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.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/NativeDdRum.js.map +1 -1
- package/lib/module/specs/NativeDdSdk.js.map +1 -1
- package/lib/module/types.js +4 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/Timer.js +1 -1
- package/lib/module/utils/Timer.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 +3 -0
- package/lib/typescript/rum/DdRum.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/EventsInterceptor.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/EventsInterceptor.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.d.ts +2 -2
- package/lib/typescript/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +4 -2
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +3 -2
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.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/rum/types.d.ts +6 -0
- package/lib/typescript/rum/types.d.ts.map +1 -1
- 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/NativeDdRum.d.ts +6 -0
- package/lib/typescript/specs/NativeDdRum.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdSdk.d.ts +17 -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/utils/Timer.d.ts +1 -1
- package/lib/typescript/utils/Timer.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 +10 -1
- package/src/__tests__/DdSdkReactNative.test.tsx +101 -12
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
- package/src/__tests__/mock.test.ts +2 -1
- package/src/nativeModulesTypes.ts +1 -1
- package/src/rum/DdRum.ts +39 -4
- package/src/rum/__mocks__/MockTimeProvider.ts +1 -1
- package/src/rum/__tests__/DdRum.test.ts +17 -0
- package/src/rum/__tests__/DdRumTimeProvider.test.ts +1 -1
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +1 -1
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +2 -2
- package/src/rum/instrumentation/interactionTracking/EventsInterceptor.tsx +1 -1
- package/src/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.tsx +2 -2
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +10 -4
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +42 -15
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +8 -6
- package/src/rum/sessionId/__tests__/sessionIdHelper.test.ts +162 -0
- package/src/rum/sessionId/sessionIdHelper.ts +59 -0
- package/src/rum/types.ts +7 -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/NativeDdRum.ts +7 -0
- package/src/specs/NativeDdSdk.ts +20 -0
- package/src/types.tsx +23 -5
- package/src/utils/Timer.ts +1 -1
- package/src/utils/__tests__/TimeProvider.test.tsx +1 -1
- package/src/utils/__tests__/Timer.test.ts +1 -1
- 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}'
|
package/android/build.gradle
CHANGED
|
@@ -192,10 +192,10 @@ dependencies {
|
|
|
192
192
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
193
193
|
compileOnly "com.squareup.okhttp3:okhttp:3.12.13"
|
|
194
194
|
|
|
195
|
-
implementation "com.datadoghq:dd-sdk-android-rum:2.
|
|
196
|
-
implementation "com.datadoghq:dd-sdk-android-logs:2.
|
|
197
|
-
implementation "com.datadoghq:dd-sdk-android-trace:2.
|
|
198
|
-
implementation "com.datadoghq:dd-sdk-android-webview:2.
|
|
195
|
+
implementation "com.datadoghq:dd-sdk-android-rum:2.19.2"
|
|
196
|
+
implementation "com.datadoghq:dd-sdk-android-logs:2.19.2"
|
|
197
|
+
implementation "com.datadoghq:dd-sdk-android-trace:2.19.2"
|
|
198
|
+
implementation "com.datadoghq:dd-sdk-android-webview:2.19.2"
|
|
199
199
|
implementation "com.google.code.gson:gson:2.10.0"
|
|
200
200
|
testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
|
|
201
201
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
|
|
@@ -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
|
*
|
|
@@ -248,6 +248,16 @@ class DdRumImplementation(private val datadog: DatadogWrapper = DatadogSDKWrappe
|
|
|
248
248
|
promise.resolve(null)
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Adds the loading time of the view to the active view.
|
|
253
|
+
* It is calculated as the difference between the current time and the start time of the view.
|
|
254
|
+
* @param overwrite: If true, overwrites the previously calculated view loading time.
|
|
255
|
+
*/
|
|
256
|
+
fun addViewLoadingTime(overwrite: Boolean, promise: Promise) {
|
|
257
|
+
datadog.getRumMonitor().addViewLoadingTime(overwrite)
|
|
258
|
+
promise.resolve(null)
|
|
259
|
+
}
|
|
260
|
+
|
|
251
261
|
/**
|
|
252
262
|
* Stops the current RUM Session.
|
|
253
263
|
*/
|
|
@@ -317,6 +327,8 @@ class DdRumImplementation(private val datadog: DatadogWrapper = DatadogSDKWrappe
|
|
|
317
327
|
"network" -> RumErrorSource.NETWORK
|
|
318
328
|
"source" -> RumErrorSource.SOURCE
|
|
319
329
|
"webview" -> RumErrorSource.WEBVIEW
|
|
330
|
+
"custom" -> RumErrorSource.CUSTOM
|
|
331
|
+
"report" -> RumErrorSource.REPORT
|
|
320
332
|
else -> RumErrorSource.SOURCE
|
|
321
333
|
}
|
|
322
334
|
}
|
|
@@ -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
|
|
|
@@ -9,7 +9,6 @@ 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.GlobalRumMonitor
|
|
13
12
|
import com.datadog.android.rum.RumPerformanceMetric
|
|
14
13
|
import com.datadog.android.rum.configuration.VitalsUpdateFrequency
|
|
15
14
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
@@ -39,7 +38,7 @@ class DdSdkImplementation(
|
|
|
39
38
|
fun initialize(configuration: ReadableMap, promise: Promise) {
|
|
40
39
|
val ddSdkConfiguration = configuration.asDdSdkConfiguration()
|
|
41
40
|
|
|
42
|
-
val nativeInitialization = DdSdkNativeInitialization(appContext, datadog)
|
|
41
|
+
val nativeInitialization = DdSdkNativeInitialization(appContext, reactContext, datadog)
|
|
43
42
|
nativeInitialization.initialize(ddSdkConfiguration)
|
|
44
43
|
|
|
45
44
|
this.frameRateProvider = createFrameRateProvider(ddSdkConfiguration)
|
|
@@ -83,12 +82,49 @@ class DdSdkImplementation(
|
|
|
83
82
|
* @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom
|
|
84
83
|
* attribute).
|
|
85
84
|
*/
|
|
85
|
+
@Deprecated("Use setUserInfo instead; the user ID is now required.")
|
|
86
86
|
fun setUser(user: ReadableMap, promise: Promise) {
|
|
87
87
|
val extraInfo = user.toHashMap().toMutableMap()
|
|
88
88
|
val id = extraInfo.remove("id")?.toString()
|
|
89
89
|
val name = extraInfo.remove("name")?.toString()
|
|
90
90
|
val email = extraInfo.remove("email")?.toString()
|
|
91
|
-
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)
|
|
92
128
|
promise.resolve(null)
|
|
93
129
|
}
|
|
94
130
|
|
|
@@ -10,35 +10,42 @@ import android.content.Context
|
|
|
10
10
|
import android.content.pm.PackageManager
|
|
11
11
|
import android.util.Log
|
|
12
12
|
import com.datadog.android.DatadogSite
|
|
13
|
+
import com.datadog.android.core.configuration.BatchProcessingLevel
|
|
13
14
|
import com.datadog.android.core.configuration.BatchSize
|
|
14
15
|
import com.datadog.android.core.configuration.Configuration
|
|
15
16
|
import com.datadog.android.core.configuration.UploadFrequency
|
|
16
|
-
import com.datadog.android.core.configuration.BatchProcessingLevel
|
|
17
17
|
import com.datadog.android.event.EventMapper
|
|
18
18
|
import com.datadog.android.log.LogsConfiguration
|
|
19
19
|
import com.datadog.android.privacy.TrackingConsent
|
|
20
20
|
import com.datadog.android.rum.RumConfiguration
|
|
21
|
+
import com.datadog.android.rum.RumSessionListener
|
|
21
22
|
import com.datadog.android.rum._RumInternalProxy
|
|
22
23
|
import com.datadog.android.rum.configuration.VitalsUpdateFrequency
|
|
24
|
+
import com.datadog.android.rum.metric.networksettled.TimeBasedInitialResourceIdentifier
|
|
23
25
|
import com.datadog.android.rum.model.ActionEvent
|
|
24
26
|
import com.datadog.android.rum.model.ResourceEvent
|
|
25
27
|
import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy
|
|
26
28
|
import com.datadog.android.telemetry.model.TelemetryConfigurationEvent
|
|
27
29
|
import com.datadog.android.trace.TraceConfiguration
|
|
30
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
31
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
32
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
28
33
|
import com.google.gson.Gson
|
|
29
34
|
import java.util.Locale
|
|
35
|
+
import kotlin.time.Duration.Companion.seconds
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
38
|
* Initializes the Android Datadog SDK.
|
|
33
39
|
*/
|
|
34
40
|
class DdSdkNativeInitialization internal constructor(
|
|
35
41
|
private val appContext: Context,
|
|
42
|
+
private val reactContext: ReactApplicationContext,
|
|
36
43
|
private val datadog: DatadogWrapper = DatadogSDKWrapper(),
|
|
37
44
|
private val jsonFileReader: JSONFileReader = JSONFileReader()
|
|
38
45
|
) {
|
|
39
46
|
internal fun initialize(ddSdkConfiguration: DdSdkConfiguration) {
|
|
40
47
|
val sdkConfiguration = buildSdkConfiguration(ddSdkConfiguration)
|
|
41
|
-
val rumConfiguration = buildRumConfiguration(ddSdkConfiguration)
|
|
48
|
+
val rumConfiguration = buildRumConfiguration(ddSdkConfiguration, reactContext)
|
|
42
49
|
val logsConfiguration = buildLogsConfiguration(ddSdkConfiguration)
|
|
43
50
|
val traceConfiguration = buildTraceConfiguration(ddSdkConfiguration)
|
|
44
51
|
val trackingConsent = buildTrackingConsent(ddSdkConfiguration.trackingConsent)
|
|
@@ -98,7 +105,7 @@ class DdSdkNativeInitialization internal constructor(
|
|
|
98
105
|
}
|
|
99
106
|
|
|
100
107
|
@Suppress("ComplexMethod")
|
|
101
|
-
private fun buildRumConfiguration(configuration: DdSdkConfiguration): RumConfiguration {
|
|
108
|
+
private fun buildRumConfiguration(configuration: DdSdkConfiguration, reactContext: ReactApplicationContext): RumConfiguration {
|
|
102
109
|
val configBuilder =
|
|
103
110
|
RumConfiguration.Builder(
|
|
104
111
|
applicationId = configuration.applicationId
|
|
@@ -202,9 +209,30 @@ class DdSdkNativeInitialization internal constructor(
|
|
|
202
209
|
configBuilder.trackNonFatalAnrs(it)
|
|
203
210
|
}
|
|
204
211
|
|
|
212
|
+
configBuilder.setSessionListener(
|
|
213
|
+
object : RumSessionListener {
|
|
214
|
+
override fun onSessionStarted(sessionId: String, isDiscarded: Boolean) {
|
|
215
|
+
sendSessionIdEvent(sessionId, isDiscarded)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
configuration.initialResourceThreshold?.let {
|
|
221
|
+
val milliseconds = it.seconds.inWholeMilliseconds
|
|
222
|
+
configBuilder.setInitialResourceIdentifier(TimeBasedInitialResourceIdentifier(milliseconds))
|
|
223
|
+
}
|
|
224
|
+
|
|
205
225
|
return configBuilder.build()
|
|
206
226
|
}
|
|
207
227
|
|
|
228
|
+
private fun sendSessionIdEvent(sessionId: String, isDiscarded: Boolean) {
|
|
229
|
+
val attributes = WritableNativeMap()
|
|
230
|
+
attributes.putString("sessionId", sessionId)
|
|
231
|
+
attributes.putBoolean("isDiscarded", isDiscarded)
|
|
232
|
+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
233
|
+
.emit("RumSessionStarted", attributes)
|
|
234
|
+
}
|
|
235
|
+
|
|
208
236
|
private fun buildLogsConfiguration(configuration: DdSdkConfiguration): LogsConfiguration {
|
|
209
237
|
val configBuilder = LogsConfiguration.Builder()
|
|
210
238
|
configuration.customEndpoints?.logs?.let {
|
|
@@ -353,8 +381,8 @@ class DdSdkNativeInitialization internal constructor(
|
|
|
353
381
|
* @param appContext: The application context of your React Native application.
|
|
354
382
|
*/
|
|
355
383
|
@JvmStatic
|
|
356
|
-
fun initFromNative(appContext: Context) {
|
|
357
|
-
val nativeInitialization = DdSdkNativeInitialization(appContext.applicationContext)
|
|
384
|
+
fun initFromNative(appContext: Context, reactContext: ReactApplicationContext) {
|
|
385
|
+
val nativeInitialization = DdSdkNativeInitialization(appContext.applicationContext, reactContext)
|
|
358
386
|
try {
|
|
359
387
|
nativeInitialization.initialize(nativeInitialization.getConfigurationFromJSONFile())
|
|
360
388
|
} catch (@Suppress("TooGenericExceptionCaught") error: Exception) {
|
|
@@ -201,6 +201,16 @@ class DdRum(
|
|
|
201
201
|
implementation.addTiming(name, promise)
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Adds the loading time of the view to the active view.
|
|
206
|
+
* It is calculated as the difference between the current time and the start time of the view.
|
|
207
|
+
* @param overwrite: If true, overwrites the previously calculated view loading time.
|
|
208
|
+
*/
|
|
209
|
+
@ReactMethod
|
|
210
|
+
override fun addViewLoadingTime(overwrite: Boolean, promise: Promise) {
|
|
211
|
+
implementation.addViewLoadingTime(overwrite, promise)
|
|
212
|
+
}
|
|
213
|
+
|
|
204
214
|
/**
|
|
205
215
|
* Stops the current RUM Session.
|
|
206
216
|
*/
|
|
@@ -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
|
}
|
|
@@ -192,6 +192,16 @@ class DdRum(
|
|
|
192
192
|
implementation.addTiming(name, promise)
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Adds the loading time of the view to the active view.
|
|
197
|
+
* It is calculated as the difference between the current time and the start time of the view.
|
|
198
|
+
* @param overwrite: If true, overwrites the previously calculated view loading time.
|
|
199
|
+
*/
|
|
200
|
+
@ReactMethod
|
|
201
|
+
fun addViewLoadingTime(overwrite: Boolean, promise: Promise) {
|
|
202
|
+
implementation.addViewLoadingTime(overwrite, promise)
|
|
203
|
+
}
|
|
204
|
+
|
|
195
205
|
/**
|
|
196
206
|
* Stops the current RUM Session.
|
|
197
207
|
*/
|
|
@@ -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',
|
|
@@ -116,4 +135,15 @@ class DdSdk(
|
|
|
116
135
|
fun clearAllData(promise: Promise) {
|
|
117
136
|
implementation.clearAllData(promise)
|
|
118
137
|
}
|
|
138
|
+
|
|
139
|
+
// Required for rn built in EventEmitter Calls.
|
|
140
|
+
@ReactMethod
|
|
141
|
+
fun addListener(eventName: String) {
|
|
142
|
+
// No-op
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@ReactMethod
|
|
146
|
+
fun removeListeners(count: Int) {
|
|
147
|
+
// No-op
|
|
148
|
+
}
|
|
119
149
|
}
|
|
@@ -456,6 +456,15 @@ internal class DdRumTest {
|
|
|
456
456
|
verify(mockRumMonitor).addTiming(timing)
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
+
@Test
|
|
460
|
+
fun `M call addViewLoadingTime w addViewLoadingTime()`(@BoolForgery overwrite: Boolean) {
|
|
461
|
+
// When
|
|
462
|
+
testedDdRum.addViewLoadingTime(overwrite, mockPromise)
|
|
463
|
+
|
|
464
|
+
// Then
|
|
465
|
+
verify(mockRumMonitor).addViewLoadingTime(overwrite)
|
|
466
|
+
}
|
|
467
|
+
|
|
459
468
|
@Test
|
|
460
469
|
fun `M call stopSession W stopSession()`() {
|
|
461
470
|
// When
|
|
@@ -62,6 +62,7 @@ internal class DdSdkNativeInitializationTest {
|
|
|
62
62
|
) doReturn mockPackageInfo
|
|
63
63
|
|
|
64
64
|
testedNativeInitialization = DdSdkNativeInitialization(
|
|
65
|
+
mockContext,
|
|
65
66
|
mockContext,
|
|
66
67
|
mockDatadog,
|
|
67
68
|
mockJSONFileReader
|
|
@@ -120,6 +121,7 @@ internal class DdSdkNativeInitializationTest {
|
|
|
120
121
|
assertThat(configuration.firstPartyHosts?.get("example.com").toString()).isEqualTo(
|
|
121
122
|
"[B3MULTI, TRACECONTEXT]"
|
|
122
123
|
)
|
|
124
|
+
assertThat(configuration.initialResourceThreshold).isEqualTo(0.5)
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
@Test
|
|
@@ -160,6 +162,7 @@ internal class DdSdkNativeInitializationTest {
|
|
|
160
162
|
assertThat(configuration.serviceName).isNull()
|
|
161
163
|
assertThat(configuration.proxyConfig).isNull()
|
|
162
164
|
assertThat(configuration.firstPartyHosts).isNull()
|
|
165
|
+
assertThat(configuration.initialResourceThreshold).isEqualTo(0.1)
|
|
163
166
|
}
|
|
164
167
|
|
|
165
168
|
@Test
|