@datadog/mobile-react-native 3.5.4 → 3.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 +7 -7
- package/README.md +10 -0
- package/android/build.gradle +22 -9
- package/android/src/main/kotlin/com/datadog/reactnative/DdFlagsImplementation.kt +7 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +23 -4
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +3 -2
- package/android/src/main/kotlin/com/datadog/reactnative/HeatmapActionHandler.kt +121 -0
- package/android/src/main/kotlin/com/datadog/reactnative/HeatmapTouchResolver.kt +108 -0
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +19 -2
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +1 -1
- package/android/src/oldarch/kotlin/com/datadog/reactnative/HeatmapViewResolverFactory.kt +38 -0
- package/android/src/oldarch65/kotlin/com/datadog/reactnative/HeatmapViewResolverFactory.kt +20 -0
- package/android/src/{oldarch → oldarchCommon}/kotlin/com/datadog/reactnative/DdRum.kt +15 -2
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +482 -0
- package/android/src/test/kotlin/com/datadog/reactnative/HeatmapTouchResolverTest.kt +529 -0
- package/datadog-configuration.schema.json +4 -0
- package/ios/Sources/DdSdk.mm +2 -0
- package/ios/Sources/DdSdkImplementation.swift +0 -1
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +3 -1
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/config/FileBasedConfiguration.js +1 -0
- package/lib/commonjs/config/FileBasedConfiguration.js.map +1 -1
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js +1 -0
- package/lib/commonjs/config/async/AutoInstrumentationConfiguration.js.map +1 -1
- package/lib/commonjs/config/features/RumConfiguration.js +4 -0
- package/lib/commonjs/config/features/RumConfiguration.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +27 -13
- package/lib/commonjs/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +270 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +38 -72
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.js +33 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +39 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/ResourceReporter.js +4 -4
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/internalDevResourceBlocklist.js +0 -18
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/internalDevResourceBlocklist.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.js +109 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/resourceTiming.js +0 -9
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/common/resourceTiming.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +3 -1
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/config/FileBasedConfiguration.js +1 -0
- package/lib/module/config/FileBasedConfiguration.js.map +1 -1
- package/lib/module/config/async/AutoInstrumentationConfiguration.js +1 -0
- package/lib/module/config/async/AutoInstrumentationConfiguration.js.map +1 -1
- package/lib/module/config/features/RumConfiguration.js +4 -0
- package/lib/module/config/features/RumConfiguration.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js +27 -13
- package/lib/module/rum/instrumentation/resourceTracking/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js +263 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js +38 -72
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.js +25 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js +32 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/ResourceReporter.js +4 -4
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/internalDevResourceBlocklist.js +0 -18
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/internalDevResourceBlocklist.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.js +101 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.js.map +1 -0
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/resourceTiming.js +0 -9
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/common/resourceTiming.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/config/FileBasedConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts +1 -0
- package/lib/typescript/config/FileBasedConfiguration.type.d.ts.map +1 -1
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts +2 -0
- package/lib/typescript/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfiguration.d.ts +2 -0
- package/lib/typescript/config/features/RumConfiguration.d.ts.map +1 -1
- package/lib/typescript/config/features/RumConfiguration.type.d.ts +7 -0
- package/lib/typescript/config/features/RumConfiguration.type.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +3 -2
- package/lib/typescript/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.d.ts +29 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.d.ts +8 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts +20 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/ResourceReporter.d.ts +2 -2
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/ResourceReporter.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/internalDevResourceBlocklist.d.ts +3 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/internalDevResourceBlocklist.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.d.ts +18 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.d.ts.map +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/resourceTiming.d.ts +0 -6
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/common/resourceTiming.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +11 -2
- package/src/DdSdkReactNative.tsx +5 -1
- package/src/__tests__/DdSdkReactNative.test.tsx +5 -2
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -0
- package/src/config/FileBasedConfiguration.ts +2 -0
- package/src/config/FileBasedConfiguration.type.ts +1 -0
- package/src/config/__tests__/FileBasedConfiguration.test.ts +3 -0
- package/src/config/__tests__/__fixtures__/configuration-all-fields.json +1 -0
- package/src/config/async/AutoInstrumentationConfiguration.ts +5 -0
- package/src/config/features/RumConfiguration.ts +4 -0
- package/src/config/features/RumConfiguration.type.ts +8 -0
- package/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx +38 -13
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +101 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/FetchProxy.ts +316 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/FetchProxy/__tests__/FetchProxy.test.ts +393 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/__tests__/ResourceReporter.test.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/__tests__/internalDevResourceBlocklist.test.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts +49 -115
- package/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/XHRProxy.test.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/FetchProxyState.ts +25 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.ts +54 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/ResourceReporter.ts +5 -5
- package/src/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/internalDevResourceBlocklist.ts +1 -17
- package/src/rum/instrumentation/resourceTracking/requestProxy/common/requestHeaders.ts +106 -0
- package/src/rum/instrumentation/resourceTracking/requestProxy/{XHRProxy/DatadogRumResource → common}/resourceTiming.ts +0 -18
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +1 -0
- package/src/version.ts +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +0 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.js.map +0 -1
- package/lib/module/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.js.map +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.d.ts.map +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.d.ts +0 -7
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.d.ts.map +0 -1
- package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.d.ts.map +0 -1
- /package/android/src/{oldarch → oldarchCommon}/kotlin/com/datadog/reactnative/DdFlags.kt +0 -0
- /package/android/src/{oldarch → oldarchCommon}/kotlin/com/datadog/reactnative/DdLogs.kt +0 -0
- /package/android/src/{oldarch → oldarchCommon}/kotlin/com/datadog/reactnative/DdSdk.kt +0 -0
- /package/android/src/{oldarch → oldarchCommon}/kotlin/com/datadog/reactnative/DdTrace.kt +0 -0
|
@@ -19,15 +19,15 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
20
|
|
|
21
21
|
# /!\ Remember to keep the versions in sync with DatadogSDKReactNativeSessionReplay.podspec
|
|
22
|
-
s.dependency 'DatadogCore', '3.
|
|
23
|
-
s.dependency 'DatadogLogs', '3.
|
|
24
|
-
s.dependency 'DatadogTrace', '3.
|
|
25
|
-
s.dependency 'DatadogRUM', '3.
|
|
26
|
-
s.dependency 'DatadogCrashReporting', '3.
|
|
27
|
-
s.dependency 'DatadogFlags', '3.
|
|
22
|
+
s.dependency 'DatadogCore', '3.16.0'
|
|
23
|
+
s.dependency 'DatadogLogs', '3.16.0'
|
|
24
|
+
s.dependency 'DatadogTrace', '3.16.0'
|
|
25
|
+
s.dependency 'DatadogRUM', '3.16.0'
|
|
26
|
+
s.dependency 'DatadogCrashReporting', '3.16.0'
|
|
27
|
+
s.dependency 'DatadogFlags', '3.16.0'
|
|
28
28
|
|
|
29
29
|
# DatadogWebViewTracking is not available for tvOS
|
|
30
|
-
s.ios.dependency 'DatadogWebViewTracking', '3.
|
|
30
|
+
s.ios.dependency 'DatadogWebViewTracking', '3.16.0'
|
|
31
31
|
|
|
32
32
|
s.test_spec 'Tests' do |test_spec|
|
|
33
33
|
test_spec.source_files = 'ios/Tests/**/*.{swift,json}'
|
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ const datadogConfiguration = new DatadogProviderConfiguration(
|
|
|
47
47
|
applicationId: '<RUM_APPLICATION_ID>',
|
|
48
48
|
trackInteractions: true, // track User interactions (e.g.: Tap on buttons. You can use 'accessibilityLabel' element property to give tap action the name, otherwise element type will be reported)
|
|
49
49
|
trackResources: true, // track XHR Resources
|
|
50
|
+
trackFetchResources: true, // Optional: also track requests made with the global Expo Fetch implementation
|
|
50
51
|
trackFrustrations: true, // track Frustrations
|
|
51
52
|
trackErrors: true, // track errors
|
|
52
53
|
nativeCrashReportEnabled: true, // Optional: enable or disable native crash reports
|
|
@@ -80,6 +81,15 @@ export default function App() {
|
|
|
80
81
|
}
|
|
81
82
|
```
|
|
82
83
|
|
|
84
|
+
`trackFetchResources` tracks calls made through the Expo-installed global
|
|
85
|
+
`fetch`. Direct imports retained from `expo/fetch` are not intercepted. XHR
|
|
86
|
+
tracking remains enabled for clients such as axios.
|
|
87
|
+
|
|
88
|
+
GraphQL error extraction (via `DatadogLink({ trackErrors: true })`) for
|
|
89
|
+
requests made through `expo/fetch` requires Expo SDK 56 or later, as older
|
|
90
|
+
versions of `expo/fetch` do not implement `Response.clone()`. On earlier
|
|
91
|
+
versions, GraphQL metadata is still reported, but response errors are not.
|
|
92
|
+
|
|
83
93
|
### Track view navigation
|
|
84
94
|
|
|
85
95
|
Because React Native offers a wide range of libraries to create screen navigation, by default only manual View tracking is supported. You can manually start and stop a View using the following `startView()` and `stopView` methods.
|
package/android/build.gradle
CHANGED
|
@@ -138,7 +138,20 @@ android {
|
|
|
138
138
|
if (isNewArchitectureEnabled()) {
|
|
139
139
|
java.srcDirs += ['src/newarch/kotlin']
|
|
140
140
|
} else {
|
|
141
|
-
|
|
141
|
+
// `oldarchCommon` holds everything shared by all old-architecture RN versions.
|
|
142
|
+
// Version-specific pieces (currently just heatmap tap-to-view resolution, whose
|
|
143
|
+
// `UIManager.resolveView` API was added in RN 0.66) live in their own small source set,
|
|
144
|
+
// named `oldarch<N>` for the highest old-arch minor version they cover (inclusive) —
|
|
145
|
+
// e.g. `oldarch65` for RN <= 65. The bare `oldarch` directory has no number because it
|
|
146
|
+
// always means "newer than the highest split defined" (today: RN > 65); if a future RN
|
|
147
|
+
// release breaks another old-arch API, split off the next `oldarch<N>` the same way and
|
|
148
|
+
// `oldarch` keeps that same "later than the highest split" meaning.
|
|
149
|
+
java.srcDirs += ['src/oldarchCommon/kotlin']
|
|
150
|
+
if (reactNativeMajorVersion == 0 && reactNativeMinorVersion <= 65) {
|
|
151
|
+
java.srcDirs += ['src/oldarch65/kotlin']
|
|
152
|
+
} else {
|
|
153
|
+
java.srcDirs += ['src/oldarch/kotlin']
|
|
154
|
+
}
|
|
142
155
|
}
|
|
143
156
|
}
|
|
144
157
|
test {
|
|
@@ -200,7 +213,7 @@ dependencies {
|
|
|
200
213
|
// This breaks builds if the React Native target is below 0.76.0. as it relies on Gradle 8.5.0.
|
|
201
214
|
// To avoid this, we enforce 1.0.0-beta01 on RN < 0.76.0
|
|
202
215
|
if (reactNativeMinorVersion < 76) {
|
|
203
|
-
implementation("com.datadoghq:dd-sdk-android-rum:3.
|
|
216
|
+
implementation("com.datadoghq:dd-sdk-android-rum:3.13.1") {
|
|
204
217
|
exclude group: "androidx.metrics", module: "metrics-performance"
|
|
205
218
|
}
|
|
206
219
|
implementation "androidx.metrics:metrics-performance:1.0.0-beta01"
|
|
@@ -220,14 +233,14 @@ dependencies {
|
|
|
220
233
|
}
|
|
221
234
|
}
|
|
222
235
|
} else {
|
|
223
|
-
implementation "com.datadoghq:dd-sdk-android-rum:3.
|
|
236
|
+
implementation "com.datadoghq:dd-sdk-android-rum:3.13.1"
|
|
224
237
|
}
|
|
225
|
-
implementation "com.datadoghq:dd-sdk-android-logs:3.
|
|
226
|
-
implementation "com.datadoghq:dd-sdk-android-trace:3.
|
|
227
|
-
implementation "com.datadoghq:dd-sdk-android-webview:3.
|
|
228
|
-
implementation "com.datadoghq:dd-sdk-android-ndk:3.
|
|
229
|
-
implementation "com.datadoghq:dd-sdk-android-flags:3.
|
|
230
|
-
implementation "com.datadoghq:dd-sdk-android-internal:3.
|
|
238
|
+
implementation "com.datadoghq:dd-sdk-android-logs:3.13.1"
|
|
239
|
+
implementation "com.datadoghq:dd-sdk-android-trace:3.13.1"
|
|
240
|
+
implementation "com.datadoghq:dd-sdk-android-webview:3.13.1"
|
|
241
|
+
implementation "com.datadoghq:dd-sdk-android-ndk:3.13.1"
|
|
242
|
+
implementation "com.datadoghq:dd-sdk-android-flags:3.13.1"
|
|
243
|
+
implementation "com.datadoghq:dd-sdk-android-internal:3.13.1"
|
|
231
244
|
implementation "com.google.code.gson:gson:2.11.0"
|
|
232
245
|
testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
|
|
233
246
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
|
|
@@ -182,6 +182,8 @@ private fun buildEvaluationContext(
|
|
|
182
182
|
return EvaluationContext(targetingKey, parsed)
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
private const val SERIAL_ID_KEY = "serialId"
|
|
186
|
+
|
|
185
187
|
private fun convertUnparsedFlagToMap(
|
|
186
188
|
flagKey: String,
|
|
187
189
|
flag: UnparsedFlag,
|
|
@@ -222,6 +224,8 @@ private fun convertUnparsedFlagToMap(
|
|
|
222
224
|
"reason" to flag.reason,
|
|
223
225
|
"doLog" to flag.doLog,
|
|
224
226
|
"extraLogging" to flag.extraLogging.toMap(),
|
|
227
|
+
// Serialized as a String because the React Native bridge converts Long values to Double
|
|
228
|
+
SERIAL_ID_KEY to flag.serialId?.toString()
|
|
225
229
|
)
|
|
226
230
|
}
|
|
227
231
|
|
|
@@ -237,4 +241,7 @@ private fun convertMapToUnparsedFlag(map: Map<String, Any>): UnparsedFlag =
|
|
|
237
241
|
(map["extraLogging"] as? Map<String, Any>)?.toJSONObject()
|
|
238
242
|
?: JSONObject()
|
|
239
243
|
override val reason: String = map["reason"] as? String ?: ""
|
|
244
|
+
override val serialId: Long? =
|
|
245
|
+
(map[SERIAL_ID_KEY] as? String)?.toLongOrNull()
|
|
246
|
+
?: (map[SERIAL_ID_KEY] as? Number)?.toLong()
|
|
240
247
|
}
|
|
@@ -22,7 +22,10 @@ import java.util.Locale
|
|
|
22
22
|
* The entry point to use Datadog's RUM feature.
|
|
23
23
|
*/
|
|
24
24
|
@Suppress("TooManyFunctions")
|
|
25
|
-
class DdRumImplementation
|
|
25
|
+
class DdRumImplementation internal constructor(
|
|
26
|
+
private val datadog: DatadogWrapper = DatadogSDKWrapper(),
|
|
27
|
+
private val heatmapActionHandler: HeatmapActionHandler = HeatmapActionHandler()
|
|
28
|
+
) {
|
|
26
29
|
/**
|
|
27
30
|
* Start tracking a RUM View.
|
|
28
31
|
* @param key The view unique key identifier.
|
|
@@ -120,11 +123,10 @@ class DdRumImplementation(private val datadog: DatadogWrapper = DatadogSDKWrappe
|
|
|
120
123
|
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
121
124
|
* @param name The action name.
|
|
122
125
|
* @param touch The native touch data for tap actions, or null for other action types.
|
|
123
|
-
* Currently unused on Android; reserved for heatmap support.
|
|
124
126
|
* @param context The additional context to send.
|
|
125
127
|
* @param timestampMs The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
126
128
|
*/
|
|
127
|
-
@Suppress("LongParameterList"
|
|
129
|
+
@Suppress("LongParameterList")
|
|
128
130
|
fun addAction(
|
|
129
131
|
type: String,
|
|
130
132
|
name: String,
|
|
@@ -136,12 +138,28 @@ class DdRumImplementation(private val datadog: DatadogWrapper = DatadogSDKWrappe
|
|
|
136
138
|
val attributes = context.toHashMap().toMutableMap().apply {
|
|
137
139
|
put(RumAttributes.INTERNAL_TIMESTAMP, timestampMs.toLong())
|
|
138
140
|
}
|
|
141
|
+
|
|
142
|
+
val eligibleAction = heatmapActionHandler.resolveEligibility(datadog, type, name, touch)
|
|
143
|
+
if (eligibleAction == null) {
|
|
144
|
+
addActionWithoutHeatmap(type, name, attributes)
|
|
145
|
+
promise.resolve(null)
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Resolve before dispatching heatmap work (iOS parity).
|
|
150
|
+
promise.resolve(null)
|
|
151
|
+
|
|
152
|
+
heatmapActionHandler.attachHeatmapData(eligibleAction, name, attributes) {
|
|
153
|
+
addActionWithoutHeatmap(type, name, attributes)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private fun addActionWithoutHeatmap(type: String, name: String, attributes: Map<String, Any?>) {
|
|
139
158
|
datadog.getRumMonitor().addAction(
|
|
140
159
|
type = type.asRumActionType(),
|
|
141
160
|
name = name,
|
|
142
161
|
attributes = attributes
|
|
143
162
|
)
|
|
144
|
-
promise.resolve(null)
|
|
145
163
|
}
|
|
146
164
|
|
|
147
165
|
/**
|
|
@@ -460,6 +478,7 @@ class DdRumImplementation(private val datadog: DatadogWrapper = DatadogSDKWrappe
|
|
|
460
478
|
}
|
|
461
479
|
|
|
462
480
|
// endregion
|
|
481
|
+
|
|
463
482
|
@Suppress("UndocumentedPublicClass")
|
|
464
483
|
companion object {
|
|
465
484
|
private const val MISSING_RESOURCE_SIZE = -1L
|
|
@@ -34,7 +34,6 @@ import com.datadog.android.trace.TraceConfiguration
|
|
|
34
34
|
import com.datadog.android.ndk.NdkCrashReports
|
|
35
35
|
import com.google.gson.Gson
|
|
36
36
|
import java.util.Locale
|
|
37
|
-
import kotlin.time.Duration.Companion.seconds
|
|
38
37
|
|
|
39
38
|
|
|
40
39
|
/**
|
|
@@ -250,7 +249,7 @@ class DdSdkNativeInitialization internal constructor(
|
|
|
250
249
|
}
|
|
251
250
|
|
|
252
251
|
configuration.rumConfiguration?.initialResourceThreshold?.let {
|
|
253
|
-
val milliseconds = it.
|
|
252
|
+
val milliseconds = (it * MILLISECONDS_IN_SECOND).toLong()
|
|
254
253
|
configBuilder.setInitialResourceIdentifier(TimeBasedInitialResourceIdentifier(milliseconds))
|
|
255
254
|
}
|
|
256
255
|
|
|
@@ -409,6 +408,8 @@ class DdSdkNativeInitialization internal constructor(
|
|
|
409
408
|
|
|
410
409
|
@Suppress("UndocumentedPublicClass")
|
|
411
410
|
companion object {
|
|
411
|
+
private const val MILLISECONDS_IN_SECOND = 1000
|
|
412
|
+
|
|
412
413
|
/**
|
|
413
414
|
* Initializes the Datadog React Native SDK from your MainApplication.
|
|
414
415
|
*
|
|
@@ -0,0 +1,121 @@
|
|
|
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 android.os.Handler
|
|
10
|
+
import android.os.Looper
|
|
11
|
+
import com.datadog.android.api.InternalLogger
|
|
12
|
+
import com.datadog.android.rum.RumActionType
|
|
13
|
+
import com.datadog.android.rum._RumInternalProxy
|
|
14
|
+
import com.facebook.react.bridge.ReadableMap
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Decides whether an `addAction` call is eligible for heatmap tracking and, if so, resolves and
|
|
18
|
+
* attaches the heatmap data via [HeatmapTouchResolver]. Split into two steps so the caller can
|
|
19
|
+
* resolve its own promise between them, before the heatmap work dispatches.
|
|
20
|
+
*/
|
|
21
|
+
class HeatmapActionHandler internal constructor(
|
|
22
|
+
private val heatmapTouchResolver: HeatmapTouchResolver = HeatmapTouchResolver(),
|
|
23
|
+
private val mainThreadExecutor: (() -> Unit) -> Unit = defaultMainThreadExecutor()
|
|
24
|
+
) {
|
|
25
|
+
|
|
26
|
+
internal data class EligibleAction(
|
|
27
|
+
val internalProxy: _RumInternalProxy,
|
|
28
|
+
val viewUrl: String,
|
|
29
|
+
val reactTag: Int,
|
|
30
|
+
val positionX: Long,
|
|
31
|
+
val positionY: Long
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
internal fun resolveEligibility(
|
|
35
|
+
datadog: DatadogWrapper,
|
|
36
|
+
type: String,
|
|
37
|
+
name: String,
|
|
38
|
+
touch: ReadableMap?
|
|
39
|
+
): EligibleAction? {
|
|
40
|
+
if (!heatmapsEnabled || touch == null || !type.equals("tap", ignoreCase = true)) {
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
val internalProxy = datadog.getRumMonitor()._getInternal()
|
|
45
|
+
// Read now — the view can transition asynchronously right after a tap.
|
|
46
|
+
val viewUrl = internalProxy?.getCurrentViewUrl()
|
|
47
|
+
val touchFields = touch.toTouchFieldsOrNull(name)
|
|
48
|
+
|
|
49
|
+
return if (internalProxy != null && viewUrl != null && touchFields != null) {
|
|
50
|
+
val (reactTag, positionX, positionY) = touchFields
|
|
51
|
+
EligibleAction(internalProxy, viewUrl, reactTag, positionX, positionY)
|
|
52
|
+
} else {
|
|
53
|
+
null
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
internal fun attachHeatmapData(
|
|
58
|
+
eligibleAction: EligibleAction,
|
|
59
|
+
name: String,
|
|
60
|
+
attributes: Map<String, Any?>,
|
|
61
|
+
fallback: () -> Unit
|
|
62
|
+
) {
|
|
63
|
+
mainThreadExecutor {
|
|
64
|
+
val heatmapData = heatmapTouchResolver.resolveHeatmapActionData(
|
|
65
|
+
eligibleAction.reactTag,
|
|
66
|
+
eligibleAction.positionX,
|
|
67
|
+
eligibleAction.positionY,
|
|
68
|
+
eligibleAction.viewUrl
|
|
69
|
+
)
|
|
70
|
+
if (heatmapData != null) {
|
|
71
|
+
eligibleAction.internalProxy.addActionWithHeatmap(
|
|
72
|
+
type = RumActionType.TAP,
|
|
73
|
+
name = name,
|
|
74
|
+
crossPlatformHeatmapActionData = heatmapData,
|
|
75
|
+
attributes = attributes
|
|
76
|
+
)
|
|
77
|
+
} else {
|
|
78
|
+
fallback()
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Missing fields are not warned on: `actionContext` is an optional addAction parameter, and
|
|
84
|
+
// a caller intentionally tracking a TAP action without real touch coordinates is valid usage.
|
|
85
|
+
private fun ReadableMap.toTouchFieldsOrNull(actionName: String): Triple<Int, Long, Long>? {
|
|
86
|
+
if (!hasKey("reactTag") || !hasKey("x") || !hasKey("y")) return null
|
|
87
|
+
return runCatching {
|
|
88
|
+
Triple(getInt("reactTag"), getDouble("x").toLong(), getDouble("y").toLong())
|
|
89
|
+
}.onFailure {
|
|
90
|
+
InternalLogger.UNBOUND.log(
|
|
91
|
+
InternalLogger.Level.WARN,
|
|
92
|
+
InternalLogger.Target.USER,
|
|
93
|
+
{
|
|
94
|
+
"addAction(\"$actionName\"): heatmap tracking requires actionContext's " +
|
|
95
|
+
"nativeEvent.target/locationX/locationY to be numbers, as produced by a " +
|
|
96
|
+
"standard onPress GestureResponderEvent. The value passed for this " +
|
|
97
|
+
"action didn't match that shape, so heatmap tracking was skipped for it " +
|
|
98
|
+
"— this is expected if actionContext came from a non-standard event " +
|
|
99
|
+
"source (e.g. a different gesture library)."
|
|
100
|
+
},
|
|
101
|
+
throwable = it,
|
|
102
|
+
onlyOnce = true
|
|
103
|
+
)
|
|
104
|
+
}.getOrNull()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@Suppress("UndocumentedPublicClass")
|
|
108
|
+
companion object {
|
|
109
|
+
private fun defaultMainThreadExecutor(): ((() -> Unit) -> Unit) {
|
|
110
|
+
val handler by lazy { Handler(Looper.getMainLooper()) }
|
|
111
|
+
return { action -> handler.post(action) }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Whether heatmap data should be attached to TAP actions. Set by
|
|
116
|
+
* [com.datadog.reactnative.sessionreplay.DdSessionReplayImplementation.enable].
|
|
117
|
+
*/
|
|
118
|
+
@Volatile
|
|
119
|
+
var heatmapsEnabled: Boolean = false
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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 android.content.res.Resources
|
|
10
|
+
import android.view.View
|
|
11
|
+
import android.view.ViewGroup
|
|
12
|
+
import com.datadog.android.heatmaps.CrossPlatformHeatmapActionData
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Resolves a React Native touch into [CrossPlatformHeatmapActionData] by walking the view
|
|
16
|
+
* hierarchy to the nearest clickable-and-visible ancestor — matching Session Replay's own
|
|
17
|
+
* `HeatmapIdentifierResolver` rule — and building its element path using the same convention, so
|
|
18
|
+
* the resulting hash matches the `permanentId` SR assigned to that view's wireframe.
|
|
19
|
+
*/
|
|
20
|
+
internal class HeatmapTouchResolver(
|
|
21
|
+
private val viewResolver: (Int) -> View? = { null },
|
|
22
|
+
private val telemetry: DdTelemetry = DdTelemetry()
|
|
23
|
+
) {
|
|
24
|
+
|
|
25
|
+
/** Returns null if [reactTag] doesn't resolve to a valid tap target. */
|
|
26
|
+
fun resolveHeatmapActionData(
|
|
27
|
+
reactTag: Int,
|
|
28
|
+
positionX: Long,
|
|
29
|
+
positionY: Long,
|
|
30
|
+
viewUrl: String
|
|
31
|
+
): CrossPlatformHeatmapActionData? = runCatching {
|
|
32
|
+
val view = viewResolver(reactTag)?.let { clickableVisibleAncestorOf(it) }
|
|
33
|
+
val elementPath = view?.let { elementPathFromRootTo(it) }
|
|
34
|
+
|
|
35
|
+
if (view != null && !elementPath.isNullOrEmpty()) {
|
|
36
|
+
val density = view.resources?.displayMetrics?.density ?: 1f
|
|
37
|
+
val targetWidth = (view.width / density).toLong().takeIf { it > 0 }
|
|
38
|
+
val targetHeight = (view.height / density).toLong().takeIf { it > 0 }
|
|
39
|
+
|
|
40
|
+
CrossPlatformHeatmapActionData(
|
|
41
|
+
elementPath = elementPath,
|
|
42
|
+
viewUrl = viewUrl,
|
|
43
|
+
positionX = positionX,
|
|
44
|
+
positionY = positionY,
|
|
45
|
+
targetWidth = targetWidth,
|
|
46
|
+
targetHeight = targetHeight
|
|
47
|
+
)
|
|
48
|
+
} else {
|
|
49
|
+
null
|
|
50
|
+
}
|
|
51
|
+
}.onFailure {
|
|
52
|
+
telemetry.telemetryError("Failed to resolve heatmap action data", it)
|
|
53
|
+
}.getOrNull()
|
|
54
|
+
|
|
55
|
+
// region Private helpers
|
|
56
|
+
|
|
57
|
+
private fun clickableVisibleAncestorOf(view: View): View? {
|
|
58
|
+
var current: View? = view
|
|
59
|
+
while (current != null) {
|
|
60
|
+
if (current.isClickable && current.visibility == View.VISIBLE) {
|
|
61
|
+
return current
|
|
62
|
+
}
|
|
63
|
+
current = current.parent as? View
|
|
64
|
+
}
|
|
65
|
+
return null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private fun elementPathFromRootTo(view: View): List<String> {
|
|
69
|
+
val path = mutableListOf<String>()
|
|
70
|
+
var current: View? = view
|
|
71
|
+
while (current != null) {
|
|
72
|
+
val parent = current.parent as? ViewGroup
|
|
73
|
+
val typeIndex = if (parent != null) computeTypeIndex(current, parent) else 0
|
|
74
|
+
path.add(pathComponentFor(current, typeIndex))
|
|
75
|
+
current = parent
|
|
76
|
+
}
|
|
77
|
+
path.reverse()
|
|
78
|
+
return path
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private fun computeTypeIndex(view: View, parent: ViewGroup): Int {
|
|
82
|
+
val cls = view.javaClass
|
|
83
|
+
var index = 0
|
|
84
|
+
for (i in 0 until parent.childCount) {
|
|
85
|
+
val child = parent.getChildAt(i) ?: continue
|
|
86
|
+
if (child === view) break
|
|
87
|
+
if (child.javaClass === cls) index++
|
|
88
|
+
}
|
|
89
|
+
return index
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private fun pathComponentFor(view: View, typeIndex: Int): String {
|
|
93
|
+
val viewId = view.id
|
|
94
|
+
if (viewId != View.NO_ID) {
|
|
95
|
+
try {
|
|
96
|
+
@Suppress("UnsafeThirdPartyFunctionCall")
|
|
97
|
+
val name = view.resources?.getResourceName(viewId)
|
|
98
|
+
if (!name.isNullOrEmpty()) {
|
|
99
|
+
return "$name#$typeIndex"
|
|
100
|
+
}
|
|
101
|
+
} catch (_: Resources.NotFoundException) {
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return "cls:${view.javaClass.name}#$typeIndex"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// endregion
|
|
108
|
+
}
|
|
@@ -12,6 +12,8 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
12
12
|
import com.facebook.react.bridge.ReactMethod
|
|
13
13
|
import com.facebook.react.bridge.ReadableArray
|
|
14
14
|
import com.facebook.react.bridge.ReadableMap
|
|
15
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
16
|
+
import com.facebook.react.uimanager.common.ViewUtil
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* The entry point to use Datadog's RUM feature.
|
|
@@ -22,7 +24,23 @@ class DdRum(
|
|
|
22
24
|
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
|
|
23
25
|
) : NativeDdRumSpec(reactContext) {
|
|
24
26
|
|
|
25
|
-
private val
|
|
27
|
+
private val telemetry = DdTelemetry()
|
|
28
|
+
|
|
29
|
+
private val implementation = DdRumImplementation(
|
|
30
|
+
datadog = datadogWrapper,
|
|
31
|
+
heatmapActionHandler = HeatmapActionHandler(
|
|
32
|
+
heatmapTouchResolver = HeatmapTouchResolver(viewResolver = { reactTag ->
|
|
33
|
+
try {
|
|
34
|
+
val uiManagerType = ViewUtil.getUIManagerType(reactTag)
|
|
35
|
+
UIManagerHelper.getUIManager(reactApplicationContext, uiManagerType)
|
|
36
|
+
?.resolveView(reactTag)
|
|
37
|
+
} catch (e: Exception) {
|
|
38
|
+
telemetry.telemetryError("Failed to resolve view for heatmap tracking", e)
|
|
39
|
+
null
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
)
|
|
43
|
+
)
|
|
26
44
|
|
|
27
45
|
override fun getName(): String = DdRumImplementation.NAME
|
|
28
46
|
|
|
@@ -105,7 +123,6 @@ class DdRum(
|
|
|
105
123
|
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
106
124
|
* @param name The action name.
|
|
107
125
|
* @param touch The native touch data for tap actions, or null for other action types.
|
|
108
|
-
* Currently unused on Android; reserved for heatmap support.
|
|
109
126
|
* @param context The additional context to send.
|
|
110
127
|
* @param timestampMs The timestamp when the action occurred (in milliseconds).
|
|
111
128
|
* If not provided, current timestamp will be used.
|
|
@@ -201,7 +201,7 @@ class DdSdk(
|
|
|
201
201
|
private fun registerLifecycleEvents(reactContext: ReactApplicationContext) {
|
|
202
202
|
reactContext.addLifecycleEventListener(object : LifecycleEventListener {
|
|
203
203
|
override fun onHostResume() {
|
|
204
|
-
val currentActivity: Activity? = currentActivity
|
|
204
|
+
val currentActivity: Activity? = reactContext.currentActivity
|
|
205
205
|
if (currentActivity != null) {
|
|
206
206
|
val intent = currentActivity.intent
|
|
207
207
|
val extras = intent.extras
|
|
@@ -0,0 +1,38 @@
|
|
|
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 android.view.View
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
12
|
+
import com.facebook.react.uimanager.common.UIManagerType
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Resolves a React tag to its native [View] for heatmap tap tracking, via
|
|
16
|
+
* `UIManager.resolveView(reactTag)`. That method exists on the old-architecture `UIManager`
|
|
17
|
+
* interface from React Native 0.66 onward — see the `oldarch65` source set's counterpart of
|
|
18
|
+
* this function for RN <= 65, where it doesn't exist.
|
|
19
|
+
*
|
|
20
|
+
* This is the base `oldarch` source set, used whenever no more specific split applies: it
|
|
21
|
+
* covers every old-architecture RN version newer than the highest version-specific split
|
|
22
|
+
* defined (currently `oldarch65`). If a future RN release removes/changes another API this
|
|
23
|
+
* function (or another old-arch file) depends on, split off a new `oldarch<N>` source set named
|
|
24
|
+
* for the highest old-arch minor version it covers — e.g. `oldarch70` for RN <= 70 — following
|
|
25
|
+
* this same pattern, and this directory keeps meaning "later than the highest split."
|
|
26
|
+
*/
|
|
27
|
+
internal fun createHeatmapViewResolver(
|
|
28
|
+
reactApplicationContext: ReactApplicationContext,
|
|
29
|
+
telemetry: DdTelemetry
|
|
30
|
+
): (Int) -> View? = { reactTag ->
|
|
31
|
+
try {
|
|
32
|
+
UIManagerHelper.getUIManager(reactApplicationContext, UIManagerType.DEFAULT)
|
|
33
|
+
?.resolveView(reactTag)
|
|
34
|
+
} catch (e: Exception) {
|
|
35
|
+
telemetry.telemetryError("Failed to resolve view for heatmap tracking", e)
|
|
36
|
+
null
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 android.view.View
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `UIManager.resolveView(reactTag)` was added in React Native 0.66; the old-architecture
|
|
14
|
+
* `UIManager` interface doesn't declare it on RN <= 65 (this source set), so a React tag can't
|
|
15
|
+
* be resolved to its native [View] for heatmap tap tracking here — this always returns null.
|
|
16
|
+
*/
|
|
17
|
+
internal fun createHeatmapViewResolver(
|
|
18
|
+
reactApplicationContext: ReactApplicationContext,
|
|
19
|
+
telemetry: DdTelemetry
|
|
20
|
+
): (Int) -> View? = { null }
|
|
@@ -23,7 +23,21 @@ class DdRum(
|
|
|
23
23
|
datadogWrapper: DatadogWrapper = DatadogSDKWrapper()
|
|
24
24
|
) : ReactContextBaseJavaModule(reactContext) {
|
|
25
25
|
|
|
26
|
-
private val
|
|
26
|
+
private val telemetry = DdTelemetry()
|
|
27
|
+
|
|
28
|
+
// `createHeatmapViewResolver` is version-gated at the source-set level: it resolves a React
|
|
29
|
+
// tag to its native View via `UIManager.resolveView`, which only exists on the
|
|
30
|
+
// old-architecture `UIManager` interface from React Native 0.66 onward. See
|
|
31
|
+
// HeatmapViewResolverFactory.kt in the `oldarch` (RN > 65) and `oldarch65` (RN <= 65, no-op)
|
|
32
|
+
// source sets.
|
|
33
|
+
private val implementation = DdRumImplementation(
|
|
34
|
+
datadog = datadogWrapper,
|
|
35
|
+
heatmapActionHandler = HeatmapActionHandler(
|
|
36
|
+
heatmapTouchResolver = HeatmapTouchResolver(
|
|
37
|
+
viewResolver = createHeatmapViewResolver(reactApplicationContext, telemetry)
|
|
38
|
+
)
|
|
39
|
+
)
|
|
40
|
+
)
|
|
27
41
|
|
|
28
42
|
override fun getName(): String = DdRumImplementation.NAME
|
|
29
43
|
|
|
@@ -98,7 +112,6 @@ class DdRum(
|
|
|
98
112
|
* @param type The action type (tap, scroll, swipe, click, custom).
|
|
99
113
|
* @param name The action name.
|
|
100
114
|
* @param touch The native touch data for tap actions, or null for other action types.
|
|
101
|
-
* Currently unused on Android; reserved for heatmap support.
|
|
102
115
|
* @param context The additional context to send.
|
|
103
116
|
* @param timestampMs The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
104
117
|
*/
|