Skip to content

feat(replay): allow disabling touch capture - #780

Merged
marandaneto merged 2 commits into
mainfrom
fix/flutter-570-capture-touches
Sep 11, 2026
Merged

feat(replay): allow disabling touch capture#780
marandaneto merged 2 commits into
mainfrom
fix/flutter-570-capture-touches

Conversation

@marandaneto

@marandaneto marandaneto commented Sep 11, 2026

Copy link
Copy Markdown
Member

💡 Motivation and Context

Masked PIN keypads can still reveal the entered value through replay touch coordinates. Pixel masking does not hide taps on a known layout. Reported in PostHog/posthog-flutter#570.

Flutter integration: PostHog/posthog-flutter#575. iOS counterpart: PostHog/posthog-ios#823.

Add PostHogSessionReplayConfig.captureTouches, enabled by default. Set it before SDK setup to disable touch recording without stopping screenshots or view capture. The interceptor still delivers touches to the app but skips replay collection when disabled. Existing constructor signatures are unchanged. Runtime changes are not supported.

💚 How did you test it?

  • All 260 replay/config tests pass. Removing the guard makes the initial opt-out regression fail.
  • Coverage includes the enabled default, initial opt-out, application touch dispatch, and screenshots while touches are disabled.
  • Tested the Flutter bridge with locally built native artifacts on an Android emulator. Separate enabled and disabled startups each received three keypad taps. Enabled capture sent six touch events, disabled capture sent zero, and both runs sent four masked screenshot frames. Replay stayed active and all taps reached the app.
  • API checks, formatting, and committed-branch autoreview pass.

📝 Checklist

  • 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

  • Added a minor changeset file.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Pi implemented the change in an isolated worktree using Gradle, Flutter, adb, a local test server, and autoreview for validation and review. The implementation follows the requested initialization-only configuration. The session transcript remains local. Human review is required.

@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Security Review

Re-enabling touch capture inside a sensitive touch's application handler can record that touch's coordinates because the interceptor first reads the setting after application dispatch. Preserve the disabled-at-arrival state to prevent this disclosure.

Prompt To Fix All With AI
### Issue 1
posthog-android/src/main/java/com/posthog/android/replay/PostHogReplayIntegration.kt:450
**Re-enabling capture exposes sensitive touches**

If capture is disabled on a PIN screen and the final key's synchronous click handler re-enables it when leaving that screen, this check sees `true` because it runs after application dispatch. The worker also sees `true`, so it records that key's ACTION_UP coordinates even though capture was disabled when the touch arrived.

Snapshot the setting before application dispatch, then require both that original value and the current value before queuing; keep the worker guard as well. Add a regression test whose dispatch callback changes the setting from false to true.

**How this was verified:** The interceptor invokes application dispatch before reading the setting, and an enabled worker converts the same event's coordinates into a replay TouchEnd event.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "feat(replay): allow disabling touch capt..." | Re-trigger Greptile

@marandaneto
marandaneto marked this pull request as draft September 11, 2026 11:11
@marandaneto
marandaneto marked this pull request as ready for review September 11, 2026 11:11
@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "refactor: configure replay touch capture..." | Re-trigger Greptile

@marandaneto
marandaneto merged commit 58294dc into main Sep 11, 2026
16 of 17 checks passed
@marandaneto
marandaneto deleted the fix/flutter-570-capture-touches branch September 11, 2026 20:41
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