feat: add Kotlin Multiplatform (KMP) framework support#906
Conversation
Registers Kotlin Multiplatform in the wizard following the existing mobile framework pattern (Android/Swift): a FrameworkConfig in src/frameworks/kmp, an Integration.kmp enum entry, and a FRAMEWORK_REGISTRY entry. Detection requires the Kotlin Multiplatform Gradle plugin or a commonMain source set, and KMP is ordered before Android/Swift so a KMP project (which also looks like an Android/Swift project) resolves to KMP first. The agent prompts install com.posthog:posthog-kmp into the shared module's commonMain dependencies and initialize PostHog from common code with a platform-specific PostHogContext. Marked beta with a pre-release notice — the KMP SDK is currently 0.x and not yet published to Maven Central. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Results will be posted here when complete. |
|
Noice! Swing by FYI -> Context mill release needs to go out before this can be merge/released |
|
Quick update on the release gating 👇
That leaves the context-mill release as the only remaining dependency here. I'm prepping the context-mill KMP PR now (adding 🤖 Generated with Claude Code |
|
Context-mill KMP PR is up 👉 PostHog/context-mill#240 (draft) It adds the How the release gets cut (per context-mill's So the sequence is: merge context-mill#240 with 🤖 Generated with Claude Code |
ioannisj
left a comment
There was a problem hiding this comment.
Should probably add some unit tests as well in framework.test.ts?
Address review feedback on #906: - Use the standard `posthog://docs/frameworks/kmp` docs reference in the agent context lines, matching every other framework config (was a raw web URL). - Add unit tests in framework.test.ts mirroring the existing per-framework structure: a `kmp detect` block (claims the KMP plugin / commonMain source set; rejects a plain Android and a Flutter project), end-to-end cases (a KMP project resolves to `kmp`; a plain Android project still resolves to `android`, so ordering KMP ahead doesn't hijack it), and an enum-order assertion that `kmp` precedes `android`/`swift`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Merging main brought in the 'every Integration enum value resolves' guard, which failed for the new Integration.kmp. Add the curated integration-kmp menu entry (framework: kmp) mirroring the other detected mobile frameworks (android/swift/react-native) so the enum→skill-variant contract holds.
What
Adds Kotlin Multiplatform (KMP) as a supported framework in the wizard, following the existing mobile-framework pattern (Android / Swift).
src/frameworks/kmp/kmp-wizard-agent.ts(KMP_AGENT_CONFIG)Integration.kmpenum entry insrc/lib/constants.ts, ordered beforeswift/androidFRAMEWORK_REGISTRYentry insrc/lib/registry.tsHow it behaves
kotlin("multiplatform")/org.jetbrains.kotlin.multiplatform) or asrc/commonMainsource set. Ordered before Android/Swift in the enum (detection returns the first match) so a KMP project — which also looks like an Android/Swift project — resolves to KMP first, and non-KMP projects fall through to Android/Swift unchanged.implementation("com.posthog:posthog-kmp:<VERSION>")to the shared module'scommonMaindependencies and initialize from common code:PostHog.setup(config = PostHogConfig(apiKey, host), context = PostHogContext()), with the platform-specificPostHogContext(AndroidPostHogContext(application); iOS/Web no-arg).betawith a pre-release notice.Why draft
The PostHog KMP SDK is currently 0.x pre-release and not yet on Maven Central, so
com.posthog:posthog-kmpwon't resolve until it publishes0.0.1. Keeping this a draft until then. Companion work: the posthog.com docs page (/docs/libraries/kmp) and the install-taxonomy entry (wizard: true+status: 'wip', "Coming soon") are in a separate posthog.com PR.Verification
pnpm build✅ (binary loads, warlock smoke test passes)vitest runon detection + TUI + CLI suites ✅ (287 tests)eslinton changed files ✅ (0 errors, 0 warnings — matches the Android config)🤖 Generated with Claude Code