PostHog / PostHog/posthog-android

Re-translate displayed survey on language change

Open
#628 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Survey
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() in posthog-android/src/main/java/com/posthog/android/surveys/PostHogSurveysIntegration.kt resolves the language (overrideDisplayLanguage → person property language → device locale) and the translations into locals, then hands the delegate a one-shot PostHogDisplaySurvey. $survey_language is stamped from that snapshot.
  • PostHogSurveysDelegate (posthog/src/main/java/com/posthog/surveys/PostHogSurveysDelegate.kt) only exposes renderSurvey and cleanupSurveys, 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.