site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Make REST and datastore API for creating/retrieving audiences consistent

Open jimmymadon opened this issue 1 year ago • 1 comments

Feature Description

In #8108, we created a REST endpoint to GET:audiences. As per this comment, we have deviated from our standard convention of returning the primary resource in the backend.


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

Acceptance criteria

  • The GET:audiences REST endpoint within the Analytics_4 class should return the list of audiences and not the whole Analytics API response directly.
  • The datastore action should be updated to return the response so that calling the getAudiences selector still returns the same list of audiences as it does now.

Implementation Brief

  • [ ] Within includes/Modules/Analytics_4.php:
    • [ ] In the parse_data_response() method, add a new case to handle the GET:audiences endpoint. Simply return (array) $response->getAudiences()
  • [ ] Within assets/js/modules/analytics-4/datastore/audiences.js:
    • [ ] In the fetchGetAudiencesStore reducer callback, simply return audiencesResponse instead of the audiences property within audiencesResponse.

Test Coverage

  • No new tests required.

QA Brief

  • Follow the QAB for #8108 and verify the getAudiences() selector still works.

Changelog entry

jimmymadon avatar Mar 24 '24 20:03 jimmymadon

I've moved this back to Backlog as the final in-progress changes to the design doc, relating to audience caching, will affect the AC for this one.

techanvil avatar Mar 28 '24 14:03 techanvil

Closing this issue, as we'll be removing the GET:audiences endpoint and the getAudiences() selector (see https://github.com/google/site-kit-wp/issues/8487), so this issue will no longer be needed.

techanvil avatar Apr 05 '24 12:04 techanvil