Skip to content

Re-translate displayed survey on language change #628

Description

@ioannisj

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: PostHog/posthog-ios#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions