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.

Trigger remote survey about Idea Hub usage

See original GitHub issue

A new remote survey for Idea Hub should be supported, specifically on the plugin side this means that the triggering logic needs to be added. Also the new survey relies on #4051 - that is only a blocker for full testing though, it shouldn’t block the implementation of this issue.

The requirements on the Site Kit Service side to trigger this survey are the following:

  • You have to be on at least Site Kit version 1.42.0.
  • You have to have first activated Idea Hub at least 2 days (48 hours) ago.

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

Acceptance criteria

  • The Idea Hub module should internally (on the server-side) introduce a single counter per user that counts the following interactions with the feature:
    • idea dismissal
    • idea save
    • idea draft creation
    • In other words, when any of these actions is performed, the count for the current user should be increased. To clarify, it should be one counter that aggregates all three interactions, we don’t need 3 individual counters.
  • The counter value for the current user should be provided from PHP to JS so that it can be used there. This can be as simple as possible, e.g. a PHP-to-JS property is preferred unless there’s a good reason to use a REST data point.
  • In JS: Whenever the current user performs one of the above three actions on the Idea Hub widget, if their current counter value is greater than 5, a survey trigger request for a new trigger interact_idea_hub should be issued. If a survey is returned it should be displayed as usual.
    • This requires that JS somehow keeps track of the value too, also when it changes (which is for example relevant if the user makes 5 interactions in a single page load). So maybe a REST data point is more reliable after all, or the JS code would need to “duplicate” and do the counting itself.
  • The timeout for /survey/trigger/ and /notifications/ requests to the proxy should be increased to 15 seconds.

Implementation Brief

The API infrastructure is currently being built. Depending on how quickly this gets implemented, the Site Kit Service part may not be ready yet. Please coordinate testing with @felixarntz.

PHP

  • Add a new Google\Site_Kit\Modules\Idea_Hub\Idea_Interaction_Count class which extends User_Setting
    • Slug googlesitekit_idea-hub_interaction_count
    • type integer
    • default value 0
    • Add an additional public method increment which simply takes the current value, increases it by 1 and saves it
    • Add a test case for this class, mostly for the added method, everything else is covered by the tests for the base class
  • Update Idea_Hub::__construct to initialize Idea_Interaction_Count to a protected interactionCount property similar to how is currently done with post name/text/topic classes
  • Update Idea_Hub::setup_assets to extend the _googlesitekitIdeaHub global with a new interactionCount property, which is defined by the current integer value of Idea_Interaction_Count
  • Update the Idea_Hub::parse_data_response method to call Idea_Interaction_Count::increment for the following datapoints:
    • POST:create-idea-draft-post
    • POST:update-idea-state

JS

  • Add a new interactions store partial to the Idea Hub data store
    • initialState will only need a single property interactionCount which should be initialized from the property by the same name on the _googlesitekitIdeaHub global
    • selectors.getInteractionCount - returns the property from state
    • actions.incrementInteractions - returns a simple action which when handled in the reducer increments the interaction count by 1
    • Be sure to merge this new partial with the aggregate combined store definition with the module in the index
  • Add JS tests for the new partial’s action and selector
  • Update Idea Hub store actions to increment the count similar to how is done on the server – this should be done by yielding incrementInteractions() after the respective interaction action has been done, and only if that action did not result in an error
    • updateIdeaState in assets/js/modules/idea-hub/datastore/idea-state.js
    • createIdeaDraftPost in assets/js/modules/idea-hub/datastore/draft-ideas.js
  • Add a new useIdeaInteractionTriggerEffect hook in assets/js/modules/idea-hub/hooks
    • selects getInteractionCount
    • defines a useEffect which runs when the interaction count updates (not on initial run/mount – ie cleanup only)
    • if the count is greater than 5, dispatch triggerSurvey with the triggerID as defined in the ACs
  • Update DashboardIdeasWidget to use the new useIdeaInteractionTriggerEffect

Test Coverage

  • Add PHPUnit test case for added Idea_Interaction_Count class
  • Add JS tests for the new store partial
  • Add Jest tests for the new custom hook

QA Brief

To test this ticket you need to use a release candidate version for 1.42.0 or higher.

  • Create a new jurrasic ninja site
  • Install the plugin and sign in using your Google account
  • Set the reference site URL to https://www.elasticpress.io/ using the develop settings plugin
  • Enable the idea hub feature flag using the tester plugin
  • Activate and set up the Idea Hub module
  • Go to the dashboard page and make actions defined in the first point of AC six times
  • Make sure that after the 6th action, you see a new survey pops up (it may take up to 10 seconds to receive and show the survey).

Changelog entry

  • Add survey trigger for Idea Hub widget interactions.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
felixarntzcommented, Sep 16, 2021

@aaemnnosttv That sounds good to me, I was also thinking something along those lines - the REST API was just an alternate solution.

0reactions
wpdarrencommented, Sep 24, 2021

QA Update: ✅

All good.

I used a site that was created and set up with Idea hub on Monday, and after triggering six actions as per the AC, the survey appeared 🎉 The first question was a rating, and I chose 5, and then the next question was multiple choice. I selected two options and clicked on next. The final message appeared thanking me for my feedback. I then chose 2 in the rating and a new set of multiple choice questions appeared based on my rating.

image

image

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Survey trigger conditions - Product Documentation | ServiceNow
Trigger conditions specify when to send a particular survey and the persons to send it to. ... To share your product suggestions, visit...
Read more >
24 Employee Engagement Survey Questions (and How to Use ...
Showing appreciation for everyone in the organization; Seeking and responding to peoples' ideas; Involving employees in important decisions ...
Read more >
How to Create an Effective Survey (Updated 2022) - Qualtrics
In this article, we're going to reveal how to create a survey that's easy to complete, encourages collecting feedback, hits the research questions...
Read more >
Sample forms to help organizations stay connected while ...
Forms is a web-based app designed to help you easily create surveys, polls, and quizzes, and collect responses in real time.
Read more >
Create a Standard Survey - Salesforce Help
Create a standard survey to collect data from customers, employees, or other people whose feedback you need.Required Editions and User Permissions Availab.
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