Repository navigation
Conversation
…ard turns on or off WordPress.com only processes WooCommerce Analytics data for a site whose synced jetpack_connection_active_plugins lists jetpack-premium-analytics. Enabling the dashboard inside Jetpack is an option change, not a plugin activation, so the Connection package never rewrote that option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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: 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. |
Code Coverage SummaryCoverage changed in 2 files.
|
Proposed changes
WordPress.com only processes WooCommerce Analytics data for a site (the
wc_product_lookuprows built from synced products, custom-table hooks, and the rest) when the site's syncedjetpack_connection_active_pluginsoption listsjetpack-premium-analytics,woocommerce-analyticsorwoocommerce-ai. Premium Analytics registers its slug at runtime throughConfig::ensure( 'connection', … ). The Connection package only rewrites the stored option after a plugin is activated or deactivated:update_option_active_pluginssets thejetpack_connection_active_plugins_refreshtransient, and the next POST request consumes it. Turning Premium Analytics on inside Jetpack is an option change, so the slug never reached the stored option. On a store without another qualifying plugin, WordPress.com then skipped product rows: products report rows had null name, SKU and type, and type-filtered widgets such as Top performing products stayed empty.This PR changes only the Premium Analytics package. It uses the Connection package's existing public
Plugin_Storage::set_flag_to_refresh_active_connected_plugins(), guarded withmethod_exists().Connection_Configuration::configure(), which runs whenever the dashboard is on, now checks whether the stored option lacks the Premium Analytics slug and, if so, sets the refresh flag. The Connection package then rewrites the option on the next POST. This covers every way of enabling the dashboard, including the option, thejetpack_premium_analytics_enabledfilter and the blog sticker, as well as sites that enabled it before this fix. Once the option is correct, the check costs one autoloadedget_option()per request. While the option is stale and no POST has arrived yet, it skips the write if the flag is already set.Enablement_Settingalso sets the flag when the opt-in option is added or changed. This is the disable direction: once the dashboard is off, the package no longer boots, so nothing else would drop the slug.Known gap: if the dashboard is turned off by any route other than the settings write, the slug stays in the stored option until the next plugin activation or deactivation. Those routes are the filter, the blog sticker, removing the Stats module, or
wp option updatefrom WP-CLI. The only effect is that WordPress.com keeps processing WooCommerce Analytics data for that site. Closing the gap would mean hooking into Jetpack's disabled branch, which I left out of this PR.The standalone
plugins/premium-analyticsis not affected. It always callsAnalytics::init(), so activating it already triggers the refresh. For that reason it gets no changelog entry.Lookup data and catalog backfill (#53728) depend on this fix.
Related product discussion/links
Does this pull request change what data or activity we track or use?
No. It changes when an existing synced option is refreshed, so WordPress.com processes the WooCommerce Analytics data this site already opted into through Premium Analytics.
Testing instructions
Unit tests:
jp test php packages/premium-analytics.On a Jurassic Ninja store with WooCommerce, Jetpack (built from this branch) and WC Smooth Generator, connected, with the Stats module active:
wp option get jetpack_connection_active_plugins. It should not listjetpack-premium-analytics.wp option update jetpack_premium_analytics_enabled 1. Do not activate or deactivate any plugin.curl -X POST https://<site>/wp-admin/admin-ajax.php.wp option get jetpack_connection_active_pluginsagain. It now listsjetpack-premium-analytics.wpcom/v2/sites/<blog_id>/analytics/reports/products,date_type=created) shows its name, SKU and type.wp-content/debug.loghas no new notices.🤖 Generated with Claude Code