Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bump-native-dd-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ build_gradle_files=(
"packages/core/android/build.gradle"
"packages/react-native-session-replay/android/build.gradle"
"packages/react-native-webview/android/build.gradle"
"packages/internal-testing-tools/android/build.gradle"
"benchmarks/android/app/build.gradle"
)

Expand Down
15 changes: 14 additions & 1 deletion packages/core/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,20 @@ android {
if (isNewArchitectureEnabled()) {
java.srcDirs += ['src/newarch/kotlin']
} else {
java.srcDirs += ['src/oldarch/kotlin']
// `oldarchCommon` holds everything shared by all old-architecture RN versions.
// Version-specific pieces (currently just heatmap tap-to-view resolution, whose
// `UIManager.resolveView` API was added in RN 0.66) live in their own small source set,
// named `oldarch<N>` for the highest old-arch minor version they cover (inclusive) —
// e.g. `oldarch65` for RN <= 65. The bare `oldarch` directory has no number because it
// always means "newer than the highest split defined" (today: RN > 65); if a future RN
// release breaks another old-arch API, split off the next `oldarch<N>` the same way and
// `oldarch` keeps that same "later than the highest split" meaning.
java.srcDirs += ['src/oldarchCommon/kotlin']
if (reactNativeMajorVersion == 0 && reactNativeMinorVersion <= 65) {
java.srcDirs += ['src/oldarch65/kotlin']
} else {
java.srcDirs += ['src/oldarch/kotlin']
}
}
}
test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class DdSdk(
private fun registerLifecycleEvents(reactContext: ReactApplicationContext) {
reactContext.addLifecycleEventListener(object : LifecycleEventListener {
override fun onHostResume() {
val currentActivity: Activity? = currentActivity
val currentActivity: Activity? = reactContext.currentActivity
if (currentActivity != null) {
val intent = currentActivity.intent
val extras = intent.extras
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/

package com.datadog.reactnative

import android.view.View
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.common.UIManagerType

/**
* Resolves a React tag to its native [View] for heatmap tap tracking, via
* `UIManager.resolveView(reactTag)`. That method exists on the old-architecture `UIManager`
* interface from React Native 0.66 onward — see the `oldarch65` source set's counterpart of
* this function for RN <= 65, where it doesn't exist.
*
* This is the base `oldarch` source set, used whenever no more specific split applies: it
* covers every old-architecture RN version newer than the highest version-specific split
* defined (currently `oldarch65`). If a future RN release removes/changes another API this
* function (or another old-arch file) depends on, split off a new `oldarch<N>` source set named
* for the highest old-arch minor version it covers — e.g. `oldarch70` for RN <= 70 — following
* this same pattern, and this directory keeps meaning "later than the highest split."
*/
internal fun createHeatmapViewResolver(
reactApplicationContext: ReactApplicationContext,
telemetry: DdTelemetry
): (Int) -> View? = { reactTag ->
try {
UIManagerHelper.getUIManager(reactApplicationContext, UIManagerType.DEFAULT)
?.resolveView(reactTag)
} catch (e: Exception) {
telemetry.telemetryError("Failed to resolve view for heatmap tracking", e)
null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/

package com.datadog.reactnative

import android.view.View
import com.facebook.react.bridge.ReactApplicationContext

/**
* `UIManager.resolveView(reactTag)` was added in React Native 0.66; the old-architecture
* `UIManager` interface doesn't declare it on RN <= 65 (this source set), so a React tag can't
* be resolved to its native [View] for heatmap tap tracking here — this always returns null.
*/
internal fun createHeatmapViewResolver(
reactApplicationContext: ReactApplicationContext,
telemetry: DdTelemetry
): (Int) -> View? = { null }
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.common.UIManagerType

/**
* The entry point to use Datadog's RUM feature.
Expand All @@ -27,18 +25,17 @@ class DdRum(

private val telemetry = DdTelemetry()

// `createHeatmapViewResolver` is version-gated at the source-set level: it resolves a React
// tag to its native View via `UIManager.resolveView`, which only exists on the
// old-architecture `UIManager` interface from React Native 0.66 onward. See
// HeatmapViewResolverFactory.kt in the `oldarch` (RN > 65) and `oldarch65` (RN <= 65, no-op)
// source sets.
private val implementation = DdRumImplementation(
datadog = datadogWrapper,
heatmapActionHandler = HeatmapActionHandler(
heatmapTouchResolver = HeatmapTouchResolver(viewResolver = { reactTag ->
try {
UIManagerHelper.getUIManager(reactApplicationContext, UIManagerType.DEFAULT)
?.resolveView(reactTag)
} catch (e: Exception) {
telemetry.telemetryError("Failed to resolve view for heatmap tracking", e)
null
}
})
heatmapTouchResolver = HeatmapTouchResolver(
viewResolver = createHeatmapViewResolver(reactApplicationContext, telemetry)
)
)
)

Expand Down
2 changes: 1 addition & 1 deletion packages/internal-testing-tools/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ dependencies {
}
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation project(path: ':datadog_mobile-react-native')
implementation "com.datadoghq:dd-sdk-android-core"
implementation "com.datadoghq:dd-sdk-android-core:3.12.1"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh boy

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to add this file to the bump-native-dd-sdk script:

build_gradle_files=(
"packages/core/android/build.gradle"
"packages/react-native-session-replay/android/build.gradle"
"packages/react-native-webview/android/build.gradle"
"benchmarks/android/app/build.gradle"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

implementation "com.google.code.gson:gson:2.11.0"

testImplementation "org.junit.platform:junit-platform-launcher:1.6.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@

#if RCT_NEW_ARCH_ENABLED
#import "RCTVersion.h"
#import "ParagraphProps.h"

#if RCT_VERSION_MINOR >= 87
#import <React/RCTParagraphComponentView.h>
#import <React/RCTConversions.h>
#else
#import "RCTParagraphComponentView.h"
#import "RCTConversions.h"
#import "ParagraphProps.h"
#endif

namespace rct = facebook::react;
#endif
Expand Down