Skip to content

Hides the Blaze badge on the Stats page when the feature is disabled #43048

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

sbarbosa
Copy link
Contributor

@sbarbosa sbarbosa commented Apr 11, 2025

Fixes Automattic/wp-calypso#101987

We are displaying the Blaze link on the Stats page when the Blaze feature is off; if users click it, they will end up on an invalid page. The main problem is that the site and user connection are now handled separately, and it's more common to land on this case. (Blaze needs both connections to work correctly).

Proposed changes:

Include the can_blaze flag as one of the initial parameters for the Jetpack Stats module (Odyssey app).

Note for Reviewers: Because of a phan error, I had to include the blaze package as a dependency in the Stats. Please let me know if there are different ways to do this. I guarded my code in case the stats module is working on a standalone solution.

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

N/A

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

No

Testing instructions:

You will need to have a site with some stats, so try to access the posts a couple of times before starting the test.

  • Access any self-hosted and navigate to Jetpack->Stats
  • Verify that you see the Blaze badge on any of the posts from the "Post & Pages" section:
    Screenshot 2025-04-11 at 5 02 40 PM
  • Now disconnect your user from WPCOM (just the user)
  • Go back to Jetpack->Stats and verify that you no longer see the Blaze Badge.

@sbarbosa sbarbosa requested a review from kangzj April 11, 2025 20:04
@sbarbosa sbarbosa self-assigned this Apr 11, 2025
Copy link
Contributor

github-actions bot commented Apr 11, 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 fix/blaze-badge-stats-page branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/blaze-badge-stats-page
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/blaze-badge-stats-page

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 Apr 11, 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:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: May 6, 2025
    • Code freeze: May 5, 2025

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


Mu Wpcom plugin:

  • Next scheduled release: WordPress.com Simple releases happen semi-continuously (PCYsg-Jjm-p2)

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


Wpcomsh plugin:

  • Next scheduled release: Atomic deploys happen twice daily on weekdays (p9o2xV-2EN-p2)

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

@github-actions github-actions bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Apr 11, 2025
@sbarbosa sbarbosa removed the request for review from kangzj April 11, 2025 20:14
@sbarbosa sbarbosa added [Status] In Progress and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Apr 11, 2025
Copy link

jp-launch-control bot commented Apr 11, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/packages/stats-admin/src/class-odyssey-config-data.php 110/112 (98.21%) 0.03% 0 💚

Full summary · PHP report · JS report

@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Wpcomsh labels Apr 14, 2025
Copy link
Contributor

@timur987 timur987 left a comment

Choose a reason for hiding this comment

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

Thanks @sbarbosa!

The code LGTM and works as advertised.

For next reviewers

Using a local Jetpack is not the best way to test this PR because when I tried it I wasn't able to bring views there even after waiting for significant amount of time and trying various devices (tried accessing a post from phone, using VPN and so on).

Instead, please use a one-time Jurassic Ninja site together with Beta Tester plugin (link) by putting a feature branch as on the image below.

Screenshot 2025-04-14 at 16 12 23


Side note

Even though what I want to mention is far beyond this PR, it still should be mentioned.
I noticed that blaze icon is shown for posts but is not shown for pages as on a gif below.

blaze-only-posts

@@ -40,6 +40,8 @@ public function get_data() {
$blog_id = Jetpack_Options::get_option( 'id' );
$host = new Host();

$can_blaze = class_exists( 'Automattic\Jetpack\Blaze' ) && \Automattic\Jetpack\Blaze::should_initialize()['can_init'] === true;
Copy link
Contributor

Choose a reason for hiding this comment

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

I see Phan static analysis gone mad and returned according error.

image

I found that there's a way to calm it a bit. Previously folks used this approach to make it happier: https://github.com/Automattic/jetpack/pull/41857/files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I changed how I guard the code and explicitly use an if wrapper. I still had to add the blaze package in the composer.

I will update the ticket to mention that so I can get feedback from the Jetapck team if I need to solve that problem differently.

@sbarbosa sbarbosa requested review from therocket-gr and kangzj April 14, 2025 13:21
@sbarbosa sbarbosa added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Apr 14, 2025
@github-actions github-actions bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Apr 14, 2025
Copy link
Contributor

@therocket-gr therocket-gr left a comment

Choose a reason for hiding this comment

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

tested using a jurrasic site and worked as described
code changes LGTM

@sbarbosa sbarbosa added [Status] Needs Review This PR is ready for review. [Type] Bug When a feature is broken and / or not performing as intended and removed Bug [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Stats Admin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Wpcomsh [Status] Needs Review This PR is ready for review. [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stats: do not display Blaze icon when user is not connected
3 participants