Skip to content

Premium Analytics: add a Regions view to the Locations widget - #51312

Merged
Nikschavan merged 3 commits into
trunkfrom
wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates
Aug 21, 2026
Merged

Nikschavan merged 3 commits into
trunkfrom
wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

Fixes WOOA7S-1922

Proposed changes

#51267 added the Regions view while this branch was open, and it shipped the dropdown option, the map rollup, and the report link. This PR is now only the part that view still lacks. In Regions mode the map colours a country by the sum of its regions, but the tooltip named only that total, so nothing said which regions the colour stood for.

  • Give each summed country a tooltip that lists its top 10 regions with views, then "…and N more locations". The listed values add up to the total that colours the country.
  • Export GoogleDataTableColumnRoleType from @automattic/charts as a value, not a type. A GeoChart tooltip column must name the enum member, so no consumer could declare one. It passes through externals and widgets-toolkit like the other chart exports.
  • Stop a GeoChart HTML tooltip from breaking its lines. Google gives that tooltip no width, so the box shrinks to the room left beside the hovered country. Near a map edge it broke even a short country name across two lines. The box now sizes to its content. This applies to every GeoChart that uses HTML tooltips, not only this widget.

Cities mode keeps the default tooltip, and the country drill-down is unchanged.

Before After
Regions mode tooltip on the United States showing only the country name and Views: 83,381 Regions mode tooltip on India listing Maharashtra, Delhi and Telangana with their views, each on one line
The tooltip gives the country total only. Nothing on the map says which regions add up to 83,381. The tooltip lists the regions behind the total, and the box widens to hold each line whole.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No. The tooltip reads the region rows that Regions mode already fetches from stats/location-views/region.

Testing instructions

  • Build and activate: jp build plugins/premium-analytics --deps.
  • Go to Jetpack → Analytics and find the Locations widget.
  • Set the View by control to Regions.
  • Hover a coloured country on the map. The tooltip should list that country's regions and their views, one region per line.
  • Confirm the listed values add up to the country total. Compare the total against the map legend.
  • Hover a country whose tooltip opens near the left or right edge of the map. Every line should stay on one line, including the country name.
  • On a country with more than 10 regions, the last line should read "…and N more locations".
  • Regression, Cities mode: the map still colours whole countries, and the tooltip still shows the country total only.
  • Regression, Countries mode: click a country row. It should still drill into that country's province map.
  • Storybook alternative: run pnpm run storybook in projects/packages/premium-analytics, then open Packages → Premium Analytics → Widgets → Locations → RegionsMode.

@Nikschavan Nikschavan self-assigned this Aug 17, 2026
@Nikschavan
Nikschavan force-pushed the wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates branch from dffdaa4 to 722984a Compare August 17, 2026 06:38
@github-actions

github-actions Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: September 7, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Mu Wpcom plugin:

  • Next scheduled release: WordPress.com Simple releases happen semi-continuously (PCYsg-Jjm-p2)

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Premium Analytics plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions

github-actions Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates
bin/jetpack-downloader test jetpack-mu-wpcom-plugin wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@jp-launch-control

jp-launch-control Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/widgets/locations/render.tsx 65/88 (73.86%) 3.73% 0 💚

Full summary · PHP report · JS report

@Nikschavan
Nikschavan force-pushed the wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates branch from bc51d82 to 8f9aff2 Compare August 17, 2026 08:42
@Nikschavan
Nikschavan marked this pull request as ready for review August 17, 2026 09:16
Copilot AI lite review requested due to automatic review settings August 17, 2026 09:16
@Nikschavan
Nikschavan requested a review from a team as a code owner August 17, 2026 09:16
@Nikschavan
Nikschavan requested a review from a team August 17, 2026 09:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores “Regions” parity in Premium Analytics’ Locations widget by adding a Regions view that spans all countries, improving map aggregation/tooltip behavior, and ensuring “View all” deep-links to the matching report tab. It also adjusts chart exports so consumers can build GeoChart tooltip columns.

Changes:

  • Add a Regions mode to the Locations widget (UI control + data/map rendering + “View all” routing).
  • Roll up region rows to country totals on the world map and add rich tooltips listing top regions per country.
  • Export GoogleDataTableColumnRoleType as a runtime value from @automattic/charts and re-export through the Premium Analytics toolkit/externals; update Storybook mocks accordingly.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
