Skip to content

Subscriptions: fix subcriber stats links when stats module is not active #44037

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 12 commits into from
Jun 20, 2025

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Jun 20, 2025

Fixes CML-601

Proposed changes:

On self-hosted sites, we link to the Stats page in wp-admin to display subscriber stats. That's problematic when the Stats module is not active, and as a result the stats page is not accessible.

Let's instead redirect folks to the subscribers stats sub-page of Calypso blue stats, when the stats module is not active.

This is now possible because the Subscribers stats sub-page of the Calypso blue stats is not accessible, even when you do not use the Stats module.
See pejTkB-24B-p2

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:

Note

You will want to test this on WordPress.com Simple sites and on a self-hosted/WoA site

  • On a self-hosted site that's connected to WordPress.com or on a simple site
  • (on self-hosted site) Go to Jetpack > Settings > Modules
  • (on self-hosted site) Deactivate the stats module and activate the subscriptions module
  • Go to the main wp-admin page
  • Check the links displayed in the newsletter dashboard widget.
    • Pay close attention to the following links:
Screenshot 2025-06-20 at 13 04 49 Screenshot 2025-06-20 at 13 04 45

=> When the stats module is not active, the links should be marked as external and direct you to calypso blue, i.e. https://wordpress.com/stats/subscribers/
=> When the stats module is active, the links should direct you to wp-admin stats, i.e. wp-admin/admin.php?page=stats#!/stats/subscribers/
=> On WordPress.com simple sites, since the stats feature is always active, you should be redirected to https://wordpress.com/stats/subscribers/
=> The "external link" icon should match the link, i.e. only appear when you're on a self-hosted site (not WoA) and the stats module is not active.

jeherve added 8 commits June 20, 2025 12:44
We will use it to change some of the links when the module is not active.
- On WordPress.com sites, always link to WordPress.com.
- On self-hosted sites, check for the status of the Stats module:
    * If it's active, link to the wp-admin stats page.
    * If it is not active, link to the Jetpack cloud subscribers page.
This is now possible because the Subscribers stats sub-page of the Calypso blue stats is not accessible, even when you do not use the Stats module.

See pejTkB-24B-p2
@jeherve jeherve requested a review from Copilot June 20, 2025 11:08
@jeherve jeherve self-assigned this Jun 20, 2025
@jeherve jeherve added [Type] Bug When a feature is broken and / or not performing as intended [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Status] In Progress [Pri] Low Bug labels Jun 20, 2025
Copy link
Contributor

github-actions bot commented Jun 20, 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), and enable the fix/newsletter-dashboard-links-no-stats branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/newsletter-dashboard-links-no-stats

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

@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels Jun 20, 2025
Copy link
Contributor

github-actions bot commented Jun 20, 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: July 1, 2025
    • Code freeze: June 30, 2025

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

Copilot

This comment was marked as outdated.

Copy link

jp-launch-control bot commented Jun 20, 2025

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/modules/subscriptions/newsletter-widget/class-jetpack-newsletter-dashboard-widget.php 0/106 (0.00%) 0.00% 1 ❤️‍🩹
projects/plugins/jetpack/modules/subscriptions/newsletter-widget/src/components/newsletter-widget.tsx 11/11 (100.00%) 0.00% 0 💚
projects/plugins/jetpack/modules/subscriptions/newsletter-widget/src/helpers.ts 40/41 (97.56%) 0.13% 0 💚

Full summary · PHP report · JS report

@jeherve jeherve requested a review from Copilot June 20, 2025 11:20
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 ensures subscriber stats links point to the correct location when the Stats module is inactive by adding an isStatsModuleActive flag throughout the widget stack.

  • Introduce isStatsModuleActive in PHP config, component props, and DOM bootstrapping
  • Update getSubscriberStatsUrl to branch on the new flag
  • Add tests covering inactive-stats behavior in both helper and widget test suites

Reviewed Changes

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

Show a summary per file
File Description
test/newsletter-widget.test.tsx Add isStatsModuleActive default and tests for inactive module
test/helpers.test.ts Update getSubscriberStatsUrl tests for new signature/behavior
src/index.tsx Pull isStatsModuleActive from config and pass to Widget
src/helpers.ts Change URL builder to handle inactive Stats module
src/components/newsletter-widget.tsx Compute isInternalLink using isStatsModuleActive
class-jetpack-newsletter-dashboard-widget.php Expose isStatsModuleActive from server-side config
changelog/fix-newsletter-dashboard-links-no-stats Document patch release
Comments suppressed due to low confidence (2)

