fix(alias): include distinct_id in $create_alias event properties - #819
Draft
posthog[bot] wants to merge 1 commit into
Draft
posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The client `alias(alias)` path built `$create_alias` properties containing only `alias`. The cross-SDK alias contract's client acceptance scenario requires the enqueued event's properties to include both `alias` and `distinct_id`. Purely additive: an extra property on one event type, no change to the top-level distinct id, ambient identity, or any existing property. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: f85eba86-15aa-428c-b47e-b7c63215bf73
Contributor
posthog-android Compliance ReportDate: 2026-09-29 06:16:39 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
|
4 of 5 tasks
|
#819 already matches what I had in the closed duplicate PR (#837) for One gap for parity with the stateless/JVM path:
props["distinct_id"] = distinctId
assertEquals("user123", event.properties!!["distinct_id"])Happy to open a tiny follow-up PR once this lands if that is easier than expanding the bot PR. |
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.
💡 Motivation and Context
The client-side
alias(alias)path builds the$create_aliasevent with only analiasproperty. The cross-SDK alias contract's client acceptance scenario (acceptance/public/alias.feature, the@clientscenario) requires the enqueued event's properties to include bothaliasanddistinct_id, so a consumer reading only the event properties can resolve both sides of the linkage. See the Alias spec.Compliance matrix note (
compliance/posthog-android.md→ n1, scored ❌ Fail):The change
PostHog.alias(...)now setsprops["distinct_id"]to the current ambient distinct id alongsidealias. Nothing else moves: the top-leveldistinct_id, the ambient identity, the person-processing guard, and every other property are untouched.buildProperties()has an unrelated session-replay branch that fills in a blankdistinct_idproperty; it only writes when the value is null/blank, so it does not interact with this change.Why it's backwards-compatible: it adds one property to one event type. No existing property changes value, no API signature changes, no behavior is removed. Existing callers and downstream consumers see a strict superset of what they saw before.
Server-side
aliasStateless(distinctId, alias)is left alone — the server acceptance scenario only requires the top-leveldistinct_id, whichcaptureStatelessalready sets correctly.💚 How did you test it?
captures an alias eventunit test to assertproperties["distinct_id"]equals the event's top-level distinct id../gradlew :posthog:test --tests "com.posthog.PostHogTest"— passes../gradlew spotlessCheck— clean.No manual/device testing was performed.
📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset fileFollow-up work
Other open
posthog-androidgaps in the same matrix that are out of scope here (one contract per PR): Capture Exception (missing top-level$exception_type/$exception_message), Shutdown (close()never flushes), Screen ($screen_nameprecedence), and the Feature Flag Called Tracker allowlist gap shared across 8 SDKs.🤖 Agent context
Autonomy: Fully autonomous
Produced by a scheduled SDK-compliance agent (Claude Opus 5 via PostHog Desktop) that reads the compliance matrices in
PostHog/sdk-specsand implements one backwards-compatible gap per run. This cell was picked over the other openposthog-androidgaps because it is a core identity contract, the remediation is a single additive line with an unambiguous acceptance scenario behind it, and no open PR or branch was already addressing it.One judgement call worth flagging for the reviewer: the Alias spec's prose says "Some stateless/server-oriented implementations also duplicate the source id into
properties.distinct_id; audited mobile client helpers do not require that duplication," which sits in tension with the@clientacceptance scenario that explicitly asserts the property. This PR follows the acceptance scenario (and the matrix verdict). If the intent is really that mobile clients should not duplicate it, the fix belongs insdk-specsinstead and this PR should be closed.Agent-authored — requires human review; not self-merged.
Created with PostHog Desktop
🤖 Generated with Claude Code