google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.25k stars 290 forks source link

Implement Search Console updates to rely on latest API version and display fresh data #2522

Closed felixarntz closed 3 years ago

felixarntz commented 3 years ago

Search Console recently released a big API update relevant for Site Kit: Related to #2284 (where we actually incorrectly assumed this was already in place), we can now display "fresh data" in Search Console reports via the API.

We should migrate from using the legacy API https://www.googleapis.com/webmasters/v3/ to https://searchconsole.googleapis.com/ as the new functionality is only available on the latter. Other than that though, the new API is fully backward-compatible, in fact it uses the same URLs (including "legacy prefix" /webmasters/v3/ within the new API) to achieve that.

We can easily take care of this migration by updating the Google API client services library to the latest version and relying on the SearchConsole class instead of the Webmasters class. We can then set the new dataState argument via the new request class to include fresh data in the API responses. In combination with that change, we can now finally change the day offset to 1 day before, from currently 2 days before.


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

Acceptance criteria

Implementation Brief

Test Coverage

Visual Regression Changes

QA Brief

Changelog entry

benbowler commented 3 years ago

IB ready for review.

benbowler commented 3 years ago

Added an estimate.

benbowler commented 3 years ago

Updated to IB slightly to mention the assets/js/modules/search-console/datastore/constants.js DATE_RANGE_OFFSET value.

felixarntz commented 3 years ago

@benbowler IB ✅ , except one thing:

Update the offset value passed DATE_RANGE_OFFSET in assets/js/modules/search-console/datastore/constants.js value back to2.

That should be set to 1 similar to how it is in PHP. Can you update that? I'll move over to Execution Backlog since that doesn't need another review 👍

benbowler commented 3 years ago

After this is merged other devs may have to run composer install within docker to update their local third-party directory using phpscoper as this directory is ignored by git.

benbowler commented 3 years ago

@felixarntz I just noticed that the dataState property is only available on master branch not on the v0.156 release as of yet. I've tested this working with the dev-master branch of the repository in composer.json.

I would normally avoid using dev-master for live projects but the Google PHP API Client Services README says:

If you are currently using the v1-master branch of the client library, but want to use the latest API services, you can do so by requiring this library directly into your project via the same composer command: composer require google/apiclient-services:dev-master.

benbowler commented 3 years ago

I've continued as such and created a PR and written a QA Brief.

felixarntz commented 3 years ago

@eclarke1 @fhollis FYI this is awaiting an external update of the Google API PHP client library we're using. The work on this issue is basically completed, but it can only be merged and QAd once that library has released an update.

felixarntz commented 3 years ago

@benbowler I've added an extra bullet point to the QA Brief here, I think it's important to mention the exact user-facing change here: Now data is shown for 1 day ago, previously it was a different offset.

wpdarren commented 3 years ago

QA Update: Pass ✅

1.24.0

image

1.25.0

image