From f72e24450404f7a37bf9d4764a0b7f812985655d Mon Sep 17 00:00:00 2001 From: "posthog[bot]" <206114724+posthog[bot]@users.noreply.github.com> Date: Tue, 29 Sep 2026 06:10:35 +0000 Subject: [PATCH] fix(alias): include distinct_id in $create_alias event properties 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 Generated-By: PostHog Desktop Task-Id: f85eba86-15aa-428c-b47e-b7c63215bf73 --- .changeset/alias-distinct-id-property.md | 5 +++++ posthog/src/main/java/com/posthog/PostHog.kt | 3 +++ posthog/src/test/java/com/posthog/PostHogTest.kt | 1 + 3 files changed, 9 insertions(+) create mode 100644 .changeset/alias-distinct-id-property.md diff --git a/.changeset/alias-distinct-id-property.md b/.changeset/alias-distinct-id-property.md new file mode 100644 index 000000000..3bf20da9b --- /dev/null +++ b/.changeset/alias-distinct-id-property.md @@ -0,0 +1,5 @@ +--- +"posthog": patch +--- + +fix: include `distinct_id` alongside `alias` in `$create_alias` event properties diff --git a/posthog/src/main/java/com/posthog/PostHog.kt b/posthog/src/main/java/com/posthog/PostHog.kt index b74829757..64d0be165 100644 --- a/posthog/src/main/java/com/posthog/PostHog.kt +++ b/posthog/src/main/java/com/posthog/PostHog.kt @@ -1319,6 +1319,9 @@ public class PostHog private constructor( val props = mutableMapOf() props["alias"] = alias + // The source identity is also duplicated into the properties so consumers that only + // read the event properties can resolve both sides of the alias linkage. + props["distinct_id"] = distinctId capture(PostHogEventName.CREATE_ALIAS.event, properties = props) } diff --git a/posthog/src/test/java/com/posthog/PostHogTest.kt b/posthog/src/test/java/com/posthog/PostHogTest.kt index 2ac6b9ffe..1c81a92d1 100644 --- a/posthog/src/test/java/com/posthog/PostHogTest.kt +++ b/posthog/src/test/java/com/posthog/PostHogTest.kt @@ -2008,6 +2008,7 @@ internal class PostHogTest { assertEquals("\$create_alias", theEvent.event) assertNotNull(theEvent.distinctId) assertEquals("theAlias", theEvent.properties!!["alias"] as String) + assertEquals(theEvent.distinctId, theEvent.properties!!["distinct_id"] as String) sut.close() }