Skip to content

Premium Analytics: Remove the hardcoded preview sections - #52865

Merged
louwie17 merged 4 commits into
trunkfrom
update/wooa7s-2225-remove-preview-sections
Sep 29, 2026
Merged

louwie17 merged 4 commits into
trunkfrom
update/wooa7s-2225-remove-preview-sections

Conversation

@louwie17

@louwie17 louwie17 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes WOOA7S-2225

Proposed changes

  • Remove the hardcoded PREVIEW_SECTIONS allow-list and everything that fed it: is_dashboard_preview_scoped() and the jetpack_premium_analytics_dashboard_preview_scope filter. is_dashboard_section_in_preview_scope() stays only as a stub (see below). The dashboard now shows every section the site qualifies for.
  • Keep the Store tab hidden on the site's own opt-in (jetpack_premium_analytics_enabled option) behind a new premium-analytics-store-section feature flag, off by default. Dashboards switched on by the blog sticker or the jetpack_premium_analytics_enabled filter leave that option off and keep every tab, Store included, as before. The new flag replaces premium-analytics-a11n-all-sections, which only existed to open the preview allow-list for Automatticians.
  • Drop "preview" from the section-slug script data the report routes read: premium_analytics.preview_sections becomes premium_analytics.sections, and isDashboardSectionInPreviewScope() becomes isDashboardSectionAvailable(). A report behind a hidden tab still redirects.
  • Keep configure_dashboard_preview_scope(), is_dashboard_section_in_preview_scope() (always true) and is_dashboard_unlocked_for_a11n() as deprecated stubs, guard the new helpers, and load the policy file in boot_routes(), so a site loading an older copy of the package next to this one does not fatal. The flags now also register on the standalone REST boot WordPress.com Simple uses.
  • Update the tests, docs/dashboard-sections.md, AGENTS.md and the diagrams to match.

