Repository navigation
docs(opt-in): restart session replay in a new session on opt-in - #138
Open
posthog[bot] wants to merge 5 commits into
Open
posthog[bot] wants to merge 5 commits into
posthog[bot] wants to merge 5 commits into
Conversation
turnipdabeets
changed the base branch from
docs/acceptance-step-catalogue
to
main
October 27, 2026 22:00
Four client SDKs now agree on what optIn() does to session replay: rotate the session before replay restarts, and leave a recording the app stopped before opting out stopped. The opt-in spec said only that "some SDKs stop or restart" replay. Add the session-rotation and restart-decision requirements, and record that the SDKs still diverge when replay is enabled but held off at opt-out by sampling, a linked flag, an event trigger, or unloaded remote config. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 792f97c9-4fe2-4ada-920a-c3a85d2d132e
posthog-ios#959 and posthog-js#5363 replaced the "was recording at opt-out" rule with the one posthog-android#839 and posthog-flutter already ship: opt-in restarts replay the app wanted (enabled in config or started manually, not stopped since) in a new session, and sampling, linked flags and event triggers are evaluated again there. Specify that rule, add scenarios for a manual start and a trigger-held replay, and drop the divergence note it resolved. Record the remaining difference: iOS and React Native rotate whenever replay was wanted, Android only when replay starts.
turnipdabeets
force-pushed
the
posthog/opt-in-replay-new-session
branch
from
October 29, 2026 20:56
a1fb25c to
6f6c423
Compare
turnipdabeets
marked this pull request as ready for review
October 29, 2026 20:56
No SDK's reset() changes the remembered replay decision: iOS, Android and React Native seed it from the session replay option at setup, and only close() clears it on iOS. Say that instead, and note that React Native's reset() after optOut() restores replay because it clears the opt-out. Also record that iOS now ignores start/stop while opted out explicitly.
marandaneto
reviewed
Oct 30, 2026
marandaneto
left a comment
Member
There was a problem hiding this comment.
Automated advisory code review.
Browser opt-in has its own consent semantics, and a browser stop stays in effect through opt-out and opt-in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Four client SDKs converged on what
optIn()does to session replay, and theopt-inspec recorded none of it — it said only that "some SDKs stop or restart them when opt state changes". Both the iOS and React Native PRs noted the gap explicitly while making the change. Without a requirement, a new SDK or a port can keep recording into the opted-out session after consent, drop a replay the app wanted, or silently undo an app'sstopSessionRecording()call.Source changes:
optIn(); #959 moved from "was recording" to "was wanted"What changed
Two requirements added to
openspec/specs/opt-in/spec.md, with the change archived underopenspec/changes/archive/2026-10-22-restart-replay-on-opt-in/:startSessionRecording(), and not stopped since. Replay held off at opt-out by sampling, a linked flag or an event trigger restarts in the new session, where those gates are evaluated again. A recording the app stopped stays stopped; start/stop calls while opted out don't count. The decision is seeded from config at launch, so an app that launches opted out with replay enabled records on first opt-in; no SDK'sreset()changes it.Scenarios cover: recording → opt-out → opt-in, a linked flag holding replay off at opt-in, a manual start with replay off in config, a trigger-held replay, a stop before opt-out, a stop while opted out, and launching opted out.
SDK alignment
Verified against
mainof each SDK on 2026-10-29, and on device (iOS simulator, Android emulator, against a local mock server). Everything above matches all four SDKs except:sessionReplay = true, a remote-config re-evaluation restarts replay afterstopSessionReplay().optIn()triggers one, and so does any flags reload. This is an existing bug, separate from the PRs above; it is described in posthog-android#915 and will be fixed separately.Merge this after posthog-android#915 lands.
Out of scope
opt_in_capturinghas its own consent semantics.Validation
openspec validate opt-in --type spec --strictpasses, andopenspec validate --specs --strictpasses 68/68. These are specification checks, not executed SDK conformance tests.Created with PostHog Desktop
🤖 Generated with Claude Code