google / google/site-kit-wp

Migrate client-side existing tag checks to backend endpoints

Open
#10,700 1 comment 0 reactions 1 assignee Claimed by @techanvil View on GitHub
P1 Type: Enhancement
Dominant language
JavaScript
Stars
1.4k
Forks
383
Avg merge
4d 14h
Merged PRs (30d)
77

Description

## Feature Description

In order to support the ability to check for existing tags on the server-side, needed for https://github.com/google/site-kit-wp/issues/10688, we should move the client-side logic for retrieving these tags to the backend.

---

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

## Acceptance criteria

- A new set of REST endpoints should be introduced for modules which can have "existing tags" (tags placed by the user rather than by Site Kit): AdSense, Analytics and Tag Manager.
- The route for the endpoints should be `GET /wp-json/google-site-kit/v1/modules/{module slug}/data/existing-tag`.
- The current client-side logic for retrieving and parsing the existing tags on a per-module basis should be migrated to these endpoints.
- The per-module `getExistingTag()` selectors and associated datastore API should be rewritten to use these new endpoints.
- The backend code should be organised for ease of reuse, so that existing tags can be looked up on the backend without needing to go via the REST API.
- In terms of user facing behaviour there should be no changes, all current existing-tag-related flows should retain their current functionality.
- For DX it should be ensured that the functionality continues to work in our local dev environments, i.e. the PHP-side request to the dev site should be successful.

## Implementation Brief

_The proposed AC has been explored for viability with a PoC: https://github.com/google/site-kit-wp/pull/10701_

- [ ]

### Test Coverage

-

## QA Brief

-

## Changelog entry

-

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.