@datadog/mobile-react-native 1.5.2 → 1.7.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 +2 -1
- package/android/gradle.properties +1 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +4 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +6 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdLogs.kt +162 -6
- package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +25 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +32 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +11 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +10 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +242 -2
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +27 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +126 -30
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +19 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +2 -2
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +18 -1
- package/ios/Sources/Attributes.swift +7 -0
- package/ios/Sources/DdLogs.m +31 -0
- package/ios/Sources/DdLogs.swift +84 -4
- package/ios/Sources/DdRum.m +8 -0
- package/ios/Sources/DdRum.swift +17 -0
- package/ios/Sources/DdSdk.swift +40 -0
- package/ios/Sources/DdSdkConfiguration.swift +19 -1
- package/ios/Sources/RNDdSdkConfiguration.swift +11 -1
- package/lib/commonjs/DdSdkReactNative.js +6 -2
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +45 -2
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/InternalLog.js +6 -2
- package/lib/commonjs/InternalLog.js.map +1 -1
- package/lib/commonjs/errorUtils.js +20 -1
- package/lib/commonjs/errorUtils.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +102 -11
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/logs/eventMapper.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +14 -0
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +62 -46
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +2 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js +9 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map +1 -1
- package/lib/commonjs/rum/types.js.map +1 -1
- package/lib/commonjs/types.js +4 -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 +6 -2
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +42 -1
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/InternalLog.js +2 -1
- package/lib/module/InternalLog.js.map +1 -1
- package/lib/module/errorUtils.js +15 -0
- package/lib/module/errorUtils.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/logs/DdLogs.js +103 -12
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/logs/eventMapper.js.map +1 -1
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +12 -0
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +63 -46
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +2 -2
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js +9 -1
- package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map +1 -1
- package/lib/module/rum/types.js.map +1 -1
- package/lib/module/types.js +4 -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 +47 -0
- package/lib/typescript/InternalLog.d.ts +1 -0
- package/lib/typescript/errorUtils.d.ts +2 -0
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/logs/DdLogs.d.ts +13 -5
- package/lib/typescript/logs/eventMapper.d.ts +5 -5
- package/lib/typescript/logs/types.d.ts +34 -8
- package/lib/typescript/nativeModulesTypes.d.ts +51 -4
- package/lib/typescript/rum/DdRum.d.ts +2 -0
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +3 -2
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.d.ts +5 -2
- package/lib/typescript/rum/types.d.ts +4 -0
- package/lib/typescript/types.d.ts +8 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +9 -1
- package/src/DdSdkReactNativeConfiguration.tsx +56 -1
- package/src/InternalLog.tsx +3 -1
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +20 -3
- package/src/__tests__/errorUtils.test.ts +49 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +14 -14
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +474 -109
- package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +18 -0
- package/src/errorUtils.ts +15 -0
- package/src/index.tsx +6 -2
- package/src/logs/DdLogs.ts +166 -16
- package/src/logs/__tests__/DdLogs.test.ts +169 -0
- package/src/logs/__tests__/eventMapper.test.ts +34 -0
- package/src/logs/eventMapper.ts +15 -4
- package/src/logs/types.ts +36 -8
- package/src/nativeModulesTypes.ts +81 -4
- package/src/rum/DdRum.ts +17 -0
- package/src/rum/__tests__/DdRum.test.ts +12 -27
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +44 -10
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +7 -4
- package/src/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.ts +11 -3
- package/src/rum/types.ts +5 -0
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +5 -0
- package/src/types.tsx +5 -0
- package/src/version.ts +1 -1
|
@@ -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.20.0'
|
|
21
|
+
s.dependency 'DatadogSDKCrashReporting', '~> 1.20.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
|
@@ -146,10 +146,11 @@ 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.19.2"
|
|
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"
|
|
153
|
+
testImplementation "org.junit.jupiter:junit-jupiter-params:5.6.2"
|
|
153
154
|
testImplementation "org.mockito:mockito-junit-jupiter:3.4.6"
|
|
154
155
|
testImplementation "org.assertj:assertj-core:3.18.1"
|
|
155
156
|
testImplementation "com.github.xgouchet.Elmyr:core:1.3.1"
|
|
@@ -16,7 +16,7 @@ import java.lang.IllegalArgumentException
|
|
|
16
16
|
/**
|
|
17
17
|
* Wrapper around [Datadog].
|
|
18
18
|
*/
|
|
19
|
-
@Suppress("ComplexInterface")
|
|
19
|
+
@Suppress("ComplexInterface", "TooManyFunctions")
|
|
20
20
|
interface DatadogWrapper {
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -104,4 +104,9 @@ interface DatadogWrapper {
|
|
|
104
104
|
* Sends Webview events.
|
|
105
105
|
*/
|
|
106
106
|
fun consumeWebviewEvent(message: String)
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Returns whether the SDK is initialized.
|
|
110
|
+
*/
|
|
111
|
+
fun isInitialized(): Boolean
|
|
107
112
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
package com.datadog.reactnative
|
|
8
8
|
|
|
9
|
+
import android.util.Log as AndroidLog
|
|
9
10
|
import com.datadog.android.log.Logger
|
|
10
11
|
import com.facebook.react.bridge.Promise
|
|
11
12
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -16,8 +17,11 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
16
17
|
/**
|
|
17
18
|
* The entry point to use Datadog's Logs feature.
|
|
18
19
|
*/
|
|
19
|
-
class DdLogs(
|
|
20
|
-
|
|
20
|
+
class DdLogs(
|
|
21
|
+
reactContext: ReactApplicationContext,
|
|
22
|
+
logger: Logger? = null,
|
|
23
|
+
private val datadog: DatadogWrapper = DatadogSDKWrapper()
|
|
24
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
21
25
|
|
|
22
26
|
override fun getName(): String = "DdLogs"
|
|
23
27
|
|
|
@@ -30,12 +34,16 @@ class DdLogs(reactContext: ReactApplicationContext, logger: Logger? = null) :
|
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
|
-
* Send a log with level
|
|
37
|
+
* Send a log with Debug level.
|
|
34
38
|
* @param message The message to send.
|
|
35
39
|
* @param context The additional context to send.
|
|
36
40
|
*/
|
|
37
41
|
@ReactMethod
|
|
38
42
|
fun debug(message: String, context: ReadableMap, promise: Promise) {
|
|
43
|
+
if (!datadog.isInitialized()) {
|
|
44
|
+
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
45
|
+
return
|
|
46
|
+
}
|
|
39
47
|
reactNativeLogger.d(
|
|
40
48
|
message = message,
|
|
41
49
|
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
@@ -44,12 +52,16 @@ class DdLogs(reactContext: ReactApplicationContext, logger: Logger? = null) :
|
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
/**
|
|
47
|
-
* Send a log with level
|
|
55
|
+
* Send a log with Info level.
|
|
48
56
|
* @param message The message to send.
|
|
49
57
|
* @param context The additional context to send.
|
|
50
58
|
*/
|
|
51
59
|
@ReactMethod
|
|
52
60
|
fun info(message: String, context: ReadableMap, promise: Promise) {
|
|
61
|
+
if (!datadog.isInitialized()) {
|
|
62
|
+
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
63
|
+
return
|
|
64
|
+
}
|
|
53
65
|
reactNativeLogger.i(
|
|
54
66
|
message = message,
|
|
55
67
|
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
@@ -58,12 +70,16 @@ class DdLogs(reactContext: ReactApplicationContext, logger: Logger? = null) :
|
|
|
58
70
|
}
|
|
59
71
|
|
|
60
72
|
/**
|
|
61
|
-
* Send a log with level
|
|
73
|
+
* Send a log with Warn level.
|
|
62
74
|
* @param message The message to send.
|
|
63
75
|
* @param context The additional context to send.
|
|
64
76
|
*/
|
|
65
77
|
@ReactMethod
|
|
66
78
|
fun warn(message: String, context: ReadableMap, promise: Promise) {
|
|
79
|
+
if (!datadog.isInitialized()) {
|
|
80
|
+
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
81
|
+
return
|
|
82
|
+
}
|
|
67
83
|
reactNativeLogger.w(
|
|
68
84
|
message = message,
|
|
69
85
|
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
@@ -72,16 +88,156 @@ class DdLogs(reactContext: ReactApplicationContext, logger: Logger? = null) :
|
|
|
72
88
|
}
|
|
73
89
|
|
|
74
90
|
/**
|
|
75
|
-
* Send a log with level
|
|
91
|
+
* Send a log with Error level.
|
|
76
92
|
* @param message The message to send.
|
|
77
93
|
* @param context The additional context to send.
|
|
78
94
|
*/
|
|
79
95
|
@ReactMethod
|
|
80
96
|
fun error(message: String, context: ReadableMap, promise: Promise) {
|
|
97
|
+
if (!datadog.isInitialized()) {
|
|
98
|
+
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
99
|
+
return
|
|
100
|
+
}
|
|
81
101
|
reactNativeLogger.e(
|
|
82
102
|
message = message,
|
|
83
103
|
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
84
104
|
)
|
|
85
105
|
promise.resolve(null)
|
|
86
106
|
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Send a log containing an error with Debug level.
|
|
110
|
+
* @param message The message to send.
|
|
111
|
+
* @param errorKind The error kind to send.
|
|
112
|
+
* @param errorMessage The error message to send.
|
|
113
|
+
* @param stacktrace The error stacktrace to send.
|
|
114
|
+
* @param context The additional context to send.
|
|
115
|
+
*/
|
|
116
|
+
@Suppress("LongParameterList")
|
|
117
|
+
@ReactMethod
|
|
118
|
+
fun debugWithError(
|
|
119
|
+
message: String,
|
|
120
|
+
errorKind: String?,
|
|
121
|
+
errorMessage: String?,
|
|
122
|
+
stacktrace: String?,
|
|
123
|
+
context: ReadableMap,
|
|
124
|
+
promise: Promise
|
|
125
|
+
) {
|
|
126
|
+
if (!datadog.isInitialized()) {
|
|
127
|
+
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
reactNativeLogger.log(
|
|
131
|
+
priority = AndroidLog.DEBUG,
|
|
132
|
+
message = message,
|
|
133
|
+
errorKind = errorKind,
|
|
134
|
+
errorMessage = errorMessage,
|
|
135
|
+
errorStacktrace = stacktrace,
|
|
136
|
+
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
137
|
+
)
|
|
138
|
+
promise.resolve(null)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Send a log with containing an error with Info level.
|
|
143
|
+
* @param message The message to send.
|
|
144
|
+
* @param errorKind The error kind to send.
|
|
145
|
+
* @param errorMessage The error message to send.
|
|
146
|
+
* @param stacktrace The error stacktrace to send.
|
|
147
|
+
* @param context The additional context to send.
|
|
148
|
+
*/
|
|
149
|
+
@Suppress("LongParameterList")
|
|
150
|
+
@ReactMethod
|
|
151
|
+
fun infoWithError(
|
|
152
|
+
message: String,
|
|
153
|
+
errorKind: String?,
|
|
154
|
+
errorMessage: String?,
|
|
155
|
+
stacktrace: String?,
|
|
156
|
+
context: ReadableMap,
|
|
157
|
+
promise: Promise
|
|
158
|
+
) {
|
|
159
|
+
if (!datadog.isInitialized()) {
|
|
160
|
+
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
reactNativeLogger.log(
|
|
164
|
+
priority = AndroidLog.INFO,
|
|
165
|
+
message = message,
|
|
166
|
+
errorKind = errorKind,
|
|
167
|
+
errorMessage = errorMessage,
|
|
168
|
+
errorStacktrace = stacktrace,
|
|
169
|
+
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
170
|
+
)
|
|
171
|
+
promise.resolve(null)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Send a log containing an error with Warn level.
|
|
176
|
+
* @param message The message to send.
|
|
177
|
+
* @param errorKind The error kind to send.
|
|
178
|
+
* @param errorMessage The error message to send.
|
|
179
|
+
* @param stacktrace The error stacktrace to send.
|
|
180
|
+
* @param context The additional context to send.
|
|
181
|
+
*/
|
|
182
|
+
@Suppress("LongParameterList")
|
|
183
|
+
@ReactMethod
|
|
184
|
+
fun warnWithError(
|
|
185
|
+
message: String,
|
|
186
|
+
errorKind: String?,
|
|
187
|
+
errorMessage: String?,
|
|
188
|
+
stacktrace: String?,
|
|
189
|
+
context: ReadableMap,
|
|
190
|
+
promise: Promise
|
|
191
|
+
) {
|
|
192
|
+
if (!datadog.isInitialized()) {
|
|
193
|
+
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
reactNativeLogger.log(
|
|
197
|
+
priority = AndroidLog.WARN,
|
|
198
|
+
message = message,
|
|
199
|
+
errorKind = errorKind,
|
|
200
|
+
errorMessage = errorMessage,
|
|
201
|
+
errorStacktrace = stacktrace,
|
|
202
|
+
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
203
|
+
)
|
|
204
|
+
promise.resolve(null)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Send a log containing an error with Error level.
|
|
209
|
+
* @param message The message to send.
|
|
210
|
+
* @param errorKind The error kind to send.
|
|
211
|
+
* @param errorMessage The error message to send.
|
|
212
|
+
* @param stacktrace The error stacktrace to send.
|
|
213
|
+
* @param context The additional context to send.
|
|
214
|
+
*/
|
|
215
|
+
@Suppress("LongParameterList")
|
|
216
|
+
@ReactMethod
|
|
217
|
+
fun errorWithError(
|
|
218
|
+
message: String,
|
|
219
|
+
errorKind: String?,
|
|
220
|
+
errorMessage: String?,
|
|
221
|
+
stacktrace: String?,
|
|
222
|
+
context: ReadableMap,
|
|
223
|
+
promise: Promise
|
|
224
|
+
) {
|
|
225
|
+
if (!datadog.isInitialized()) {
|
|
226
|
+
promise.reject(IllegalStateException(SDK_NOT_INITIALIZED_MESSAGE))
|
|
227
|
+
return
|
|
228
|
+
}
|
|
229
|
+
reactNativeLogger.log(
|
|
230
|
+
priority = AndroidLog.ERROR,
|
|
231
|
+
message = message,
|
|
232
|
+
errorKind = errorKind,
|
|
233
|
+
errorMessage = errorMessage,
|
|
234
|
+
errorStacktrace = stacktrace,
|
|
235
|
+
attributes = context.toHashMap() + GlobalState.globalAttributes
|
|
236
|
+
)
|
|
237
|
+
promise.resolve(null)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
companion object {
|
|
241
|
+
private const val SDK_NOT_INITIALIZED_MESSAGE = "DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT"
|
|
242
|
+
}
|
|
87
243
|
}
|
|
@@ -21,6 +21,7 @@ import java.util.Locale
|
|
|
21
21
|
/**
|
|
22
22
|
* The entry point to use Datadog's RUM feature.
|
|
23
23
|
*/
|
|
24
|
+
@Suppress("TooManyFunctions")
|
|
24
25
|
class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
25
26
|
|
|
26
27
|
override fun getName(): String = "DdRum"
|
|
@@ -255,6 +256,30 @@ class DdRum(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
|
|
|
255
256
|
promise.resolve(null)
|
|
256
257
|
}
|
|
257
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Stops the current RUM Session.
|
|
261
|
+
*/
|
|
262
|
+
@ReactMethod
|
|
263
|
+
fun stopSession(promise: Promise) {
|
|
264
|
+
GlobalRum.get().stopSession()
|
|
265
|
+
promise.resolve(null)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Adds result of evaluating a feature flag to the view.
|
|
270
|
+
* Feature flag evaluations are local to the active view and are cleared when the view is stopped.
|
|
271
|
+
* @param name The name of the feature flag
|
|
272
|
+
* @param value The value the feature flag evaluated to, encapsulated in a Map
|
|
273
|
+
*/
|
|
274
|
+
@ReactMethod
|
|
275
|
+
fun addFeatureFlagEvaluation(name: String, value: ReadableMap, promise: Promise) {
|
|
276
|
+
val value = value.toHashMap()["value"]
|
|
277
|
+
if (value != null) {
|
|
278
|
+
GlobalRum.get().addFeatureFlagEvaluation(name, value)
|
|
279
|
+
}
|
|
280
|
+
promise.resolve(null)
|
|
281
|
+
}
|
|
282
|
+
|
|
258
283
|
// region Internal
|
|
259
284
|
|
|
260
285
|
private fun String.asRumActionType(): RumActionType {
|
|
@@ -12,8 +12,10 @@ import android.util.Log
|
|
|
12
12
|
import android.view.Choreographer
|
|
13
13
|
import com.datadog.android.DatadogSite
|
|
14
14
|
import com.datadog.android._InternalProxy
|
|
15
|
+
import com.datadog.android.core.configuration.BatchSize
|
|
15
16
|
import com.datadog.android.core.configuration.Configuration
|
|
16
17
|
import com.datadog.android.core.configuration.Credentials
|
|
18
|
+
import com.datadog.android.core.configuration.UploadFrequency
|
|
17
19
|
import com.datadog.android.core.configuration.VitalsUpdateFrequency
|
|
18
20
|
import com.datadog.android.event.EventMapper
|
|
19
21
|
import com.datadog.android.privacy.TrackingConsent
|
|
@@ -209,11 +211,18 @@ class DdSdk(
|
|
|
209
211
|
}
|
|
210
212
|
|
|
211
213
|
configBuilder.trackFrustrations(configuration.trackFrustrations ?: true)
|
|
214
|
+
configBuilder.trackBackgroundRumEvents(configuration.trackBackgroundEvents ?: false)
|
|
212
215
|
|
|
213
216
|
configBuilder.useSite(buildSite(configuration.site))
|
|
214
217
|
configBuilder.setVitalsUpdateFrequency(
|
|
215
218
|
buildVitalUpdateFrequency(configuration.vitalsUpdateFrequency)
|
|
216
219
|
)
|
|
220
|
+
configBuilder.setUploadFrequency(
|
|
221
|
+
buildUploadFrequency(configuration.uploadFrequency)
|
|
222
|
+
)
|
|
223
|
+
configBuilder.setBatchSize(
|
|
224
|
+
buildBatchSize(configuration.batchSize)
|
|
225
|
+
)
|
|
217
226
|
|
|
218
227
|
val telemetrySampleRate = (configuration.telemetrySampleRate as? Number)?.toFloat()
|
|
219
228
|
telemetrySampleRate?.let { configBuilder.sampleTelemetry(it) }
|
|
@@ -303,6 +312,10 @@ class DdSdk(
|
|
|
303
312
|
configuration.configurationForTelemetry?.trackNetworkRequests
|
|
304
313
|
event.telemetry.configuration.trackNetworkRequests =
|
|
305
314
|
configuration.configurationForTelemetry?.trackNetworkRequests
|
|
315
|
+
event.telemetry.configuration.reactVersion =
|
|
316
|
+
configuration.configurationForTelemetry?.reactVersion
|
|
317
|
+
event.telemetry.configuration.reactNativeVersion =
|
|
318
|
+
configuration.configurationForTelemetry?.reactNativeVersion
|
|
306
319
|
|
|
307
320
|
return event
|
|
308
321
|
}
|
|
@@ -433,6 +446,25 @@ class DdSdk(
|
|
|
433
446
|
}
|
|
434
447
|
}
|
|
435
448
|
|
|
449
|
+
private fun buildUploadFrequency(uploadFrequency: String?): UploadFrequency {
|
|
450
|
+
val uploadFrequency = uploadFrequency?.lowercase(Locale.US)
|
|
451
|
+
return when (uploadFrequency) {
|
|
452
|
+
"rare" -> UploadFrequency.RARE
|
|
453
|
+
"average" -> UploadFrequency.AVERAGE
|
|
454
|
+
"frequent" -> UploadFrequency.FREQUENT
|
|
455
|
+
else -> UploadFrequency.AVERAGE
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
private fun buildBatchSize(batchSize: String?): BatchSize {
|
|
460
|
+
return when (batchSize?.lowercase(Locale.US)) {
|
|
461
|
+
"small" -> BatchSize.SMALL
|
|
462
|
+
"medium" -> BatchSize.MEDIUM
|
|
463
|
+
"large" -> BatchSize.LARGE
|
|
464
|
+
else -> BatchSize.MEDIUM
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
436
468
|
private fun handlePostFrameCallbackError(e: IllegalStateException) {
|
|
437
469
|
datadog.telemetryError(e.message ?: MONITOR_JS_ERROR_MESSAGE, e)
|
|
438
470
|
}
|
|
@@ -20,6 +20,9 @@ package com.datadog.reactnative
|
|
|
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
22
|
* @param trackFrustrations Whether to track frustration signals or not.
|
|
23
|
+
* @param uploadFrequency The frequency to which batches of data are sent (can be 'RARE', 'AVERAGE' (default), 'FREQUENT')
|
|
24
|
+
* @param batchSize The preferred size for uploaded batches of data (can be 'SMALL', 'MEDIUM' (default), 'LARGE')
|
|
25
|
+
* @param trackBackgroundEvents Enables/Disables tracking RUM event when no RUM View is active. Might increase number of sessions and billing.
|
|
23
26
|
* @param additionalConfig Additional configuration parameters.
|
|
24
27
|
* @param configurationForTelemetry Additional configuration data for Datadog telemetry.
|
|
25
28
|
*/
|
|
@@ -36,6 +39,9 @@ data class DdSdkConfiguration(
|
|
|
36
39
|
val telemetrySampleRate: Double? = null,
|
|
37
40
|
val vitalsUpdateFrequency: String? = null,
|
|
38
41
|
val trackFrustrations: Boolean? = null,
|
|
42
|
+
val uploadFrequency: String? = null,
|
|
43
|
+
val batchSize: String? = null,
|
|
44
|
+
val trackBackgroundEvents: Boolean? = null,
|
|
39
45
|
val additionalConfig: Map<String, Any?>? = null,
|
|
40
46
|
val configurationForTelemetry: ConfigurationForTelemetry? = null
|
|
41
47
|
)
|
|
@@ -46,10 +52,14 @@ data class DdSdkConfiguration(
|
|
|
46
52
|
* @param trackErrors Whether JS errors are tracked.
|
|
47
53
|
* @param trackInteractions Whether interactions are tracked.
|
|
48
54
|
* @param trackNetworkRequests Whether network requests are tracked.
|
|
55
|
+
* @param reactVersion Version of react used in app.
|
|
56
|
+
* @param reactNativeVersion Version of react-native used in app.
|
|
49
57
|
*/
|
|
50
58
|
data class ConfigurationForTelemetry(
|
|
51
59
|
val initializationType: String? = null,
|
|
52
60
|
val trackErrors: Boolean? = null,
|
|
53
61
|
val trackInteractions: Boolean? = null,
|
|
54
|
-
val trackNetworkRequests: Boolean? = null
|
|
62
|
+
val trackNetworkRequests: Boolean? = null,
|
|
63
|
+
val reactVersion: String? = null,
|
|
64
|
+
val reactNativeVersion: String? = null
|
|
55
65
|
)
|
|
@@ -25,6 +25,9 @@ internal fun ReadableMap.asDdSdkConfiguration(): DdSdkConfiguration {
|
|
|
25
25
|
telemetrySampleRate = getDouble("telemetrySampleRate"),
|
|
26
26
|
vitalsUpdateFrequency = getString("vitalsUpdateFrequency"),
|
|
27
27
|
trackFrustrations = getBoolean("trackFrustrations"),
|
|
28
|
+
uploadFrequency = getString("uploadFrequency"),
|
|
29
|
+
batchSize = getString("batchSize"),
|
|
30
|
+
trackBackgroundEvents = getBoolean("trackBackgroundEvents"),
|
|
28
31
|
additionalConfig = getMap("additionalConfig")?.toHashMap(),
|
|
29
32
|
configurationForTelemetry = getMap(
|
|
30
33
|
"configurationForTelemetry"
|
|
@@ -38,6 +41,8 @@ internal fun ReadableMap.asConfigurationForTelemetry(): ConfigurationForTelemetr
|
|
|
38
41
|
trackErrors = getBoolean("trackErrors"),
|
|
39
42
|
trackInteractions = getBoolean("trackInteractions"),
|
|
40
43
|
trackNetworkRequests = getBoolean("trackNetworkRequests"),
|
|
44
|
+
reactVersion = getString("reactVersion"),
|
|
45
|
+
reactNativeVersion = getString("reactNativeVersion"),
|
|
41
46
|
)
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -68,6 +73,9 @@ internal fun DdSdkConfiguration.toReadableMap(): ReadableMap {
|
|
|
68
73
|
telemetrySampleRate?.let { map.putDouble("telemetrySampleRate", it) }
|
|
69
74
|
vitalsUpdateFrequency?.let { map.putString("vitalsUpdateFrequency", it) }
|
|
70
75
|
trackFrustrations?.let { map.putBoolean("trackFrustrations", it) }
|
|
76
|
+
uploadFrequency?.let { map.putString("uploadFrequency", it) }
|
|
77
|
+
batchSize?.let { map.putString("batchSize", it) }
|
|
78
|
+
trackBackgroundEvents?.let { map.putBoolean("trackBackgroundEvents", it) }
|
|
71
79
|
additionalConfig?.let { map.putMap("additionalConfig", it.toWritableMap()) }
|
|
72
80
|
return map
|
|
73
81
|
}
|
|
@@ -78,5 +86,7 @@ internal fun ConfigurationForTelemetry.toReadableMap(): ReadableMap {
|
|
|
78
86
|
trackErrors?.let { map.putBoolean("trackErrors", it) }
|
|
79
87
|
trackInteractions?.let { map.putBoolean("trackInteractions", it) }
|
|
80
88
|
trackNetworkRequests?.let { map.putBoolean("trackNetworkRequests", it) }
|
|
89
|
+
reactVersion?.let { map.putString("reactVersion", it) }
|
|
90
|
+
reactNativeVersion?.let { map.putString("reactNativeVersion", it) }
|
|
81
91
|
return map
|
|
82
92
|
}
|