Skip to content

STATS-60 - Fix: match the Video stats CSV download to the production export #103287

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 2 commits into
base: trunk
Choose a base branch
from

Conversation

Nikschavan
Copy link
Contributor

@Nikschavan Nikschavan commented May 9, 2025

Part of STATS-60

Proposed Changes

  • Introduce a new normalizer statsVideoPlaysCompleteStats to normalize the stats from video stats query where complete_stats=1 is passed

Why are these changes being made?

  • To match the CSV export in the new header layout

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)?

@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 a review from Copilot May 9, 2025 12:22
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 introduces a new normalizer (statsVideoPlaysCompleteStats) to process video plays data when the query includes complete stats, matching the CSV format of production.

  • Introduces a new normalizer to enrich video plays data with impressions, watch time, and retention rate.
  • Sets a complete_stats flag in the stats summary module to trigger the new behavior.
  • Updates CSV export logic to use normalized data for video plays stats.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
client/state/stats/lists/utils.js Adds the statsVideoPlaysCompleteStats normalizer function.
client/my-sites/stats/summary/index.jsx Adds moduleQuery.complete_stats to trigger the complete stats flow.
client/my-sites/stats/stats-download-csv/index.jsx Uses getSiteStatsNormalizedData for statsVideoPlays to fetch CSV data.
Comments suppressed due to low confidence (1)

client/state/stats/lists/utils.js:483

  • Consider renaming the 'label' property to 'title' to match the header row and ensure consistency between the object property and CSV header.
label: item.title,

@matticbot
Copy link
Contributor

matticbot commented May 9, 2025

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

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

  • help-center
  • odyssey-stats

To test WordPress.com changes, run install-plugin.sh $pluginSlug stats-59-video-stats on your sandbox.

const data =
statType === 'statsVideoPlays'
? getSiteStatsNormalizedData( state, siteId, statType, query )
: getSiteStatsCSVData( state, siteId, statType, query );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am adding a condition here because getSiteStatsCSVData calles another function that only keeps three columns of data in the export. This is being used in all the other exports hence I did not refactor this to handle this data for now to avoid a larger PR

@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:

Sections (~259 bytes added 📈 [gzipped])

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

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

name                                       parsed_size           gzip_size
async-load-calypso-my-sites-stats-summary        +19 B  (+0.0%)       +5 B  (+0.0%)

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 requested a review from a team May 9, 2025 12:26
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.

2 participants