Skip to content

Update the stats icon and add pageview count in the post list #42218

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

Merged
merged 38 commits into from
Mar 31, 2025

Conversation

BogdanUngureanu
Copy link
Contributor

@BogdanUngureanu BogdanUngureanu commented Mar 5, 2025

Updates the icon in the Post and Page lists and adds the page view count for each post. The code was also moved in Stats Admin package so that we can be able to reuse the implementation in WPCOM Simple.

The counter displayed in the post list displays the number of views an article had in the last 30 days.

Fixes Automattic/wp-calypso#98912

Before
Screenshot 2025-03-12 at 13 02 13

After
Screenshot 2025-03-12 at 13 01 46

Proposed changes:

  • Change the icon in the post list
  • Add the page views next to the icon for each post
  • Move the logic in a separate class so that it can be reused in WPCOM Simple

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Use the beta tester on an Atomic site and apply these changes
  • Apply the changes on your sandbox
  • Checkout the branch from 176412-ghe-Automattic/wpcom on your sandbox
  • Go to WP-Admin > Posts / Pages (both Atomic and Simple)
  • Notice that we display a different icon for the stats column, with a number of page views

…s directly

Instead of calling the admin menu class, we now use a helper function that returns the object.

This also removes a quick fix that prevented the quick switcher to be registered twice in the UI.
Copy link
Contributor

github-actions bot commented Mar 5, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the update/stats-icon branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/stats-icon
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/stats-icon

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Mar 5, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added [Package] Stats Admin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Mar 5, 2025
Copy link

jp-launch-control bot commented Mar 5, 2025

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/stats/src/class-wpcom-stats.php 85/126 (67.46%) 4.84% 1 ❤️‍🩹
projects/plugins/jetpack/modules/stats.php 3/580 (0.52%) 0.03% -41 💚

1 file is newly checked for coverage.

File Coverage
projects/packages/stats-admin/src/class-admin-post-list-column.php 71/84 (84.52%) 💚

Full summary · PHP report · JS report

/**
* Add a Stats column in the post and page lists.
*/
class Admin_Post_List_Column {
Copy link
Contributor Author

@BogdanUngureanu BogdanUngureanu Mar 10, 2025

Choose a reason for hiding this comment

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

Most of the code here is just moved from modules/stats.php.

We need to move it in a separate class to also use it on Simple Sites.

@BogdanUngureanu BogdanUngureanu requested a review from a team March 14, 2025 16:43
@BogdanUngureanu BogdanUngureanu requested a review from a team March 19, 2025 15:26
@BogdanUngureanu
Copy link
Contributor Author

Hey @Automattic/red Can you have a look at this PR?

This adds a counter in the WP-Admin -> Post list with the number of pageviews a user had in the last 30 days (the same amount of days we used to display in Calypso Post list).

However, there's no UI indication that it's for the last 30 days (like we do in Calypso).

How do you feel about changing the title of the link from "View stats for this post" to something like "X views in the last 30 days. View more stats"?

Copy link
Contributor

@dsas dsas left a comment

Choose a reason for hiding this comment

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

This works nicely for me, and it's good to see more of the implementation unified.

The one last thing remaining is the question about how to make it clear to users what they're looking at.

@dsas dsas requested a review from ederrengifo March 20, 2025 11:40
@BogdanUngureanu BogdanUngureanu requested a review from a team March 26, 2025 22:13
dsas
dsas previously approved these changes Mar 28, 2025
@BogdanUngureanu BogdanUngureanu merged commit e9a49af into trunk Mar 31, 2025
67 checks passed
@BogdanUngureanu BogdanUngureanu deleted the update/stats-icon branch March 31, 2025 15:04
@github-actions github-actions bot removed the [Status] Needs Team Review Obsolete. Use Needs Review instead. label Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Stats Admin [Package] Stats Data [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests [Type] Feature Development of a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add Recent views as a column in Screen Options for Pages/Posts screen
4 participants