Repository navigation
feat(replay): support session replay v2 trigger groups - #850
Open
marc-merino wants to merge 1 commit into
Open
marc-merino wants to merge 1 commit into
marc-merino wants to merge 1 commit into
Conversation
Evaluate the v2 trigger groups from the sessionRecording remote config: per-group event, screen and flag conditions combined with any/all, per-group sampling with the same hash as posthog-js, and recording when any activated group is sampled in. The lowest minDurationMs among activated groups replaces the v1 minimum duration, and the $sdk_debug_replay_* properties report the matched groups. Configs without version 2 keep the v1 behaviour. Assisted-by: OpenCode/glm-5.3 Assisted-by: Claude Code/claude-opus-5-5
This was referenced Oct 7, 2026
Open
This branch has not been deployed
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.
Knit Bundle
View bundle
This PR is part of Knit bundle
session-replay-v2-trigger-groups-on-mobile.See the other review objects in this bundle:
posthog-ios: feat(replay): support session replay v2 trigger groups posthog-ios#921posthog-android: feat(replay): support session replay v2 trigger groups #850 (this PR)posthog-flutter: feat(replay): raise native floors for session replay v2 trigger groups posthog-flutter#648posthog-js: feat(react-native): support session replay v2 trigger groups posthog-js#5239Bundle id:
session-replay-v2-trigger-groups-on-mobileBundle title: Session replay v2 trigger groups on mobile
💡 Motivation and Context
Closes #712.
The server and posthog-js already support session replay v2 trigger groups (
sessionRecording.version: 2with atriggerGroupsarray). This SDK ignored them, so a project configured with trigger groups recorded on Android without the per-group conditions or sampling.This PR evaluates the groups the same way posthog-js does (
V2TriggerGroupStrategy):any/all. Screen names take the place of URLs on mobile. A group with no conditions activates immediately.sessionId + groupId), so web and mobile reach the same decision for a session.minDurationMsamong activated groups replaces the v1 minimum duration.$sdk_debug_replay_remote_trigger_matching_config,$sdk_debug_replay_trigger_groups_countand$sdk_debug_replay_matched_recording_trigger_groupsmatch posthog-js.versionis missing or 1.The new methods on
PostHogRemoteConfigsit on an@PostHogInternalclass, so no public API changes.sdk-specs
session-replay-ingestion-controlscurrently describes v2 as web-only. Happy to add the mobile behaviour there in a follow-up.Companion PRs for iOS, React Native and Flutter are linked in the Knit block above. I'd especially like a sanity check on the union rule and the React Native split.
💚 How did you test it?
./gradlew :posthog:test :posthog-android:testDebugUnitTest apiCheck spotlessCheckpasses.posthog-android-sampleon an Android 15 emulator, pointed at a local mock PostHog server (POSTHOG_HOST) that served two groups: one onstart_replay_trigger_2withsampleRate: 0, one onstart_replay_trigger_1withsampleRate: 1. Tapping the sample's buttons:$snapshotuploads,$recording_status: disabled,matched_recording_trigger_groups: []start_replay_trigger_2: still no snapshots; the group reportsmatched: true, sampled: falsestart_replay_trigger_1: snapshots start uploading within a second,$recording_status: active, both groups reported with the rightsampledvalue📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)