Repository navigation
fix(identify): keep identify running while opted out - #167
Merged
Merged
Conversation
5 of 6 tasks
dustinbyrne
approved these changes
Nov 4, 2026
andehen
added a commit
to PostHog/posthog-sdk-test-harness
that referenced
this pull request
Nov 5, 2026
The new sdk-specs pin adds scenarios that the companion tests count: - on-feature-flags.feature gains a client-only failed-load listener scenario (PostHog/sdk-specs#94), so the server profile sees 4 not-applicable cases. - identify.feature gains two client-only opted-out identify scenarios (PostHog/sdk-specs#167), so the feature set has 11 cases. - evaluate-flags.feature gains seven "Server snapshot" event opt-out scenarios tagged @server, not @SDK:server (PostHog/sdk-specs#111). The snapshot matrix now selects only @SDK:server scenarios, the same scope as the acceptance suite, so it keeps its 21 cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 9, 2026
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.
Problem
identifylists "the user is opted out" as a guard that short-circuits the whole call, andopt-insays opt-out short-circuitsidentify. posthog-js and posthog-android don't do that. Theiridentifykeeps going while opted out: it updates local identity and reloads flags. The only thing opt-out drops is the event.identify()(packages/browser/src/posthog-core.ts:3327) only returns early for an uninitialized SDK, an invalid id, or_requirePersonProcessing. Opt-out is enforced incapture()(posthog-core.ts:1795). The person-properties hash only gets cached ifcapture()accepted the event (posthog-core.ts:3411-3424). Flags reload when the distinct id changes (posthog-core.ts:3456-3461).identify()(PostHog.kt:1592) has no opt-out check. Opt-out is enforced incapture()(PostHog.kt:972).bootstrapalready says the same thing: "opt-out suppresses event emission, not the local identity state".Changes
identify: the requirement now says client SDKs must not short-circuitidentifyon opt-out. While opted out,identifyupdates local identity state and person properties for flags, and reloads flags when the distinct id changes. It doesn't capture$identify/$set, and it doesn't update the dedup hash for an event it didn't capture. In the Behavior section, opt-out comes out of the step 1 guards and the Error handling drop list.@clientscenarios:$set, because the opted-out call didn't cache the hashopt-in:optOutstep 3 and Interactions now say opt-out blocks the event, and thatidentifystill updates identity and reloads flags. What they say aboutcapture/group/aliasis unchanged.acceptance/public/identify.feature: the same two scenarios, built only from existing steps.openspec/changes/archive/2026-11-02-fix-identify-runs-while-opted-out/.Reference coverage is partial. posthog-js
defaultOptOutScenario(packages/browser/src/__tests__/browser-next-differential/scenarios.ts:126) checks identity state and that no event goes out while opted out, but its harness disables flags (legacy-browser-adapter.ts:54), so nothing in the reference suite covers the flags reload. The hash rule is covered bypersonProcessing.test.ts:1051, with the event dropped bybefore_sendrather than opt-out.Where other SDKs stand on the hash rule:
capture()dropped the event (PostHog.kt:1693).packages/core) already keeps identity and flags running while opted out, but it caches the hash on a new distinct id regardless (packages/core/src/posthog-core.ts:399), so it fails the opt-in scenario.Testing
openspec validate --specs --strict --no-interactive: 68 passed, 0 failed.Agent context
DRI: @ioannisj
Autonomy: Human-driven (agent-assisted)