question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avoid double-triggering of survey and additional prompts

See original GitHub issue

Feature Description

Let’s make sure the prompt doesn’t show when there’s a second prompt on a different part of the dashboard (e.g. in the future this could happen with the UXR study recruitment form).

image


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

Acceptance criteria

  • When a remote-controlled survey is being displayed, no remote-controlled top notification (i.e. from core/site/data/notifications) must be displayed at the same time.
    • In other words, the surveys always take precedence. Furthermore, since the notifications are cached on the client-side, they can still easily be displayed again on next page load.
    • Technically, if a survey is being rendered, it needs to be ensured the site notifications state in the data store is emptied or kept empty to avoid those notifications from appearing.

Implementation Brief

  1. Use some state to determine whether or not a survey is being displayed. getCurrentSurvey() (this already exists) https://github.com/google/site-kit-wp/blob/38a001c4b564a9cf0b5c4fcccaf8f97c187ed00e/assets/js/googlesitekit/datastore/user/surveys.js#L157

  2. Make some changes assets/js/components/legacy-notifications/dashboard-core-site-alerts.js

  • Copy the file to assets/js/components/legacy-notifications/DashboardCoreSiteAlerts.js

  • Set a timeout to only render content after 5 seconds, though returning null doesn’t need to block.

  • Refactor it to a stateless functional component, instead of the call to getNotifications() from assets/js/components/legacy-notifications/site/get-notifications.js, use the getNotifications() selector window.googlesitekit.data.stores['core/site'].selectors.getNotifications().

  • After the five seconds timeout completes, add another call to the getCurrentSurvey() in case a remote survey has come in and if it returns a survey, return null, otherwise implemenent the remainder of the return statement as per the legacy render function.

  • Combining the changes from above, we do the following:

  • When the component loads, start the 5s timer,

  • If getCurrentSurvey() returns a survey, we return null and don’t render notifications.

  • If we don’t have a survey, we call getNotifications,

  • After the 5s have passed, we once more call getCurrentSurvey(), if it returns a survey, we return null, otherwise we return the notifications as per the current render() function of the legacy dashboard-core-site-alerts.

  1. Remove the assets/js/components/legacy-notifications/site/get-notifications.js and assets/js/components/legacy-notifications/dashboard-core-site-alerts.js files, any tests for them.

  2. Update components/legacy-notifications/index.js to call the new Component in const addCoreSiteNotifications = createAddToFilter( <DashboardCoreSiteAlerts />);

  3. Create storybook component stories for assets/js/components/notifications/DashboardCoreSiteAlerts.js

Test Coverage

Update tests/e2e/specs/dashboard/notifications.test.js to cover the following scenarios:

  • surveys and notifications to display, the notifications should not display.
  • no current survey but one appearing in 3 seconds, the notifications should not display.
  • no current survey but one appearing in 6 seconds, the notifications should display.

Visual Regression Changes

  • Add VRT for the storybook stories.

QA Brief

Changelog entry

  • Don’t show notifications if a user survey has already been displayed.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Hazlittecommented, Jun 28, 2021

@tofumatt Yes if the User Survey shows up within 5 seconds the notification is not displayed.

1reaction
ivankruchkoffcommented, Jun 16, 2021

@aaemnnosttv updated to call notifications before the 5s are up.

Moved the component to the legacy-notifications, my rationale for the notifications folder was that this new component is a refactored functional component rather than the legacy class based, but I can see the rationale for moving it as a block of functionality.

Back over to you for review @aaemnnosttv.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Patient-ventilator asynchronies: types, outcomes and nursing ...
Double -triggering and premature cycling can also occur when the patient's ventilatory demand is high and the ventilator inspiratory time is too short...
Read more >
Email Triggers
Qtip: An incomplete survey response will only cause an email trigger to send an email if the trigger has a condition that was...
Read more >
Survey Questions 101: Question Types, Examples, and Tips
Here are the types of survey questions you should be using to get more survey responses: Open-ended questions. Closed-ended questions. Rating questions.
Read more >
Double Triggering and Ventilator Asynchrony/Dyssynchrony
When they double trigger, another x amount of tidal volumes gets forced into their lungs on top of what was already there. Not...
Read more >
Avoid Bad Survey Questions: Loaded Question, Leading ...
Learn more about bad survey questions, loaded questions, leading questions, and mistakes to avoid if you want to write good surveys.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found