site-kit-wp
site-kit-wp copied to clipboard
Make REST and datastore API for creating/retrieving audiences consistent
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:audiencesREST endpoint within theAnalytics_4class 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
getAudiencesselector 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 theGET:audiencesendpoint. Simply return(array) $response->getAudiences()
- [ ] In the
- [ ] Within
assets/js/modules/analytics-4/datastore/audiences.js:- [ ] In the
fetchGetAudiencesStorereducer callback, simply returnaudiencesResponseinstead of theaudiencesproperty withinaudiencesResponse.
- [ ] In the
Test Coverage
- No new tests required.
QA Brief
- Follow the QAB for #8108 and verify the
getAudiences()selector still works.
Changelog entry
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.
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.