No site sees a different set of tabs than on trunk: opt-in sites already hid Store (and got Ads back in #52864), and sticker or filter sites keep every tab. So only the package gets a changelog entry.

Note on the script-data rename: PHP now publishes sections and the JS reads sections. If two versions of the package were ever mixed in one request, with the PHP from one and the JS from the other, the JS would find no list and treat every tab as available, so a report behind a hidden tab would be reachable by URL. The server still authorizes the data. Both sides ship from the same copy of the package, so this should not happen in practice.

Related product discussion/links

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

No.

Testing instructions

Use a site with WooCommerce active (and WordAds, to see the Ads tab). The Store tab depends on how the dashboard was switched on, so test both ways.

The site's own opt-in (jetpack_premium_analytics_enabled option on)

  • Switch the option on: wp option update jetpack_premium_analytics_enabled 1, or use the site's own toggle to switch the new dashboard on.
  • Open the dashboard. Confirm Traffic, Insights and Subscribers show, plus Ads on a site that uses WordAds, and that Store does not.
  • Visit the dashboard with ?section=store. It falls back to the first tab.
  • Switch the Store flag on (on WordPress.com: Tools → Feature Flags; on Jurassic Ninja: wp companion feature-flag enable premium-analytics-store-section; locally: add_filter( 'jetpack_feature_flag_enabled_premium-analytics-store-section', '__return_true' );), reload, and confirm the Store tab shows.
  • Switch the flag off again (wp companion feature-flag reset premium-analytics-store-section, or remove the filter).

Switched on by the blog sticker or the filter (option off)

  • Switch the option off: wp option update jetpack_premium_analytics_enabled 0 (or wp option delete jetpack_premium_analytics_enabled).
  • Switch the dashboard on with the jetpack-premium-analytics blog sticker, or with add_filter( 'jetpack_premium_analytics_enabled', '__return_true' ); in a mu-plugin.
  • Open the dashboard with the Store flag off. Confirm every tab shows, Store included, as on trunk.

Also

  • Confirm premium-analytics-a11n-all-sections is no longer listed among the feature flags, and premium-analytics-store-section is.
  • jp test php packages/premium-analytics and jp test js packages/premium-analytics pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_018rbRpLy4L7yKdf79uL4MFx

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

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 update/wooa7s-2225-remove-preview-sections branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/wooa7s-2225-remove-preview-sections

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 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

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 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: October 6, 2026

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.


Premium Analytics 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.

@louwie17
louwie17 force-pushed the update/wooa7s-2225-remove-preview-sections branch from 6939665 to a9f250b Compare September 28, 2026 11:36
@jp-launch-control

jp-launch-control Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 6 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/src/class-dashboard-support-routes.php 10/15 (66.67%) 0.00% 1 ❤️‍🩹
projects/packages/premium-analytics/src/class-analytics.php 154/167 (92.22%) 0.05% 0 💚
projects/packages/premium-analytics/src/class-dashboard-section.php 50/50 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/src/dashboard-policy.php 23/23 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/src/dashboard-sections.php 151/158 (95.57%) -0.16% 0 💚

Full summary · PHP report · JS report

Base automatically changed from update/premium-analytics-ads-tab-back-in-preview to trunk September 28, 2026 12:08
@github-actions github-actions Bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Wpcomsh labels Sep 28, 2026
@louwie17
louwie17 force-pushed the update/wooa7s-2225-remove-preview-sections branch from a9f250b to f7ddb04 Compare September 28, 2026 12:10
@louwie17 louwie17 added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Sep 28, 2026
@louwie17
louwie17 marked this pull request as ready for review September 28, 2026 13:15
@louwie17
louwie17 requested a review from a team as a code owner September 28, 2026 13:15
@retrofox

Copy link
Copy Markdown
Contributor

The compat stubs cover configure_dashboard_preview_scope() and is_dashboard_unlocked_for_a11n(), but not is_dashboard_section_in_preview_scope(). The previous Dashboard_Section::is_available() calls it on every availability check; the sun and moon vendored copies on wpcom still do (class-dashboard-section.php:175).

With two copies of the package in one request, an older Dashboard_Section class next to this dashboard-sections.php fatals on the first section read, since the class comes from the autoloader and the file-scope functions from whichever copy loaded first. The same deprecated no-op treatment, returning true, would close it.

louwie17 and others added 4 commits September 28, 2026 17:04
Every section a site qualifies for is now a tab. The Store tab moves behind
the premium-analytics-store-section feature flag, which replaces
premium-analytics-a11n-all-sections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018rbRpLy4L7yKdf79uL4MFx
Guard the new Store flag helper and script-data configurator for an older
copy's files, keep the two removed functions an older copy still calls as
stubs, register the flags on the standalone REST boot, and make two tests
exercise the behaviour their names describe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018rbRpLy4L7yKdf79uL4MFx
The blog sticker and the jetpack_premium_analytics_enabled filter leave the
site option off, and used to see every section; they keep the Store tab
without the flag. Also load the policy file in boot_routes() for package
copies whose dashboard-sections.php does not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018rbRpLy4L7yKdf79uL4MFx
An older Dashboard_Section class next to this dashboard-sections.php calls
it on every availability check, so removing it fatals. Keep it as a
deprecated stub that returns true and lets the section's own rule decide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018rbRpLy4L7yKdf79uL4MFx
@louwie17
louwie17 force-pushed the update/wooa7s-2225-remove-preview-sections branch from 18fd618 to 7117d75 Compare September 28, 2026 15:05
@louwie17

Copy link
Copy Markdown
Contributor Author

@retrofox I updated it, see: 7117d75

@retrofox retrofox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for addressing the feedback. That closes it.

LGTM 🚀

@louwie17
louwie17 merged commit 44810f6 into trunk Sep 29, 2026
82 of 83 checks passed
@louwie17
louwie17 deleted the update/wooa7s-2225-remove-preview-sections branch September 29, 2026 07:29
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Sep 29, 2026
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] In Progress labels Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs [Package] Premium Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Premium Analytics [Plugin] Wpcomsh [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants