-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(web-analytics): Display visits by language #26432
Conversation
const parsedCountryCode = countryCode?.match(/([A-Z]{2})/)?.[0] ?? '' | ||
return ( | ||
<> | ||
{countryCodeToFlag(parsedCountryCode)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a fallbackFlag(language)
, it doesn't need many entries, but would have nl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only added nl
because it's probably the most impactful one that hasn't got any followups (Germany would be too, but there's de-DE
and de-AT
, and Poland seems to always be pl-PL
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we have this running in prod I can go back and check if there's any obvious offender here
This is doing some magic to filter by language. It's taking the browser language and then moving on to get just the language from the locale (i.e. pt from pt-BR). Because we want to be smart with the flags, however, we are collecting the country with the most views out of them. This should guarantee that people will see a British flag for en if most of their userbase is in the UK or an American flag if it's in America (or India, Nigeria, Australia, etc.) There's still a small bug where filtering won't work if you simply click on the row, that needs to be updated. See #26376
6ad1fc1
to
30b9a1e
Compare
Size Change: 0 B Total Size: 1.16 MB ℹ️ View Unchanged
|
# which is causing this to be flaky (en-GB happens sometimes), | ||
# we'll instead assert on a reduced form where we're | ||
# not counting the country, but only the locale | ||
# assert results == [["en-US", 1.0, 3.0], ["pt-BR", 1.0, 2.0], ["nl-", 1.0, 1.0]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning
We need to wait for #26409 because I've fixed some sorting issues during tests in that PRThis is doing some magic to filter by language. It's taking the browser language and then moving on to get just the language from the locale (i.e. pt from pt-BR). Because we want to be smart with the flags, however, we are collecting the country with the most views out of them. This should guarantee that people will see a British flag for en if most of their userbase is in the UK or an American flag if it's in America (or India, Nigeria, Australia, etc.)
Closes #26376
Changes
Does this work well for both Cloud and self-hosted?
Yep
How did you test this code?
Manually + unit tests on the new language code.