projects/plugins/wpcomsh/changelog/wooa7s-1922-locations-regions Add wpcomsh changelog entry for Regions view.
projects/plugins/premium-analytics/changelog/wooa7s-1922-locations-regions Add premium-analytics plugin changelog entry for Regions view.
projects/plugins/mu-wpcom-plugin/changelog/wooa7s-1922-locations-regions Add mu-wpcom-plugin changelog entry for Regions view.
projects/plugins/jetpack/changelog/wooa7s-1922-locations-regions Add Jetpack plugin changelog entry for Regions view.
projects/packages/premium-analytics/widgets/locations/widget.ts Extend widget attribute union + add “Regions” option in View By list.
projects/packages/premium-analytics/widgets/locations/stories/locations-widget.stories.tsx Add Regions mode Storybook story and update controls/docs text.
projects/packages/premium-analytics/widgets/locations/render.tsx Implement Regions rendering: country rollups, tooltips, and correct report section linking.
projects/packages/premium-analytics/widgets/locations/package.json Add formatter dependency used by tooltip formatting.
projects/packages/premium-analytics/widgets/locations/tests/locations.test.tsx Add tests for report linking and Regions rollup/tooltip behavior; adjust mocks.
projects/packages/premium-analytics/packages/widgets-toolkit/src/stories/mocks/register-stats-mocks.ts Return unscoped regions across all countries in Storybook mocks (endpoint parity).
projects/packages/premium-analytics/packages/widgets-toolkit/src/index.ts Re-export GoogleDataTableColumnRoleType for widget consumers.
projects/packages/premium-analytics/packages/externals/src/index.ts Re-export GoogleDataTableColumnRoleType via externals.
projects/packages/premium-analytics/changelog/wooa7s-1922-locations-regions Add package changelog entry for Locations widget Regions parity.
projects/js-packages/charts/src/index.ts Export GoogleDataTableColumnRoleType as a runtime value (not type-only).
projects/js-packages/charts/changelog/wooa7s-1922-locations-regions Add charts changelog entry for the new value export.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread projects/packages/premium-analytics/widgets/locations/render.tsx Outdated
@dognose24

Copy link
Copy Markdown
Contributor

Heads-up: this collides with #51267 (WOOA7S-1940 — a duplicate report of WOOA7S-1922), which adds the same Regions view and touches the same five files; whichever merges first conflicts the other. Since #51267 is a few days into review, one clean split would be: #51267 lands the core view, and this PR shrinks to its genuinely distinctive parts — the per-country region tooltip and the GoogleDataTableColumnRoleType value export (which also keeps the js-packages/charts bump out of the core fix). Worth syncing with @kangzj before either moves.

Two findings that would apply to the tooltip follow-up either way:

  1. buildCountryTooltip interpolates location.label into an html: true tooltip string unescaped — geo names are WPCOM-derived, but nothing upstream sanitizes them, so escape before interpolating.
  2. The rollup sums the capped rows (maxRows trims to 10 in the data layer), so a country's map value is "its regions that made the global top 10", not its regions total — and the tooltip's "…and N more" counts within that cap. Cities mode has the same pre-existing flaw. The email-breakdown widget's mapRows={ allRows } pattern (uncapped rows for the map, capped for the leaderboard) is the in-repo precedent for fixing it.

@kangzj

kangzj commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

I went ahead a merged #51267. Sorry I didn't realized there was already an issue WOOA7S-1922 for this.

@Nikschavan
Nikschavan force-pushed the wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates branch from 8f9aff2 to 6db632e Compare August 18, 2026 05:10
chihsuan
chihsuan previously approved these changes Aug 19, 2026

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update @Nikschavan Looks good to me! 👍

Image

@Nikschavan
Nikschavan force-pushed the wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates branch 2 times, most recently from 6f9cd5f to 9506324 Compare August 20, 2026 12:53
The Locations widget offered Countries and Cities only, so regions were reachable just by drilling into one country. Current Jetpack Stats has a Regions tab, so v2 lost state-level traffic for sites that rely on it.

Regions joins the View by dropdown and spans every country. Google GeoChart draws subdivisions only inside a single country's map, so region rows are summed onto their country on the world map, and each country carries its own regions in a tooltip.

Fixes WOOA7S-1922
The widget test mocked the data hook empty, so neither the country rollup nor the tooltip builder ever ran.
Google gives its HTML tooltip no width, so the box shrink-to-fits against
the room left beside the hovered feature. Opened near a map edge it broke
even a short country name across lines, which the default SVG tooltip
never did.
@Nikschavan
Nikschavan force-pushed the wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates branch from 9506324 to 698e261 Compare August 21, 2026 01:32
@Nikschavan
Nikschavan merged commit b806b7c into trunk Aug 21, 2026
126 of 127 checks passed
@Nikschavan
Nikschavan deleted the wooa7s-1922-feedback-stats-v2-locations-view-is-missing-regionsstates branch August 21, 2026 04:46
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] In Progress labels Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[JS Package] Charts [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Premium Analytics [Plugin] Wpcomsh RNA [Status] UI Changes Add this to PRs that change the UI so documentation can be updated.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants