@datadog/mobile-react-native 1.9.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +8 -2
- package/android/build.gradle +7 -5
- package/android/gradle.properties +4 -4
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -13
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +36 -9
- package/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt +1 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +37 -17
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +1 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +3 -3
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +71 -70
- package/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt +10 -2
- package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +2 -1
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +1 -1
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +48 -30
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +648 -641
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +122 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +0 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ActionEventForgeryFactory.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +3 -3
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ResourceEventForgeryFactory.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +4 -0
- package/ios/Sources/DdLogsImplementation.swift +10 -38
- package/ios/Sources/DdRumImplementation.swift +26 -39
- package/ios/Sources/DdSdkConfiguration.swift +55 -8
- package/ios/Sources/DdSdkImplementation.swift +141 -143
- package/ios/Sources/DdTraceImplementation.swift +2 -2
- package/ios/Sources/RNDdSdkConfiguration.swift +4 -2
- package/ios/Sources/RUMMonitorInternalProtocol.swift +40 -0
- package/lib/commonjs/DdSdkReactNative.js +2 -2
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/index.js +20 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +2 -2
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +10 -4
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.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/resourceTracking/distributedTracing/distributedTracingHeaders.js +19 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js +26 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +30 -10
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +37 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/commonjs/trace/DdTrace.js +2 -2
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/utils/jsUtils.js +26 -0
- package/lib/commonjs/utils/jsUtils.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +1 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/DdRum.js +1 -1
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +8 -3
- package/lib/module/rum/instrumentation/DdRumErrorTracking.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/resourceTracking/distributedTracing/distributedTracingHeaders.js +17 -0
- package/lib/module/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js +13 -0
- package/lib/module/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js +30 -10
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +36 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/module/trace/DdTrace.js +1 -1
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/utils/jsUtils.js +17 -0
- package/lib/module/utils/jsUtils.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.d.ts +4 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +6 -0
- package/lib/typescript/utils/jsUtils.d.ts +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +11 -3
- package/src/DdSdkReactNative.tsx +1 -1
- package/src/DdSdkReactNativeConfiguration.tsx +4 -1
- package/src/__tests__/DdSdkReactNative.test.tsx +16 -4
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +2 -0
- package/src/index.tsx +9 -1
- package/src/rum/DdRum.ts +1 -1
- package/src/rum/__tests__/DdRum.test.ts +1 -1
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +13 -4
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +1 -1
- package/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.ts +35 -10
- package/src/rum/instrumentation/resourceTracking/graphql/__tests__/graphqlHeaders.test.ts +28 -0
- package/src/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.ts +15 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.ts +35 -20
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +48 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +252 -5
- package/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.ts +7 -0
- package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +1 -1
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +2 -2
- package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +8 -3
- package/src/trace/DdTrace.ts +1 -1
- package/src/utils/__mocks__/jsUtils.ts +21 -0
- package/src/utils/jsUtils.ts +20 -0
- package/src/version.ts +1 -1
- /package/lib/commonjs/{TimeProvider.js → utils/TimeProvider.js} +0 -0
- /package/lib/commonjs/{TimeProvider.js.map → utils/TimeProvider.js.map} +0 -0
- /package/lib/commonjs/{Timer.js → utils/Timer.js} +0 -0
- /package/lib/commonjs/{Timer.js.map → utils/Timer.js.map} +0 -0
- /package/lib/commonjs/{errorUtils.js → utils/errorUtils.js} +0 -0
- /package/lib/commonjs/{errorUtils.js.map → utils/errorUtils.js.map} +0 -0
- /package/lib/commonjs/{longTasksUtils.js → utils/longTasksUtils.js} +0 -0
- /package/lib/commonjs/{longTasksUtils.js.map → utils/longTasksUtils.js.map} +0 -0
- /package/lib/module/{TimeProvider.js → utils/TimeProvider.js} +0 -0
- /package/lib/module/{TimeProvider.js.map → utils/TimeProvider.js.map} +0 -0
- /package/lib/module/{Timer.js → utils/Timer.js} +0 -0
- /package/lib/module/{Timer.js.map → utils/Timer.js.map} +0 -0
- /package/lib/module/{errorUtils.js → utils/errorUtils.js} +0 -0
- /package/lib/module/{errorUtils.js.map → utils/errorUtils.js.map} +0 -0
- /package/lib/module/{longTasksUtils.js → utils/longTasksUtils.js} +0 -0
- /package/lib/module/{longTasksUtils.js.map → utils/longTasksUtils.js.map} +0 -0
- /package/lib/typescript/{TimeProvider.d.ts → utils/TimeProvider.d.ts} +0 -0
- /package/lib/typescript/{Timer.d.ts → utils/Timer.d.ts} +0 -0
- /package/lib/typescript/{errorUtils.d.ts → utils/errorUtils.d.ts} +0 -0
- /package/lib/typescript/{longTasksUtils.d.ts → utils/longTasksUtils.d.ts} +0 -0
- /package/src/{TimeProvider.tsx → utils/TimeProvider.tsx} +0 -0
- /package/src/{Timer.ts → utils/Timer.ts} +0 -0
- /package/src/{__tests__ → utils/__tests__}/TimeProvider.test.tsx +0 -0
- /package/src/{__tests__ → utils/__tests__}/Timer.test.ts +0 -0
- /package/src/{__tests__ → utils/__tests__}/errorUtils.test.ts +0 -0
- /package/src/{__tests__ → utils/__tests__}/longTasksUtils.test.ts +0 -0
- /package/src/{errorUtils.ts → utils/errorUtils.ts} +0 -0
- /package/src/{longTasksUtils.ts → utils/longTasksUtils.ts} +0 -0
|
@@ -17,9 +17,15 @@ 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.22.0'
|
|
21
|
-
s.dependency 'DatadogSDKCrashReporting', '~> 1.22.0'
|
|
22
20
|
|
|
21
|
+
# /!\ Remember to keep the versions in sync with DatadogSDKReactNativeSessionReplay.podspec
|
|
22
|
+
s.dependency 'DatadogCore', '~> 2.4.0'
|
|
23
|
+
s.dependency 'DatadogLogs', '~> 2.4.0'
|
|
24
|
+
s.dependency 'DatadogTrace', '~> 2.4.0'
|
|
25
|
+
s.dependency 'DatadogRUM', '~> 2.4.0'
|
|
26
|
+
s.dependency 'DatadogCrashReporting', '~> 2.4.0'
|
|
27
|
+
s.dependency 'DatadogWebViewTracking', '~> 2.4.0'
|
|
28
|
+
|
|
23
29
|
s.test_spec 'Tests' do |test_spec|
|
|
24
30
|
test_spec.source_files = 'ios/Tests/*.swift'
|
|
25
31
|
end
|
package/android/build.gradle
CHANGED
|
@@ -12,7 +12,7 @@ buildscript {
|
|
|
12
12
|
classpath 'com.android.tools.build:gradle:7.2.2'
|
|
13
13
|
// noinspection DifferentKotlinGradleVersion
|
|
14
14
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
15
|
-
classpath "org.jlleitschuh.gradle:ktlint-gradle:
|
|
15
|
+
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1"
|
|
16
16
|
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.0"
|
|
17
17
|
classpath 'com.github.bjoernq:unmockplugin:0.7.9'
|
|
18
18
|
}
|
|
@@ -130,8 +130,8 @@ android {
|
|
|
130
130
|
disable 'GradleCompatible'
|
|
131
131
|
}
|
|
132
132
|
compileOptions {
|
|
133
|
-
sourceCompatibility JavaVersion.
|
|
134
|
-
targetCompatibility JavaVersion.
|
|
133
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
134
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -169,7 +169,10 @@ dependencies {
|
|
|
169
169
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
170
170
|
compileOnly "com.squareup.okhttp3:okhttp:3.12.13"
|
|
171
171
|
|
|
172
|
-
implementation "com.datadoghq:dd-sdk-android:
|
|
172
|
+
implementation "com.datadoghq:dd-sdk-android-rum:2.2.0"
|
|
173
|
+
implementation "com.datadoghq:dd-sdk-android-logs:2.2.0"
|
|
174
|
+
implementation "com.datadoghq:dd-sdk-android-trace:2.2.0"
|
|
175
|
+
implementation "com.datadoghq:dd-sdk-android-webview:2.2.0"
|
|
173
176
|
testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
|
|
174
177
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
|
|
175
178
|
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.6.2"
|
|
@@ -214,7 +217,6 @@ ktlint {
|
|
|
214
217
|
outputToConsole.set(true)
|
|
215
218
|
ignoreFailures.set(false)
|
|
216
219
|
enableExperimentalRules.set(false)
|
|
217
|
-
additionalEditorconfigFile.set(file("${project.rootDir}/script/config/.editorconfig"))
|
|
218
220
|
filter {
|
|
219
221
|
exclude("**/generated/**")
|
|
220
222
|
include("**/kotlin/**")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
DdSdkReactNative_kotlinVersion=1.
|
|
2
|
-
DdSdkReactNative_compileSdkVersion=
|
|
3
|
-
DdSdkReactNative_buildToolsVersion=
|
|
4
|
-
DdSdkReactNative_targetSdkVersion=
|
|
1
|
+
DdSdkReactNative_kotlinVersion=1.7.21
|
|
2
|
+
DdSdkReactNative_compileSdkVersion=33
|
|
3
|
+
DdSdkReactNative_buildToolsVersion=33.0.0
|
|
4
|
+
DdSdkReactNative_targetSdkVersion=33
|
|
5
5
|
android.useAndroidX=true
|
|
@@ -8,25 +8,65 @@ package com.datadog.reactnative
|
|
|
8
8
|
|
|
9
9
|
import android.content.Context
|
|
10
10
|
import com.datadog.android.Datadog
|
|
11
|
+
import com.datadog.android._InternalProxy
|
|
11
12
|
import com.datadog.android.core.configuration.Configuration
|
|
12
|
-
import com.datadog.android.
|
|
13
|
+
import com.datadog.android.log.Logs
|
|
14
|
+
import com.datadog.android.log.LogsConfiguration
|
|
13
15
|
import com.datadog.android.privacy.TrackingConsent
|
|
14
|
-
import com.datadog.android.rum.
|
|
16
|
+
import com.datadog.android.rum.GlobalRumMonitor
|
|
17
|
+
import com.datadog.android.rum.Rum
|
|
18
|
+
import com.datadog.android.rum.RumConfiguration
|
|
15
19
|
import com.datadog.android.rum.RumMonitor
|
|
20
|
+
import com.datadog.android.trace.Trace
|
|
21
|
+
import com.datadog.android.trace.TraceConfiguration
|
|
22
|
+
import com.datadog.android.webview.WebViewTracking
|
|
16
23
|
|
|
17
24
|
internal class DatadogSDKWrapper : DatadogWrapper {
|
|
18
25
|
|
|
26
|
+
// We use Kotlin backing field here to initialize once the telemetry proxy
|
|
27
|
+
// and make sure it is only after SDK is initialized.
|
|
28
|
+
private var telemetryProxy: _InternalProxy._TelemetryProxy? = null
|
|
29
|
+
get() {
|
|
30
|
+
if (field == null && isInitialized()) {
|
|
31
|
+
field = Datadog._internalProxy()._telemetry
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return field
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// We use Kotlin backing field here to initialize once the telemetry proxy
|
|
38
|
+
// and make sure it is only after SDK is initialized.
|
|
39
|
+
private var webViewProxy: WebViewTracking._InternalWebViewProxy? = null
|
|
40
|
+
get() {
|
|
41
|
+
if (field == null && isInitialized()) {
|
|
42
|
+
field = WebViewTracking._InternalWebViewProxy(Datadog.getInstance())
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return field
|
|
46
|
+
}
|
|
47
|
+
|
|
19
48
|
override fun setVerbosity(level: Int) {
|
|
20
49
|
Datadog.setVerbosity(level)
|
|
21
50
|
}
|
|
22
51
|
|
|
23
52
|
override fun initialize(
|
|
24
53
|
context: Context,
|
|
25
|
-
credentials: Credentials,
|
|
26
54
|
configuration: Configuration,
|
|
27
55
|
consent: TrackingConsent
|
|
28
56
|
) {
|
|
29
|
-
Datadog.initialize(context,
|
|
57
|
+
Datadog.initialize(context, configuration, consent)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
override fun enableRum(configuration: RumConfiguration) {
|
|
61
|
+
Rum.enable(configuration)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
override fun enableLogs(configuration: LogsConfiguration) {
|
|
65
|
+
Logs.enable(configuration)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
override fun enableTrace(configuration: TraceConfiguration) {
|
|
69
|
+
Trace.enable(configuration)
|
|
30
70
|
}
|
|
31
71
|
|
|
32
72
|
override fun setUserInfo(
|
|
@@ -38,13 +78,10 @@ internal class DatadogSDKWrapper : DatadogWrapper {
|
|
|
38
78
|
Datadog.setUserInfo(id, name, email, extraInfo)
|
|
39
79
|
}
|
|
40
80
|
|
|
41
|
-
override fun registerRumMonitor(rumMonitor: RumMonitor) {
|
|
42
|
-
GlobalRum.registerIfAbsent(rumMonitor)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
81
|
override fun addRumGlobalAttributes(attributes: Map<String, Any?>) {
|
|
82
|
+
val rumMonitor = this.getRumMonitor()
|
|
46
83
|
attributes.forEach {
|
|
47
|
-
|
|
84
|
+
rumMonitor.addAttribute(it.key, it.value)
|
|
48
85
|
}
|
|
49
86
|
}
|
|
50
87
|
|
|
@@ -53,22 +90,26 @@ internal class DatadogSDKWrapper : DatadogWrapper {
|
|
|
53
90
|
}
|
|
54
91
|
|
|
55
92
|
override fun telemetryDebug(message: String) {
|
|
56
|
-
|
|
93
|
+
telemetryProxy?.debug(message)
|
|
57
94
|
}
|
|
58
95
|
|
|
59
96
|
override fun telemetryError(message: String, stack: String?, kind: String?) {
|
|
60
|
-
|
|
97
|
+
telemetryProxy?.error(message, stack, kind)
|
|
61
98
|
}
|
|
62
99
|
|
|
63
100
|
override fun telemetryError(message: String, throwable: Throwable?) {
|
|
64
|
-
|
|
101
|
+
telemetryProxy?.error(message, throwable)
|
|
65
102
|
}
|
|
66
103
|
|
|
67
104
|
override fun consumeWebviewEvent(message: String) {
|
|
68
|
-
|
|
105
|
+
webViewProxy?.consumeWebviewEvent(message)
|
|
69
106
|
}
|
|
70
107
|
|
|
71
108
|
override fun isInitialized(): Boolean {
|
|
72
109
|
return Datadog.isInitialized()
|
|
73
110
|
}
|
|
111
|
+
|
|
112
|
+
override fun getRumMonitor(): RumMonitor {
|
|
113
|
+
return GlobalRumMonitor.get()
|
|
114
|
+
}
|
|
74
115
|
}
|
|
@@ -8,9 +8,12 @@ package com.datadog.reactnative
|
|
|
8
8
|
|
|
9
9
|
import android.content.Context
|
|
10
10
|
import com.datadog.android.core.configuration.Configuration
|
|
11
|
-
import com.datadog.android.
|
|
11
|
+
import com.datadog.android.log.LogsConfiguration
|
|
12
12
|
import com.datadog.android.privacy.TrackingConsent
|
|
13
|
+
import com.datadog.android.rum.GlobalRumMonitor
|
|
14
|
+
import com.datadog.android.rum.RumConfiguration
|
|
13
15
|
import com.datadog.android.rum.RumMonitor
|
|
16
|
+
import com.datadog.android.trace.TraceConfiguration
|
|
14
17
|
import java.lang.IllegalArgumentException
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -45,11 +48,37 @@ interface DatadogWrapper {
|
|
|
45
48
|
*/
|
|
46
49
|
fun initialize(
|
|
47
50
|
context: Context,
|
|
48
|
-
credentials: Credentials,
|
|
49
51
|
configuration: Configuration,
|
|
50
52
|
consent: TrackingConsent
|
|
51
53
|
)
|
|
52
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Enables the RUM feature of the SDK.
|
|
57
|
+
*
|
|
58
|
+
* @param configuration the configuration for the RUM feature
|
|
59
|
+
*/
|
|
60
|
+
fun enableRum(
|
|
61
|
+
configuration: RumConfiguration
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Enables the Logs feature of the SDK.
|
|
66
|
+
*
|
|
67
|
+
* @param configuration the configuration for the Logs feature
|
|
68
|
+
*/
|
|
69
|
+
fun enableLogs(
|
|
70
|
+
configuration: LogsConfiguration
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Enables the Trace feature of the SDK.
|
|
75
|
+
*
|
|
76
|
+
* @param configuration the configuration for the Trace feature
|
|
77
|
+
*/
|
|
78
|
+
fun enableTrace(
|
|
79
|
+
configuration: TraceConfiguration
|
|
80
|
+
)
|
|
81
|
+
|
|
53
82
|
/**
|
|
54
83
|
* Sets the user information.
|
|
55
84
|
*
|
|
@@ -66,13 +95,6 @@ interface DatadogWrapper {
|
|
|
66
95
|
extraInfo: Map<String, Any?>
|
|
67
96
|
)
|
|
68
97
|
|
|
69
|
-
/**
|
|
70
|
-
* Registers a given monitor in [GlobalRum].
|
|
71
|
-
*
|
|
72
|
-
* @param rumMonitor to register
|
|
73
|
-
*/
|
|
74
|
-
fun registerRumMonitor(rumMonitor: RumMonitor)
|
|
75
|
-
|
|
76
98
|
/**
|
|
77
99
|
* Adds global attributes.
|
|
78
100
|
*
|
|
@@ -109,4 +131,9 @@ interface DatadogWrapper {
|
|
|
109
131
|
* Returns whether the SDK is initialized.
|
|
110
132
|
*/
|
|
111
133
|
fun isInitialized(): Boolean
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Returns the RUM Monitor for the default SDK core.
|
|
137
|
+
*/
|
|
138
|
+
fun getRumMonitor(): RumMonitor
|
|
112
139
|
}
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import android.util.Log
|
|
10
10
|
import com.datadog.android.rum.RumActionType
|
|
11
11
|
import com.datadog.android.rum.RumAttributes
|
|
12
12
|
import com.datadog.android.rum.RumErrorSource
|
|
13
13
|
import com.datadog.android.rum.RumResourceKind
|
|
14
|
+
import com.datadog.android.rum.RumResourceMethod
|
|
14
15
|
import com.facebook.react.bridge.Promise
|
|
15
16
|
import com.facebook.react.bridge.ReadableMap
|
|
16
17
|
import java.util.Locale
|
|
@@ -19,7 +20,7 @@ import java.util.Locale
|
|
|
19
20
|
* The entry point to use Datadog's RUM feature.
|
|
20
21
|
*/
|
|
21
22
|
@Suppress("TooManyFunctions")
|
|
22
|
-
class DdRumImplementation {
|
|
23
|
+
class DdRumImplementation(private val datadog: DatadogWrapper = DatadogSDKWrapper()) {
|
|
23
24
|
/**
|
|
24
25
|
* Start tracking a RUM View.
|
|
25
26
|
* @param key The view unique key identifier.
|
|
@@ -37,7 +38,7 @@ class DdRumImplementation {
|
|
|
37
38
|
val attributes = context.toHashMap().toMutableMap().apply {
|
|
38
39
|
put(RumAttributes.INTERNAL_TIMESTAMP, timestampMs.toLong())
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
+
datadog.getRumMonitor().startView(
|
|
41
42
|
key = key,
|
|
42
43
|
name = name,
|
|
43
44
|
attributes = attributes
|
|
@@ -55,7 +56,7 @@ class DdRumImplementation {
|
|
|
55
56
|
val attributes = context.toHashMap().toMutableMap().apply {
|
|
56
57
|
put(RumAttributes.INTERNAL_TIMESTAMP, timestampMs.toLong())
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
+
datadog.getRumMonitor().stopView(
|
|
59
60
|
key = key,
|
|
60
61
|
attributes = attributes
|
|
61
62
|
)
|
|
@@ -79,7 +80,7 @@ class DdRumImplementation {
|
|
|
79
80
|
val attributes = context.toHashMap().toMutableMap().apply {
|
|
80
81
|
put(RumAttributes.INTERNAL_TIMESTAMP, timestampMs.toLong())
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
+
datadog.getRumMonitor().startAction(
|
|
83
84
|
type = type.asRumActionType(),
|
|
84
85
|
name = name,
|
|
85
86
|
attributes = attributes
|
|
@@ -104,7 +105,7 @@ class DdRumImplementation {
|
|
|
104
105
|
val attributes = context.toHashMap().toMutableMap().apply {
|
|
105
106
|
put(RumAttributes.INTERNAL_TIMESTAMP, timestampMs.toLong())
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
+
datadog.getRumMonitor().stopAction(
|
|
108
109
|
type = type.asRumActionType(),
|
|
109
110
|
name = name,
|
|
110
111
|
attributes = attributes
|
|
@@ -129,7 +130,7 @@ class DdRumImplementation {
|
|
|
129
130
|
val attributes = context.toHashMap().toMutableMap().apply {
|
|
130
131
|
put(RumAttributes.INTERNAL_TIMESTAMP, timestampMs.toLong())
|
|
131
132
|
}
|
|
132
|
-
|
|
133
|
+
datadog.getRumMonitor().addAction(
|
|
133
134
|
type = type.asRumActionType(),
|
|
134
135
|
name = name,
|
|
135
136
|
attributes = attributes
|
|
@@ -157,9 +158,9 @@ class DdRumImplementation {
|
|
|
157
158
|
val attributes = context.toHashMap().toMutableMap().apply {
|
|
158
159
|
put(RumAttributes.INTERNAL_TIMESTAMP, timestampMs.toLong())
|
|
159
160
|
}
|
|
160
|
-
|
|
161
|
+
datadog.getRumMonitor().startResource(
|
|
161
162
|
key = key,
|
|
162
|
-
method = method,
|
|
163
|
+
method = method.asRumResourceMethod(),
|
|
163
164
|
url = url,
|
|
164
165
|
attributes = attributes
|
|
165
166
|
)
|
|
@@ -193,7 +194,7 @@ class DdRumImplementation {
|
|
|
193
194
|
} else {
|
|
194
195
|
size.toLong()
|
|
195
196
|
}
|
|
196
|
-
|
|
197
|
+
datadog.getRumMonitor().stopResource(
|
|
197
198
|
key = key,
|
|
198
199
|
statusCode = statusCode.toInt(),
|
|
199
200
|
kind = kind.asRumResourceKind(),
|
|
@@ -223,7 +224,7 @@ class DdRumImplementation {
|
|
|
223
224
|
val attributes = context.toHashMap().toMutableMap().apply {
|
|
224
225
|
put(RumAttributes.INTERNAL_TIMESTAMP, timestampMs.toLong())
|
|
225
226
|
}
|
|
226
|
-
|
|
227
|
+
datadog.getRumMonitor().addErrorWithStacktrace(
|
|
227
228
|
message = message,
|
|
228
229
|
source = source.asErrorSource(),
|
|
229
230
|
stacktrace = stacktrace,
|
|
@@ -237,7 +238,7 @@ class DdRumImplementation {
|
|
|
237
238
|
* @param name The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
|
|
238
239
|
*/
|
|
239
240
|
fun addTiming(name: String, promise: Promise) {
|
|
240
|
-
|
|
241
|
+
datadog.getRumMonitor().addTiming(name)
|
|
241
242
|
promise.resolve(null)
|
|
242
243
|
}
|
|
243
244
|
|
|
@@ -245,7 +246,7 @@ class DdRumImplementation {
|
|
|
245
246
|
* Stops the current RUM Session.
|
|
246
247
|
*/
|
|
247
248
|
fun stopSession(promise: Promise) {
|
|
248
|
-
|
|
249
|
+
datadog.getRumMonitor().stopSession()
|
|
249
250
|
promise.resolve(null)
|
|
250
251
|
}
|
|
251
252
|
|
|
@@ -253,12 +254,12 @@ class DdRumImplementation {
|
|
|
253
254
|
* Adds result of evaluating a feature flag to the view.
|
|
254
255
|
* Feature flag evaluations are local to the active view and are cleared when the view is stopped.
|
|
255
256
|
* @param name The name of the feature flag
|
|
256
|
-
* @param
|
|
257
|
+
* @param valueAsMap The value the feature flag evaluated to, encapsulated in a Map
|
|
257
258
|
*/
|
|
258
|
-
fun addFeatureFlagEvaluation(name: String,
|
|
259
|
-
val value =
|
|
259
|
+
fun addFeatureFlagEvaluation(name: String, valueAsMap: ReadableMap, promise: Promise) {
|
|
260
|
+
val value = valueAsMap.toHashMap()["value"]
|
|
260
261
|
if (value != null) {
|
|
261
|
-
|
|
262
|
+
datadog.getRumMonitor().addFeatureFlagEvaluation(name, value)
|
|
262
263
|
}
|
|
263
264
|
promise.resolve(null)
|
|
264
265
|
}
|
|
@@ -305,6 +306,25 @@ class DdRumImplementation {
|
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
308
|
|
|
309
|
+
private fun String.asRumResourceMethod(): RumResourceMethod {
|
|
310
|
+
return when(lowercase(Locale.US)) {
|
|
311
|
+
"get" -> RumResourceMethod.GET
|
|
312
|
+
"delete" -> RumResourceMethod.DELETE
|
|
313
|
+
"head" -> RumResourceMethod.HEAD
|
|
314
|
+
"patch" -> RumResourceMethod.PATCH
|
|
315
|
+
"put" -> RumResourceMethod.PUT
|
|
316
|
+
"post" -> RumResourceMethod.POST
|
|
317
|
+
else -> {
|
|
318
|
+
Log.w(
|
|
319
|
+
DdRum::class.java.canonicalName,
|
|
320
|
+
"Unknown RUM resource method given: $this, " +
|
|
321
|
+
"using ${RumResourceMethod.GET} as default"
|
|
322
|
+
)
|
|
323
|
+
RumResourceMethod.GET
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
308
328
|
// endregion
|
|
309
329
|
|
|
310
330
|
companion object {
|
|
@@ -29,7 +29,7 @@ package com.datadog.reactnative
|
|
|
29
29
|
data class DdSdkConfiguration(
|
|
30
30
|
val clientToken: String,
|
|
31
31
|
val env: String,
|
|
32
|
-
val applicationId: String
|
|
32
|
+
val applicationId: String,
|
|
33
33
|
val nativeCrashReportEnabled: Boolean? = null,
|
|
34
34
|
val nativeLongTaskThresholdMs: Double? = null,
|
|
35
35
|
val longTaskThresholdMs: Double? = null,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
|
-
import com.datadog.android.
|
|
9
|
+
import com.datadog.android.trace.TracingHeaderType
|
|
10
10
|
import com.facebook.react.bridge.ReadableArray
|
|
11
11
|
import com.facebook.react.bridge.ReadableMap
|
|
12
12
|
import com.facebook.react.bridge.WritableNativeMap
|
|
@@ -15,7 +15,7 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
15
15
|
return DdSdkConfiguration(
|
|
16
16
|
clientToken = getString("clientToken").orEmpty(),
|
|
17
17
|
env = getString("env").orEmpty(),
|
|
18
|
-
applicationId = getString("applicationId"),
|
|
18
|
+
applicationId = getString("applicationId").orEmpty(),
|
|
19
19
|
nativeCrashReportEnabled = getBoolean("nativeCrashReportEnabled"),
|
|
20
20
|
nativeLongTaskThresholdMs = getDouble("nativeLongTaskThresholdMs"),
|
|
21
21
|
longTaskThresholdMs = getDouble("longTaskThresholdMs"),
|
|
@@ -63,7 +63,7 @@ internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
|
|
|
63
63
|
val map = WritableNativeMap()
|
|
64
64
|
map.putString("clientToken", clientToken)
|
|
65
65
|
map.putString("env", env)
|
|
66
|
-
|
|
66
|
+
map.putString("applicationId", applicationId)
|
|
67
67
|
nativeCrashReportEnabled?.let { map.putBoolean("nativeCrashReportEnabled", it) }
|
|
68
68
|
nativeLongTaskThresholdMs?.let { map.putDouble("nativeLongTaskThresholdMs", it) }
|
|
69
69
|
longTaskThresholdMs?.let { map.putDouble("longTaskThresholdMs", it) }
|