projects/plugins/jetpack/modules/subscriptions/newsletter-widget/test/newsletter-widget.test.tsx:261

  • Consider adding a complementary test block for when the stats module is active on a self-hosted site, verifying that the link is internal and points to the wp-admin URL.
	describe( 'Stats module inactive behavior', () => {

@jeherve jeherve added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jun 20, 2025
@jeherve jeherve requested a review from a team June 20, 2025 11:46
Copy link
Member

@allilevine allilevine left a comment

Choose a reason for hiding this comment

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

This is working correctly for me:

  • Self-hosted has external links when the Stats module is deactivated:
Screenshot 2025-06-20 at 9 34 57 AM
  • When I click to enable Stats on Calypso blue, they load correctly.

  • WoA doesn't have the external links when the module is deactivated, and Calypso blue stats continue to work:

Screenshot 2025-06-20 at 9 47 55 AM
  • Simple shows no change:
Screenshot 2025-06-20 at 9 59 50 AM

Not related to this PR, but I wonder if we could add something more helpful to the self-hosted Stats empty state that shows on both Calypso blue and wp-admin. It's a bit sparse:
Screenshot 2025-06-20 at 9 36 19 AM

@@ -256,4 +257,30 @@ describe( 'NewsletterWidget', () => {
expect( screen.queryByText( 'Total Subscribers' ) ).not.toBeInTheDocument();
} );
} );

