@datadog/mobile-react-native 1.7.1 → 1.8.0-rc0
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 +14 -1
- package/android/build.gradle +20 -7
- package/android/src/main/kotlin/com/datadog/reactnative/{DdLogs.kt → DdLogsImplementation.kt} +3 -17
- package/android/src/main/kotlin/com/datadog/reactnative/{DdRum.kt → DdRumImplementation.kt} +2 -18
- package/android/src/main/kotlin/com/datadog/reactnative/{DdSdk.kt → DdSdkImplementation.kt} +3 -14
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +34 -17
- package/android/src/main/kotlin/com/datadog/reactnative/{DdTrace.kt → DdTraceImplementation.kt} +6 -11
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdLogs.kt +148 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +199 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +90 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdTrace.kt +46 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +163 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +200 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +91 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +47 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +3 -13
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +2 -6
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +33 -33
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +2 -6
- package/ios/Sources/{DdSdkReactNative-Bridging-Header.h → DatadogSDKReactNative.h} +2 -1
- package/ios/Sources/DdLogs.h +24 -0
- package/ios/Sources/DdLogs.mm +149 -0
- package/ios/Sources/{DdLogs.swift → DdLogsImplementation.swift} +20 -29
- package/ios/Sources/DdRum.h +24 -0
- package/ios/Sources/DdRum.mm +188 -0
- package/ios/Sources/{DdRum.swift → DdRumImplementation.swift} +28 -35
- package/ios/Sources/DdSdk.h +24 -0
- package/ios/Sources/DdSdk.mm +119 -0
- package/ios/Sources/{DdSdk.swift → DdSdkImplementation.swift} +20 -25
- package/ios/Sources/DdTrace.h +24 -0
- package/ios/Sources/DdTrace.mm +66 -0
- package/ios/Sources/{DdTrace.swift → DdTraceImplementation.swift} +10 -17
- package/ios/Sources/QueueHolder.swift +8 -0
- package/jest/mock.js +3 -1
- package/lib/commonjs/DdSdkReactNative.js +32 -49
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +18 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +33 -40
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +13 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +104 -106
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/eventMappers/errorEventMapper.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/sdk/DdSdk.js +3 -3
- package/lib/commonjs/sdk/DdSdk.js.map +1 -1
- package/lib/commonjs/specs/NativeDdLogs.js +20 -0
- package/lib/commonjs/specs/NativeDdLogs.js.map +1 -0
- package/lib/commonjs/specs/NativeDdRum.js +20 -0
- package/lib/commonjs/specs/NativeDdRum.js.map +1 -0
- package/lib/commonjs/specs/NativeDdSdk.js +20 -0
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -0
- package/lib/commonjs/specs/NativeDdTrace.js +20 -0
- package/lib/commonjs/specs/NativeDdTrace.js.map +1 -0
- package/lib/commonjs/trace/DdTrace.js +10 -12
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +27 -44
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +18 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/logs/DdLogs.js +33 -39
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +13 -0
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +100 -101
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/eventMappers/errorEventMapper.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/sdk/DdSdk.js +3 -2
- package/lib/module/sdk/DdSdk.js.map +1 -1
- package/lib/module/specs/NativeDdLogs.js +14 -0
- package/lib/module/specs/NativeDdLogs.js.map +1 -0
- package/lib/module/specs/NativeDdRum.js +14 -0
- package/lib/module/specs/NativeDdRum.js.map +1 -0
- package/lib/module/specs/NativeDdSdk.js +14 -0
- package/lib/module/specs/NativeDdSdk.js.map +1 -0
- package/lib/module/specs/NativeDdTrace.js +14 -0
- package/lib/module/specs/NativeDdTrace.js.map +1 -0
- package/lib/module/trace/DdTrace.js +10 -11
- package/lib/module/trace/DdTrace.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +4 -4
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +14 -0
- package/lib/typescript/logs/DdLogs.d.ts +4 -4
- package/lib/typescript/nativeModulesTypes.d.ts +28 -168
- package/lib/typescript/rum/DdRum.d.ts +12 -12
- package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +4 -4
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +4 -0
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +3 -1
- package/lib/typescript/specs/NativeDdLogs.d.ts +69 -0
- package/lib/typescript/specs/NativeDdRum.d.ts +92 -0
- package/lib/typescript/specs/NativeDdSdk.d.ts +46 -0
- package/lib/typescript/specs/NativeDdTrace.d.ts +23 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +10 -2
- package/src/DdSdkReactNative.tsx +12 -10
- package/src/DdSdkReactNativeConfiguration.tsx +22 -0
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
- package/src/__tests__/longTasksUtils.test.ts +5 -0
- package/src/__tests__/mock.test.ts +89 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +54 -0
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +118 -68
- package/src/logs/DdLogs.ts +11 -11
- package/src/logs/__tests__/DdLogs.test.ts +1 -1
- package/src/nativeModulesTypes.ts +49 -254
- package/src/rum/DdRum.ts +36 -32
- package/src/rum/eventMappers/errorEventMapper.ts +4 -4
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +15 -0
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +6 -2
- package/src/sdk/DdSdk.ts +2 -3
- package/src/specs/NativeDdLogs.ts +110 -0
- package/src/specs/NativeDdRum.ts +151 -0
- package/src/specs/NativeDdSdk.ts +62 -0
- package/src/specs/NativeDdTrace.ts +42 -0
- package/src/trace/DdTrace.ts +9 -9
- package/src/version.ts +1 -1
- package/ios/Sources/DdLogs.m +0 -62
- package/ios/Sources/DdRum.m +0 -82
- package/ios/Sources/DdSdk.m +0 -41
- package/ios/Sources/DdTrace.m +0 -23
|
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.license = package["license"]
|
|
11
11
|
s.authors = package["author"]
|
|
12
12
|
|
|
13
|
-
s.platforms = { :ios => "11.0" }
|
|
13
|
+
s.platforms = { :ios => "11.0", :tvos => "11.0" }
|
|
14
14
|
s.source = { :git => "https://github.com/DataDog/dd-sdk-reactnative.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
16
|
|
|
@@ -23,4 +23,17 @@ Pod::Spec.new do |s|
|
|
|
23
23
|
s.test_spec 'Tests' do |test_spec|
|
|
24
24
|
test_spec.source_files = 'ios/Tests/*.swift'
|
|
25
25
|
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# This guard prevents installing the dependencies when we run `pod install` in the old architecture.
|
|
29
|
+
# The `install_modules_dependencies` function is only available from RN 0.71, the new architecture is not
|
|
30
|
+
# supported on earlier RN versions.
|
|
31
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
32
|
+
s.pod_target_xcconfig = {
|
|
33
|
+
"DEFINES_MODULE" => "YES",
|
|
34
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DRCT_NEW_ARCH_ENABLED=1"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
install_modules_dependencies(s)
|
|
38
|
+
end
|
|
26
39
|
end
|
package/android/build.gradle
CHANGED
|
@@ -20,7 +20,15 @@ buildscript {
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
apply plugin: 'de.mobilej.unmock'
|
|
23
|
+
|
|
24
|
+
def isNewArchitectureEnabled() {
|
|
25
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
apply plugin: 'com.android.library'
|
|
29
|
+
if (isNewArchitectureEnabled()) {
|
|
30
|
+
apply plugin: 'com.facebook.react'
|
|
31
|
+
}
|
|
24
32
|
apply plugin: 'kotlin-android'
|
|
25
33
|
apply plugin: 'org.jlleitschuh.gradle.ktlint'
|
|
26
34
|
apply plugin: "io.gitlab.arturbosch.detekt"
|
|
@@ -81,15 +89,20 @@ android {
|
|
|
81
89
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
82
90
|
versionCode 1
|
|
83
91
|
versionName "1.0"
|
|
84
|
-
|
|
92
|
+
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
|
|
85
93
|
}
|
|
86
94
|
|
|
87
|
-
sourceSets
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
sourceSets {
|
|
96
|
+
main {
|
|
97
|
+
if (isNewArchitectureEnabled()) {
|
|
98
|
+
java.srcDirs += ['src/newarch/kotlin']
|
|
99
|
+
} else {
|
|
100
|
+
java.srcDirs += ['src/oldarch/kotlin']
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
test {
|
|
104
|
+
java.srcDir("src/test/kotlin")
|
|
105
|
+
}
|
|
93
106
|
}
|
|
94
107
|
|
|
95
108
|
testOptions {
|
package/android/src/main/kotlin/com/datadog/reactnative/{DdLogs.kt → DdLogsImplementation.kt}
RENAMED
|
@@ -9,22 +9,15 @@ package com.datadog.reactnative
|
|
|
9
9
|
import android.util.Log as AndroidLog
|
|
10
10
|
import com.datadog.android.log.Logger
|
|
11
11
|
import com.facebook.react.bridge.Promise
|
|
12
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
14
|
-
import com.facebook.react.bridge.ReactMethod
|
|
15
12
|
import com.facebook.react.bridge.ReadableMap
|
|
16
13
|
|
|
17
14
|
/**
|
|
18
15
|
* The entry point to use Datadog's Logs feature.
|
|
19
16
|
*/
|
|
20
|
-
class
|
|
21
|
-
reactContext: ReactApplicationContext,
|
|
17
|
+
class DdLogsImplementation(
|
|
22
18
|
logger: Logger? = null,
|
|
23
19
|
private val datadog: DatadogWrapper = DatadogSDKWrapper()
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
override fun getName(): String = "DdLogs"
|
|
27
|
-
|
|
20
|
+
) {
|
|
28
21
|
private val reactNativeLogger: Logger by lazy {
|
|
29
22
|
logger ?: Logger.Builder()
|
|
30
23
|
.setDatadogLogsEnabled(true)
|
|
@@ -38,7 +31,6 @@ class DdLogs(
|
|
|
38
31
|
* @param message The message to send.
|
|
39
32
|
* @param context The additional context to send.
|
|
40
33
|
*/
|
|
41
|
-
@ReactMethod
|
|
42
34
|
fun debug(message: String, context: ReadableMap, promise: Promise) {
|
|
43
35
|
if (!datadog.isInitialized()) {
|
|
44
36
|
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
@@ -56,7 +48,6 @@ class DdLogs(
|
|
|
56
48
|
* @param message The message to send.
|
|
57
49
|
* @param context The additional context to send.
|
|
58
50
|
*/
|
|
59
|
-
@ReactMethod
|
|
60
51
|
fun info(message: String, context: ReadableMap, promise: Promise) {
|
|
61
52
|
if (!datadog.isInitialized()) {
|
|
62
53
|
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
@@ -74,7 +65,6 @@ class DdLogs(
|
|
|
74
65
|
* @param message The message to send.
|
|
75
66
|
* @param context The additional context to send.
|
|
76
67
|
*/
|
|
77
|
-
@ReactMethod
|
|
78
68
|
fun warn(message: String, context: ReadableMap, promise: Promise) {
|
|
79
69
|
if (!datadog.isInitialized()) {
|
|
80
70
|
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
@@ -92,7 +82,6 @@ class DdLogs(
|
|
|
92
82
|
* @param message The message to send.
|
|
93
83
|
* @param context The additional context to send.
|
|
94
84
|
*/
|
|
95
|
-
@ReactMethod
|
|
96
85
|
fun error(message: String, context: ReadableMap, promise: Promise) {
|
|
97
86
|
if (!datadog.isInitialized()) {
|
|
98
87
|
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
@@ -114,7 +103,6 @@ class DdLogs(
|
|
|
114
103
|
* @param context The additional context to send.
|
|
115
104
|
*/
|
|
116
105
|
@Suppress("LongParameterList")
|
|
117
|
-
@ReactMethod
|
|
118
106
|
fun debugWithError(
|
|
119
107
|
message: String,
|
|
120
108
|
errorKind: String?,
|
|
@@ -147,7 +135,6 @@ class DdLogs(
|
|
|
147
135
|
* @param context The additional context to send.
|
|
148
136
|
*/
|
|
149
137
|
@Suppress("LongParameterList")
|
|
150
|
-
@ReactMethod
|
|
151
138
|
fun infoWithError(
|
|
152
139
|
message: String,
|
|
153
140
|
errorKind: String?,
|
|
@@ -180,7 +167,6 @@ class DdLogs(
|
|
|
180
167
|
* @param context The additional context to send.
|
|
181
168
|
*/
|
|
182
169
|
@Suppress("LongParameterList")
|
|
183
|
-
@ReactMethod
|
|
184
170
|
fun warnWithError(
|
|
185
171
|
message: String,
|
|
186
172
|
errorKind: String?,
|
|
@@ -213,7 +199,6 @@ class DdLogs(
|
|
|
213
199
|
* @param context The additional context to send.
|
|
214
200
|
*/
|
|
215
201
|
@Suppress("LongParameterList")
|
|
216
|
-
@ReactMethod
|
|
217
202
|
fun errorWithError(
|
|
218
203
|
message: String,
|
|
219
204
|
errorKind: String?,
|
|
@@ -239,5 +224,6 @@ class DdLogs(
|
|
|
239
224
|
|
|
240
225
|
companion object {
|
|
241
226
|
private const val SDK_NOT_INITIALIZED_MESSAGE = "DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT"
|
|
227
|
+
internal const val NAME = "DdLogs"
|
|
242
228
|
}
|
|
243
229
|
}
|
|
@@ -12,9 +12,6 @@ import com.datadog.android.rum.RumAttributes
|
|
|
12
12
|
import com.datadog.android.rum.RumErrorSource
|
|
13
13
|
import com.datadog.android.rum.RumResourceKind
|
|
14
14
|
import com.facebook.react.bridge.Promise
|
|
15
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
16
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
17
|
-
import com.facebook.react.bridge.ReactMethod
|
|
18
15
|
import com.facebook.react.bridge.ReadableMap
|
|
19
16
|
import java.util.Locale
|
|
20
17
|
|
|
@@ -22,10 +19,7 @@ import java.util.Locale
|
|
|
22
19
|
* The entry point to use Datadog's RUM feature.
|
|
23
20
|
*/
|
|
24
21
|
@Suppress("TooManyFunctions")
|
|
25
|
-
class
|
|
26
|
-
|
|
27
|
-
override fun getName(): String = "DdRum"
|
|
28
|
-
|
|
22
|
+
class DdRumImplementation {
|
|
29
23
|
/**
|
|
30
24
|
* Start tracking a RUM View.
|
|
31
25
|
* @param key The view unique key identifier.
|
|
@@ -33,7 +27,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
33
27
|
* @param context The additional context to send.
|
|
34
28
|
* @param timestampMs The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
|
|
35
29
|
*/
|
|
36
|
-
@ReactMethod
|
|
37
30
|
fun startView(
|
|
38
31
|
key: String,
|
|
39
32
|
name: String,
|
|
@@ -58,7 +51,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
58
51
|
* @param context The additional context to send.
|
|
59
52
|
* @param timestampMs The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
60
53
|
*/
|
|
61
|
-
@ReactMethod
|
|
62
54
|
fun stopView(key: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
63
55
|
val attributes = context.toHashMap().toMutableMap().apply {
|
|
64
56
|
put(RumAttributes.INTERNAL_TIMESTAMP, timestampMs.toLong())
|
|
@@ -77,7 +69,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
77
69
|
* @param context The additional context to send.
|
|
78
70
|
* @param timestampMs The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
79
71
|
*/
|
|
80
|
-
@ReactMethod
|
|
81
72
|
fun startAction(
|
|
82
73
|
type: String,
|
|
83
74
|
name: String,
|
|
@@ -103,7 +94,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
103
94
|
* @param context The additional context to send.
|
|
104
95
|
* @param timestampMs The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
105
96
|
*/
|
|
106
|
-
@ReactMethod
|
|
107
97
|
fun stopAction(
|
|
108
98
|
type: String,
|
|
109
99
|
name: String,
|
|
@@ -129,7 +119,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
129
119
|
* @param context The additional context to send.
|
|
130
120
|
* @param timestampMs The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
131
121
|
*/
|
|
132
|
-
@ReactMethod
|
|
133
122
|
fun addAction(
|
|
134
123
|
type: String,
|
|
135
124
|
name: String,
|
|
@@ -157,7 +146,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
157
146
|
* @param timestampMs The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
|
|
158
147
|
*/
|
|
159
148
|
@Suppress("LongParameterList")
|
|
160
|
-
@ReactMethod
|
|
161
149
|
fun startResource(
|
|
162
150
|
key: String,
|
|
163
151
|
method: String,
|
|
@@ -188,7 +176,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
188
176
|
* @param timestampMs The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
189
177
|
*/
|
|
190
178
|
@Suppress("LongParameterList")
|
|
191
|
-
@ReactMethod
|
|
192
179
|
fun stopResource(
|
|
193
180
|
key: String,
|
|
194
181
|
statusCode: Double,
|
|
@@ -225,7 +212,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
225
212
|
* @param timestampMs The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
226
213
|
*/
|
|
227
214
|
@Suppress("LongParameterList")
|
|
228
|
-
@ReactMethod
|
|
229
215
|
fun addError(
|
|
230
216
|
message: String,
|
|
231
217
|
source: String,
|
|
@@ -250,7 +236,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
250
236
|
* Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.
|
|
251
237
|
* @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.
|
|
252
238
|
*/
|
|
253
|
-
@ReactMethod
|
|
254
239
|
fun addTiming(name: String, promise: Promise) {
|
|
255
240
|
GlobalRum.get().addTiming(name)
|
|
256
241
|
promise.resolve(null)
|
|
@@ -259,7 +244,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
259
244
|
/**
|
|
260
245
|
* Stops the current RUM Session.
|
|
261
246
|
*/
|
|
262
|
-
@ReactMethod
|
|
263
247
|
fun stopSession(promise: Promise) {
|
|
264
248
|
GlobalRum.get().stopSession()
|
|
265
249
|
promise.resolve(null)
|
|
@@ -271,7 +255,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
271
255
|
* @param name The name of the feature flag
|
|
272
256
|
* @param value The value the feature flag evaluated to, encapsulated in a Map
|
|
273
257
|
*/
|
|
274
|
-
@ReactMethod
|
|
275
258
|
fun addFeatureFlagEvaluation(name: String, value: ReadableMap, promise: Promise) {
|
|
276
259
|
val value = value.toHashMap()["value"]
|
|
277
260
|
if (value != null) {
|
|
@@ -326,5 +309,6 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
326
309
|
|
|
327
310
|
companion object {
|
|
328
311
|
private const val MISSING_RESOURCE_SIZE = -1L
|
|
312
|
+
internal const val NAME = "DdRum"
|
|
329
313
|
}
|
|
330
314
|
}
|
|
@@ -29,8 +29,6 @@ import com.datadog.android.telemetry.model.TelemetryConfigurationEvent
|
|
|
29
29
|
import com.datadog.android.tracing.TracingHeaderType
|
|
30
30
|
import com.facebook.react.bridge.Promise
|
|
31
31
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
32
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
33
|
-
import com.facebook.react.bridge.ReactMethod
|
|
34
32
|
import com.facebook.react.bridge.ReadableArray
|
|
35
33
|
import com.facebook.react.bridge.ReadableMap
|
|
36
34
|
import java.net.InetSocketAddress
|
|
@@ -40,24 +38,20 @@ import java.util.concurrent.TimeUnit
|
|
|
40
38
|
import java.util.concurrent.atomic.AtomicBoolean
|
|
41
39
|
|
|
42
40
|
/** The entry point to initialize Datadog's features. */
|
|
43
|
-
class
|
|
41
|
+
class DdSdkImplementation(
|
|
44
42
|
reactContext: ReactApplicationContext,
|
|
45
43
|
private val datadog: DatadogWrapper = DatadogSDKWrapper()
|
|
46
|
-
)
|
|
47
|
-
|
|
44
|
+
) {
|
|
48
45
|
internal val appContext: Context = reactContext.applicationContext
|
|
49
46
|
internal val reactContext: ReactApplicationContext = reactContext
|
|
50
47
|
internal val initialized = AtomicBoolean(false)
|
|
51
48
|
|
|
52
|
-
override fun getName(): String = "DdSdk"
|
|
53
|
-
|
|
54
49
|
// region DdSdk
|
|
55
50
|
|
|
56
51
|
/**
|
|
57
52
|
* Initializes Datadog's features.
|
|
58
53
|
* @param configuration The configuration to use.
|
|
59
54
|
*/
|
|
60
|
-
@ReactMethod
|
|
61
55
|
fun initialize(configuration: ReadableMap, promise: Promise) {
|
|
62
56
|
val ddSdkConfiguration = configuration.asDdSdkConfiguration()
|
|
63
57
|
val credentials = buildCredentials(ddSdkConfiguration)
|
|
@@ -80,7 +74,6 @@ class DdSdk(
|
|
|
80
74
|
* events.
|
|
81
75
|
* @param attributes The global context attributes.
|
|
82
76
|
*/
|
|
83
|
-
@ReactMethod
|
|
84
77
|
fun setAttributes(attributes: ReadableMap, promise: Promise) {
|
|
85
78
|
datadog.addRumGlobalAttributes(attributes.toHashMap())
|
|
86
79
|
attributes.toHashMap().forEach { (k, v) -> GlobalState.addAttribute(k, v) }
|
|
@@ -92,7 +85,6 @@ class DdSdk(
|
|
|
92
85
|
* @param user The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom
|
|
93
86
|
* attribute).
|
|
94
87
|
*/
|
|
95
|
-
@ReactMethod
|
|
96
88
|
fun setUser(user: ReadableMap, promise: Promise) {
|
|
97
89
|
val extraInfo = user.toHashMap().toMutableMap()
|
|
98
90
|
val id = extraInfo.remove("id")?.toString()
|
|
@@ -107,7 +99,6 @@ class DdSdk(
|
|
|
107
99
|
* @param trackingConsent Consent, which can take one of the following values: 'pending',
|
|
108
100
|
* 'granted', 'not_granted'.
|
|
109
101
|
*/
|
|
110
|
-
@ReactMethod
|
|
111
102
|
fun setTrackingConsent(trackingConsent: String, promise: Promise) {
|
|
112
103
|
datadog.setTrackingConsent(buildTrackingConsent(trackingConsent))
|
|
113
104
|
promise.resolve(null)
|
|
@@ -117,7 +108,6 @@ class DdSdk(
|
|
|
117
108
|
* Sends a telemetry debug event.
|
|
118
109
|
* @param message Debug message.
|
|
119
110
|
*/
|
|
120
|
-
@ReactMethod
|
|
121
111
|
fun telemetryDebug(message: String, promise: Promise) {
|
|
122
112
|
datadog.telemetryDebug(message)
|
|
123
113
|
promise.resolve(null)
|
|
@@ -129,7 +119,6 @@ class DdSdk(
|
|
|
129
119
|
* @param stack Error stack.
|
|
130
120
|
* @param kind Error kind.
|
|
131
121
|
*/
|
|
132
|
-
@ReactMethod
|
|
133
122
|
fun telemetryError(message: String, stack: String, kind: String, promise: Promise) {
|
|
134
123
|
datadog.telemetryError(message, stack, kind)
|
|
135
124
|
promise.resolve(null)
|
|
@@ -139,7 +128,6 @@ class DdSdk(
|
|
|
139
128
|
* Sends WebView Events.
|
|
140
129
|
* @param message User action.
|
|
141
130
|
*/
|
|
142
|
-
@ReactMethod
|
|
143
131
|
fun consumeWebviewEvent(message: String, promise: Promise) {
|
|
144
132
|
datadog.consumeWebviewEvent(message)
|
|
145
133
|
promise.resolve(null)
|
|
@@ -536,5 +524,6 @@ class DdSdk(
|
|
|
536
524
|
internal const val DD_DROP_ACTION = "_dd.action.drop_action"
|
|
537
525
|
internal const val MONITOR_JS_ERROR_MESSAGE = "Error monitoring JS refresh rate"
|
|
538
526
|
internal const val PACKAGE_INFO_NOT_FOUND_ERROR_MESSAGE = "Error getting package info"
|
|
527
|
+
internal const val NAME = "DdSdk"
|
|
539
528
|
}
|
|
540
529
|
}
|
|
@@ -6,30 +6,47 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
|
-
import com.facebook.react.
|
|
9
|
+
import com.facebook.react.TurboReactPackage
|
|
10
10
|
import com.facebook.react.bridge.NativeModule
|
|
11
11
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
|
-
import com.facebook.react.
|
|
12
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
13
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Package of native dd-sdk-reactnative native modules.
|
|
16
17
|
*/
|
|
17
|
-
class DdSdkReactNativePackage :
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
class DdSdkReactNativePackage : TurboReactPackage() {
|
|
19
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
20
|
+
return when (name) {
|
|
21
|
+
DdSdkImplementation.NAME -> DdSdk(reactContext)
|
|
22
|
+
DdRumImplementation.NAME -> DdRum(reactContext)
|
|
23
|
+
DdTraceImplementation.NAME -> DdTrace(reactContext)
|
|
24
|
+
DdLogsImplementation.NAME -> DdLogs(reactContext)
|
|
25
|
+
else -> null
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
override fun
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
30
|
+
return ReactModuleInfoProvider {
|
|
31
|
+
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
32
|
+
val moduleInfos = listOf(
|
|
33
|
+
DdSdkImplementation.NAME,
|
|
34
|
+
DdRumImplementation.NAME,
|
|
35
|
+
DdTraceImplementation.NAME,
|
|
36
|
+
DdLogsImplementation.NAME
|
|
37
|
+
).associateWith {
|
|
38
|
+
ReactModuleInfo(
|
|
39
|
+
it,
|
|
40
|
+
it,
|
|
41
|
+
false, // canOverrideExistingModule
|
|
42
|
+
false, // needsEagerInit
|
|
43
|
+
true, // hasConstants
|
|
44
|
+
false, // isCxxModule
|
|
45
|
+
isTurboModule // isTurboModule
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
moduleInfos
|
|
50
|
+
}
|
|
34
51
|
}
|
|
35
52
|
}
|
package/android/src/main/kotlin/com/datadog/reactnative/{DdTrace.kt → DdTraceImplementation.kt}
RENAMED
|
@@ -8,9 +8,6 @@ package com.datadog.reactnative
|
|
|
8
8
|
|
|
9
9
|
import com.datadog.android.tracing.AndroidTracer
|
|
10
10
|
import com.facebook.react.bridge.Promise
|
|
11
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
13
|
-
import com.facebook.react.bridge.ReactMethod
|
|
14
11
|
import com.facebook.react.bridge.ReadableMap
|
|
15
12
|
import io.opentracing.Span
|
|
16
13
|
import io.opentracing.Tracer
|
|
@@ -19,26 +16,21 @@ import java.util.concurrent.TimeUnit
|
|
|
19
16
|
/**
|
|
20
17
|
* The entry point to use Datadog's Trace feature.
|
|
21
18
|
*/
|
|
22
|
-
class
|
|
23
|
-
reactContext: ReactApplicationContext,
|
|
19
|
+
class DdTraceImplementation(
|
|
24
20
|
private val tracerProvider: () -> Tracer = { AndroidTracer.Builder().build() }
|
|
25
|
-
)
|
|
26
|
-
|
|
21
|
+
) {
|
|
27
22
|
private val spanMap: MutableMap<String, Span> = mutableMapOf()
|
|
28
23
|
|
|
29
24
|
// lazy here is on purpose. The thing is that this class will be instantiated even
|
|
30
25
|
// before Sdk.initialize is called, but Tracer can be created only after SDK is initialized.
|
|
31
26
|
private val tracer by lazy { tracerProvider.invoke() }
|
|
32
27
|
|
|
33
|
-
override fun getName(): String = "DdTrace"
|
|
34
|
-
|
|
35
28
|
/**
|
|
36
29
|
* Start a span, and returns a unique identifier for the span.
|
|
37
30
|
* @param operation The operation name of the span.
|
|
38
31
|
* @param context The additional context to send.
|
|
39
32
|
* @param timestampMs The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
|
|
40
33
|
*/
|
|
41
|
-
@ReactMethod
|
|
42
34
|
fun startSpan(operation: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
43
35
|
val span = tracer.buildSpan(operation)
|
|
44
36
|
.withStartTimestamp(TimeUnit.MILLISECONDS.toMicros(timestampMs.toLong()))
|
|
@@ -59,7 +51,6 @@ class DdTrace(
|
|
|
59
51
|
* @param context The additional context to send.
|
|
60
52
|
* @param timestampMs The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
61
53
|
*/
|
|
62
|
-
@ReactMethod
|
|
63
54
|
fun finishSpan(spanId: String, context: ReadableMap, timestampMs: Double, promise: Promise) {
|
|
64
55
|
val span = spanMap.remove(spanId)
|
|
65
56
|
if (span == null) {
|
|
@@ -83,4 +74,8 @@ class DdTrace(
|
|
|
83
74
|
}
|
|
84
75
|
}
|
|
85
76
|
}
|
|
77
|
+
|
|
78
|
+
companion object {
|
|
79
|
+
internal const val NAME = "DdTrace"
|
|
80
|
+
}
|
|
86
81
|
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
package com.datadog.reactnative
|
|
8
|
+
|
|
9
|
+
import com.facebook.react.bridge.Promise
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
+
import com.facebook.react.bridge.ReactMethod
|
|
12
|
+
import com.facebook.react.bridge.ReadableMap
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The entry point to use Datadog's Logs feature.
|
|
16
|
+
*/
|
|
17
|
+
class DdLogs(
|
|
18
|
+
reactContext: ReactApplicationContext
|
|
19
|
+
) : NativeDdLogsSpec(reactContext) {
|
|
20
|
+
|
|
21
|
+
private val implementation = DdLogsImplementation()
|
|
22
|
+
|
|
23
|
+
override fun getName(): String = DdLogsImplementation.NAME
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Send a log with Debug level.
|
|
27
|
+
* @param message The message to send.
|
|
28
|
+
* @param context The additional context to send.
|
|
29
|
+
*/
|
|
30
|
+
@ReactMethod
|
|
31
|
+
override fun debug(message: String, context: ReadableMap, promise: Promise) {
|
|
32
|
+
implementation.debug(message, context, promise)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Send a log with Info level.
|
|
37
|
+
* @param message The message to send.
|
|
38
|
+
* @param context The additional context to send.
|
|
39
|
+
*/
|
|
40
|
+
@ReactMethod
|
|
41
|
+
override fun info(message: String, context: ReadableMap, promise: Promise) {
|
|
42
|
+
implementation.info(message, context, promise)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Send a log with Warn level.
|
|
47
|
+
* @param message The message to send.
|
|
48
|
+
* @param context The additional context to send.
|
|
49
|
+
*/
|
|
50
|
+
@ReactMethod
|
|
51
|
+
override fun warn(message: String, context: ReadableMap, promise: Promise) {
|
|
52
|
+
implementation.warn(message, context, promise)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Send a log with Error level.
|
|
57
|
+
* @param message The message to send.
|
|
58
|
+
* @param context The additional context to send.
|
|
59
|
+
*/
|
|
60
|
+
@ReactMethod
|
|
61
|
+
override fun error(message: String, context: ReadableMap, promise: Promise) {
|
|
62
|
+
implementation.error(message, context, promise)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Send a log containing an error with Debug level.
|
|
67
|
+
* @param message The message to send.
|
|
68
|
+
* @param errorKind The error kind to send.
|
|
69
|
+
* @param errorMessage The error message to send.
|
|
70
|
+
* @param stacktrace The error stacktrace to send.
|
|
71
|
+
* @param context The additional context to send.
|
|
72
|
+
*/
|
|
73
|
+
@Suppress("LongParameterList")
|
|
74
|
+
@ReactMethod
|
|
75
|
+
override fun debugWithError(
|
|
76
|
+
message: String,
|
|
77
|
+
errorKind: String?,
|
|
78
|
+
errorMessage: String?,
|
|
79
|
+
stacktrace: String?,
|
|
80
|
+
context: ReadableMap,
|
|
81
|
+
promise: Promise
|
|
82
|
+
) {
|
|
83
|
+
implementation.debugWithError(message, errorKind, errorMessage, stacktrace, context, promise)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Send a log with containing an error with Info level.
|
|
88
|
+
* @param message The message to send.
|
|
89
|
+
* @param errorKind The error kind to send.
|
|
90
|
+
* @param errorMessage The error message to send.
|
|
91
|
+
* @param stacktrace The error stacktrace to send.
|
|
92
|
+
* @param context The additional context to send.
|
|
93
|
+
*/
|
|
94
|
+
@Suppress("LongParameterList")
|
|
95
|
+
@ReactMethod
|
|
96
|
+
override fun infoWithError(
|
|
97
|
+
message: String,
|
|
98
|
+
errorKind: String?,
|
|
99
|
+
errorMessage: String?,
|
|
100
|
+
stacktrace: String?,
|
|
101
|
+
context: ReadableMap,
|
|
102
|
+
promise: Promise
|
|
103
|
+
) {
|
|
104
|
+
implementation.infoWithError(message, errorKind, errorMessage, stacktrace, context, promise)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Send a log containing an error with Warn level.
|
|
109
|
+
* @param message The message to send.
|
|
110
|
+
* @param errorKind The error kind to send.
|
|
111
|
+
* @param errorMessage The error message to send.
|
|
112
|
+
* @param stacktrace The error stacktrace to send.
|
|
113
|
+
* @param context The additional context to send.
|
|
114
|
+
*/
|
|
115
|
+
@Suppress("LongParameterList")
|
|
116
|
+
@ReactMethod
|
|
117
|
+
override fun warnWithError(
|
|
118
|
+
message: String,
|
|
119
|
+
errorKind: String?,
|
|
120
|
+
errorMessage: String?,
|
|
121
|
+
stacktrace: String?,
|
|
122
|
+
context: ReadableMap,
|
|
123
|
+
promise: Promise
|
|
124
|
+
) {
|
|
125
|
+
implementation.warnWithError(message, errorKind, errorMessage, stacktrace, context, promise)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Send a log containing an error with Error level.
|
|
130
|
+
* @param message The message to send.
|
|
131
|
+
* @param errorKind The error kind to send.
|
|
132
|
+
* @param errorMessage The error message to send.
|
|
133
|
+
* @param stacktrace The error stacktrace to send.
|
|
134
|
+
* @param context The additional context to send.
|
|
135
|
+
*/
|
|
136
|
+
@Suppress("LongParameterList")
|
|
137
|
+
@ReactMethod
|
|
138
|
+
override fun errorWithError(
|
|
139
|
+
message: String,
|
|
140
|
+
errorKind: String?,
|
|
141
|
+
errorMessage: String?,
|
|
142
|
+
stacktrace: String?,
|
|
143
|
+
context: ReadableMap,
|
|
144
|
+
promise: Promise
|
|
145
|
+
) {
|
|
146
|
+
implementation.errorWithError(message, errorKind, errorMessage, stacktrace, context, promise)
|
|
147
|
+
}
|
|
148
|
+
}
|