-
Notifications
You must be signed in to change notification settings - Fork 297
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
Issue / 10036 Duplicate Survey Triggers view_kmw
view_ga4_dashboard
Surveys
#10161
base: develop
Are you sure you want to change the base?
Issue / 10036 Duplicate Survey Triggers view_kmw
view_ga4_dashboard
Surveys
#10161
Conversation
…w-kmw-view-ga4-dashboard-surveys.
…setup by current user. Add trigger for view_kmw survey.
Build files for 1b52106 are ready:
|
Size Change: -299 B (-0.01%) Total Size: 2 MB
ℹ️ View Unchanged
|
…, implement async on tests and waitForRegistry() in order to suppress act() errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @10upsimon LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @10upsimon ! Apologies for the late feedback in the cycle here but it seems we're maybe trying to solve the problem in the wrong place.
A survey shouldn't really be possible to be triggered multiple times (regardless of where or how) because we "timeout" survey triggers and so only triggers that aren't timed out should hit the backend.
site-kit-wp/assets/js/googlesitekit/datastore/user/surveys.js
Lines 212 to 234 in f4f7360
// Both isTimedOut and isTimingOut variables are already resolved since they depend on | |
// the getSurveyTimeouts selector which we've resolved just before getting these variables. | |
if ( ! isTimedOut && ! isTimingOut ) { | |
const { response, error } = | |
yield fetchTriggerSurveyStore.actions.fetchTriggerSurvey( | |
triggerID | |
); | |
if ( error ) { | |
return { response, error }; | |
} | |
// If TTL isn't empty, then sleep for 30s and set survey timeout. | |
if ( ttl > 0 ) { | |
yield new Promise( ( resolve ) => { | |
setTimeout( resolve, 30000 ); | |
} ); | |
yield commonActions.await( | |
dispatch( CORE_USER ).setSurveyTimeout( triggerID, ttl ) | |
); | |
} | |
} |
Looking at the action, it seems we're not protecting against a survey from being triggered again if that happens before the timeout is set, which is delayed by 30 seconds as you can see above. I'm not familiar with why that is but I'm sure we can avoid concurrent triggers during this time by revisiting this behavior in the datastore and fix the issue everywhere at once rather than fixing it at each point where the trigger is invoked.
@@ -69,7 +123,6 @@ export default function ChangeMetricsLink() { | |||
> | |||
{ __( 'Change metrics', 'google-site-kit' ) } | |||
</Link> | |||
<SetupCompletedSurveyTrigger /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this is counter to the IB but I'd prefer if we didn't change this, but also I don't quite see the benefit of pulling so much of this component (which is now unused) into this one. If the in view state is beneficial, we could source that via useInView
(which should source its state from the InViewProvider
of the KMW area) although I'm not sure we need to implement an observer just for this button. Pushing the tracking into the render here allows us to use the same conditions for the trigger as for showing. I don't think it's particularly important that the button itself is viewed.
currentUserID, | ||
isKeyMetricsSetupCompletedBy, | ||
] ); | ||
|
||
if ( ! renderChangeMetricLink ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IB says
Include
renderChangeMetricLink
in the condition, surveys shouldn't be triggered if the value is falsy
this wouldn't be necessary though if we can keep the former render-based triggering.
Thanks @aaemnnosttv , just to chip in here, It is nice to fix the root problem, but since this issue is a launch blocker for an epic, IB proposed a fix for issue at hand, as working on a core logic will affect all possible surveys which means long and thorough QA to test everything, watch for regression, etc. I would suggest we do that in a separate issue since that can be done at any time, unlike the launch blocker. WDYT? |
Summary
Addresses issue:
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist