-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make timeout for view_dashboard
surveys more reliable and extend it
#4925
Comments
Nice work, @techanvil! IB ✔️ |
@eugene-manuilov @tofumatt One question for you here: #5003 (review) |
QA Update: ❌@tofumatt as per our Slack conversation, I tested this on
I also checked the I don't know if this change also updated main but I do not remember seeing this issue when previously testing this. |
@wpdarren Odd, I didn't see that error when testing locally. That said, the session param being missing would make sense if we're using the plugin to force a survey. @eugene-manuilov Is this just caused because of the plugin? I don't think it's related to the change, right? |
@wpdarren if you use the plugin that simulates surveys, then that's okay because you see fake surveys and there is no way to submit survey events for them. |
@eugene-manuilov @tofumatt Just noting that #5129 was created based on Can you please approve #5134? |
@felixarntz, yes, you are right. Sorry about that. PR is approved. |
Ah, sure thing. I actually figured since the issue was already QA'd as-shipped in I've approved that |
It is currently possible to see a few too many surveys in short time frame, which isn't that great from a user experience perspective. This is particularly related to the
view_dashboard
trigger, which several surveys get attached to. While there is already a 1 hour timeout, it is only stored on the client-side and it is regularly invalidated e.g. when activating a new module, so that can result in an overload of surveys being shown in little time.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
view_dashboard
trigger, which is the only survey trigger ID currently relying on a timeout, but the implementation should be generic enough to support other triggers in the future.view_dashboard
trigger.view_dashboard
trigger specifically should be extended to 24 hours (instead of 1 hour as it is now).Implementation Brief
Create new REST endpoints
Note: The Dismissed Items endpoints and related code under
includes/Core/Dismissals
can serve as a reference and broadly be copied here.Working in the directory
includes/Core/User_Surveys
:Survey_Timeouts
to represent the survey timeouts as a user setting.includes/Core/Dismissals/Dismissed_Items.php
, renamed for survey timeouts.OPTION
should begooglesitekit_survey_timeouts
.get_dismissed_items
andfilter_dismissed_items
should be renamedget_survey_timeouts
andfilter_survey_timeouts
.is_dismissed
and this can be ignored/removed inSurvey_Timeouts
.User_Surveys
, as a container forSurvey_Timeouts
andREST_User_Surveys_Controller
, following the same pattern asincludes/Core/Dismissals/Dismissals.php
.includes/Plugin.php
to create and registerUser_Surveys
instead ofREST_User_Surveys_Controller
.REST_User_Surveys_Controller
:GET core/user/data/survey-timeouts
for retrieving the list of survey timeouts.POST core/user/data/survey-timeout
for setting a survey timeout.GET core/user/data/dismissed-items
andPOST core/user/data/dismiss-item
routes inincludes/Core/Dismissals/REST_Dismissals_Controller.php
.core/user/data/survey-timeouts
is preloaded by adding it to thegooglesitekit_apifetch_preload_paths
filter in theregister
method.googlesitekit_apifetch_preload_paths
inREST_Dismissals_Controller
for an example.Create Redux interface to new endpoints
Note: The Redux store for Dismissed Items in
assets/js/googlesitekit/datastore/user/dismissed-items.js
can serve as a reference and broadly be copied here.assets/js/googlesitekit/datastore/user/survey-timeouts.js
.assets/js/googlesitekit/datastore/user/dismissed-items.js
, renamed for survey timeouts.createFetchStore
store for theGET .../survey-timeouts
endpoint should have thebaseName
ofgetSurveyTimeouts
.createFetchStore
store for thePOST .../survey-timeout
endpoint should have thebaseName
ofsetSurveyTimeout
.dismissItem
should be renamedsetSurveyTimeout
.getDismissedItems
should be renamedgetSurveyTimeouts
.isItemDismissed
should be renamedisSurveyTimedOut
.isDismissingItem
should be renamedisTimingOutSurvey
.assets/js/googlesitekit/datastore/user/index.js
.Update
triggerSurvey
action to use backend dataUpdate the
triggerSurvey
action inassets/js/googlesitekit/datastore/user/surveys.js
to use backend data via the new store actions and selectors, instead of checking local storage.isSurveyTimedOut
selector returnsfalse
and theisTimingOutSurvey
selector returnsfalse
, for the giventriggerID
.isSurveyTimedOut
must be checked for explicit=== false
, asundefined
indicates the state is not resolved yet.setTimeout
callback:setItem
with adispatch
of thesetSurveyTimeout
action, passing in thetriggerID
andttl
.receiveGetSurveyTimeouts
action with the received survey timeouts, thus updating the local state.Replace
useMount
withuseEffect
inSurveyViewTrigger
Within
SurveyViewTrigger
:shouldTriggerSurvey
, containing the boolean value of the condition as described above:true
if theisSurveyTimedOut
selector returnsfalse
and theisTimingOutSurvey
selector returnsfalse
, for the giventriggerID
.false
.useSelect
to access the selectors.The survey should now be triggered in a
useEffect
with the value ofshouldTriggerSurvey
as a dependency. This is because the survey timeout state is not guaranteed to be available in theuseMount
hook, as it may still be resolving at this point.useMount
withuseEffect
.shouldTriggerSurvey
in the condition for triggering the survey.shouldTriggerSurvey
is included in theuseEffect
dependencies.Update the
view_dashboard
survey timeouts to one dayDashboardApp
andDashboardMainApp
, update theview_dashboard
TTL value to86400
(i.e. one day, in seconds).Test Coverage
triggerSurvey
to reflect the new behaviour.QA Brief
Always Surveys
pluginChangelog entry
The text was updated successfully, but these errors were encountered: