PostHog / PostHog/posthog-flutter
Re-translate displayed survey on language change
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 97
- Forks
- 85
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 31
Description
Summary
The Flutter SDK renders a pre-translated snapshot serialized from the native SDKs. There's no channel message to update a displayed survey, so even once the native SDKs support live re-translation, a displayed Flutter survey stays in the language it was shown with.
Current State
- The native SDK resolves the translation and serializes only the resolved strings (
posthog_flutter/darwin/posthog_flutter/Sources/posthog_flutter/PostHogDisplaySurvey+Dict.swifton iOS,toMap()on Android). The Dart models are immutable and have no language or translation fields. - The delegate → Dart channel only has
showSurveyandhideSurveys, andSurveyServicedrops renders while_isShowingSurvey(posthog_flutter/lib/src/surveys/survey_service.dart), so there's no path to update a survey that's already on screen.
Expected Behavior
When the native SDK re-resolves the active survey's translation (e.g. the language person property changed), the plugin's native delegates should forward an updateSurvey channel message and the displayed survey widget should rebuild from the new payload.
Dependencies
Needs the native SDKs to support live re-translation and expose it on their surveys delegates first:
- posthog-ios: https://github.com/PostHog/posthog-ios/pull/686 (open)
- posthog-android: https://github.com/PostHog/posthog-android/issues/628
Reference Implementation
posthog-ios: https://github.com/PostHog/posthog-ios/pull/686 subscribes to person-property changes, re-resolves the active survey's translation, and pushes the update to the rendering delegate, no-oping 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
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
Read posthog_flutter/lib/src/surveys/survey_service.dart and the native serialization path at posthog_flutter/darwin/posthog_flutter/Sources/posthog_flutter/PostHogDisplaySurvey+Dict.swift, plus Android's toMap(). After the linked native SDK work is available, trace the existing showSurvey/hideSurveys channel flow. Done means an updateSurvey payload reaches the displayed Flutter survey and causes it to rebuild with the new translation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100