Skip to content
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

Trigger remote survey about Idea Hub usage #4052

Closed
felixarntz opened this issue Sep 15, 2021 · 11 comments
Closed

Trigger remote survey about Idea Hub usage #4052

felixarntz opened this issue Sep 15, 2021 · 11 comments
Labels
Module: Idea Hub Google Idea Hub module related issues P0 High priority Type: Enhancement Improvement of an existing feature
Milestone

Comments

@felixarntz
Copy link
Member

felixarntz commented Sep 15, 2021

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.
@felixarntz felixarntz added P0 High priority Type: Enhancement Improvement of an existing feature Module: Idea Hub Google Idea Hub module related issues labels Sep 15, 2021
@felixarntz felixarntz assigned felixarntz and unassigned felixarntz Sep 15, 2021
@felixarntz felixarntz added this to the Sprint 58 milestone Sep 16, 2021
@aaemnnosttv
Copy link
Collaborator

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.

@felixarntz I don't think we need to introduce a REST endpoint for this. I think it would be simpler to manage the count in client side state and just initialize the value on page load from what the server provides. Even if there is some duplication, it's just a counter, so there isn't really much business logic to worry about getting out of sync. We can just annotate both parts to ensure the other is updated if/when it ever needs to be.

@tofumatt tofumatt assigned tofumatt and unassigned tofumatt Sep 16, 2021
@tofumatt
Copy link
Collaborator

IB ✅

@eugene-manuilov eugene-manuilov self-assigned this Sep 16, 2021
@felixarntz
Copy link
Member Author

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

@felixarntz
Copy link
Member Author

@eugene-manuilov I've added a point to the ACs to include here the timeout increase we've discussed.

@eugene-manuilov
Copy link
Collaborator

@felixarntz @aaemnnosttv I had to recreate the PR for this ticket because the original PR contains unwanted changes from the develop branch. Please, review #4100 now.

@aaemnnosttv
Copy link
Collaborator

@eugene-manuilov would you please add a QAB?

@eugene-manuilov eugene-manuilov removed their assignment Sep 22, 2021
@eugene-manuilov
Copy link
Collaborator

eugene-manuilov commented Sep 22, 2021

@felixarntz could you please add instructions on how the new survey should work? Which questions should be shown based on user answers?

@felixarntz
Copy link
Member Author

felixarntz commented Sep 22, 2021

@eugene-manuilov @wpdarren I'm not gonna go into detail on which answer choices etc there should be, you can assume those are correct. High-level it should be as follows:

  1. There is a "rating" question on overall satisfaction with Idea Hub so far. Based on what rating you give, the second question shown will differ.
  2. The second question is a "multi-select" question. If you gave 4-5 points above, it asks why you are satisfied with Idea Hub. If you gave 1-3 points above, it asks why you are dissatisfied with Idea Hub.
  3. At the end there should just be a single completion prompt (no matter what you replied) that thanks for the feedback.

You should never see both the question about whether you're satisfied and the question whether you're dissatisfied in the same session, i.e. it has to be ensured that it's the above 2 questions that show, never all 3 (that's the part mostly related to #4051).

In order to trigger the notification, in addition to the plugin-side requirements, you have to be on version 1.42.0 and you have to have activated Idea Hub in the site at least 48 hours ago. Also as soon as you complete or close the survey, you won't be able to trigger it again on the same site and same Google account. If needed, coordinate with me to reset that.

@wpdarren
Copy link
Collaborator

wpdarren commented Sep 23, 2021

QA Update: ⚠️

This is looking good from my first round of testing.

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.

@felixarntz I would like to run through it one more time with a rating of 1-3 so I can see what appears. I will send you a message on Slack with my site and account details so you can reset it for me. Also do we have any figma designs for this so I can make sure that the UI is looking as expected, or are we okay with that?

@wpdarren wpdarren self-assigned this Sep 23, 2021
@felixarntz
Copy link
Member Author

@wpdarren I've cleared the storage so you should now be able to retrigger the notification.

Also do we have any figma designs for this so I can make sure that the UI is looking as expected, or are we okay with that?

We don't have any designs, all the UI components used here were already QAd before when they were originally introduced, so it's not necessary to review the exact design as part of this. I think once you've confirmed the flow works as well for replying something between 1-3, this should be good to go.

@wpdarren
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Idea Hub Google Idea Hub module related issues P0 High priority Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

5 participants