Repository navigation
feat: add PostHog.setAppLanguage() and send $locale as BCP 47 on JVM - #115
Merged
Merged
Conversation
|
There was a problem hiding this comment.
PostHog Review · Standard · reviewed f3d8f16: 1 Consider.
See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.
Set $app_language on every platform: forwarded to the native SDKs on Android, JVM, iOS and macOS, and added in before_send on JS and Wasm, where posthog-js has no such property. Document the Compose Multiplatform resources gap in MIGRATION.md.
turnipdabeets
force-pushed
the
feat/kmp-set-app-language
branch
from
November 6, 2026 20:16
f3d8f16 to
faabe09
Compare
5 of 15 tasks
…p() on Android and JVM
3 of 4 tasks
marandaneto
approved these changes
Nov 9, 2026
…linkable (#116) * fix(jvm): keep PostHogConfig copy and default-argument constructor linkable Adding evaluationContexts changed the data class copy and the synthetic default-argument constructor, so JVM code compiled against 0.10 that calls copy(...) or PostHogConfig(..., capturePush...= ...) hit NoSuchMethodError. Add a hidden 20-parameter copy and give the retained 20-parameter constructor its defaults back. Also drop the duplicated evaluationContexts assignment on Android and JVM. * test(config): use assertNull for the null evaluation contexts check * chore: re-run CI after retitling to chore
4 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
posthog-android 4.0 and posthog-ios 4.0 add
$app_language, the language the app displays, detected from the languages the app declares. Compose Multiplatform resources declare neitherlocaleConfignor bundle localizations, so KMP apps get a wrong or missing value. This addsPostHog.setAppLanguage()so apps can set it on Android, iOS, macOS and JVM, and aligns the JVM$localewith posthog-android.Decisions:
localeConfig,CFBundleLocalizations), and turning it off would take a working value from them.setAppLanguage()overrides it, and a registered$app_languagesuper property still wins. MIGRATION.md explains the Compose Multiplatform gap: iOS and macOS report the development language, Android sends nothing, and the fix is to list the languages or callsetAppLanguage().$app_languageyet, because posthog-js doesn't support it, sosetAppLanguage()does nothing there. Abefore_sendhook in the wrapper would have to reimplement the filtering posthog-js applies beforebefore_send(property_denylist, minimal$feature_flag_calledevents), so this waits for posthog-js. Apps canregister()it themselves meanwhile. The KDoc, MIGRATION.md and the changeset say so.$localeis nowLocale.toLanguageTag()without extensions, matching posthog-android. It keeps the script (zh-Hant-TW), giveseninstead ofen-when there's no region, and is omitted for an undetermined locale. This is a breaking change for filters on the old format, and MIGRATION.md and the changeset list it.💚 How did you test it?
Unit tests on every target, all passing: jvmTest 73, testAndroidHostTest 55, jsNodeTest 65, wasmJsBrowserTest 51, iosSimulatorArm64Test 45, macosArm64Test 45. The new tests cover
$app_languageon every event on those platforms, survivingreset(),beforeSendseeing it, and the override and register precedence.posthog-ios 4.0.0 isn't tagged yet, so the iOS and macOS tests ran against a local checkout of posthog-ios
chore/v4-remove-deprecated(7b4580c). This PR keeps the pinnedswiftPackageand.swiftpm-locks. No manual testing on a device.📝 Checklist
If releasing new changes
pnpm changeto generate a change intent file (updated the existingadopt-native-4-0intent)🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Written with Claude Code. Native detection was kept rather than disabled, and JS and Wasm wait for posthog-js instead of injecting the value in
before_send(see the decisions above).🤖 Generated with Claude Code