Repository navigation
Conversation
posthog-android Compliance ReportDate: 2026-11-20T20:44:50.927208+00:00 ✅ All Tests Passed!232/232 tests passed Capture_V1 Tests✅ 105/105 tests passed View Details
Capture_Ai_V1 Tests✅ 110/110 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
PostHog Review · Deep · reviewed
|
| Step | Status | Result |
|---|---|---|
| Prepare the diff | done | 3 files, 1 chunk |
| Pick perspectives | done | 2 perspectives |
| Run review passes | done | 2 issues (+1 blind-spot) |
| Merge overlapping findings | done | 3 → 2 |
| Validate findings | done | 1 kept, 1 dismissed |
| Publish | done | 1 posted (view review) |
There was a problem hiding this comment.
See this review and its findings in PostHog Review.
dustinbyrne
left a comment
There was a problem hiding this comment.
The off-state payload reduction works in the base/head comparison. Before approval, please keep the capture status consistent with the running recorder during the config callback, and coordinate the new wire shape with sdk-specs#232, including the mobile missing-field rule and wrapper scope.
AI-assisted review.
| return props | ||
| } | ||
| val claimed = claimReplayDebugBundle() | ||
| val replayOff = isSessionReplayIntentionallyOff() |
There was a problem hiding this comment.
[P1/design] Agree on the reduced wire shape before releasing it
IMPORTANT · REQUIRED acceptance decision · intentional wire change, not a second recorder defect
Initialize the client without a replay integration and capture the first eligible event, such as sdk.screen("Home"). On base the event carries $sdk_debug_session_start; on head it does not. The current replay-debug spec expects the fallback session-start key when available and capture mode where provided. It separately requires config-derived diagnostics after stop or uninstall. The equivalent base/head probe verified the session-start removal, and the batch fixture records the intended wire change. Running more tests cannot resolve which contract should govern the release.
sdk-specs#232 proposes the reduced shape but is still open. It also says a successful mobile response missing sessionRecording is not remote-off. Android’s decoder already treated omission as false for recording; this PR newly makes omission suppress event diagnostics too. The executed probe verified suppression for both omitted and explicit false, while an enabled-object response retained diagnostics on both revisions. The current backend producer always writes the field, so this is a compatibility decision for omitted-field responses, not evidence of a current Cloud failure. The proposed spec also calls for gating the raw wrapper map; the React Native Android bridge reads PostHogReplayIntegration.debugProperties() directly and is not gated by this change.
Consider landing the spec change first or explicitly sequencing the two releases. Record whether omission should preserve diagnostics, including after a previously known remote-off result, and whether the native bridge is in scope or owned by a separate change. If omission should preserve diagnostics, distinguish field presence for this diagnostic gate without changing existing recording eligibility. Once agreed, pin the distinction with separate omitted, explicit-false, quota, and valid-object response assertions; verify the native bridge separately if the agreed contract covers it.
There was a problem hiding this comment.
Agreed on the order, I'll hold this until sdk-specs#232 lands so the release doesn't go out ahead of the spec.
On the two open bits:
- Missing
sessionRecordingkey: I'll amend chore: delete queue files if serialization fails #232 to record that Android treats it as off, which is what the recorder already does (more on the missing-key thread). - RN bridge: I'd rather amend chore: delete queue files if serialization fails #232's wrapper scenario than add a gated accessor, since RN already gates in JS in fix(replay): drop replay debug properties while session replay is off posthog-js#5797.
There was a problem hiding this comment.
Correction on the RN bridge bit: #232 keeps the wrapper-map requirement and marks Android partial, rather than amending the scenario. A follow-up adds a gated internal accessor and moves the RN bridge to it.
The status already follows the running recorder here (!handler.isActive() in PostHog.kt), and #232 now makes that the rule for every SDK. The missing-key allowance is in the spec text too. #232 is approved at 9b0ba3a, so this one goes in right after it merges.
turnipdabeets
left a comment
There was a problem hiding this comment.
[question] The RN plugin bridge (PosthogReactNativePluginModule.kt:300 in posthog-js) calls PostHogReplayIntegration.debugProperties() directly, so it gets the ungated map, while iOS gates its SPI. RN events aren't affected because #5797 gates in JS. Should we amend #232's wrapper scenario, or file a follow-up for a gated @PostHogInternal accessor?
|
@turnipdabeets on the RN bridge question: I'd amend #232's wrapper scenario. RN events already get the off shape because PostHog/posthog-js#5797 gates in JS, so a gated |
marandaneto
left a comment
There was a problem hiding this comment.
The code looks good; no qualifying findings. Verdict: correct.
Verified the claimed fixes against the base: the PR's new PostHogTest cases fail on 1101d79b (recorder bundle still attached while off, off events using up the 30 s window) and pass on e8809d38. Behavior matches PostHog/posthog-js#5797 apart from the two divergences below.
Before merging, please resolve the two open threads once PostHog/sdk-specs#232 has the agreed amendments:
- #992 (comment): hold until #232 lands, including amending its wrapper scenario ("A debug map handed to a wrapper SDK is gated") since
PostHogReplayIntegration.debugProperties()stays ungated for the RN bridge. - #992 (comment): record in the #232 spec text (not only the compliance note) that Android treats a missing
sessionRecordingkey as remote off.
|
@ioannisj mind holding until we release 4.0? |
# Conflicts: # posthog-android/src/test/resources/json/snapshots/batch-request.json # posthog/src/main/java/com/posthog/PostHog.kt
💡 Motivation and Context
Events keep carrying the
$sdk_debug_replay_*keys and$sdk_debug_session_starteven when session replay is off on purpose. Those keys exist to explain why a session isn't recording, so on an app that never wanted replay they're just noise on every event.This drops them while replay is intentionally off:
sessionReplayis off in config and the app never calledstartSessionReplay(), or the app calledstopSessionReplay()./configturned replay off:sessionRecording: false, a response with nosessionRecordingkey, orquotaLimitedcontainingmobile_recordings.While off, an event still gets
$recording_status: "disabled"and$sdk_debug_pending_queue_size, and it doesn't use up the 30s debug bundle window, so the first event after replay comes back gets the full bundle.Sampled out, trigger pending, linked flag pending and awaiting the first
/configare not "off". Those keys are what explain the missing recording, so they stay.A few things worth calling out:
/configwith nosessionRecordingkey counts as remote off.PostHogRemoteConfigResponse.sessionRecordingdefaults tofalse, and posthog-js does the same (enabled: !!undefined).SESSION_REPLAYvalue on remote off, so there's nothing cached to read. The remote-off state lives in a@Volatilefield onPostHogRemoteConfig, set from each/configresponse and read through an internal accessor. It isn't persisted, so after a relaunch the keys come back until the first/configlands. No public API change.PostHogReplayIntegration.debugProperties()directly. If it does, it still gets the ungated map. I didn't change that here.💚 How did you test it?
New tests in
posthog/src/test/java/com/posthog/PostHogTest.ktcover each off case (config off, explicit stop, remotefalse, missing key, quota limited) and each case that keeps the keys (no config yet, sampled out, linked flag pending, event trigger pending, awaiting the first/config). They also cover manual start withsessionReplay = false, restart after stop, opt in after opt out, remote off then on, a lifted quota limit, and the off state not using up the bundle window.The
batch-request.jsonevent-shape snapshot drops only the replay debug keys and$sdk_debug_session_start../gradlew :posthog:test: 1146 passed./gradlew :posthog-android:testReleaseUnitTest: 1036 run, 0 failuresapiCheckandmake checkFormatpass📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
DRI: @ioannisj
Autonomy: Human-driven (agent-assisted)