Skip to content

Conversation

@hussain-t
Copy link
Collaborator

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

…ved health monitoring.

Update methods to utilize health state data and enhance health check functionality.
…e management.

Add new endpoints for gtg-health and gtg-health-checks.
Update existing methods to return combined health data for backward compatibility.
…am and Mpath health status.

Update related methods for consistency across ads, analytics-4, and tagmanager modules.
… status checks. Replace previous health checks with upstream and Mpath health checks.
…ust state management.

Replace deprecated server requirement checks with upstream and Mpath health checks.
… and adjust test cases for upstream and Mpath health statuses.
…ed settings and incorporate new GTG health checks for upstream and Mpath statuses.
…t checks with new health checks for upstream and Mpath statuses across ads and analytics-4 modules.
…nt new GTG health checks for upstream and Mpath statuses, removing deprecated settings.
…ag_Gateway_Health and update health check assertions.
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Storybook is ready:

@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Build files for 8528386 are ready:

@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Size Change: +72 B (0%)

Total Size: 2.23 MB

ℹ️ View Unchanged
Filename Size Change
./dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.css 124 B 0 B
./dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.js 20 B 0 B
./dist/assets/blocks/reader-revenue-manager/block-editor-plugin/index.js 42.7 kB 0 B
./dist/assets/blocks/reader-revenue-manager/common/editor-styles.css 307 B 0 B
./dist/assets/blocks/reader-revenue-manager/common/editor-styles.js 20 B 0 B
./dist/assets/blocks/reader-revenue-manager/contribute-with-google/index.js 5.88 kB 0 B
./dist/assets/blocks/reader-revenue-manager/contribute-with-google/non-site-kit-user.js 5.07 kB 0 B
./dist/assets/blocks/reader-revenue-manager/subscribe-with-google/index.js 5.88 kB 0 B
./dist/assets/blocks/reader-revenue-manager/subscribe-with-google/non-site-kit-user.js 5.07 kB 0 B
./dist/assets/blocks/sign-in-with-google/editor-styles.css 84 B 0 B
./dist/assets/blocks/sign-in-with-google/editor-styles.js 20 B 0 B
./dist/assets/blocks/sign-in-with-google/index.js 18.6 kB 0 B
./dist/assets/css/googlesitekit-admin-css-********************.min.css 65.2 kB 0 B
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11.7 kB 0 B
./dist/assets/css/googlesitekit-authorize-application-css-********************.min.css 846 B 0 B
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 8.6 kB 0 B
./dist/assets/js/146-********************.js 963 B 0 B
./dist/assets/js/201-********************.js 2.85 kB 0 B
./dist/assets/js/314-********************.js 100 kB 0 B
./dist/assets/js/315-********************.js 3.08 kB 0 B
./dist/assets/js/379-********************.js 3.7 kB 0 B
./dist/assets/js/590-********************.js 1.89 kB 0 B
./dist/assets/js/640-********************.js 2.36 kB 0 B
./dist/assets/js/909-********************.js 1.01 kB 0 B
./dist/assets/js/analytics-advanced-tracking-********************.js 475 B 0 B
./dist/assets/js/googlesitekit-activation-********************.js 24.6 kB 0 B
./dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 56.4 kB 0 B
./dist/assets/js/googlesitekit-adminbar-********************.js 34.8 kB 0 B
./dist/assets/js/googlesitekit-api-********************.js 7.88 kB 0 B
./dist/assets/js/googlesitekit-block-tracking-********************.js 5.49 kB 0 B
./dist/assets/js/googlesitekit-components-********************.js 5.81 kB 0 B
./dist/assets/js/googlesitekit-consent-mode-********************.js 25.5 kB 0 B
./dist/assets/js/googlesitekit-data-********************.js 1.7 kB 0 B
./dist/assets/js/googlesitekit-datastore-forms-********************.js 6.95 kB 0 B
./dist/assets/js/googlesitekit-datastore-location-********************.js 1.51 kB 0 B
./dist/assets/js/googlesitekit-datastore-site-********************.js 17.5 kB +79 B (+0.45%)
./dist/assets/js/googlesitekit-datastore-ui-********************.js 7.1 kB 0 B
./dist/assets/js/googlesitekit-datastore-user-********************.js 22.7 kB 0 B
./dist/assets/js/googlesitekit-entity-dashboard-********************.js 65.7 kB 0 B
./dist/assets/js/googlesitekit-events-provider-contact-form-7-********************.js 1.77 kB 0 B
./dist/assets/js/googlesitekit-events-provider-easy-digital-downloads-********************.js 745 B 0 B
./dist/assets/js/googlesitekit-events-provider-mailchimp-********************.js 1.77 kB 0 B
./dist/assets/js/googlesitekit-events-provider-ninja-forms-********************.js 1.69 kB 0 B
./dist/assets/js/googlesitekit-events-provider-optin-monster-********************.js 1.72 kB 0 B
./dist/assets/js/googlesitekit-events-provider-popup-maker-********************.js 1.79 kB 0 B
./dist/assets/js/googlesitekit-events-provider-woocommerce-********************.js 1.14 kB 0 B
./dist/assets/js/googlesitekit-events-provider-wpforms-********************.js 1.77 kB 0 B
./dist/assets/js/googlesitekit-i18n-********************.js 6.16 kB 0 B
./dist/assets/js/googlesitekit-key-metrics-setup-********************.js 50.2 kB 0 B
./dist/assets/js/googlesitekit-main-dashboard-********************.js 138 kB 0 B
./dist/assets/js/googlesitekit-metric-selection-********************.js 54.9 kB 0 B
./dist/assets/js/googlesitekit-modules-********************.js 19.9 kB 0 B
./dist/assets/js/googlesitekit-modules-ads-********************.js 48.5 kB -7 B (-0.01%)
./dist/assets/js/googlesitekit-modules-adsense-********************.js 134 kB 0 B
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 189 kB -4 B (0%)
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 23.3 kB 0 B
./dist/assets/js/googlesitekit-modules-reader-revenue-manager-********************.js 43.7 kB 0 B
./dist/assets/js/googlesitekit-modules-search-console-********************.js 65.3 kB 0 B
./dist/assets/js/googlesitekit-modules-sign-in-with-google-********************.js 33.7 kB 0 B
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 30.2 kB -4 B (-0.01%)
./dist/assets/js/googlesitekit-notifications-********************.js 63.3 kB +8 B (+0.01%)
./dist/assets/js/googlesitekit-polyfills-********************.js 230 B 0 B
./dist/assets/js/googlesitekit-settings-********************.js 128 kB 0 B
./dist/assets/js/googlesitekit-splash-********************.js 75.3 kB 0 B
./dist/assets/js/googlesitekit-user-input-********************.js 48.3 kB 0 B
./dist/assets/js/googlesitekit-vendor-********************.js 328 kB 0 B
./dist/assets/js/googlesitekit-widgets-********************.js 104 kB 0 B
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 60.8 kB 0 B
./dist/assets/js/runtime-********************.js 1.92 kB 0 B

