Remote user surveys no longer triggering since 1.71.0
See original GitHub issueBug Description
User surveys for viewing the dashboard are no longer triggering, as I’ve noticed today. After some digging, it looks like this is due to #4806, which means this broke in 1.71.0.
The problem is the following: The triggerSurvey
action now calls the isAuthenticated
selector and bails if it is false-y. However, on page load that selector (as all our API-driven selectors) can be undefined
, and this action call basically happens on page load, so in this case the triggerSurvey
function bails just because the value for the selector isn’t loaded yet.
This is a critical bug so we need to fix it asap and get it into the upcoming 1.72.0 release.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- User surveys should only not be triggered via
triggerSurvey
if the user is not authenticated. Currently the action also bails when that selector’s value isundefined
, i.e. not loaded yet. - We need to ensure the value is loaded at the point that the action accesses it.
Implementation Brief
The PR should be based on main
.
- Replace the current approach (checking for any false-y value in
select( CORE_USER ).isAuthenticated()
, which will always returnundefined
at first, with an action to await for the value returned after the resolver has run. - Essentially, replace https://github.com/google/site-kit-wp/blob/f05f66155e0d6d429ee3a4025fb24fd6aaacb366/assets/js/googlesitekit/datastore/user/surveys.js#L105-L109 with:
const {
__experimentalResolveSelect,
select,
} = yield Data.commonActions.getRegistry();
yield Data.commonActions.await(
__experimentalResolveSelect( CORE_USER ).getAuthentication()
);
if ( select( CORE_USER ).isAuthenticated() === false ) {
return {};
}
Test Coverage
- A data store test to ensure the result is returned would be a good starting-point safeguard here.
QA Brief
- Ensure the
google-site-kit/v1/core/user/data/survey-trigger
request is made when viewing the SK dashboard - Session storage may need to be cleared for it to be triggered again
Changelog entry
- Fix bug where user surveys would not trigger when viewing the dashboard.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (1 by maintainers)
@aaemnnosttv Oops, yes, sorry, I forgot that one was an indirect selector, but thanks for getting the idea 😅. Also the double yield was indeed a typo 😅
@wpdarren I think that’s correct—I don’t think we currently trigger surveys on entity dashboard pages… that said I’m not sure why? 🤔
@tofumatt resolve select only works on selectors that have a resolver, so this would require selecting
getAuthentication
rather thanisAuthenticated
. (also there is a doubleyield
there but I assume that’s just a typo 😄 )Otherwise LGTM – I’ll update this detail in the IB and then this will be good to go 👍