Skip to content

Heartbeat: move site environment stats to Connection package#50006

Draft
bindlegirl wants to merge 1 commit into
trunkfrom
update/heartbeat-env-stats-to-package
Draft

Heartbeat: move site environment stats to Connection package#50006
bindlegirl wants to merge 1 commit into
trunkfrom
update/heartbeat-env-stats-to-package

Conversation

@bindlegirl

Copy link
Copy Markdown
Contributor

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).

  • Add 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.
  • Port permit_ssl() (for the ssl stat) and get_active_plugins() (for the plugins stat) into the package, and use Status::is_multi_network() for is-multi-network. The ported permit_ssl() shares the jetpack_https_test transient 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).
  • The Jetpack plugin's Jetpack_Heartbeat::generate_stats_array() now only returns plugin-specific stats (version, branch, manage-enabled, module-*).
  • Refactor the plugin's local consumers so their output is unchanged: Jetpack::get_stat_data() (WPCOM sync) and Jetpack::jetpack_check_heartbeat_data() (wp jetpack status full) now merge the environment stats from the Connection package.
  • Add Heartbeat_Test coverage and extend the Manager heartbeat tests.

Stats intentionally left in the Jetpack plugin

version / branch (JETPACK__VERSION), manage-enabled, and module-* 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 the wp jetpack status full output are unchanged.

Testing instructions

  • Code review.
  • On a connected site, trigger 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.
  • Run wp jetpack status full and confirm wp-version / php-version are still listed/flagged correctly.
  • jetpack test php packages/connection passes (includes new Heartbeat_Test coverage).

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>
@bindlegirl bindlegirl self-assigned this Jun 26, 2026
@github-actions

github-actions Bot commented Jun 26, 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 or WordPress.com Site Helper), and enable the update/heartbeat-env-stats-to-package branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/heartbeat-env-stats-to-package
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/heartbeat-env-stats-to-package

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 added [Package] Connection [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests labels Jun 26, 2026
@github-actions

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!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jun 26, 2026
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/connection/src/class-heartbeat.php 71/129 (55.04%) 3.09% 21 💔
projects/packages/connection/src/class-manager.php 689/1032 (66.76%) 0.03% 0 💚
projects/plugins/jetpack/class.jetpack-heartbeat.php 12/16 (75.00%) -5.95% -4 💚

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Connection [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant