PostHog / PostHog/posthog-android
Re-translate displayed survey on language change
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 90
- Forks
- 49
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 61
Description
Summary
The Android SDK resolves a survey's display language once, at show time. A displayed survey is frozen after that: changing the language person property doesn't re-translate it, and there's no delegate hook to update a rendered survey in place.
Current State
showSurvey()inposthog-android/src/main/java/com/posthog/android/surveys/PostHogSurveysIntegration.ktresolves the language (overrideDisplayLanguage→ person propertylanguage→ device locale) and the translations into locals, then hands the delegate a one-shotPostHogDisplaySurvey.$survey_languageis stamped from that snapshot.PostHogSurveysDelegate(posthog/src/main/java/com/posthog/surveys/PostHogSurveysDelegate.kt) only exposesrenderSurveyandcleanupSurveys, so there's no way to push new content to a survey that's already rendered.setPersonPropertiesForFlags()only triggers a flags reload, and that path doesn't reprocess surveys.canShowNextSurvey()bails while a survey is active, so nothing ever revisits the one on screen.
Expected Behavior
When person properties change while a survey is displayed and the resolved language differs from what's shown, the SDK should re-resolve the active survey's translation and push it to the delegate for an in-place update. $survey_language on subsequent survey events should match what's actually on screen.
Concretely this needs an optional updateSurvey on PostHogSurveysDelegate (implemented by the Compose delegate) plus a person-properties-changed subscription in PostHogSurveysIntegration.
Reference Implementation
posthog-ios: https://github.com/PostHog/posthog-ios/pull/686 adds an optional updateSurvey to the surveys delegate and a person-properties-for-flags change subscription, and no-ops when the matched language is unchanged.
Related
- posthog-js (browser): https://github.com/PostHog/posthog-js/issues/4174
- posthog-js (React Native): https://github.com/PostHog/posthog-js/issues/4175
- posthog-flutter: https://github.com/PostHog/posthog-flutter/issues/483
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading showSurvey() in posthog-android/src/main/java/com/posthog/android/surveys/PostHogSurveysIntegration.kt and the delegate contract in posthog/src/main/java/com/posthog/surveys/PostHogSurveysDelegate.kt. Use the posthog-ios pull request as a reference, then inspect the Compose delegate and person-properties-for-flags flow. Done means an active survey updates in place when the resolved language changes, while unchanged languages are ignored and later events report the displayed language.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100