Skip to content

Comments

Stats: Disable subscribers tab if subscribers module is disabled#101842

Merged
Nikschavan merged 19 commits intotrunkfrom
fix/80572-disable-stats-tab-if-subscribers-disabled
Mar 28, 2025
Merged

Stats: Disable subscribers tab if subscribers module is disabled#101842
Nikschavan merged 19 commits intotrunkfrom
fix/80572-disable-stats-tab-if-subscribers-disabled

Conversation

@Nikschavan
Copy link
Member

@Nikschavan Nikschavan commented Mar 25, 2025

Related to #80572

Proposed Changes

  • Don't render the menu item of "subscribers" page if the module is disabled
  • Redirect to the /stats homepage from the subscribers stats page if the stats module is disabled.

Why are these changes being made?

  • To not show the settings of the module if it is not activated

Testing Instructions

  • Go to wp-admin > Jetpack > Settings
  • Disable the Subscriptions feature
  • Go to wp-admin > Jetpack > Stats
  • The "Subscribers" nav menu item should be hidden
  • If you try to go by URL to the subscribers stats page, it should redirect you to the stats page

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

@github-actions
Copy link

github-actions bot commented Mar 25, 2025

@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 Mar 25, 2025
@Nikschavan Nikschavan requested a review from a team March 25, 2025 13:57
@matticbot
Copy link
Contributor

matticbot commented Mar 25, 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/80572-disable-stats-tab-if-subscribers-disabled on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented Mar 25, 2025

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

App Entrypoints (~6 bytes added 📈 [gzipped])

Details
name                   parsed_size           gzip_size
entry-main                  +138 B  (+0.0%)       +6 B  (+0.0%)
entry-subscriptions          +58 B  (+0.0%)       -2 B  (-0.0%)
entry-stepper                +58 B  (+0.0%)       -2 B  (-0.0%)
entry-login                  +58 B  (+0.0%)       -2 B  (-0.0%)
entry-domains-landing        +58 B  (+0.0%)       -2 B  (-0.0%)
entry-browsehappy            +58 B  (+0.0%)       -2 B  (-0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~3901 bytes removed 📉 [gzipped])

Details
name                parsed_size           gzip_size
google-my-business       +371 B  (+0.1%)    +1131 B  (+0.7%)
stats                    +241 B  (+0.0%)     +995 B  (+0.3%)
woocommerce               +40 B  (+0.0%)       +7 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 (~613 bytes added 📈 [gzipped])

Details
name                                                 parsed_size           gzip_size
async-load-store-app-store-stats                          +371 B  (+0.1%)     +527 B  (+0.7%)
async-load-calypso-my-sites-stats-pages-subscribers       +211 B  (+0.1%)      +86 B  (+0.1%)

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.

Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

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

Fantastic work! It works well for me and the changes look good to me!

Copy link
Contributor

@annacmc annacmc left a comment

Choose a reason for hiding this comment

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

Looks great, works well for me! 🚀

Copy link
Contributor

@dognose24 dognose24 left a comment

Choose a reason for hiding this comment

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

Great work to reuse siteSelection for the site data before going to pages on Odyssey Stats! It works well to avoid the Subscribers tab item flickering. 👍🏼 Just left some nit comments.

On the other hand, can we fetch the site options.active_modules when preparing the initial state on the Jetpack side? 🤔 cc @kangzj

@Nikschavan
Copy link
Member Author

On the other hand, can we fetch the site options.active_modules when preparing the initial state on the Jetpack side?

I was planning to add this and make the render blocking stats request optional if we already have active_plugins, but now that we have removed the /site request from the routes (#101842 (comment)) I feel like there is no specific advantage of having or not having this extra option. Let me know your thoughts @dognose24, @kangzj

setupContextMiddleware( store, queryClient );

// Initialize site data early in the app boot process.
await initializeSiteData( store );
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏼

Copy link
Contributor

@dognose24 dognose24 left a comment

Choose a reason for hiding this comment

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

LGTM and works as described! 👍🏼

@dognose24
Copy link
Contributor

I was planning to add this and make the render blocking stats request optional if we already have active_plugins

The current improvement looks good enough. I was just curious if we could easily fetch active_modules on the backend, as it came from the endpoint /wp-json/jetpack/v4/site on the Jetpack side.

@kangzj
Copy link
Contributor

kangzj commented Mar 28, 2025

I was planning to add this and make the render blocking stats request optional if we already have active_plugins

I personally prefer doing async requests after the page generated. Fetching those data in the initial state would increase the page execution time, which isn't ideal as users wouldn't even see a spinner if the page is not generated by PHP yet. So I would like the current approach better.

@kangzj
Copy link
Contributor

kangzj commented Mar 28, 2025

As an improvement point for the future:

We could send the setLocale asynchronous calls together with the site information request in parallel, so that the page finishes loading faster.

PS: I can feel the latency added to the page loading on my local with this PR, so it might be worth looking into as follow ups.

Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

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

:shipit:

@Nikschavan Nikschavan merged commit 6cd8e0f into trunk Mar 28, 2025
13 checks passed
@Nikschavan Nikschavan deleted the fix/80572-disable-stats-tab-if-subscribers-disabled branch March 28, 2025 06:17
@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 Mar 28, 2025
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.

5 participants