-
Notifications
You must be signed in to change notification settings - Fork 822
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
Conversation
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
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
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:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 3 files.
|
There was a problem hiding this 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', () => {
There was a problem hiding this 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:

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

- Simple shows no change:

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:
@@ -256,4 +257,30 @@ describe( 'NewsletterWidget', () => { | |||
expect( screen.queryByText( 'Total Subscribers' ) ).not.toBeInTheDocument(); | |||
} ); | |||
} ); | |||
|
|||
describe( 'Stats module inactive behavior', () => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
projects/plugins/jetpack/modules/subscriptions/newsletter-widget/src/helpers.ts
Show resolved
Hide resolved
See #44037 (comment) Co-authored-by: Allison Levine <[email protected]>
There was a problem hiding this 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.
🚀🚀
…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
…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
* 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]>
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:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
Note
You will want to test this on WordPress.com Simple sites and on a self-hosted/WoA site
=> 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.