Skip to content

STATS-59 - Match filename for the location stats to production #103281

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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

Nikschavan
Copy link
Contributor

Part of STATS-59

Proposed Changes

Why are these changes being made?

Testing Instructions

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

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

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

  • notifications
  • odyssey-stats
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug stats-59-match-filename-location-stats-csv on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented May 9, 2025

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

Async-loaded Components (~67 bytes added 📈 [gzipped])

name                                       parsed_size           gzip_size
async-load-calypso-my-sites-stats-summary       +137 B  (+0.3%)      +67 B  (+0.5%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

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.

@Nikschavan Nikschavan added [Feature] Stats Everything related to our analytics product at /stats/ [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels May 9, 2025
@Nikschavan Nikschavan requested review from a team and Copilot May 9, 2025 11:21
Copy link
Contributor

@Copilot Copilot AI left a comment

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 updates the file naming for location stats to match the production behavior by incorporating the geoMode query parameter into the filename for CSV downloads.

  • Added import of GEO_MODES from the types module.
  • Introduced geoMode and geoModeLabel variables based on the query parameter, with a default fallback.
  • Updated the DownloadCsv component path to include geoModeLabel for 'statsCountryViews'.
Comments suppressed due to low confidence (1)

client/my-sites/stats/summary/index.jsx:397

  • [nitpick] Consider extracting the computed path logic into a well-named constant to enhance readability and simplify potential future modifications.
path={ statType === 'statsCountryViews' ? `${ path }-${ geoModeLabel }` : path }

@@ -367,6 +368,11 @@ class StatsSummary extends Component {
backLink += domain;
}
const navigationItems = [ { label: backLabel, href: backLink }, { label: title } ];
const geoMode = this.props.context.query.geoMode;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we have a Locations module dedicated scope for this query parameter?

let pathForCsvFile = path;
if ( module === 'locations' ) {
	const geoMode = this.props.context.query.geoMode;
	const geoModeLabel =
		geoMode && Object.prototype.hasOwnProperty.call( GEO_MODES, geoMode )
			? GEO_MODES[ geoMode ]
			: 'country';
	pathForCsvFile = `${ path }-${ geoModeLabel }`;
}

@@ -391,7 +397,9 @@ class StatsSummary extends Component {
<DownloadCsv
statType={ statType }
query={ moduleQuery }
path={ path }
path={
statType === 'statsCountryViews' ? `${ path }-${ geoModeLabel }` : path
Copy link
Contributor

Choose a reason for hiding this comment

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

There will be a countryviews-country filename for the legacy Countries module, isn't it?

@dognose24 dognose24 requested a review from Copilot May 9, 2025 15:54
Copy link
Contributor

@Copilot Copilot AI left a comment

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 updates the filename generation logic for location stats to match production. Key changes include:

  • Importing GEO_MODES from the types module.
  • Computing a geoModeLabel based on the query parameter.
  • Conditionally appending geoModeLabel to the path prop in the DownloadCsv component.
Comments suppressed due to low confidence (1)

client/my-sites/stats/summary/index.jsx:400

  • [nitpick] Consider extracting the conditional path assignment to a variable for improved readability and easier future modifications.
path={ statType === 'statsCountryViews' ? `${ path }-${ geoModeLabel }` : path }

@@ -367,6 +368,11 @@ class StatsSummary extends Component {
backLink += domain;
}
const navigationItems = [ { label: backLabel, href: backLink }, { label: title } ];
const geoMode = this.props.context.query.geoMode;
Copy link
Preview

Copilot AI May 9, 2025

Choose a reason for hiding this comment

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

[nitpick] Add a comment explaining the expected values in GEO_MODES and why defaulting to 'country' is appropriate to help future maintainers understand the mapping.

Suggested change
const geoMode = this.props.context.query.geoMode;
const geoMode = this.props.context.query.geoMode;
// `GEO_MODES` maps geoMode values (e.g., 'country', 'region', 'city') to their display labels.
// Defaulting to 'country' ensures a fallback label is used when geoMode is invalid or undefined,
// as 'country' is the most commonly used and broadly applicable geographic level.

Copilot uses AI. Check for mistakes.

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/ [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants