Skip to content

feat: add surveys option to PostHogConfig - #125

Open
turnipdabeets wants to merge 1 commit into
mainfrom
feat/surveys-config
Open

turnipdabeets wants to merge 1 commit into
mainfrom
feat/surveys-config

Conversation

@turnipdabeets

Copy link
Copy Markdown
Collaborator

💡 Motivation and Context

Closes #124.

Developers can't turn surveys off from KMP. posthog-ios has surveys on by default and shows popovers with its built-in UI, and posthog-js does the same on web. Libraries that embed posthog-kmp, like HDCharts' usage telemetry, need to rule out survey UI appearing in the apps that use them. HDCharts keeps iOS reporting off for this reason.

This adds surveys: Boolean = true to PostHogConfig:

Platform Mapping Change from today
iOS 15+ config.surveys none (native default is true)
Web (JS/Wasm) disable_surveys = !surveys none (posthog-js default is on)
Android config.surveys native default was false. The surveys integration now loads. It shows surveys only if the app also depends on posthog-android-surveys-compose (documented beta). Otherwise the native default delegate only logs.
macOS, JVM ignored none

For reviewers:

  • Android default. I matched the default most SDKs use (iOS, web, React Native and Flutter all default to on) rather than Android's. The change intent tells Android users to set false to keep the old behavior. If we'd rather not change Android, the alternative is to leave Android unwired for now.
  • Binary compatibility. I followed feat: expose Android push capture options #101's pattern: kept the previous constructor and copy signatures, and every existing copy overload now passes surveys through. Without that, config.copy(debug = true) would reset surveys to true. Tests cover both cases.
  • sdk-specs. The surveys spec says the subsystem is installed only when config enables it, but doesn't name the option or set a default, so nothing diverges.
  • posthog-ios 4.0. It keeps config.surveys behind the Surveys package trait, which is on by default, so this mapping still compiles on 4.0.

💚 How did you test it?

  • ./gradlew allTests passed: 462 tests, 0 failures, across JVM, Android host, JS (node and browser), Wasm, iOS simulator and macOS. That includes new tests for the default, for copy keeping the value, for the Android and JS/Wasm mappings, and for Java callers of the previous signatures.
  • ./gradlew detekt passed.
  • I didn't test on a device or simulator against a live project with a survey configured. The iOS mapping is checked only by compiling, since the module has no seam for unit-testing the native config.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed. (The KMP docs page on posthog.com still needs a follow-up.)
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm change to generate a change intent file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Written with Claude Code. Before implementing, I compared the option across posthog-ios, posthog-android, posthog-js, React Native and Flutter, and checked posthog-ios 4.0. 4.0's Surveys SwiftPM package trait was considered and rejected as the fix. Only posthog-kmp's own SwiftPM declaration can set the trait, so it would apply to every KMP user. And SwiftPM adds traits up across the dependency graph, so an app could switch it back on.

🤖 Generated with Claude Code

Map it to config.surveys on iOS and Android and to disable_surveys on
web, so apps and libraries can keep the SDK from loading or showing
surveys. Defaults to true. Closes #124.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@turnipdabeets
turnipdabeets requested a review from a team as a code owner November 15, 2026 00:19
@turnipdabeets turnipdabeets self-assigned this Nov 15, 2026
@sampo-s-bot

sampo-s-bot Bot commented Nov 15, 2026

Copy link
Copy Markdown

⚠️ No changeset detected

No new .sampo/changesets/*.md files were detected in this PR. To add one:

  • run sampo add
  • follow the prompts to pick the affected packages and describe the change
  • commit the generated file to this pull request, and it will be detected automatically

If this PR isn't supposed to introduce any changes (e.g., documentation updates), you can ignore this message.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose the native iOS surveys option in PostHogConfig

1 participant