Premium Analytics: Add Locations geo mode controls - #50251
Merged
Conversation
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
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! |
Code Coverage SummaryCoverage changed in 1 file.
|
…ne-geo-mode # Conflicts: # projects/packages/premium-analytics/widgets/locations/package.json # projects/packages/premium-analytics/widgets/locations/render.tsx # projects/packages/premium-analytics/widgets/locations/style.module.css # projects/packages/premium-analytics/widgets/locations/widget.ts
The ChartWrapper error event does not fire when GeoChart's async map-file load fails, so watch the chart container for the error elements Google injects and report them through the same onError callback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Treat any GeoChart error during a provinces draw as an unsupported province map instead of matching the (localizable) error message, and add Singapore to the known-unsupported fast path alongside Taiwan. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Drop the hardcoded country list; every country now goes through the GeoChart onError detection, with a module-level cache so each country pays the failed provinces draw at most once per page load. The error element is removed in a MutationObserver microtask before the next paint, so the failed draw is not visible. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
dognose24
marked this pull request as ready for review
July 8, 2026 06:24
Expose the geoGranularity toolbar attribute as a Storybook control with a dedicated CitiesMode story, and re-export GeoChartError through the widgets-toolkit charts passthrough instead of re-declaring the shape inline. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Markers with named locations require Google Maps geocoding (a mapsApiKey in the charts loader), which the package does not configure, so they silently render nothing. Switch the story to latitude/longitude city data and document the constraint. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The Cities-as-markers design that motivated it was abandoned mid-branch (markers with named locations need a Google Maps geocoding key), leaving displayMode with no consumers. Keep only the error reporting additions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GeoChart mutates its container heavily while drawing and resizing; rescan for rendered error elements only when a mutation record's added nodes involve a Google error element instead of on every mutation batch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The outer component already defaults max and geoGranularity before passing them down; type LocationsInner's props as required so the invariant is visible and drop the duplicated fallbacks inside. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
useSelectedCountryFallbackMap became identical to useCountryFallbackMap after the fallback-state stabilization; drop it and derive fallbackCountry from the single remaining flag. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Stragglers from a failed provinces draw arrive after the widget already switched to the fallback map; match them via the learned unsupported-country set instead of relying only on the English error message, which Google may localize. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Part of WOOA7S-1491.
Proposed changes
onErrorerror reporting to@automattic/chartsGeoChart. AMutationObserveron the chart container also reports the draw errors Google renders as DOM elements without firing the ChartWrappererrorevent (e.g. async map-file load failures).geoGranularitytoolbar attribute (promoted to the widget host in Premium Analytics: update widget packages and promote in-body controls to widget attributes #50293) — Countries with a world map, country drill-down into a region leaderboard + province map, and Cities with a country-level map aggregated from city rows.provincesmap (e.g. Taiwan, Singapore) to a world map scoped to the selected country. Unsupported countries are learned at runtime from any error during a provinces draw — no hardcoded list — cached per page load, and the injected error element is removed before the next paint, so noRequested map does not exist.error is shown.geoGranularitycontrol to the Locations stories, and update the GeoChart API reference/docs withonError/GeoChartError(backfilling the pre-existingregion/resolutionprops in the same table).Related product discussion/links
Does this pull request change what data or activity we track or use?
No. This changes how existing Locations widget data is displayed.
Testing instructions
projects/js-packages/charts:pnpm run test -- src/charts/geo-chart/test/geo-chart.test.tsx,pnpm run typecheck,pnpm run build.projects/packages/premium-analytics:pnpm run typecheck,pnpm run build.pnpm run storybook:devfromprojects/js-packages/storybook) and check the Locations stories (Default / CitiesMode / WidgetDashboardWithWidget) and the Geo Chart API Reference page.Requested map does not exist.error and a world map containing only the selected country.2026-07-08.10.29.35.mov