Skip to content

fix: identify anonymous user when id already matches persisted distinct id - #666

Merged
ioannisj merged 3 commits into
mainfrom
fix/identify-anonymous-matching-id
Jul 30, 2026
Merged

fix: identify anonymous user when id already matches persisted distinct id#666
ioannisj merged 3 commits into
mainfrom
fix/identify-anonymous-matching-id

Conversation

@ioannisj

@ioannisj ioannisj commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Calling identify(id) where id already equals the persisted distinct ID left the user anonymous: no transition fired, no person-processed event was sent, and $is_identified stayed 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 under identifiedLock, so two concurrent identify() 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 $set is captured (no $identify), and flags reload only when the caller supplies properties that affect evaluation. Ran the unit suite.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

DRI: @ioannisj
Autonomy: Human-driven (agent-assisted)

@ioannisj ioannisj self-assigned this Jul 30, 2026
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-07-30 19:09:50 UTC
Duration: 118392ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 401ms
Format Validation.Event Has Uuid 31ms
Format Validation.Event Has Lib Properties 30ms
Format Validation.Distinct Id Is String 25ms
Format Validation.Token Is Present 26ms
Format Validation.Custom Properties Preserved 29ms
Format Validation.Event Has Timestamp 24ms
Retry Behavior.Retries On 503 7024ms
Retry Behavior.Does Not Retry On 400 4023ms
Retry Behavior.Does Not Retry On 401 4023ms
Retry Behavior.Respects Retry After Header 7026ms
Retry Behavior.Implements Backoff 17034ms
Retry Behavior.Retries On 500 7019ms
Retry Behavior.Retries On 502 7021ms
Retry Behavior.Retries On 504 7017ms
Retry Behavior.Max Retries Respected 17039ms
Deduplication.Generates Unique Uuids 37ms
Deduplication.Preserves Uuid On Retry 7016ms
Deduplication.Preserves Uuid And Timestamp On Retry 12019ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7019ms
Deduplication.No Duplicate Events In Batch 36ms
Deduplication.Different Events Have Different Uuids 24ms
Compression.Sends Gzip When Enabled 18ms
Batch Format.Uses Proper Batch Structure 17ms
Batch Format.Flush With No Events Sends Nothing 12ms
Batch Format.Multiple Events Batched Together 32ms
Error Handling.Does Not Retry On 403 4017ms
Error Handling.Does Not Retry On 413 4019ms
Error Handling.Retries On 408 5025ms

Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 31ms
Request Payload.Flags Request Uses V2 Query Param 22ms
Request Payload.Flags Request Hits Flags Path Not Decide 35ms
Request Payload.Flags Request Omits Authorization Header 21ms
Request Payload.Token In Flags Body Matches Init 21ms
Request Payload.Groups Round Trip 23ms
Request Payload.Groups Default To Empty Object 23ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 21ms
Request Payload.Disable Geoip Omitted Defaults To False 21ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 20ms
Request Lifecycle.No Flags Request On Init Alone 8ms
Request Lifecycle.No Flags Request On Normal Capture 23ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 34ms
Request Lifecycle.Mock Response Value Is Returned To Caller 21ms
Retry Behavior.Retries Flags On 502 322ms
Retry Behavior.Retries Flags On 504 323ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 21ms

@ioannisj
ioannisj marked this pull request as ready for review July 30, 2026 14:02
@ioannisj
ioannisj requested a review from a team as a code owner July 30, 2026 14:02
@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "chore: declare posthog core in changeset" | Re-trigger Greptile

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unblocking, check for concurrency issues if not yet

@ioannisj
ioannisj merged commit cf1cea2 into main Jul 30, 2026
17 checks passed
@ioannisj
ioannisj deleted the fix/identify-anonymous-matching-id branch July 30, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants