Repository navigation
Premium Analytics: Remove the hardcoded preview sections - #52865
Conversation
|
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. Wpcomsh plugin:
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. |
6939665 to
a9f250b
Compare
Code Coverage SummaryCoverage changed in 6 files. Only the first 5 are listed here.
|
a9f250b to
f7ddb04
Compare
|
The compat stubs cover With two copies of the package in one request, an older |
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
18fd618 to
7117d75
Compare
retrofox
left a comment
There was a problem hiding this comment.
Thanks for addressing the feedback. That closes it.
LGTM 🚀
Fixes WOOA7S-2225
Proposed changes
PREVIEW_SECTIONSallow-list and everything that fed it:is_dashboard_preview_scoped()and thejetpack_premium_analytics_dashboard_preview_scopefilter.is_dashboard_section_in_preview_scope()stays only as a stub (see below). The dashboard now shows every section the site qualifies for.jetpack_premium_analytics_enabledoption) behind a newpremium-analytics-store-sectionfeature flag, off by default. Dashboards switched on by the blog sticker or thejetpack_premium_analytics_enabledfilter leave that option off and keep every tab, Store included, as before. The new flag replacespremium-analytics-a11n-all-sections, which only existed to open the preview allow-list for Automatticians.premium_analytics.preview_sectionsbecomespremium_analytics.sections, andisDashboardSectionInPreviewScope()becomesisDashboardSectionAvailable(). A report behind a hidden tab still redirects.configure_dashboard_preview_scope(),is_dashboard_section_in_preview_scope()(alwaystrue) andis_dashboard_unlocked_for_a11n()as deprecated stubs, guard the new helpers, and load the policy file inboot_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.docs/dashboard-sections.md,AGENTS.mdand 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
sectionsand the JS readssections. 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_enabledoption on)wp option update jetpack_premium_analytics_enabled 1, or use the site's own toggle to switch the new dashboard on.?section=store. It falls back to the first tab.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.wp companion feature-flag reset premium-analytics-store-section, or remove the filter).Switched on by the blog sticker or the filter (option off)
wp option update jetpack_premium_analytics_enabled 0(orwp option delete jetpack_premium_analytics_enabled).jetpack-premium-analyticsblog sticker, or withadd_filter( 'jetpack_premium_analytics_enabled', '__return_true' );in a mu-plugin.Also
premium-analytics-a11n-all-sectionsis no longer listed among the feature flags, andpremium-analytics-store-sectionis.jp test php packages/premium-analyticsandjp test js packages/premium-analyticspass.🤖 Generated with Claude Code
https://claude.ai/code/session_018rbRpLy4L7yKdf79uL4MFx