Skip to content

[FIX] Support Android prepared text layouts in Session Replay - #1574

Open
cdn34dd wants to merge 4 commits into
developfrom
carlosnogueira/fix/support-prepare-text-layouts-sr
Open

cdn34dd wants to merge 4 commits into
developfrom
carlosnogueira/fix/support-prepare-text-layouts-sr

Conversation

@cdn34dd

@cdn34dd cdn34dd commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds Session Replay support for Android’s PreparedLayoutTextView, including text content, styling, alignment, padding, truncation, and existing text privacy rules.

The mapper is registered only when the class is available, preserving compatibility with older React Native versions. Includes ProGuard rules and regression tests for mapping, privacy, registration, and reflection failures.

Motivation

React Native 0.89 enables a new text renderer whose views extend ViewGroup rather than TextView. Existing Session Replay text mappers do not handle this class, causing text to disappear from recordings.

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

@cdn34dd
cdn34dd added this pull request to stack #1576 November 20, 2026 16:42
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@cdn34dd
cdn34dd marked this pull request as ready for review November 23, 2026 18:08
@cdn34dd
cdn34dd requested a review from a team as a code owner November 23, 2026 18:08
Copilot AI balanced review requested due to automatic review settings November 23, 2026 18:08
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T14:55:09.956508Z 97498ed New commits
🔒 Security Review ✅ Completed 2026-11-24T14:58:46.556011Z 97498ed New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cdn34dd
cdn34dd force-pushed the carlosnogueira/fix/support-prepare-text-layouts-sr branch from 5ff645c to 99818e8 Compare November 23, 2026 18:09

@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: 5ff645c61e

ℹ️ 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".

This comment was marked as outdated.

@datadog-official datadog-official 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.

Bits Code Review: FAIL

Two distinct correctness issues exist in PreparedLayoutTextViewMapper: span-level font sizes (AbsoluteSizeSpan) are not resolved before using the layout paint's base text size, and view.alpha is silently dropped when no background drawable is present, causing text to render fully opaque in session replay.

Open Bits AI session

🤖 Bits Code Review · Commit 99818e8

Copilot AI balanced review requested due to automatic review settings November 24, 2026 10:42

@datadog-official datadog-official 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.

Bits Code Review: PASS

More details

The PR adds Android Session Replay support for prepared text views, preserving optional registration and existing privacy rules. The latest commit fixes both reported defects: span-level font sizes and opacity without a background. It also adds regression coverage and stabilizes the registration test. No findings remain open, and the incremental review identified no new issues. Native Android tests remain unexecuted because required dependencies and the SDK are unavailable.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit c9c573b

Copilot AI 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.

🔵 Needs a closer look

The tests do not validate the reflection contract against a real React Native 0.89 PreparedLayoutTextView, so incorrect class names or accessor signatures could silently omit prepared text from recordings.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Add React Native reflection compatibility coverage

packages/​react-native-session-replay/​android/​src/​main/​kotlin/​com/​datadog/​reactnative/​sessionreplay/​mappers/​PreparedLayoutTextViewMapper.kt:196

The tests do not verify the reflection contract with React Native: registration injects ViewGroup::class.java or null, and the reader uses hand-written fake classes. A wrong class name or accessor signature would therefore go undetected and leave prepared text absent from recordings. Add an RN 0.89 compatibility test that uses the default resolver and reads a real, laid-out PreparedLayoutTextView.

3 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 24, 2026 10:52

Copilot AI 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.

🔵 Needs a closer look

RN 0.89 Android runtime and R8-minified release validation are still needed because the dependency-free RN 0.76.9 checkout cannot verify the reflective internal APIs or shrinker contracts.

No open issues 🎉

Review effort: Balanced

@cursor cursor 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.

PR Review — Quality: 5.0 / 5 · Review load: Broad (~1–1.5h)

Prepared-layout text is recorded on Android only when PreparedLayoutTextView is on the classpath, and the span size, opacity, ellipsized text, font family, padding, and privacy behavior match the existing React text mappers and React Native 0.89's draw path. This is ready to merge as-is. Quality stays 5.0 after the span-size, opacity, and accessor-test updates.

Customer impact: Medium — Android Session Replay on React Native versions that render Text with PreparedLayoutTextView records that text under the existing text privacy modes. iOS and apps with Session Replay disabled are unaffected.

Concern
Prepared-layout text wireframe mapping (content, style, alignment, padding, truncation, privacy) Risky
Optional registration, reflective access, and ProGuard keep rules Risky

Assessment: capturedText uses layout.text, then the same privacy switch as TextViewMapper.resolveCapturedText. Color, font family, and size are read from sourceText, which is the spannable React Native keeps beside the ellipsized layout. fontSize() follows LegacyTextViewUtils.resolveTextSize (AbsoluteSizeSpan, DIP as-is, pixels divided by density, otherwise the layout paint). With no resolved background, shapeStyle carries view.alpha on a transparent fill, which is the opacity slot DefaultMapper already uses. Padding uses paddingLeft / paddingTop plus verticalOffset, matching onDraw. Registration stays off when the class is missing, reflected reads fail closed to a background wireframe, and the ProGuard keeps match getPreparedLayout, getText, getLayout, and getVerticalOffset. The RN 0.89 reader test constructs the real PreparedLayout and is skipped on this repo's 0.76 classpath.

Review load — Broad (~1–1.5h): The effort is the mapping contract against ReactTextMapper / TextViewMapper and the reflective registration/ProGuard path. Those belong in one review; they fail independently but ship as one Android mapper.

This run reviewed the full current diff and revalidated the prior findings. The font-family and captured-text comments (font family, captured text) stay fixed.

Open in Web View Automation 

Sent by Cursor Automation: dd-sdk-react-native reviews

- Add PreparedLayoutTextViewMapper and PreparedTextLayoutReader.
- Register the mapper when the RN class is available.
- Include ProGuard rules and the mapper, reader, and registration tests
@cdn34dd
cdn34dd force-pushed the carlosnogueira/fix/support-prepare-text-layouts-sr branch from b17418b to 97498ed Compare November 24, 2026 14:53
Copilot AI balanced review requested due to automatic review settings November 24, 2026 14:53

Copilot AI 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.

🟡 Changes recommended

The density clamp incorrectly replaces valid values below 1, causing text and padding to render too small relative to wireframe bounds on ldpi Android devices.

1 open issue

Review effort: Balanced

val background = super.map(view, mappingContext, asyncJobStatusCallback, internalLogger)
.first() as MobileSegment.Wireframe.ShapeWireframe
val prepared = layoutReader(view, internalLogger) ?: return listOf(background)
val density = mappingContext.systemInformation.screenDensity.coerceAtLeast(1f)

@datadog-official datadog-official 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.

Bits Code Review: PASS

More details

The static specialist reported no actionable defects. Android runtime behavior remains unverified because the checkout lacks the React Native dependencies and Android SDK needed to execute native tests.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 97498ed

This branch has not been deployed

No deployments
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.

2 participants