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"])