From 1029800f83a8a67fe37068cda213ee040966a931 Mon Sep 17 00:00:00 2001 From: Omid Mirzaei Date: Sun, 4 Oct 2026 13:03:07 +0400 Subject: [PATCH] fix: include distinct_id on $identify properties Align Android identify payloads with iOS so dashboards and tools that read properties.distinct_id behave consistently. --- .changeset/identify-distinct-id-in-properties.md | 5 +++++ posthog/src/main/java/com/posthog/PostHog.kt | 2 ++ posthog/src/test/java/com/posthog/PostHogTest.kt | 1 + 3 files changed, 8 insertions(+) create mode 100644 .changeset/identify-distinct-id-in-properties.md diff --git a/.changeset/identify-distinct-id-in-properties.md b/.changeset/identify-distinct-id-in-properties.md new file mode 100644 index 000000000..02fe5a475 --- /dev/null +++ b/.changeset/identify-distinct-id-in-properties.md @@ -0,0 +1,5 @@ +--- +"posthog": patch +--- + +Include `distinct_id` in `$identify` event properties for parity with the iOS SDK. diff --git a/posthog/src/main/java/com/posthog/PostHog.kt b/posthog/src/main/java/com/posthog/PostHog.kt index b74829757..b1d067199 100644 --- a/posthog/src/main/java/com/posthog/PostHog.kt +++ b/posthog/src/main/java/com/posthog/PostHog.kt @@ -1319,6 +1319,7 @@ public class PostHog private constructor( val props = mutableMapOf() props["alias"] = alias + props["distinct_id"] = distinctId capture(PostHogEventName.CREATE_ALIAS.event, properties = props) } @@ -1459,6 +1460,7 @@ public class PostHog private constructor( if (shouldIdentify || shouldTransitionToIdentified) config.notifyIntegrationsChanged() if (shouldIdentify) { + props["distinct_id"] = distinctId capture( PostHogEventName.IDENTIFY.event, distinctId = distinctId, diff --git a/posthog/src/test/java/com/posthog/PostHogTest.kt b/posthog/src/test/java/com/posthog/PostHogTest.kt index 90f52559e..bdba41717 100644 --- a/posthog/src/test/java/com/posthog/PostHogTest.kt +++ b/posthog/src/test/java/com/posthog/PostHogTest.kt @@ -1702,6 +1702,7 @@ internal class PostHogTest { val theEvent = batch.batch.first() assertEquals("\$identify", theEvent.event) assertEquals(DISTINCT_ID, theEvent.distinctId) + assertEquals(DISTINCT_ID, theEvent.properties!!["distinct_id"] as String) assertNotNull(theEvent.properties!!["\$anon_distinct_id"]) assertEquals(userProps, theEvent.properties!!["\$set"]) assertEquals(userPropsOnce, theEvent.properties!!["\$set_once"])