Skip to content

fix(replay): drop touches inside explicitly masked views - #922

Merged
ioannisj merged 8 commits into
mainfrom
fix/replay-drop-masked-touches
Nov 4, 2026
Merged

ioannisj merged 8 commits into
mainfrom
fix/replay-drop-masked-touches

Conversation

@ioannisj

@ioannisj ioannisj commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Closes #907. iOS counterpart: PostHog/posthog-ios#995.

Session replay masks the pixels of ph-no-capture views and Modifier.postHogMask() nodes, but still uploads the exact coordinates of every tap inside them, so a recording shows which key of a masked PIN pad was pressed. posthog-js drops interactions inside ph-no-capture elements (packages/rrweb/rrweb/src/record/observer.ts:239); this does the same on Android.

  • A touch is dropped when it lands on something the screenshot mask walk treats as an explicit mask. Views reuse the shared maskRule() classifier, including children of unclipped containers that draw outside them. Compose follows the same mask/unmask precedence.
  • Once a gesture starts inside a mask, its TouchEnd is dropped too, even if the masked view went away or the finger ended outside.
  • Only explicit masks count. Taps on fields masked by maskAllTextInputs / maskAllImages are still recorded.
  • The check runs on the main thread before dispatch, only on DOWN/UP. It walks views in local coordinates, so each visited view is O(1), and Compose stays optional.

Known gap, pre-existing and tracked separately: a postHogMask() that merges under a postHogMask(false) parent is lost by the screenshot mask walk, so its touches aren't dropped either.

💚 How did you test it?

  • Robolectric tests through the window touch path: tagged and content-description masks, postHogMask() (including a node drawn outside its parent), overflowing children, scrolled and translated views, a masked view that removes itself, gestures that end outside a mask, maskAllTextInputs, and an unmasked control. Each fails without its fix.
  • PostHogReplayTouchWithoutComposeTest runs in testWithoutCompose, so touches keep working with Compose off the classpath.
  • Emulator repro against a mock server: on main every masked tap was uploaded with exact coordinates; on this branch only the unmasked tap was. That ran on 7d5b4e7, before the later fixes.

📝 Checklist

  • All commits are signed (see Commit signing)
  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

DRI: @ioannisj
Autonomy: Human-driven (agent-assisted)

@ioannisj ioannisj self-assigned this Nov 2, 2026

@posthog posthog Bot 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.

PostHog Review · Standard · reviewed c743db8: 2 Must fix, 1 Should fix.

This is the only automatic review while this pull request is a draft. Comment @posthog review to review new changes sooner. Otherwise, a review of the new changes runs when you mark it ready for review.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

@ioannisj
ioannisj marked this pull request as ready for review November 3, 2026 11:41
@ioannisj
ioannisj requested a review from a team as a code owner November 3, 2026 11:41
@ioannisj
ioannisj marked this pull request as draft November 3, 2026 11:41

@posthog posthog Bot 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.

PostHog Review · Standard · reviewed 46191d6: 1 Must fix.

@veria-ai

veria-ai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 2 · PR risk: 0/10

@ioannisj

ioannisj commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@PostHog review

@posthog

posthog Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@ioannisj PostHog Review is reviewing this pull request.

@posthog posthog Bot 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.

PostHog Review · Standard · reviewed fe6c78e: 1 Must fix.

This is review round 3 on this pull request. When findings keep coming back in the same code, the approach is usually the problem. Before the next fix, check whether a different design would remove the whole class of findings.

@ioannisj
ioannisj marked this pull request as ready for review November 3, 2026 12:17
@ioannisj
ioannisj merged commit b17ca78 into main Nov 4, 2026
17 checks passed
@ioannisj
ioannisj deleted the fix/replay-drop-masked-touches branch November 4, 2026 13:00
turnipdabeets added a commit that referenced this pull request Nov 4, 2026
…cated

Brings in #922 (drop touches inside masked views) and #937 (no
$feature_flag_called for survey targeting flags).

Resolution:
- PostHogReplayIntegration imports: union of both sides.
- PostHogReplayIntegrationTest: keep main's MaskedTouchHarness tests and
  drop the three wireframe-mode tests, since 4.0 removes wireframe mode.
- PostHogSurveysFlagEventTest: use the 2-argument getFeatureFlag, since
  4.0 removes the defaultValue overload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
turnipdabeets added a commit that referenced this pull request Nov 4, 2026
The touch drop from #922 read the merged semantics tree, but the 4.0
mask walk reads the unmerged one. Inside a clickable parent, merging
folds a postHogMask child into the parent node, so a tap on the masked
child was recorded when the parent also held an unmasked sibling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Session replay records touch coordinates inside masked views

2 participants