fix(surveys): re-translate displayed surveys when user language changes#4195
Open
nandinitiw wants to merge 3 commits into
Open
fix(surveys): re-translate displayed surveys when user language changes#4195nandinitiw wants to merge 3 commits into
nandinitiw wants to merge 3 commits into
Conversation
…cking Include service_tier in the getModelParams extraction so that flex/priority tier requests are reflected in $ai_model_parameters and the backend can apply the correct pricing multiplier when calculating $ai_total_cost_usd. Closes #2323
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
When identify() sets a new 'language' person property, or the browser fires a languagechange event, any popover survey currently on screen stays in the old language until dismissed. This wires up both triggers to re-detect the resolved language and re-render in place when it differs from what was originally shown. Closes PostHog#4174
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.
What
When a survey popover is on screen, it was never re-translated if the user's language changed mid-session. This happened in two scenarios:
posthog.identify()/setPersonPropertiesForFlags()sets a newlanguageperson propertylanguagechangeevent (OS/browser language switch)The TODO comment in
survey-translations.tsalready called this out as a known gap.How
In
SurveyManager:window.languagechangelistener in the constructorposthog.onFeatureFlags()(which fires afteridentify()reloads flags)_onLanguageChange(), which:_currentLanguageand re-renders the popover viarenderPopover()destroy()_currentLanguageis cleared when a survey is dismissedThe iOS reference implementation in posthog-ios #686 follows the same pattern.
Tests
5 new unit tests covering:
_currentLanguageon dismisslanguagechangelistener ondestroy()Closes #4174