Heartbeat: move site environment stats to Connection package#50006
Heartbeat: move site environment stats to Connection package#50006bindlegirl wants to merge 1 commit into
Conversation
Move the generic site environment heartbeat stats (WordPress/PHP versions, public, ssl, language, charset, multisite/network topology, active plugins, space used, IP) out of the Jetpack plugin and into the Connection package via Heartbeat::get_environment_stats(), so they are reported for every connected site including standalone-connection installs. Port permit_ssl() and get_active_plugins() into the package and use Status::is_multi_network(). The Jetpack plugin's generate_stats_array() now only returns plugin-specific stats (version, branch, manage-enabled, modules), and its local consumers (get_stat_data() for WPCOM sync and jetpack_check_heartbeat_data() for the status CLI) merge in the environment stats from the Connection package so their output is unchanged. Add Heartbeat unit tests and extend the Manager heartbeat tests. Co-authored-by: Cursor <cursoragent@cursor.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! |
Code Coverage SummaryCoverage changed in 3 files.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
Fixes CONNECT-167
Proposed changes
Follow-up to #46967 and #49922. This completes the heartbeat-stats audit by moving the generic site environment stats out of the Jetpack plugin and into the Connection package, so they're reported for every connected site (including standalone-connection installs).
Automattic\Jetpack\Heartbeat::get_environment_stats()to the Connection package, generating:wp-version,php-version,wp-branch,php-branch,public,ssl,is-https,language,charset,is-multisite,plugins,mu-plugins,space-used,is-multi-network,ip-2-octets.permit_ssl()(for thesslstat) andget_active_plugins()(for thepluginsstat) into the package, and useStatus::is_multi_network()foris-multi-network. The portedpermit_ssl()shares thejetpack_https_testtransient with the plugin's copy to avoid duplicate network checks.Manager::add_stats_to_heartbeat()now merges the environment stats (gated on connection, as before).Jetpack_Heartbeat::generate_stats_array()now only returns plugin-specific stats (version,branch,manage-enabled,module-*).Jetpack::get_stat_data()(WPCOM sync) andJetpack::jetpack_check_heartbeat_data()(wp jetpack status full) now merge the environment stats from the Connection package.Heartbeat_Testcoverage and extend theManagerheartbeat tests.Stats intentionally left in the Jetpack plugin
version/branch(JETPACK__VERSION),manage-enabled, andmodule-*are Jetpack-plugin-specific and stay in the plugin's heartbeat contribution.Related product discussion/links
Does this pull request change what data or activity we track or use?
No new data is collected. The same environment stats are still sent; they now originate from the Connection heartbeat instead of the Jetpack plugin. As a side effect, standalone-connection sites (a connection but no Jetpack plugin) will now report these environment stats. They are still only sent for connected sites. WPCOM sync stat data (
get_stat_data) and thewp jetpack status fulloutput are unchanged.Testing instructions
jetpack_v2_heartbeat(e.g. via the Crontrol plugin) and confirm the environment stats (wp-version,php-version,ssl,plugins, etc.) are part of the heartbeat received on WPCOM, matching the previous behavior.wp jetpack status fulland confirmwp-version/php-versionare still listed/flagged correctly.jetpack test php packages/connectionpasses (includes newHeartbeat_Testcoverage).