describe( 'Stats module inactive behavior', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Should the "renders correct quick links when self-hosted" test above now be more explicit about whether the stats module is active?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point. done in cbbc817

Copy link
Contributor

@arcangelini arcangelini left a comment

Choose a reason for hiding this comment

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

Everything is tested and looks good to me.

🚀🚀

@jeherve jeherve merged commit f718984 into trunk Jun 20, 2025
65 checks passed
@jeherve jeherve deleted the fix/newsletter-dashboard-links-no-stats branch June 20, 2025 15:27
@github-actions github-actions bot added this to the jetpack/14.8 milestone Jun 20, 2025
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Jun 20, 2025
matticbot pushed a commit to Automattic/jetpack-storybook that referenced this pull request Jun 20, 2025
…ive (#44037)

* Subscriber dashboard: pass stats module status to JS

We will use it to change some of the links when the module is not active.

* Add extra space for better readability

* Pass new prop to newsletter component

* Use new prop to change the status of the links

- On WordPress.com sites, always link to WordPress.com.
- On self-hosted sites, check for the status of the Stats module:
    * If it's active, link to the wp-admin stats page.
    * If it is not active, link to the Jetpack cloud subscribers page.

* Update test accordingly

* Update dashboard links to be aware of stats module status

* Add changelog

* Redirect folks to Calypso blue stats when stats module is inactive

This is now possible because the Subscribers stats sub-page of the Calypso blue stats is not accessible, even when you do not use the Stats module.

See pejTkB-24B-p2

* simplify internal link logic

See https://github.com/Automattic/jetpack/pull/44037/files#r2158706216

* Update doc comment

* Be more explicit about stats being enabled in original test

See Automattic/jetpack#44037 (comment)

Co-authored-by: Allison Levine <[email protected]>

---------

Co-authored-by: Tony Arcangelini <[email protected]>
Co-authored-by: Allison Levine <[email protected]>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/15782344573

Upstream-Ref: Automattic/jetpack@f718984
matticbot pushed a commit to Automattic/jetpack-production that referenced this pull request Jun 20, 2025
…ive (#44037)

* Subscriber dashboard: pass stats module status to JS

We will use it to change some of the links when the module is not active.

* Add extra space for better readability

* Pass new prop to newsletter component

* Use new prop to change the status of the links

- On WordPress.com sites, always link to WordPress.com.
- On self-hosted sites, check for the status of the Stats module:
    * If it's active, link to the wp-admin stats page.
    * If it is not active, link to the Jetpack cloud subscribers page.

* Update test accordingly

* Update dashboard links to be aware of stats module status

* Add changelog

* Redirect folks to Calypso blue stats when stats module is inactive

This is now possible because the Subscribers stats sub-page of the Calypso blue stats is not accessible, even when you do not use the Stats module.

See pejTkB-24B-p2

* simplify internal link logic

See https://github.com/Automattic/jetpack/pull/44037/files#r2158706216

* Update doc comment

* Be more explicit about stats being enabled in original test

See Automattic/jetpack#44037 (comment)

Co-authored-by: Allison Levine <[email protected]>

---------

Co-authored-by: Tony Arcangelini <[email protected]>
Co-authored-by: Allison Levine <[email protected]>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/15782344573

Upstream-Ref: Automattic/jetpack@f718984
grzegorz-cp added a commit that referenced this pull request Jun 23, 2025
* Getting chart data

* Updating chart and data transformation

* Implement interactive stats chart with clickable metric tabs and single-series visualization

* Fixing Stats card tab styling

* Fixing Stats card tab CSS and label position

* changelog

* Added new card style for Stats in My Jetpack

* Empty data notification

* Empty data notification styling

* Adding charts package again

* Updating CSS after review, adding click redirect

* pnpm lock update

* script changes

* Social Previews: Fix Mastodon preview stretching (#44019)

* Fix Mastodon description overflow with previews

* changelog

* Lockfile

* Bump to 12

* Admin Menu: Add "Dashboard > Updates" screen to Simple sites (#44024)

* Admin Menu: Add "Dashboard > Updates" menu to Simple sites

* Remove WP version

* Add changelog

* Exclude VIP sites, since the plugins (and their updates) are managed a little bit differently there, and parity with Atomic sites is also not important for them.

* Check that function exists

* Zendesk: Add CSAT endpoint (#44029)

* Blocks: In scan_delimiters extract static method (#43984)

Ports 185482-ghe-Automattic/wpcom

When `scan_delimiters()` is attempting to find the end of an HTML
comment, it’s calling a convenience method which is also a closure
in the code (or an anonymous function). This carries a marginal
performance overhead and limits reuse.

In this change that method is extracted onto the class as its own static
method; this should simplify reasoning about the method itself and
provide a perofmrnace lift to the calling code.

Co-authored-by: Dennis Snell <[email protected]>
Co-authored-by: Brandon Kraft <[email protected]>

* WordAds: Remove package from monorepo (#44025)

* Fix test description

* Delete packages/wordads

* Add changelog

* Fix project lint issues

* Subscriptions: fix subcriber stats links when stats module is not active (#44037)

* Subscriber dashboard: pass stats module status to JS

We will use it to change some of the links when the module is not active.

* Add extra space for better readability

* Pass new prop to newsletter component

* Use new prop to change the status of the links

- On WordPress.com sites, always link to WordPress.com.
- On self-hosted sites, check for the status of the Stats module:
    * If it's active, link to the wp-admin stats page.
    * If it is not active, link to the Jetpack cloud subscribers page.

* Update test accordingly

* Update dashboard links to be aware of stats module status

* Add changelog

* Redirect folks to Calypso blue stats when stats module is inactive

This is now possible because the Subscribers stats sub-page of the Calypso blue stats is not accessible, even when you do not use the Stats module.

See pejTkB-24B-p2

* simplify internal link logic

See https://github.com/Automattic/jetpack/pull/44037/files#r2158706216

* Update doc comment

* Be more explicit about stats being enabled in original test

See #44037 (comment)

Co-authored-by: Allison Levine <[email protected]>

---------

Co-authored-by: Tony Arcangelini <[email protected]>
Co-authored-by: Allison Levine <[email protected]>

* Update dependency copy-webpack-plugin to v13 (#44040)

Co-authored-by: Renovate Bot <[email protected]>

* fixing package dependency

* Update margin-inline-end

Co-authored-by: Manzoor Wani <[email protected]>

* Revert "fixing package dependency"

This reverts commit b592fd9.

* Charts webpack fix

* changelog

* Fixing timezones to match Stats and hiding 0 diff values for catds

---------

Co-authored-by: Gergely Márk Juhász <[email protected]>
Co-authored-by: Miguel Torres <[email protected]>
Co-authored-by: Kosta <[email protected]>
Co-authored-by: Jeremy Herve <[email protected]>
Co-authored-by: Dennis Snell <[email protected]>
Co-authored-by: Brandon Kraft <[email protected]>
Co-authored-by: tbradsha <[email protected]>
Co-authored-by: Tony Arcangelini <[email protected]>
Co-authored-by: Allison Levine <[email protected]>
Co-authored-by: Automattic Bot <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Manzoor Wani <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Low [Tests] Includes Tests [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.

3 participants