Skip to content

PANA-5681: Integrate HeatmapIdentifierRegistry into Session Replay for heatmaps [4 of 4]#3206

Open
gonzalezreal wants to merge 3 commits into
feature/heatmapsfrom
gonzalezreal/PANA-5681/session-replay-heatmaps
Open

PANA-5681: Integrate HeatmapIdentifierRegistry into Session Replay for heatmaps [4 of 4]#3206
gonzalezreal wants to merge 3 commits into
feature/heatmapsfrom
gonzalezreal/PANA-5681/session-replay-heatmaps

Conversation

@gonzalezreal

Copy link
Copy Markdown

What does this PR do?

Wires ViewIdentityResolver into Session Replay to populate permanentId on wireframes. This enables correlating wireframes with RUM action events for heatmap visualization.

Key changes:

  • Adds public ViewIdentityProvider interface for Session Replay's view identity resolution
  • Adapts internal ViewIdentityResolver (from RUM feature context) via ViewIdentityResolverAdapter
  • Adds viewIdentityProvider to MappingContext for use by all wireframe mappers
  • Populates permanentId in all wireframe types (Shape, Text, Image, Placeholder, Webview)
  • Calls onWindowRefreshed() on each draw pass to index the current view hierarchy

Motivation

Support mobile heatmaps. This is the final piece connecting Session Replay wireframes to RUM actions.

Additional Notes

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • 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)

@gonzalezreal gonzalezreal marked this pull request as ready for review February 27, 2026 10:40
@gonzalezreal gonzalezreal requested review from a team as code owners February 27, 2026 10:40

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39a5a2b5af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@gonzalezreal gonzalezreal force-pushed the gonzalezreal/PANA-5681/session-replay-heatmaps branch from 39a5a2b to 2f8955a Compare February 27, 2026 13:25
@datadog-datadog-prod-us1-2

This comment has been minimized.

@codecov-commenter

codecov-commenter commented Feb 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.45729% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.19%. Comparing base (ac886da) to head (eeca598).

Files with missing lines Patch % Lines
...lay/internal/recorder/HeatmapIdentifierResolver.kt 91.57% 6 Missing and 1 partial ⚠️
...essionreplay/internal/recorder/SnapshotProducer.kt 92.68% 0 Missing and 3 partials ⚠️
...onreplay/internal/LazyHeatmapIdentifierRegistry.kt 90.91% 2 Missing ⚠️
...internal/recorder/DefaultOnDrawListenerProducer.kt 50.00% 2 Missing ⚠️
...nreplay/internal/recorder/SessionReplayRecorder.kt 85.71% 1 Missing and 1 partial ⚠️
.../sessionreplay/internal/processor/NodeFlattener.kt 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           feature/heatmaps    #3206      +/-   ##
====================================================
+ Coverage             72.04%   72.19%   +0.14%     
====================================================
  Files                   967      970       +3     
  Lines                 35499    35666     +167     
  Branches               5887     5938      +51     
