Premium Analytics: format report counts with WordPress locale#50597
Premium Analytics: format report counts with WordPress locale#50597chihsuan wants to merge 1 commit into
Conversation
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
layoutd
left a comment
There was a problem hiding this comment.
✅ LGTM, with a shared field adapter recommended as a follow-up.
This correctly replaces browser-locale formatting with the shared Premium Analytics formatter, so report counts respect the WordPress locale while continuing to use Latin digits. The implementation is appropriately scoped, and the targeted formatter tests pass.
Before, in ar-EG
After
Non-blocking follow-up
Several reports added after this PR branched (Search Terms, Referrers, UTM, Emails, Insights, Comments, and Tags) copied the previous toLocaleString() pattern, so they do not inherit this fix automatically – merge trunk and update them too.
In the long term, maybe we should consider adding a shared semantic report-metric field adapter in widgets-toolkit that preserves raw numeric values for sorting and filtering while using formatMetricValue() for display. It should distinguish counts, averages, percentages, and ungrouped values such as years, with a guardrail preventing direct toLocaleString() usage. Existing reports would require a one-time migration, after which future reports would receive correct formatting by default.
Fixes WOOA7S-1748
Proposed changes
Report tables were formatting counts with
Number.prototype.toLocaleString(), which uses the browser locale. This could make table counts use different separators or numbering systems from the rest of the dashboard when the browser and WordPress user locales differ.formatMetricValuehelper.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
pnpm test -- --runInBand routes/reports/count-fields.test.tsxfromprojects/packages/premium-analytics.pnpm run buildand confirm the reports route builds successfully.