Skip to content

Expose settable PostHogConfig.getAnonymousId for anonymous-id seeding - #3

Open
vincentborko wants to merge 1 commit into
skiptools:mainfrom
vincentborko:feat/module-api-bridges
Open

vincentborko wants to merge 1 commit into
skiptools:mainfrom
vincentborko:feat/module-api-bridges

Conversation

@vincentborko

Copy link
Copy Markdown

PostHogConfig currently exposes getAnonymousId as a getter only. The underlying posthog-android PostHogConfig.getAnonymousId is a settable (UUID) -> UUID property, used to seed PostHog's anonymous distinct_id from an app-controlled durable id — the recommended pattern for stable flag/experiment bucketing across the anonymous→identified transition.

This adds a get/set public var getAnonymousId: (UUID) -> UUID on PostHogConfig, bridging Swift UUID ↔ java.util.UUID on Android (and passing through to the native config on #if !SKIP).

Verified on-device (Android, posthog-android 3.47): seeding config.getAnonymousId = { _ in durableUUID } makes the persisted anonymousId / distinct_id equal the supplied UUID on first launch, and bucketing stays stable across login/logout (no identify / reset).

Expose the settable `getAnonymousId: (UUID) -> UUID` closure on
PostHogConfig, mirroring posthog-ios/posthog-android. On Android the
closure operates on java.util.UUID; the #if SKIP branch bridges to
Foundation UUID via KotlinConverting (.kotlin() / init(platformValue:)).

Lets apps seed PostHog's anonymous distinct_id from a durable client id
so flag/experiment bucketing stays stable across the anon->identified switch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cla-bot cla-bot Bot added the cla-signed label Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant