@datadog/mobile-react-native 1.3.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +2 -2
- package/android/build.gradle +5 -5
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +4 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +6 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +155 -92
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +2 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +16 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +293 -30
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +5 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +7 -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 +10 -0
- package/datadog-sourcemaps.gradle +55 -7
- package/ios/Sources/DdSdk.m +4 -0
- package/ios/Sources/DdSdk.swift +19 -2
- package/ios/Sources/DdSdkConfiguration.swift +6 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +44 -0
- package/jest/mock.js +1 -1
- package/lib/commonjs/DdSdkReactNative.js +3 -3
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +34 -2
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +5 -5
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +101 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +136 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.js +39 -6
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.js +4 -4
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.js +2 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.js +15 -24
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.js +2 -2
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -0
- package/lib/commonjs/rum/types.js +19 -1
- package/lib/commonjs/rum/types.js.map +1 -1
- package/lib/commonjs/types.js +2 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +4 -4
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +30 -1
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +6 -6
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js +93 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js +115 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.js +37 -3
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.js +4 -4
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.js +2 -2
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.js +13 -18
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.js +2 -2
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.js.map +1 -0
- package/lib/module/rum/types.js +16 -0
- package/lib/module/rum/types.js.map +1 -1
- package/lib/module/types.js +2 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +16 -3
- package/lib/typescript/index.d.ts +3 -3
- package/lib/typescript/nativeModulesTypes.d.ts +5 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +2 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +45 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +21 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +8 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.d.ts +2 -7
- package/lib/typescript/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.d.ts +6 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.d.ts +1 -1
- package/lib/typescript/rum/types.d.ts +17 -0
- package/lib/typescript/types.d.ts +2 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +76 -76
- package/src/DdSdkReactNative.tsx +9 -4
- package/src/DdSdkReactNativeConfiguration.tsx +44 -4
- package/src/__tests__/DdSdkReactNative.test.tsx +16 -4
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +7 -2
- package/src/index.tsx +6 -3
- package/src/nativeModulesTypes.ts +6 -0
- package/src/rum/__tests__/DdRum.test.ts +17 -1
- package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +10 -7
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +13 -2
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/distributedTracing.test.ts +71 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/__tests__/firstPartyHosts.test.ts +34 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.tsx +131 -0
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +141 -0
- package/src/rum/instrumentation/resourceTracking/{domain → distributedTracing}/firstPartyHosts.ts +42 -7
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/ResourceReporter.ts +6 -6
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -2
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/__tests__/__utils__/ResourceMockFactory.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/URLHostParser.ts +3 -3
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/XHRProxy.ts +13 -28
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/__tests__/XHRProxy.test.ts +257 -79
- package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.ts +2 -2
- package/src/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.ts +8 -1
- package/src/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.ts +1 -1
- package/src/rum/types.ts +19 -0
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +1 -0
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +1 -1
- package/src/types.tsx +1 -0
- package/src/version.ts +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js +0 -83
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js +0 -71
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/firstPartyHosts.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/internalDevResourceBlocklist.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/URLHostParser.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/XHRProxy.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/responseSize.js.map +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +0 -19
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/firstPartyHosts.d.ts +0 -6
- package/src/rum/instrumentation/resourceTracking/domain/__tests__/distributedTracing.test.ts +0 -31
- package/src/rum/instrumentation/resourceTracking/domain/__tests__/firstPartyHosts.test.ts +0 -22
- package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +0 -89
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.js +0 -0
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js +0 -0
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js.map +0 -0
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.js +0 -0
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js +0 -0
- /package/lib/commonjs/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js.map +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/internalDevResourceBlocklist.js +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.js.map +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RequestProxy.js +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js +0 -0
- /package/lib/module/rum/instrumentation/resourceTracking/{domain → requestProxy}/interfaces/RumResource.js.map +0 -0
- /package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.d.ts +0 -0
- /package/lib/typescript/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/responseSize.d.ts +0 -0
- /package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/__tests__/internalDevResourceBlocklist.test.ts +0 -0
- /package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/DatadogRumResource/resourceTiming.ts +0 -0
- /package/src/rum/instrumentation/resourceTracking/{implementation → requestProxy/XHRProxy}/__tests__/URLHostParser.test.ts +0 -0
|
@@ -17,8 +17,8 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.source_files = "ios/Sources/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
|
-
s.dependency 'DatadogSDK', '~> 1.
|
|
21
|
-
s.dependency 'DatadogSDKCrashReporting', '~> 1.
|
|
20
|
+
s.dependency 'DatadogSDK', '~> 1.16.0'
|
|
21
|
+
s.dependency 'DatadogSDKCrashReporting', '~> 1.16.0'
|
|
22
22
|
|
|
23
23
|
s.test_spec 'Tests' do |test_spec|
|
|
24
24
|
test_spec.source_files = 'ios/Tests/*.swift'
|
package/android/build.gradle
CHANGED
|
@@ -73,15 +73,15 @@ def getExtOrIntegerDefault(name) {
|
|
|
73
73
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['DdSdkReactNative_' + name]).toInteger()
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
android {
|
|
76
|
+
android {
|
|
77
77
|
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
78
78
|
buildToolsVersion getExtOrDefault('buildToolsVersion')
|
|
79
79
|
defaultConfig {
|
|
80
|
-
minSdkVersion
|
|
80
|
+
minSdkVersion 21
|
|
81
81
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
82
82
|
versionCode 1
|
|
83
83
|
versionName "1.0"
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
sourceSets.named("main") {
|
|
@@ -97,7 +97,7 @@ android {
|
|
|
97
97
|
returnDefaultValues = true
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
buildTypes {
|
|
102
102
|
release {
|
|
103
103
|
minifyEnabled false
|
|
@@ -146,7 +146,7 @@ dependencies {
|
|
|
146
146
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
147
147
|
compileOnly "com.squareup.okhttp3:okhttp:3.12.13"
|
|
148
148
|
|
|
149
|
-
implementation "com.datadoghq:dd-sdk-android:1.
|
|
149
|
+
implementation "com.datadoghq:dd-sdk-android:1.18.1"
|
|
150
150
|
testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
|
|
151
151
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
|
|
152
152
|
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.6.2"
|
|
@@ -63,4 +63,8 @@ internal class DatadogSDKWrapper : DatadogWrapper {
|
|
|
63
63
|
override fun telemetryError(message: String, throwable: Throwable?) {
|
|
64
64
|
Datadog._internal._telemetry.error(message, throwable)
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
override fun consumeWebviewEvent(message: String) {
|
|
68
|
+
Datadog._internal.consumeWebviewEvent(message)
|
|
69
|
+
}
|
|
66
70
|
}
|
|
@@ -16,6 +16,7 @@ import java.lang.IllegalArgumentException
|
|
|
16
16
|
/**
|
|
17
17
|
* Wrapper around [Datadog].
|
|
18
18
|
*/
|
|
19
|
+
@Suppress("ComplexInterface")
|
|
19
20
|
interface DatadogWrapper {
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -98,4 +99,9 @@ interface DatadogWrapper {
|
|
|
98
99
|
* Sends telemetry error.
|
|
99
100
|
*/
|
|
100
101
|
fun telemetryError(message: String, throwable: Throwable?)
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Sends Webview events.
|
|
105
|
+
*/
|
|
106
|
+
fun consumeWebviewEvent(message: String)
|
|
101
107
|
}
|
|
@@ -24,10 +24,12 @@ import com.datadog.android.rum.model.ActionEvent
|
|
|
24
24
|
import com.datadog.android.rum.model.ResourceEvent
|
|
25
25
|
import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy
|
|
26
26
|
import com.datadog.android.telemetry.model.TelemetryConfigurationEvent
|
|
27
|
+
import com.datadog.android.tracing.TracingHeaderType
|
|
27
28
|
import com.facebook.react.bridge.Promise
|
|
28
29
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
29
30
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
30
31
|
import com.facebook.react.bridge.ReactMethod
|
|
32
|
+
import com.facebook.react.bridge.ReadableArray
|
|
31
33
|
import com.facebook.react.bridge.ReadableMap
|
|
32
34
|
import java.net.InetSocketAddress
|
|
33
35
|
import java.net.Proxy
|
|
@@ -35,9 +37,7 @@ import java.util.Locale
|
|
|
35
37
|
import java.util.concurrent.TimeUnit
|
|
36
38
|
import java.util.concurrent.atomic.AtomicBoolean
|
|
37
39
|
|
|
38
|
-
/**
|
|
39
|
-
* The entry point to initialize Datadog's features.
|
|
40
|
-
*/
|
|
40
|
+
/** The entry point to initialize Datadog's features. */
|
|
41
41
|
class DdSdk(
|
|
42
42
|
reactContext: ReactApplicationContext,
|
|
43
43
|
private val datadog: DatadogWrapper = DatadogSDKWrapper()
|
|
@@ -74,21 +74,21 @@ class DdSdk(
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Sets the global context (set of attributes) attached with all future Logs, Spans and RUM
|
|
77
|
+
* Sets the global context (set of attributes) attached with all future Logs, Spans and RUM
|
|
78
|
+
* events.
|
|
78
79
|
* @param attributes The global context attributes.
|
|
79
80
|
*/
|
|
80
81
|
@ReactMethod
|
|
81
82
|
fun setAttributes(attributes: ReadableMap, promise: Promise) {
|
|
82
83
|
datadog.addRumGlobalAttributes(attributes.toHashMap())
|
|
83
|
-
attributes.toHashMap().forEach { (k, v) ->
|
|
84
|
-
GlobalState.addAttribute(k, v)
|
|
85
|
-
}
|
|
84
|
+
attributes.toHashMap().forEach { (k, v) -> GlobalState.addAttribute(k, v) }
|
|
86
85
|
promise.resolve(null)
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
/**
|
|
90
89
|
* Set the user information.
|
|
91
|
-
* @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom
|
|
90
|
+
* @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom
|
|
91
|
+
* attribute).
|
|
92
92
|
*/
|
|
93
93
|
@ReactMethod
|
|
94
94
|
fun setUser(user: ReadableMap, promise: Promise) {
|
|
@@ -102,7 +102,8 @@ class DdSdk(
|
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Set the tracking consent regarding the data collection.
|
|
105
|
-
* @param trackingConsent Consent, which can take one of the following values: 'pending',
|
|
105
|
+
* @param trackingConsent Consent, which can take one of the following values: 'pending',
|
|
106
|
+
* 'granted', 'not_granted'.
|
|
106
107
|
*/
|
|
107
108
|
@ReactMethod
|
|
108
109
|
fun setTrackingConsent(trackingConsent: String, promise: Promise) {
|
|
@@ -132,19 +133,30 @@ class DdSdk(
|
|
|
132
133
|
promise.resolve(null)
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Sends WebView Events.
|
|
138
|
+
* @param message User action.
|
|
139
|
+
*/
|
|
140
|
+
@ReactMethod
|
|
141
|
+
fun consumeWebviewEvent(message: String, promise: Promise) {
|
|
142
|
+
datadog.consumeWebviewEvent(message)
|
|
143
|
+
promise.resolve(null)
|
|
144
|
+
}
|
|
145
|
+
|
|
135
146
|
// endregion
|
|
136
147
|
|
|
137
148
|
// region Internal
|
|
138
149
|
|
|
139
150
|
private fun configureSdkVerbosity(configuration: DdSdkConfiguration) {
|
|
140
151
|
val verbosityConfig = configuration.additionalConfig?.get(DD_SDK_VERBOSITY) as? String
|
|
141
|
-
val verbosity =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
152
|
+
val verbosity =
|
|
153
|
+
when (verbosityConfig?.lowercase(Locale.US)) {
|
|
154
|
+
"debug" -> Log.DEBUG
|
|
155
|
+
"info" -> Log.INFO
|
|
156
|
+
"warn" -> Log.WARN
|
|
157
|
+
"error" -> Log.ERROR
|
|
158
|
+
else -> null
|
|
159
|
+
}
|
|
148
160
|
if (verbosity != null) {
|
|
149
161
|
datadog.setVerbosity(verbosity)
|
|
150
162
|
}
|
|
@@ -152,19 +164,20 @@ class DdSdk(
|
|
|
152
164
|
|
|
153
165
|
private fun getDefaultAppVersion(): String {
|
|
154
166
|
val packageName = appContext.packageName
|
|
155
|
-
val packageInfo =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
val packageInfo =
|
|
168
|
+
try {
|
|
169
|
+
appContext.packageManager.getPackageInfo(packageName, 0)
|
|
170
|
+
} catch (e: PackageManager.NameNotFoundException) {
|
|
171
|
+
datadog.telemetryError(e.message ?: PACKAGE_INFO_NOT_FOUND_ERROR_MESSAGE, e)
|
|
172
|
+
return DEFAULT_APP_VERSION
|
|
173
|
+
}
|
|
161
174
|
|
|
162
175
|
return packageInfo?.let {
|
|
163
176
|
// we need to use the deprecated method because getLongVersionCode method is only
|
|
164
177
|
// available from API 28 and above
|
|
165
|
-
@Suppress("DEPRECATION")
|
|
166
|
-
|
|
167
|
-
|
|
178
|
+
@Suppress("DEPRECATION") it.versionName ?: it.versionCode.toString()
|
|
179
|
+
}
|
|
180
|
+
?: DEFAULT_APP_VERSION
|
|
168
181
|
}
|
|
169
182
|
|
|
170
183
|
@Suppress("ComplexMethod", "LongMethod", "UnsafeCallOnNullableType")
|
|
@@ -177,21 +190,26 @@ class DdSdk(
|
|
|
177
190
|
additionalConfig.put(DD_VERSION, defaultVersion + versionSuffix)
|
|
178
191
|
}
|
|
179
192
|
|
|
180
|
-
val configBuilder =
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
additionalConfig
|
|
188
|
-
?.filterValues { it != null }
|
|
189
|
-
?.mapValues { it.value!! } ?: emptyMap()
|
|
193
|
+
val configBuilder =
|
|
194
|
+
Configuration.Builder(
|
|
195
|
+
logsEnabled = true,
|
|
196
|
+
tracesEnabled = true,
|
|
197
|
+
crashReportsEnabled = configuration.nativeCrashReportEnabled
|
|
198
|
+
?: false,
|
|
199
|
+
rumEnabled = true
|
|
190
200
|
)
|
|
201
|
+
.setAdditionalConfiguration(
|
|
202
|
+
additionalConfig?.filterValues { it != null }?.mapValues {
|
|
203
|
+
it.value!!
|
|
204
|
+
}
|
|
205
|
+
?: emptyMap()
|
|
206
|
+
)
|
|
191
207
|
if (configuration.sampleRate != null) {
|
|
192
208
|
configBuilder.sampleRumSessions(configuration.sampleRate.toFloat())
|
|
193
209
|
}
|
|
194
210
|
|
|
211
|
+
configBuilder.trackFrustrations(configuration.trackFrustrations ?: true)
|
|
212
|
+
|
|
195
213
|
configBuilder.useSite(buildSite(configuration.site))
|
|
196
214
|
configBuilder.setVitalsUpdateFrequency(
|
|
197
215
|
buildVitalUpdateFrequency(configuration.vitalsUpdateFrequency)
|
|
@@ -213,45 +231,58 @@ class DdSdk(
|
|
|
213
231
|
configBuilder.useViewTrackingStrategy(NoOpViewTrackingStrategy)
|
|
214
232
|
}
|
|
215
233
|
|
|
216
|
-
val interactionTracking =
|
|
217
|
-
DD_NATIVE_INTERACTION_TRACKING
|
|
218
|
-
) as? Boolean
|
|
234
|
+
val interactionTracking =
|
|
235
|
+
configuration.additionalConfig?.get(DD_NATIVE_INTERACTION_TRACKING) as? Boolean
|
|
219
236
|
if (interactionTracking == false) {
|
|
220
237
|
configBuilder.disableInteractionTracking()
|
|
221
238
|
}
|
|
222
239
|
|
|
240
|
+
@Suppress("UNCHECKED_CAST")
|
|
223
241
|
val firstPartyHosts =
|
|
224
|
-
(configuration.additionalConfig?.get(DD_FIRST_PARTY_HOSTS) as?
|
|
242
|
+
(configuration.additionalConfig?.get(DD_FIRST_PARTY_HOSTS) as? ReadableArray)
|
|
243
|
+
?.toArrayList() as?
|
|
244
|
+
List<ReadableMap>
|
|
225
245
|
if (firstPartyHosts != null) {
|
|
226
|
-
|
|
246
|
+
val firstPartyHostsWithHeaderTypes = buildFirstPartyHosts(firstPartyHosts)
|
|
247
|
+
|
|
248
|
+
configBuilder.setFirstPartyHostsWithHeaderType(firstPartyHostsWithHeaderTypes)
|
|
227
249
|
}
|
|
228
250
|
|
|
229
251
|
buildProxyConfiguration(configuration)?.let { (proxy, authenticator) ->
|
|
230
252
|
configBuilder.setProxy(proxy, authenticator)
|
|
231
253
|
}
|
|
232
254
|
|
|
233
|
-
configBuilder.setRumResourceEventMapper(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
255
|
+
configBuilder.setRumResourceEventMapper(
|
|
256
|
+
object : EventMapper<ResourceEvent> {
|
|
257
|
+
override fun map(event: ResourceEvent): ResourceEvent? {
|
|
258
|
+
if (event.context?.additionalProperties?.containsKey(DD_DROP_RESOURCE) ==
|
|
259
|
+
true
|
|
260
|
+
) {
|
|
261
|
+
return null
|
|
262
|
+
}
|
|
263
|
+
return event
|
|
237
264
|
}
|
|
238
|
-
return event
|
|
239
265
|
}
|
|
240
|
-
|
|
266
|
+
)
|
|
241
267
|
|
|
242
|
-
configBuilder.setRumActionEventMapper(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
268
|
+
configBuilder.setRumActionEventMapper(
|
|
269
|
+
object : EventMapper<ActionEvent> {
|
|
270
|
+
override fun map(event: ActionEvent): ActionEvent? {
|
|
271
|
+
if (event.context?.additionalProperties?.containsKey(DD_DROP_ACTION) == true
|
|
272
|
+
) {
|
|
273
|
+
return null
|
|
274
|
+
}
|
|
275
|
+
return event
|
|
246
276
|
}
|
|
247
|
-
return event
|
|
248
277
|
}
|
|
249
|
-
|
|
278
|
+
)
|
|
250
279
|
|
|
251
280
|
_InternalProxy.setTelemetryConfigurationEventMapper(
|
|
252
281
|
configBuilder,
|
|
253
282
|
object : EventMapper<TelemetryConfigurationEvent> {
|
|
254
|
-
override fun map(
|
|
283
|
+
override fun map(
|
|
284
|
+
event: TelemetryConfigurationEvent
|
|
285
|
+
): TelemetryConfigurationEvent? {
|
|
255
286
|
event.telemetry.configuration.trackNativeErrors =
|
|
256
287
|
configuration.nativeCrashReportEnabled
|
|
257
288
|
// trackCrossPlatformLongTasks will be deprecated for trackLongTask
|
|
@@ -281,6 +312,34 @@ class DdSdk(
|
|
|
281
312
|
return configBuilder.build()
|
|
282
313
|
}
|
|
283
314
|
|
|
315
|
+
private fun buildFirstPartyHosts(
|
|
316
|
+
firstPartyHosts: List<ReadableMap>
|
|
317
|
+
): Map<String, Set<TracingHeaderType>> {
|
|
318
|
+
/**
|
|
319
|
+
* Adapts the data format from the React Native SDK configuration to match with the Android
|
|
320
|
+
* SDK configuration. For example:
|
|
321
|
+
*
|
|
322
|
+
* RN config: [{ match: "example.com", propagatorTypes: [DATADOG, B3] }] Android config: {
|
|
323
|
+
* "example.com": [DATADOG, B3] }
|
|
324
|
+
*/
|
|
325
|
+
val firstPartyHostsWithHeaderTypes = mutableMapOf<String, MutableSet<TracingHeaderType>>()
|
|
326
|
+
|
|
327
|
+
firstPartyHosts.forEach {
|
|
328
|
+
val match = it.getString("match")
|
|
329
|
+
val propagatorTypes = it.getArray("propagatorTypes")?.asTracingHeaderTypes()
|
|
330
|
+
if (match != null && propagatorTypes != null && propagatorTypes.isNotEmpty()) {
|
|
331
|
+
val hostMatch = firstPartyHostsWithHeaderTypes[match]
|
|
332
|
+
if (hostMatch != null) {
|
|
333
|
+
hostMatch.addAll(propagatorTypes)
|
|
334
|
+
} else {
|
|
335
|
+
firstPartyHostsWithHeaderTypes[match] = propagatorTypes.toMutableSet()
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return firstPartyHostsWithHeaderTypes
|
|
341
|
+
}
|
|
342
|
+
|
|
284
343
|
private fun buildCredentials(configuration: DdSdkConfiguration): Credentials {
|
|
285
344
|
val serviceName = configuration.additionalConfig?.get(DD_SERVICE_NAME) as? String
|
|
286
345
|
return Credentials(
|
|
@@ -308,40 +367,44 @@ class DdSdk(
|
|
|
308
367
|
}
|
|
309
368
|
}
|
|
310
369
|
|
|
311
|
-
internal fun buildProxyConfiguration(
|
|
312
|
-
|
|
370
|
+
internal fun buildProxyConfiguration(
|
|
371
|
+
configuration: DdSdkConfiguration
|
|
372
|
+
): Pair<Proxy, ProxyAuthenticator?>? {
|
|
313
373
|
val additionalConfig = configuration.additionalConfig ?: return null
|
|
314
374
|
|
|
315
375
|
val address = additionalConfig[DD_PROXY_ADDRESS] as? String
|
|
316
376
|
val port = (additionalConfig[DD_PROXY_PORT] as? Number)?.toInt()
|
|
317
|
-
val type =
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
377
|
+
val type =
|
|
378
|
+
(additionalConfig[DD_PROXY_TYPE] as? String)?.let {
|
|
379
|
+
when (it.lowercase(Locale.US)) {
|
|
380
|
+
"http", "https" -> Proxy.Type.HTTP
|
|
381
|
+
"socks" -> Proxy.Type.SOCKS
|
|
382
|
+
else -> {
|
|
383
|
+
Log.w(
|
|
384
|
+
DdSdk::class.java.canonicalName,
|
|
385
|
+
"Unknown proxy type given: $it, skipping proxy configuration."
|
|
386
|
+
)
|
|
387
|
+
null
|
|
388
|
+
}
|
|
327
389
|
}
|
|
328
390
|
}
|
|
329
|
-
}
|
|
330
391
|
|
|
331
|
-
val proxy =
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
392
|
+
val proxy =
|
|
393
|
+
if (address != null && port != null && type != null) {
|
|
394
|
+
Proxy(type, InetSocketAddress(address, port))
|
|
395
|
+
} else {
|
|
396
|
+
return null
|
|
397
|
+
}
|
|
336
398
|
|
|
337
399
|
val username = additionalConfig[DD_PROXY_USERNAME] as? String
|
|
338
400
|
val password = additionalConfig[DD_PROXY_PASSWORD] as? String
|
|
339
401
|
|
|
340
|
-
val authenticator =
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
402
|
+
val authenticator =
|
|
403
|
+
if (username != null && password != null) {
|
|
404
|
+
ProxyAuthenticator(username, password)
|
|
405
|
+
} else {
|
|
406
|
+
null
|
|
407
|
+
}
|
|
345
408
|
|
|
346
409
|
return Pair(proxy, authenticator)
|
|
347
410
|
}
|
|
@@ -354,6 +417,7 @@ class DdSdk(
|
|
|
354
417
|
"us3" -> DatadogSite.US3
|
|
355
418
|
"us5" -> DatadogSite.US5
|
|
356
419
|
"us1_fed", "gov" -> DatadogSite.US1_FED
|
|
420
|
+
"ap1" -> DatadogSite.AP1
|
|
357
421
|
else -> DatadogSite.US1
|
|
358
422
|
}
|
|
359
423
|
}
|
|
@@ -378,10 +442,7 @@ class DdSdk(
|
|
|
378
442
|
if (frameTimeCallback != null) {
|
|
379
443
|
reactContext.runOnJSQueueThread {
|
|
380
444
|
val vitalFrameCallback =
|
|
381
|
-
VitalFrameCallback(
|
|
382
|
-
frameTimeCallback,
|
|
383
|
-
::handlePostFrameCallbackError
|
|
384
|
-
) {
|
|
445
|
+
VitalFrameCallback(frameTimeCallback, ::handlePostFrameCallbackError) {
|
|
385
446
|
initialized.get()
|
|
386
447
|
}
|
|
387
448
|
try {
|
|
@@ -394,11 +455,12 @@ class DdSdk(
|
|
|
394
455
|
}
|
|
395
456
|
}
|
|
396
457
|
|
|
397
|
-
private fun buildFrameTimeCallback(
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
458
|
+
private fun buildFrameTimeCallback(
|
|
459
|
+
ddSdkConfiguration: DdSdkConfiguration
|
|
460
|
+
): ((Double) -> Unit)? {
|
|
461
|
+
val jsRefreshRateMonitoringEnabled =
|
|
462
|
+
buildVitalUpdateFrequency(ddSdkConfiguration.vitalsUpdateFrequency) !=
|
|
463
|
+
VitalsUpdateFrequency.NEVER
|
|
402
464
|
val jsLongTasksMonitoringEnabled = ddSdkConfiguration.longTaskThresholdMs != 0.0
|
|
403
465
|
|
|
404
466
|
if (!jsLongTasksMonitoringEnabled && !jsRefreshRateMonitoringEnabled) {
|
|
@@ -407,14 +469,15 @@ class DdSdk(
|
|
|
407
469
|
|
|
408
470
|
return {
|
|
409
471
|
if (jsRefreshRateMonitoringEnabled && it > 0.0) {
|
|
410
|
-
GlobalRum.get()
|
|
411
|
-
|
|
412
|
-
it
|
|
413
|
-
)
|
|
472
|
+
GlobalRum.get()
|
|
473
|
+
._getInternal()
|
|
474
|
+
?.updatePerformanceMetric(RumPerformanceMetric.JS_FRAME_TIME, it)
|
|
414
475
|
}
|
|
415
|
-
if (jsLongTasksMonitoringEnabled &&
|
|
416
|
-
|
|
417
|
-
|
|
476
|
+
if (jsLongTasksMonitoringEnabled &&
|
|
477
|
+
it >
|
|
478
|
+
TimeUnit.MILLISECONDS.toNanos(
|
|
479
|
+
ddSdkConfiguration.longTaskThresholdMs?.toLong() ?: 0L
|
|
480
|
+
)
|
|
418
481
|
) {
|
|
419
482
|
GlobalRum.get()._getInternal()?.addLongTask(it.toLong(), "javascript")
|
|
420
483
|
}
|
|
@@ -19,6 +19,7 @@ package com.datadog.reactnative
|
|
|
19
19
|
* @param trackingConsent Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
|
|
20
20
|
* @param telemetrySampleRate The sample rate (between 0 and 100) of telemetry events.
|
|
21
21
|
* @param vitalsUpdateFrequency The frequency to which vitals update are sent (can be 'NEVER', 'RARE', 'AVERAGE' (default), 'FREQUENT').
|
|
22
|
+
* @param trackFrustrations Whether to track frustration signals or not.
|
|
22
23
|
* @param additionalConfig Additional configuration parameters.
|
|
23
24
|
* @param configurationForTelemetry Additional configuration data for Datadog telemetry.
|
|
24
25
|
*/
|
|
@@ -34,6 +35,7 @@ data class DdSdkConfiguration(
|
|
|
34
35
|
val trackingConsent: String? = null,
|
|
35
36
|
val telemetrySampleRate: Double? = null,
|
|
36
37
|
val vitalsUpdateFrequency: String? = null,
|
|
38
|
+
val trackFrustrations: Boolean? = null,
|
|
37
39
|
val additionalConfig: Map<String, Any?>? = null,
|
|
38
40
|
val configurationForTelemetry: ConfigurationForTelemetry? = null
|
|
39
41
|
)
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
|
+
import com.datadog.android.tracing.TracingHeaderType
|
|
10
|
+
import com.facebook.react.bridge.ReadableArray
|
|
9
11
|
import com.facebook.react.bridge.ReadableMap
|
|
10
12
|
import com.facebook.react.bridge.WritableNativeMap
|
|
11
13
|
|
|
@@ -22,6 +24,7 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
22
24
|
trackingConsent = getString("trackingConsent"),
|
|
23
25
|
telemetrySampleRate = getDouble("telemetrySampleRate"),
|
|
24
26
|
vitalsUpdateFrequency = getString("vitalsUpdateFrequency"),
|
|
27
|
+
trackFrustrations = getBoolean("trackFrustrations"),
|
|
25
28
|
additionalConfig = getMap("additionalConfig")?.toHashMap(),
|
|
26
29
|
configurationForTelemetry = getMap(
|
|
27
30
|
"configurationForTelemetry"
|
|
@@ -38,6 +41,18 @@ internal fun ReadableMap.asConfigurationForTelemetry(): ConfigurationForTelemetr
|
|
|
38
41
|
)
|
|
39
42
|
}
|
|
40
43
|
|
|
44
|
+
internal fun ReadableArray.asTracingHeaderTypes(): Set<TracingHeaderType> {
|
|
45
|
+
return this.toArrayList().mapNotNull {
|
|
46
|
+
when (it) {
|
|
47
|
+
"datadog" -> TracingHeaderType.DATADOG
|
|
48
|
+
"b3" -> TracingHeaderType.B3
|
|
49
|
+
"b3multi" -> TracingHeaderType.B3MULTI
|
|
50
|
+
"tracecontext" -> TracingHeaderType.TRACECONTEXT
|
|
51
|
+
else -> null
|
|
52
|
+
}
|
|
53
|
+
}.toSet()
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
@Suppress("ComplexMethod")
|
|
42
57
|
internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
|
|
43
58
|
val map = WritableNativeMap()
|
|
@@ -52,6 +67,7 @@ internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
|
|
|
52
67
|
trackingConsent?.let { map.putString("trackingConsent", it) }
|
|
53
68
|
telemetrySampleRate?.let { map.putDouble("telemetrySampleRate", it) }
|
|
54
69
|
vitalsUpdateFrequency?.let { map.putString("vitalsUpdateFrequency", it) }
|
|
70
|
+
trackFrustrations?.let { map.putBoolean("trackFrustrations", it) }
|
|
55
71
|
additionalConfig?.let { map.putMap("additionalConfig", it.toWritableMap()) }
|
|
56
72
|
return map
|
|
57
73
|
}
|