Skip to content

RUMS-5681: Add support for Android heatmaps - #1341

Open
jonathanmos wants to merge 3 commits into
developfrom
jmoskovich/rums-5681/rn-heatmaps
Open

RUMS-5681: Add support for Android heatmaps#1341
jonathanmos wants to merge 3 commits into
developfrom
jmoskovich/rums-5681/rn-heatmaps

Conversation

@jonathanmos

Copy link
Copy Markdown
Member

What does this PR do?

Adds heatmap support for Android RN

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

@jonathanmos jonathanmos changed the title RUMS-5681: Add support for heatmaps RUMS-5681: Add support for Android heatmaps Jul 20, 2026
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jul 20, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9720abc | Docs | Datadog PR Page | Give us feedback!

@jonathanmos
jonathanmos force-pushed the jmoskovich/rums-5681/rn-heatmaps branch 4 times, most recently from 662fe52 to b81ec1d Compare July 21, 2026 09:40
@jonathanmos
jonathanmos marked this pull request as ready for review July 21, 2026 11:37
@jonathanmos
jonathanmos requested a review from a team as a code owner July 21, 2026 11:37
Base automatically changed from jmoskovich/bump-android-3.12.1 to develop July 21, 2026 11:52

@marco-saia-datadog marco-saia-datadog left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍 Good to go as soon as we add test coverage in our E2E test matrix, so that we can verify these changes across different versions of React Native, old vs new architecture, hermes vs non-hermes etc.

Copilot AI review requested due to automatic review settings August 5, 2026 14:00
@marco-saia-datadog
marco-saia-datadog force-pushed the jmoskovich/rums-5681/rn-heatmaps branch from b81ec1d to 9720abc Compare August 5, 2026 14:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Android-side heatmap support for the React Native SDK by wiring a new heatmap touch-resolution pipeline into RUM TAP actions and exposing an enableHeatmaps toggle via Session Replay enablement.

Changes:

  • Add HeatmapTouchResolver + HeatmapActionHandler to compute and attach CrossPlatformHeatmapActionData for eligible TAP actions.
  • Propagate enableHeatmaps into Android Session Replay configuration and store a global heatmap-enabled flag used by RUM.
  • Add/extend Android unit tests to cover heatmap eligibility, fallback behavior, and resolver output; update the example app to enable Session Replay with heatmaps.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt Enables heatmaps in SR config and toggles the global heatmaps-enabled flag.
packages/react-native-session-replay/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementationTest.kt Adds tests validating enableHeatmaps propagation and global flag behavior.
packages/core/android/src/main/kotlin/com/datadog/reactnative/HeatmapTouchResolver.kt New resolver that turns a React tag + coordinates into CrossPlatformHeatmapActionData.
packages/core/android/src/main/kotlin/com/datadog/reactnative/HeatmapActionHandler.kt New eligibility + attachment logic that dispatches view work on the main thread and calls addActionWithHeatmap.
packages/core/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt Routes TAP actions through heatmap handling, resolving the JS promise before dispatching heatmap work.
packages/core/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt Wires HeatmapActionHandler/HeatmapTouchResolver using UIManagerHelper view resolution (old arch).
packages/core/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt Wires HeatmapActionHandler/HeatmapTouchResolver using UIManagerHelper + ViewUtil UIManager type (new arch).
packages/core/android/src/test/kotlin/com/datadog/reactnative/HeatmapTouchResolverTest.kt New unit test suite for heatmap touch resolution and element path generation.
packages/core/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt Adds tests for heatmap gating, internal proxy path, fallback behavior, and promise ordering.
example/src/ddUtils.tsx Removes now-inlined initialization helper.
example/src/App.tsx Inlines initialization logic and enables Session Replay with enableHeatmaps: true.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +26
class HeatmapActionHandler internal constructor(
private val heatmapTouchResolver: HeatmapTouchResolver = HeatmapTouchResolver(),
private val mainThreadExecutor: (() -> Unit) -> Unit = { action ->
Handler(Looper.getMainLooper()).post(action)
}
) {
Comment on lines +96 to +101
"addAction(\"$actionName\"): heatmap tracking requires actionContext's " +
"nativeEvent.target/locationX/locationY to be numbers, as produced by a " +
"standard onPress GestureResponderEvent. The value passed for this " +
"action didn't match that shape, so heatmap tracking was skipped for it " +
"— this is expected if actionContext came from a non-standard event " +
"source (e.g. a different gesture library)."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants