Skip to content
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

Stats Location: update geochart to use coordinates for Regions and Cities #99142

Merged
merged 13 commits into from
Feb 4, 2025

Conversation

Initsogar
Copy link
Contributor

@Initsogar Initsogar commented Jan 31, 2025

Related to https://github.com/Automattic/jetpack-roadmap/issues/2242

Proposed Changes

  • Use coordinates to render markers for cities and regions in Geochart.

Note

The regions API doesn’t return coordinates yet, but the idea is to have the code ready for when they become available.

Why are these changes being made?

We tried an approach that uses geocoding to obtain coordinates from the Google Maps API. The goal is to use the coordinates available in our Locations API to avoid relying on the Google Maps API.

Testing Instructions

  • Spin up Calypso Live Branch.
  • Navigate to the Stats page.
  • Ensure that switching to the Cities tab renders the markers quickly.
  • Try to see the Cities tab on the summary/detailed page, and try some country filters.
  • The regions tab should not draw any marker.
  • Using a site with WordPress.com Personal plan, you can validate the Regions and Cities tabs are gated and loads markers in the blurry map.

CleanShot 2025-02-03 at 22 10 50@2x

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@matticbot
Copy link
Contributor

matticbot commented Jan 31, 2025

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • odyssey-stats

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/stats-locations-cities-map on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented Jan 31, 2025

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~281 bytes added 📈 [gzipped])

