Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
21991e7
Add Google_Tag_Gateway_Health class for monitoring GTG health data.
hussain-t Dec 2, 2025
f9458af
Refactor Google_Tag_Gateway_Settings to remove health status handling…
hussain-t Dec 2, 2025
e65d03a
Integrate Google_Tag_Gateway_Health into Google_Tag_Gateway for impro…
hussain-t Dec 2, 2025
fe0ee26
Enhance REST_Google_Tag_Gateway_Controller by integrating health stat…
hussain-t Dec 2, 2025
95810eb
Refactor SettingsView components to replace health checks with upstre…
hussain-t Dec 3, 2025
5f98499
Update default notifications to incorporate Google Tag Gateway health…
hussain-t Dec 3, 2025
576ec4a
Remove deprecated endpoint for GTG server requirement status in REST_…
hussain-t Dec 3, 2025
10599bc
Update GoogleTagGatewayToggle to use new health check methods and adj…
hussain-t Dec 3, 2025
17fa297
Refactor GoogleTagGatewayToggle stories to utilize new health checks …
hussain-t Dec 3, 2025
4a7068d
Refactor GoogleTagGatewayToggle tests to utilize new health checks en…
hussain-t Dec 3, 2025
8dd5887
Update GoogleTagGatewaySetupBanner tests to use new GTG health checks…
hussain-t Dec 3, 2025
973fba6
Refactor GoogleTagGatewayWarningNotification tests to remove deprecat…
hussain-t Dec 3, 2025
b4071b7
Refactor settings stories to replace deprecated GTG server requiremen…
hussain-t Dec 3, 2025
0a51a0a
Refactor settings stories to implement new GTG health checks for upst…
hussain-t Dec 3, 2025
e5b1b2e
Refactor tests in ads, analytics-4, and tagmanager modules to impleme…
hussain-t Dec 3, 2025
6b0f8ea
Implement tests for new Google Tag Gateway health status checks.
hussain-t Dec 3, 2025
c22bd44
Update snapshot for GoogleTagGatewayToggle test to reflect changes in…
hussain-t Dec 4, 2025
9b63fb1
Refactor GTG datastore to implement new state structure for health ch…
hussain-t Dec 4, 2025
4e902fa
Add migration class for decoupling Google Tag Gateway health status.
hussain-t Dec 4, 2025
bd18a74
Register migration class for next version in Plugin.php.
hussain-t Dec 4, 2025
89a6f06
Update GTag.php to utilize Google_Tag_Gateway::is_ready_and_active() …
hussain-t Dec 5, 2025
f891618
Enhance Tag_ManagerTest to include Google Tag Gateway health checks i…
hussain-t Dec 5, 2025
a19661d
Update GTagTest to incorporate Google Tag Gateway health checks in te…
hussain-t Dec 5, 2025
fd72ef7
Add Google_Tag_Gateway_HealthTest to validate health check functional…
hussain-t Dec 5, 2025
b8d7729
Refactor Google_Tag_Gateway_SettingsTest to simplify settings asserti…
hussain-t Dec 5, 2025
8a10bd9
Enhance Google_Tag_GatewayTest to include health data.
hussain-t Dec 5, 2025
503d8f7
Refactor REST_Google_Tag_Gateway_ControllerTest to integrate Google_T…
hussain-t Dec 5, 2025
faf05f8
Add Migration_N_E_X_TTest to validate migration logic for Google Tag …
hussain-t Dec 5, 2025
d61bbf2
Merge branch 'develop' into enhancement/#11541-decouple-gtg-heath-sta…
hussain-t Dec 5, 2025
bcba6ce
Update Google_Tag_Gateway_SettingsTest to use setExpectedDeprecated f…
hussain-t Dec 5, 2025
1f5ce6f
Update Debug_DataTest to assert new Google Tag Gateway health fields.
hussain-t Dec 5, 2025
0134281
Refactor Tag_Manager to utilize Google_Tag_Gateway for health checks.
hussain-t Dec 5, 2025
0531ef2
Ensure array handling in Google_Tag_Gateway_Health for health check s…
hussain-t Dec 7, 2025
5a2ce9d
Improve handling of isEnabled setting in Migration_N_E_X_T by deletin…
hussain-t Dec 7, 2025
d16553c
Bypass sanitization in Migration_N_E_X_TTest to allow setting legacy …
hussain-t Dec 7, 2025
3e9d028
Merge branch 'develop' into enhancement/#11541-decouple-gtg-heath-sta…
hussain-t Dec 7, 2025
55095dc
Refactor health check to use array_key_exists for improved null check…
hussain-t Dec 8, 2025
31cfbfa
Refactor Migration_N_E_X_T to directly retrieve GTG settings from opt…
hussain-t Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ export default function GoogleTagGatewayToggle( { className } ) {
select( CORE_SITE ).isGoogleTagGatewayEnabled()
);
const isLoading = useSelect( ( select ) =>
select( CORE_SITE ).isFetchingGetGTGServerRequirementStatus()
select( CORE_SITE ).isFetchingPostGTGHealthChecks()
);
const hasMetServerRequirements = useSelect( ( select ) => {
const { isGTGHealthy, isScriptAccessEnabled } = select( CORE_SITE );
const { isUpstreamHealthy, isMpathHealthy } = select( CORE_SITE );

return isGTGHealthy() !== false && isScriptAccessEnabled() !== false;
return isUpstreamHealthy() !== false && isMpathHealthy() !== false;
} );

const { fetchGetGTGServerRequirementStatus, setGoogleTagGatewayEnabled } =
const { fetchPostGTGHealthChecks, setGoogleTagGatewayEnabled } =
useDispatch( CORE_SITE );

const learnMoreURL = useSelect( ( select ) => {
Expand All @@ -74,8 +74,8 @@ export default function GoogleTagGatewayToggle( { className } ) {
);
} );

// Fetch the server requirement status on mount.
useMount( fetchGetGTGServerRequirementStatus );
// Fetch the GTG health status on mount.
useMount( fetchPostGTGHealthChecks );

const handleClick = useCallback( () => {
const action = isGoogleTagGatewayEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function Template() {
);
}

const serverRequirementStatusEndpoint = new RegExp(
'^/google-site-kit/v1/core/site/data/gtg-server-requirement-status'
const healthChecksEndpoint = new RegExp(
'^/google-site-kit/v1/core/site/data/gtg-health-checks'
);

export const Default = Template.bind( {} );
Expand All @@ -48,11 +48,10 @@ export const ServerRequirementsFail = Template.bind( {} );
ServerRequirementsFail.storyName = 'Server requirements fail';
ServerRequirementsFail.args = {
setupRegistry: () => {
fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: {
isEnabled: false,
isGTGHealthy: false,
isScriptAccessEnabled: false,
isUpstreamHealthy: false,
isMpathHealthy: false,
},
status: 200,
} );
Expand All @@ -64,7 +63,7 @@ export const ServerRequirementsLoading = Template.bind( {} );
ServerRequirementsLoading.storyName = 'Server requirements loading';
ServerRequirementsLoading.args = {
setupRegistry: () => {
freezeFetch( serverRequirementStatusEndpoint );
freezeFetch( healthChecksEndpoint );
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ mockTrackEvent.mockImplementation( () => Promise.resolve() );
describe( 'GoogleTagGatewayToggle', () => {
let registry;

const serverRequirementStatusEndpoint = new RegExp(
'^/google-site-kit/v1/core/site/data/gtg-server-requirement-status'
const healthChecksEndpoint = new RegExp(
'^/google-site-kit/v1/core/site/data/gtg-health-checks'
);

beforeEach( () => {
Expand All @@ -62,29 +62,27 @@ describe( 'GoogleTagGatewayToggle', () => {

registry.dispatch( CORE_SITE ).receiveGetGoogleTagGatewaySettings( {
isEnabled: false,
isGTGHealthy: null,
isScriptAccessEnabled: null,
} );
} );

afterEach( () => {
jest.clearAllMocks();
} );

it( 'should make a request to fetch the server requirement status', async () => {
muteFetch( serverRequirementStatusEndpoint );
it( 'should make a request to run health checks', async () => {
muteFetch( healthChecksEndpoint );

const { waitForRegistry } = render( <GoogleTagGatewayToggle />, {
registry,
} );

await waitForRegistry();

expect( fetchMock ).toHaveFetched( serverRequirementStatusEndpoint );
expect( fetchMock ).toHaveFetched( healthChecksEndpoint );
} );

it( 'should render in loading state if the server requirement status is still loading', async () => {
freezeFetch( serverRequirementStatusEndpoint );
it( 'should render in loading state if health checks are still loading', async () => {
freezeFetch( healthChecksEndpoint );

const { container, getByRole, waitForRegistry } = render(
<GoogleTagGatewayToggle />,
Expand All @@ -101,11 +99,10 @@ describe( 'GoogleTagGatewayToggle', () => {
} );

it( 'should render in default state', async () => {
fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: {
isEnabled: false,
isGTGHealthy: true,
isScriptAccessEnabled: true,
isUpstreamHealthy: true,
isMpathHealthy: true,
},
status: 200,
} );
Expand All @@ -127,11 +124,10 @@ describe( 'GoogleTagGatewayToggle', () => {
} );

it( 'should render in disabled state if server requirements are not met', async () => {
fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: {
isEnabled: false,
isGTGHealthy: false,
isScriptAccessEnabled: false,
isUpstreamHealthy: false,
isMpathHealthy: false,
},
status: 200,
} );
Expand All @@ -157,11 +153,10 @@ describe( 'GoogleTagGatewayToggle', () => {
} );

it( 'should not track an event when the toggle is viewed with no warning notice', async () => {
fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: {
isEnabled: false,
isGTGHealthy: true,
isScriptAccessEnabled: true,
isUpstreamHealthy: true,
isMpathHealthy: true,
},
status: 200,
} );
Expand Down Expand Up @@ -196,11 +191,10 @@ describe( 'GoogleTagGatewayToggle', () => {
} );

it( 'should track an event when the warning notice is viewed', async () => {
fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: {
isEnabled: false,
isGTGHealthy: false,
isScriptAccessEnabled: false,
isUpstreamHealthy: false,
isMpathHealthy: false,
},
status: 200,
} );
Expand Down Expand Up @@ -241,11 +235,10 @@ describe( 'GoogleTagGatewayToggle', () => {
} );

it( 'should track an event when the `Learn more` link is clicked in the toggle description', async () => {
fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: {
isEnabled: false,
isGTGHealthy: true,
isScriptAccessEnabled: true,
isUpstreamHealthy: true,
isMpathHealthy: true,
},
status: 200,
} );
Expand Down Expand Up @@ -276,11 +269,10 @@ describe( 'GoogleTagGatewayToggle', () => {
} );

it( 'should track an event when the `Learn more` link is clicked in the warning notice', async () => {
fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: {
isEnabled: false,
isGTGHealthy: false,
isScriptAccessEnabled: false,
isUpstreamHealthy: false,
isMpathHealthy: false,
},
status: 200,
} );
Expand Down Expand Up @@ -310,18 +302,17 @@ describe( 'GoogleTagGatewayToggle', () => {
);
} );

it.each( [ 'isGTGHealthy', 'isScriptAccessEnabled' ] )(
it.each( [ 'isUpstreamHealthy', 'isMpathHealthy' ] )(
'should not render in disabled state unless %s is explicitly false',
async ( requirement ) => {
const response = {
isEnabled: false,
isGTGHealthy: true,
isScriptAccessEnabled: true,
isUpstreamHealthy: true,
isMpathHealthy: true,
};

response[ requirement ] = null;

fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: response,
status: 200,
} );
Expand All @@ -341,18 +332,17 @@ describe( 'GoogleTagGatewayToggle', () => {
}
);

it.each( [ 'isGTGHealthy', 'isScriptAccessEnabled' ] )(
it.each( [ 'isUpstreamHealthy', 'isMpathHealthy' ] )(
'should render in disabled state if %s is false',
async ( requirement ) => {
const response = {
isEnabled: false,
isGTGHealthy: true,
isScriptAccessEnabled: true,
isUpstreamHealthy: true,
isMpathHealthy: true,
};

response[ requirement ] = false;

fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: response,
status: 200,
} );
Expand All @@ -373,11 +363,10 @@ describe( 'GoogleTagGatewayToggle', () => {
);

it( 'should toggle Google tag gateway for advertisers on click', async () => {
fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: {
isEnabled: false,
isGTGHealthy: true,
isScriptAccessEnabled: true,
isUpstreamHealthy: true,
isMpathHealthy: true,
},
status: 200,
} );
Expand Down Expand Up @@ -426,11 +415,10 @@ describe( 'GoogleTagGatewayToggle', () => {
} );

it( 'should track an event when the toggle is clicked', async () => {
fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: {
isEnabled: false,
isGTGHealthy: true,
isScriptAccessEnabled: true,
isUpstreamHealthy: true,
isMpathHealthy: true,
},
status: 200,
} );
Expand Down Expand Up @@ -473,11 +461,10 @@ describe( 'GoogleTagGatewayToggle', () => {
} );

it( 'should render a "Beta" badge', async () => {
fetchMock.getOnce( serverRequirementStatusEndpoint, {
fetchMock.postOnce( healthChecksEndpoint, {
body: {
isEnabled: false,
isGTGHealthy: true,
isScriptAccessEnabled: true,
isUpstreamHealthy: true,
isMpathHealthy: true,
},
status: 200,
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ exports[`GoogleTagGatewayToggle should render in disabled state if server requir
</div>
`;

exports[`GoogleTagGatewayToggle should render in loading state if the server requirement status is still loading 1`] = `
exports[`GoogleTagGatewayToggle should render in loading state if health checks are still loading 1`] = `
<div>
<div
class="googlesitekit-google-tag-gateway-toggle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ describe( 'GoogleTagGatewaySetupBanner', () => {

registry.dispatch( CORE_SITE ).receiveGetGoogleTagGatewaySettings( {
isEnabled: false,
isGTGHealthy: true,
isScriptAccessEnabled: true,
} );

registry.dispatch( CORE_SITE ).receiveGetGTGHealth( {
isUpstreamHealthy: true,
isMpathHealthy: true,
} );

registry
Expand Down Expand Up @@ -121,8 +124,11 @@ describe( 'GoogleTagGatewaySetupBanner', () => {
it( 'is not active when GTG is enabled', async () => {
registry.dispatch( CORE_SITE ).receiveGetGoogleTagGatewaySettings( {
isEnabled: true,
isGTGHealthy: true,
isScriptAccessEnabled: true,
} );

registry.dispatch( CORE_SITE ).receiveGetGTGHealth( {
isUpstreamHealthy: true,
isMpathHealthy: true,
} );

const isActive = await notification.checkRequirements(
Expand All @@ -133,11 +139,14 @@ describe( 'GoogleTagGatewaySetupBanner', () => {
expect( isActive ).toBe( false );
} );

it( 'is not active when GTG is not healthy', async () => {
it( 'is not active when upstream is not healthy', async () => {
registry.dispatch( CORE_SITE ).receiveGetGoogleTagGatewaySettings( {
isEnabled: false,
isGTGHealthy: false,
isScriptAccessEnabled: true,
} );

registry.dispatch( CORE_SITE ).receiveGetGTGHealth( {
isUpstreamHealthy: false,
isMpathHealthy: true,
} );

const isActive = await notification.checkRequirements(
Expand All @@ -148,11 +157,14 @@ describe( 'GoogleTagGatewaySetupBanner', () => {
expect( isActive ).toBe( false );
} );

it( 'is not active when script access is not enabled', async () => {
it( 'is not active when mpath is not healthy', async () => {
registry.dispatch( CORE_SITE ).receiveGetGoogleTagGatewaySettings( {
isEnabled: false,
isGTGHealthy: true,
isScriptAccessEnabled: false,
} );

registry.dispatch( CORE_SITE ).receiveGetGTGHealth( {
isUpstreamHealthy: true,
isMpathHealthy: false,
} );

const isActive = await notification.checkRequirements(
Expand Down Expand Up @@ -196,8 +208,6 @@ describe( 'GoogleTagGatewaySetupBanner', () => {
fetchMock.postOnce( gtgSettingsEndpoint, {
body: JSON.stringify( {
isEnabled: true,
isGTGHealthy: true,
isScriptAccessEnabled: true,
} ),
status: 200,
} );
Expand Down Expand Up @@ -289,8 +299,6 @@ describe( 'GoogleTagGatewaySetupBanner', () => {
fetchMock.postOnce( gtgSettingsEndpoint, {
body: JSON.stringify( {
isEnabled: true,
isGTGHealthy: true,
isScriptAccessEnabled: true,
} ),
status: 200,
} );
Expand Down
Loading
Loading