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

Add exit survey #3729

Merged
merged 18 commits into from
Oct 28, 2020
Merged

Add exit survey #3729

merged 18 commits into from
Oct 28, 2020

Conversation

yscik
Copy link
Contributor

@yscik yscik commented Oct 21, 2020

Fixes #2374

Changes proposed in this Pull Request

  • When clicking Deactivate on the plugins screen, open up a modal with an exit survey form
  • Add AJAX action to save the submitted feedback and send track event
  • Send the event anonymously, with a hashed site ID, when usage tracking is disabled

Testing instructions

  • Go to the Plugins screen, and click Deactivate on the Sensei LMS plugin
  • A modal should open up
  • Clicking Skip Feedback should continue with deactivating plugin
    --
  • Do it again, select a reason, type in details and submit
  • A sensei_plugin_deactivate track event should be sent, with the selected reason and details

Screenshot / Video

image

QuickTime movie

@yscik yscik added this to the 3.5.3 milestone Oct 21, 2020
@yscik yscik requested a review from a team October 21, 2020 13:04
Copy link
Contributor

@renatho renatho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works well!

Just when we're submitting the survey, if the usage tracking is disabled, it doesn't send. Maybe should we send it anyway? Or maybe don't show the modal in this case?

assets/admin/exit-survey/form-item.js Outdated Show resolved Hide resolved
'sensei-lms'
) }
</p>
{ reasons.map( ExitSurveyFormItem ) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! I have never seen this approach to map directly in the component instead of the instance. I didn't know it worked!
But while debugging, I noticed that React dev tools don't recognize the mapped components. Do you know a way to fix that? Or maybe we should map it using the component instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is just a function, so it works. But updated it to component instance to make it clearer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with this change we can also remove the key={ label } from the ExitSurveyFormItem render, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, updated in 180ed8b

assets/admin/exit-survey/form.js Show resolved Hide resolved
@renatho
Copy link
Contributor

renatho commented Oct 21, 2020

Hum, I think we also need to update some e2e tests that are failing. ;)

@renatho
Copy link
Contributor

renatho commented Oct 21, 2020

Ah, sorry! Another thing I remembered only now. I think we should use the release/3.5.3 branch as source and target for this feature because our master is with the code to the 3.6.0.

@yscik yscik changed the base branch from master to release/3.5.3 October 21, 2020 16:29
Co-authored-by: Renatho De Carli Rosa <[email protected]>
@yscik
Copy link
Contributor Author

yscik commented Oct 21, 2020

Rebased to release/3.5.3 and updated the E2E tests this affects.

@yscik
Copy link
Contributor Author

yscik commented Oct 21, 2020

if the usage tracking is disabled, it doesn't send. Maybe should we send it anyway? Or maybe don't show the modal in this case?

Right, sending it anyway was the plan I think. That also means though that we are sending along all the base fields for the site. What should we do here @donnapep?

  • Send the full event when the user submits this feedback
  • Send a partial event with only these fields (eg. no site url, admin email)
  • Do not show the exit survey

@donnapep
Copy link
Collaborator

  • Send a partial event with only these fields (eg. no site url, admin email)

This would be the safest thing to do from a privacy perspective. We really shouldn't submit any data that they haven't opted in to sending.

Copy link
Contributor

@renatho renatho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the d44d4fa and it worked well! Just adding some comments about that.

'details' => isset( $_POST['details'] ) ? sanitize_text_field( wp_unslash( $_POST['details'] ) ) : null,
];

update_option( 'sensei_exit_survey_data', $feedback );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I noticed that. More for documentation purposes, what's the idea of this option?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a new option, we should also add it to class-sensei-data-cleaner.php.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall talking about storing this, but we can get rid of it if we don't want to. Not used for anything right now.

* @param null|int $event_timestamp When the event occurred.
*
* @return bool
**/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the other functions in this file close the PHPDoc with **/, but considering it's a new function, maybe we could add it correctly */. WDYT?
Or we could also take the opportunity to replace all of them in this file! =)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned them up in a54b8b9

*
* @return bool
**/
public function send_anonymous_event( $event, $properties = array(), $event_timestamp = null ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the normal events, sounds a little weird to me going through the send_anonymous_event. Maybe we could call it as create_pixel, or something like that, and also have send_anonymous_event to be called in the save_exit_survey. The send_anonymous_event would also call the create_pixel (and it wouldn't do anything else for now). Does it make sense to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this up in bda3c37, as the anonymous method has it's own logic now.

@donnapep
Copy link
Collaborator

donnapep commented Oct 23, 2020

Could the background be made a bit darker when the modal is displayed? I think it would help the modal stand out a bit more.

This event is being rejected by Tracks:

Screen Shot 2020-10-23 at 8 29 45 AM

Looks like we are going to need to send userid and useridtype at a minimum. If usage tracking is enabled though, we may as well send everything as per usual. That will be especially important for us to be able to determine if they are also using WCPC.

Also, @gkaragia will want this new event to be registered in Tracks. 🙂

@yscik
Copy link
Contributor Author

yscik commented Oct 27, 2020

Also had to update the event name to match the <source>_<context>_<action> pattern required by tracks. Changed it to sensei_plugin_deactivate.

When usage tracking is enabled, we send the full event. When it's not, we send the hash of the site url as the user ID. This way it's always the same for the same site, but still anonymous.

@donnapep
Copy link
Collaborator

Event is being logged now. 🙌

With usage tracking enabled, details and reason are logged, but I'm not seeing data like admin_email, courses, paid etc.

@yscik
Copy link
Contributor Author

yscik commented Oct 27, 2020

Sorry about that, must have removed that logic at some point — f587121 now sends the full event if tracking is enabled.

@donnapep
Copy link
Collaborator

Something is still a wee bit off. admin_email is there now, but courses, learners, paid and source are not.

Copy link
Collaborator

@donnapep donnapep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving based on Renatho's previous code review and the fact that logging is working well. 👍

@yscik yscik merged commit e9affe2 into release/3.5.3 Oct 28, 2020
@yscik yscik deleted the add/exit-survey branch October 28, 2020 12:28
@yscik yscik linked an issue Oct 28, 2020 that may be closed by this pull request
@donnapep donnapep changed the title Add Exit Survey Add exit survey Oct 28, 2020
@alexsanford alexsanford mentioned this pull request Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an exit survey when the plugin is deactivated
3 participants