-
Notifications
You must be signed in to change notification settings - Fork 330
Enhancement/#11541 - Decouple Google Tag Gateway health status from GTG settings #11881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
… and update related methods.
…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.
…Google_Tag_Gateway_Controller.
…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.
…ream and Mpath statuses.
…nt new GTG health checks for upstream and Mpath statuses, removing deprecated settings.
… health check status wording.
…ecks and settings.
…for improved health checks.
…ons and remove deprecated properties.
…ag_Gateway_Health and update health check assertions.
…Gateway settings and health data.
|
Storybook is ready:
|
|
Build files for 8528386 are ready:
|
|
Size Change: +72 B (0%) Total Size: 2.23 MB ℹ️ View Unchanged
|
…or deprecation handling in is_google_tag_gateway_active test.
…g deprecated options to prevent issues during updates.
…health fields for pre-migration state simulation.
…s on isUpstreamHealthy and isMpathHealthy fields.
…ions. Initialize health data with default null values before migration.
aaemnnosttv
left a comment
There was a problem hiding this 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.
| $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.' ); |
There was a problem hiding this comment.
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
| // 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 ); |
There was a problem hiding this comment.
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.
| // Verify settings option was deleted. | ||
| $this->assertFalse( |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
| // 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| // 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']; | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // 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'] ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if ( isset( $gtg_settings['isEnabled'] ) && true === $gtg_settings['isEnabled'] ) { | |
| if ( ! empty( $gtg_settings['isEnabled'] ) ) { |
…gacy data to avoid sanitization issues.
…implifying the code and removing unnecessary checks.
…ue instead of strict true.
…s to clarify the process of re-saving isEnabled option.
|
Thanks for your kind review, @aaemnnosttv! Back to you for another review. |
Summary
Addresses issue:
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist