fix: identify anonymous user when id already matches persisted distinct id - #666
Merged
Conversation
Contributor
posthog-android Compliance ReportDate: 2026-07-30 19:09:50 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
ioannisj
marked this pull request as ready for review
July 30, 2026 14:02
Contributor
|
Reviews (1): Last reviewed commit: "chore: declare posthog core in changeset" | Re-trigger Greptile |
marandaneto
approved these changes
Jul 30, 2026
marandaneto
left a comment
Member
There was a problem hiding this comment.
unblocking, check for concurrency issues if not yet
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.
💡 Motivation and Context
Calling
identify(id)whereidalready equals the persisted distinct ID left the user anonymous: no transition fired, no person-processed event was sent, and$is_identifiedstayed false. It's easy to hit after a non-identified bootstrap seeds the same ID.The SDK now upgrades the user to identified and captures one person-processed
$set(no$identify, since there's no anonymous ID to merge). The transition is decided and persisted atomically underidentifiedLock, so two concurrentidentify()calls can't both emit a person event for the same transition. Ports PostHog/posthog-js#4328.💚 How did you test it?
Added a regression test for the matching-ID-while-anonymous path in
PostHogBootstrapTest: the user ends up identified, one$setis captured (no$identify), and flags reload only when the caller supplies properties that affect evaluation. Ran the unit suite.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
DRI: @ioannisj
Autonomy: Human-driven (agent-assisted)