====================================================
+ Hits                  25575    25747     +172     
+ Misses                 8304     8303       -1     
+ Partials               1620     1616       -4     
Files with missing lines Coverage Δ
...dog/android/internal/heatmaps/HeatmapIdentifier.kt 77.78% <100.00%> (ø)
.../sessionreplay/internal/DefaultRecorderProvider.kt 94.37% <100.00%> (+0.04%) ⬆️
...replay/internal/SessionReplayRumContextProvider.kt 92.31% <100.00%> (+0.64%) ⬆️
...onreplay/internal/processor/HeatmapWireframeExt.kt 100.00% <100.00%> (ø)
...ssionreplay/internal/processor/MutationResolver.kt 89.45% <100.00%> (+0.04%) ⬆️
...og/android/sessionreplay/internal/recorder/Node.kt 100.00% <100.00%> (ø)
...nternal/recorder/listener/WindowsOnDrawListener.kt 93.18% <100.00%> (+0.50%) ⬆️
...onreplay/internal/utils/SessionReplayRumContext.kt 90.91% <100.00%> (+0.91%) ⬆️
.../sessionreplay/internal/processor/NodeFlattener.kt 94.44% <50.00%> (-5.56%) ⬇️
...onreplay/internal/LazyHeatmapIdentifierRegistry.kt 90.91% <90.91%> (ø)
... and 4 more

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jonathanmos jonathanmos marked this pull request as draft May 5, 2026 10:51
@jonathanmos jonathanmos changed the title PANA-5681: Integrate ViewIdentityResolver into Session Replay for heatmaps PANA-5681: Integrate ViewIdentityResolver into Session Replay for heatmaps [4 of 4] May 5, 2026
@jonathanmos jonathanmos force-pushed the gonzalezreal/PANA-5681/rum-heatmaps branch 2 times, most recently from cbfbf76 to 9a2e330 Compare May 14, 2026 12:23
@jonathanmos jonathanmos changed the title PANA-5681: Integrate ViewIdentityResolver into Session Replay for heatmaps [4 of 4] PANA-5681: Integrate HeatmapIdentifierRegistry into Session Replay for heatmaps [4 of 4] May 14, 2026
@jonathanmos jonathanmos changed the title PANA-5681: Integrate HeatmapIdentifierRegistry into Session Replay for heatmaps [4 of 4] PANA-5681: Integrate HeatmapIdentifierRegistry into Session Replay for heatmaps [4 of 4] May 14, 2026
@jonathanmos jonathanmos force-pushed the gonzalezreal/PANA-5681/rum-heatmaps branch from 9a2e330 to e63b7f4 Compare May 18, 2026 08:12
@jonathanmos jonathanmos force-pushed the gonzalezreal/PANA-5681/rum-heatmaps branch from 6210b4b to fa8baf8 Compare May 28, 2026 13:19
Base automatically changed from gonzalezreal/PANA-5681/rum-heatmaps to feature/heatmaps June 1, 2026 09:09
@jonathanmos jonathanmos force-pushed the gonzalezreal/PANA-5681/session-replay-heatmaps branch 4 times, most recently from 803a051 to 11ba9b6 Compare June 4, 2026 07:56
@jonathanmos jonathanmos force-pushed the gonzalezreal/PANA-5681/session-replay-heatmaps branch 2 times, most recently from 0014da6 to 03802d0 Compare June 4, 2026 10:55
@jonathanmos jonathanmos marked this pull request as ready for review June 4, 2026 11:45

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 03802d0335

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jonathanmos jonathanmos force-pushed the gonzalezreal/PANA-5681/session-replay-heatmaps branch from 03802d0 to acb5749 Compare June 7, 2026 10:59

@0xnm 0xnm 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.

I briefly went through the production files and left some comments, I didn't cover tests.

Given the size of this PR we need to have more several reviewers here.

import com.datadog.android.internal.heatmaps.HeatmapIdentifierRegistryProvider

/**
* Session Replay may be initialized before RUM — the SDK does not mandate a registration order.

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.

Do we actually need to support this case? Cannot we print a warning that RUM is not yet initialized during Session Replay start?

By looking at https://docs.datadoghq.com/session_replay/mobile/setup_and_configuration/?platform=android it is not clear from code snippets that RUM should be initialized first, though (it is only mentioned that RUM SDK setup should be completed).

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.

The problem is that without this mechanism, the heatmaps registry is resolved once at SessionReplay.enable() time. If RUM hasn't registered yet then the registry is permanently null and heatmaps are silently disabled for the entire session. Printing a warning means heatmaps are still broken, and the user has no way to recover without restarting the app.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it make sense to add permanentId to the _common-wireframe-schema.json file? So we don't need to do these mappings.

@jonathanmos jonathanmos Jun 10, 2026

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.

It's possible to put permanentId on the common schema but the reason we didn't do this is that it breaks the previous ordering of arguments for the wireframe constructors instead of permanentId being the last argument, and it also wouldn't remove the need for these mappings. The root issue is that .copy() only exists on data classes, not on the Wireframe sealed class, so to stamp permanentId onto a wireframe subtype we have to downcast via when. To avoid that we'd need to touch the schema generator to emit a withPermanentId() method on each subtype that delegates to its own copy().

@jonathanmos jonathanmos force-pushed the gonzalezreal/PANA-5681/session-replay-heatmaps branch from 698a9eb to eeca598 Compare June 10, 2026 12:39
@jonathanmos jonathanmos requested review from 0xnm and kikoveiga June 10, 2026 13:36

@hamorillo hamorillo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I went through the production code and haven't found any blockers. That said, the PR is quite big (so it's not easy to review), and it's my first time reviewing SR code, so I'm not confident at all, as I spend most of the time trying to understand everything.

I'll try to come back later with fresh eyes.

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.

6 participants