compressed-size-action

Copy link
Collaborator

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

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

Thanks @hussain-t ! This is off to a good start and there is a lot to review here so there may be more but I thought I'd do a first pass and let you iterate on it to avoid being too much of a bottleneck.

Comment on lines 79 to 80
$this->assertFalse( $this->options->has( Google_Tag_Gateway_Settings::OPTION ), 'GTG settings should not be created if they did not exist.' );
$this->assertFalse( $this->options->has( Google_Tag_Gateway_Health::OPTION ), 'GTG health should not be created if settings did not exist.' );
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have dedicated custom assertions for testing the existence of an option. See assertOption(Not)Exists

Comment on lines 93 to 95
// Bypass sanitization to allow setting legacy health fields (which are stripped by the current class)
// in order to simulate the pre-migration state.
remove_all_filters( 'sanitize_option_' . Google_Tag_Gateway_Settings::OPTION );
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be cleaner to do this before the settings class is registered.

Comment on lines 141 to 142
// Verify settings option was deleted.
$this->assertFalse(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use the dedicated assertions for option existence

);
}

public function test_migrate_preserves_db_version() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This sounds like we expect the db version not to be set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right - the name test_migrate_preserves_db_version is misleading. I've renamed it to test_migrate_sets_db_version to reflect what it's testing.

* @since n.e.x.t
*/
protected function migrate_gtg_health_data() {
// Check if GTG settings exist using the Options::has() method.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please save comments for adding content or explaining why we're doing something that may not be obvious. This comment simply restates the next line which is already clear.

Suggested change
// Check if GTG settings exist using the Options::has() method.

}

// Get the existing GTG settings directly from options to preserve old health properties.
// Using $this->gtg_settings->get() would apply sanitization and strip out the old properties.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you sure? Sanitization is applied on write, not read.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right - my bad. That was added in an inappropriate place.

Comment on lines 135 to 148
// Migrate health data to new health option.
// Start with default null values, then override with migrated values if they exist.
$health_data = array(
'isUpstreamHealthy' => null,
'isMpathHealthy' => null,
);

if ( array_key_exists( 'isGTGHealthy', $gtg_settings ) ) {
$health_data['isUpstreamHealthy'] = $gtg_settings['isGTGHealthy'];
}

if ( array_key_exists( 'isScriptAccessEnabled', $gtg_settings ) ) {
$health_data['isMpathHealthy'] = $gtg_settings['isScriptAccessEnabled'];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this could be simplified into the definition of the array.
ie. newKey => $old[oldKey] ?? null

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great suggestion - thanks!

$health_data['isMpathHealthy'] = $gtg_settings['isScriptAccessEnabled'];
}

// Save migrated health data.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Save migrated health data.

// This avoids issues where sanitization safeguards might preserve old keys during an update.
$this->options->delete( Google_Tag_Gateway_Settings::OPTION );

if ( isset( $gtg_settings['isEnabled'] ) && true === $gtg_settings['isEnabled'] ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if ( isset( $gtg_settings['isEnabled'] ) && true === $gtg_settings['isEnabled'] ) {
if ( ! empty( $gtg_settings['isEnabled'] ) ) {

@hussain-t
Copy link
Collaborator Author

Thanks for your kind review, @aaemnnosttv! Back to you for another review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants