UNI-828: Premium Analytics: Show cities as markers on the Locations map - #52859
Nikschavan merged 3 commits into
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
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 2 files.
|
The Cities view summed cities back up to shaded countries, so the map did not change when Cities was picked. Draw each city at the coordinates the API already sends, as Calypso Stats does, in the widget and the report.
7c584fe to
006960e
Compare
A header-only table makes Google type every column as a string, which a markers map rejects with an error bar. Type the header columns, and share StatsLocationCoordinates instead of repeating the shape.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Correct marker data ordering and address the documentation and plugin changelog gaps.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
Adds city markers to Premium Analytics Locations maps using API-provided coordinates, while preserving country and region shading.
Changes:
- Propagates and validates city coordinates through widgets and reports.
- Adds marker-mode support to
GeoChart. - Updates tests, documentation, and changelogs.
Review notes: Correct the marker data column ordering, add a focused marker story and guidance, and add corresponding Premium Analytics plugin changelog entries.
| File | Summary |
|---|---|
projects/packages/premium-analytics/widgets/locations/use-location-views.ts |
Carries coordinates into widget rows. |
projects/packages/premium-analytics/widgets/locations/render.tsx |
Passes coordinates to the widget map. |
projects/packages/premium-analytics/routes/reports/locations/page.tsx |
Passes coordinates to the report map. |
projects/packages/premium-analytics/routes/reports/locations/config/fields.tsx |
Adds coordinates to report row types. |
projects/packages/premium-analytics/routes/reports/locations/config/aggregate.ts |
Preserves coordinates during aggregation. |
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/report-page/report-locations-map.tsx |
Updates map guidance text. |
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/locations-geo-chart/locations-geo-chart.tsx |
Supplies marker mode to GeoChart. |
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/locations-geo-chart/build-geo-data.ts |
Builds marker and regional data; marker value ordering needs correction. |
projects/packages/premium-analytics/packages/widgets-toolkit/src/components/locations-geo-chart/__tests__/build-geo-data.test.ts |
Tests marker data and filtering. |
projects/packages/premium-analytics/packages/data/src/processing/stats/locations.ts |
Parses coordinate data. |
projects/packages/premium-analytics/packages/data/src/processing/stats/index.ts |
Exports coordinate types. |
projects/packages/premium-analytics/packages/data/src/processing/stats/__tests__/locations.test.ts |
Tests coordinate normalization. |
projects/packages/premium-analytics/packages/data/src/index.ts |
Re-exports coordinate types. |
projects/packages/premium-analytics/changelog/uni-828-city-map-markers |
Adds the package changelog entry. |
projects/js-packages/charts/src/index.ts |
Exports GeoDisplayMode. |
projects/js-packages/charts/src/charts/geo-chart/types.ts |
Defines the marker display-mode API. |
projects/js-packages/charts/src/charts/geo-chart/test/geo-chart.test.tsx |
Tests marker option forwarding. |
projects/js-packages/charts/src/charts/geo-chart/stories/index.api.mdx |
Documents the new prop; needs a focused marker story and usage guidance. |
projects/js-packages/charts/src/charts/geo-chart/index.ts |
Re-exports the new type. |
projects/js-packages/charts/src/charts/geo-chart/geo-chart.tsx |
Applies marker display options. |
projects/js-packages/charts/changelog/uni-828-city-map-markers |
Adds the Charts package changelog entry. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
louwie17
left a comment
There was a problem hiding this comment.
Thanks @Nikschavan, this tested well and code looks good! I bet users will be happy with this update, it seems to be one of the main requested items in the feedback. I also tested this with some larger numbers and it all looked good.
I did leave one small inline comment, but it's not a blocker. LGTM 🚀
| GeoChartProps, | ||
| GeoRegion, | ||
| GeoResolution, | ||
| GeoDisplayMode, |
There was a problem hiding this comment.
Do we need to export GeoDisplayMode? Nothing imports it, and build-geo-data.ts writes out 'regions' | 'markers' inline anyway. So we should either use it there or keep it internal, GeoChartProps['displayMode'] covers any outside callers. Small nit, happy to ignore this.
There was a problem hiding this comment.
Thank you. I went with using it: #53016 re-exports GeoDisplayMode through externals and uses it in buildLocationsGeoChart in place of the inline union. I kept the export because the type already shipped in Charts 4.6.0 and it names a value that is already part of GeoChartProps.

Fixes UNI-828
Proposed changes
@automattic/chartsGeoChartgets adisplayModeprop ('regions'by default, or'markers') so the Locations map can ask for markers. Every otherGeoChartkeeps the shaded regions it draws today.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Get this branch onto a Jetpack site with Stats data from a few cities, either with the Jetpack Beta Tester plugin pointed at this branch or on a Jurassic Ninja site with the branch synced.
I tested this on a local site against trunk with cities in India and the United States. I did not have a site where the API sends cities without coordinates, so I removed the coordinates from the locations response in the browser; the Cities map then drew an empty world map with no error.