name                               parsed_size           gzip_size
stats                                   +813 B  (+0.1%)     +281 B  (+0.1%)
woocommerce-installation                 +46 B  (+0.0%)      +18 B  (+0.0%)
woocommerce                              +46 B  (+0.0%)      +18 B  (+0.0%)
themes                                   +46 B  (+0.0%)      +18 B  (+0.0%)
theme                                    +46 B  (+0.0%)      +18 B  (+0.0%)
subscribers                              +46 B  (+0.0%)      +18 B  (+0.0%)
staging-site                             +46 B  (+0.0%)      +18 B  (+0.0%)
sites-dashboard                          +46 B  (+0.0%)      +18 B  (+0.0%)
site-tools                               +46 B  (+0.0%)      +18 B  (+0.0%)
site-settings                            +46 B  (+0.0%)      +18 B  (+0.0%)
site-purchases                           +46 B  (+0.0%)      +18 B  (+0.0%)
site-performance                         +46 B  (+0.0%)      +18 B  (+0.0%)
site-overview                            +46 B  (+0.0%)      +18 B  (+0.0%)
site-monitoring                          +46 B  (+0.0%)      +18 B  (+0.0%)
site-marketing                           +46 B  (+0.0%)      +18 B  (+0.0%)
site-logs                                +46 B  (+0.0%)      +18 B  (+0.0%)
settings-writing                         +46 B  (+0.0%)      +18 B  (+0.0%)
settings-security                        +46 B  (+0.0%)      +18 B  (+0.0%)
settings-reading                         +46 B  (+0.0%)      +18 B  (+0.0%)
settings-podcast                         +46 B  (+0.0%)      +18 B  (+0.0%)
settings-performance                     +46 B  (+0.0%)      +18 B  (+0.0%)
settings-newsletter                      +46 B  (+0.0%)      +18 B  (+0.0%)
settings-jetpack                         +46 B  (+0.0%)      +18 B  (+0.0%)
settings-discussion                      +46 B  (+0.0%)      +18 B  (+0.0%)
settings                                 +46 B  (+0.0%)      +18 B  (+0.0%)
scan                                     +46 B  (+0.0%)      +18 B  (+0.0%)
purchases                                +46 B  (+0.0%)      +18 B  (+0.0%)
promote-post-i2                          +46 B  (+0.0%)      +18 B  (+0.0%)
preview                                  +46 B  (+0.0%)      +18 B  (+0.0%)
posts-custom                             +46 B  (+0.0%)      +18 B  (+0.0%)
posts                                    +46 B  (+0.0%)      +18 B  (+0.0%)
plugins                                  +46 B  (+0.0%)      +18 B  (+0.0%)
plans                                    +46 B  (+0.0%)      +18 B  (+0.0%)
people                                   +46 B  (+0.0%)      +18 B  (+0.0%)
pages                                    +46 B  (+0.0%)      +18 B  (+0.0%)
migrate                                  +46 B  (+0.0%)      +18 B  (+0.0%)
media                                    +46 B  (+0.0%)      +18 B  (+0.0%)
marketplace                              +46 B  (+0.0%)      +18 B  (+0.0%)
marketing                                +46 B  (+0.0%)      +18 B  (+0.0%)
jetpack-social                           +46 B  (+0.0%)      +18 B  (+0.0%)
jetpack-search                           +46 B  (+0.0%)      +18 B  (+0.0%)
jetpack-connect                          +46 B  (+0.0%)      +18 B  (+0.0%)
jetpack-cloud-settings                   +46 B  (+0.0%)      +18 B  (+0.0%)
jetpack-cloud-pricing                    +46 B  (+0.0%)      +18 B  (+0.0%)
jetpack-cloud-plugin-management          +46 B  (+0.0%)      +18 B  (+0.0%)
jetpack-cloud-overview                   +46 B  (+0.0%)      +18 B  (+0.0%)
jetpack-cloud-features-comparison        +46 B  (+0.0%)      +18 B  (+0.0%)
jetpack-cloud                            +46 B  (+0.0%)      +18 B  (+0.0%)
import                                   +46 B  (+0.0%)      +18 B  (+0.0%)
hosting-features                         +46 B  (+0.0%)      +18 B  (+0.0%)
hosting                                  +46 B  (+0.0%)      +18 B  (+0.0%)
home                                     +46 B  (+0.0%)      +18 B  (+0.0%)
gutenberg-editor                         +46 B  (+0.0%)      +18 B  (+0.0%)
google-my-business                       +46 B  (+0.0%)      +18 B  (+0.0%)
github-deployments                       +46 B  (+0.0%)      +18 B  (+0.0%)
export                                   +46 B  (+0.0%)      +18 B  (+0.0%)
email                                    +46 B  (+0.0%)      +18 B  (+0.0%)
earn                                     +46 B  (+0.0%)      +18 B  (+0.0%)
domains                                  +46 B  (+0.0%)      +18 B  (+0.0%)
customize                                +46 B  (+0.0%)      +18 B  (+0.0%)
concierge                                +46 B  (+0.0%)      +18 B  (+0.0%)
comments                                 +46 B  (+0.0%)      +18 B  (+0.0%)
checkout                                 +46 B  (+0.0%)      +18 B  (+0.0%)
backup                                   +46 B  (+0.0%)      +18 B  (+0.0%)
add-ons                                  +46 B  (+0.0%)      +18 B  (+0.0%)
activity                                 +46 B  (+0.0%)      +18 B  (+0.0%)
a8c-for-agencies-plugins                 +46 B  (+0.0%)      +18 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@@ -209,22 +210,9 @@ const StatsLocations: React.FC< StatsModuleLocationsProps > = ( { query, summary
</StatsInfoArea>
);

const fakeData = [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We needed to add coordinates, and I think it’s too much data to keep in this file, so I preferred to move it to its own sample-locations.js file.

@Initsogar Initsogar changed the title Stats Location: update geochart to use coordinates for Cities view Stats Location: update geochart to use coordinates for Regions and Cities Feb 4, 2025
@Initsogar Initsogar requested a review from myhro February 4, 2025 03:12
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 4, 2025
@Initsogar Initsogar added [Feature] Stats Everything related to our analytics product at /stats/ and removed [Status] In Progress labels Feb 4, 2025
Copy link
Contributor

@myhro myhro left a comment

Choose a reason for hiding this comment

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

Nice work, Rafa! I'm approving it, as it LGTM, and we can roll it out as soon as we get support for Regions coordinates. ✅


Ensure that switching to the Cities tab renders the markers quickly.

Not just quickly, but instantly with no network requests:

image

Try to see the Cities tab on the summary/detailed page, and try some country filters.

image

The regions tab should not draw any marker.

image

Using a site with WordPress.com Personal plan, you can validate the Regions and Cities tabs are gated and loads markers in the blurry map.

image

@Initsogar
Copy link
Contributor Author

As discussed in sync, we will proceed with merging this PR even if the coordinates for regions are not ready yet. However, since this PR enables support for them in Stats, we shouldn’t need to create another PR once they are ready.

If we decide to pivot to a different approach, we will prepare a new PR accordingly.

@Initsogar Initsogar merged commit 7b2982e into trunk Feb 4, 2025
13 checks passed
@Initsogar Initsogar deleted the fix/stats-locations-cities-map branch February 4, 2025 15:01
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 4, 2025
JessBoctor pushed a commit that referenced this pull request Mar 13, 2025
…ties (#99142)

* Stats: add subdivisions tooltip

* Update geochart to accept coordinates for Cities view

* Omit coordinates property when no data exists

* Handle region and city mode as markers

* Filter locations with coordinates

* Remove prop that is not needed for now

* Refactor sample locations using coordinates

* Simplify conditions

* Remove unused attribute to sample locations

---------

Co-authored-by: Tiago Ilieve <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Stats Everything related to our analytics product at /stats/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants