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 survey when disabling new experience #36544

Merged
merged 13 commits into from Jan 24, 2023

Conversation

octaedro
Copy link
Contributor

@octaedro octaedro commented Jan 22, 2023

All Submissions:

Changes proposed in this Pull Request:

This PR adds a survey when the user disables the new product management experience. Is based on this PR.

Screenshot 2023-01-20 at 10 48 01

It will be visible every time the user disables the new experience.

  • This PR is a very minor change/addition and does not require testing instructions (if checked you can ignore/remove the next section).

How to test the changes in this Pull Request:

  1. Go to a new product using the new product management experience and disable it. Use the bottom bar button or select the "use the classic editor" option at the top bar.

Screenshot 2023-01-06 at 15 53 57

Captura de ecrã 2022-10-17, às 16 29 58

  1. Make sure you have tracks enabled and also outputted in the console: localStorage.setItem( 'debug', 'wc-admin:*' );
  2. A survey will be shown, and the Send feedback button should be disabled until an option is selected or a text is added to the text area.
  3. Send feedback and verify that the checked options and comment are being tracked.
  4. A notice should be shown in the old experience saying:

Screenshot 2023-01-06 at 15 48 59

6. Verify that the `Skip` button and the `X` to close the modal work as expected.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you created a changelog file for each project being changed, ie pnpm --filter=<project> changelog add?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@github-actions github-actions bot added focus: react admin package: @woocommerce/customer-effort-score issues related to @woocommerce/customer-effort-score plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Jan 22, 2023
@octaedro octaedro changed the title Add/survey after disabling new exp Add survey when disabling new experience Jan 22, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2023

Test Results Summary

Commit SHA: d34541e

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 53s
E2E Tests189006019515m 46s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@octaedro octaedro changed the base branch from trunk to add/feedback_modal_and_product_mvp_feedback_modal_components January 22, 2023 19:20
@octaedro octaedro marked this pull request as ready for review January 22, 2023 21:30
@octaedro octaedro self-assigned this Jan 23, 2023
Copy link
Contributor

@joshuatf joshuatf left a comment

Choose a reason for hiding this comment

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

Very nicely done! Added a few minor comments and question around how we show notices via the data store.

};
} );

const classEditorUrl = values.id
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const classEditorUrl = values.id
const classicEditorUrl = values.id

@@ -62,6 +63,16 @@ const reducer = ( state = DEFAULT_STATE, action ) => {
...state,
queue: [ ...state.queue, newTrack ],
};
case TYPES.SHOW_PRODUCT_MVP_FEEDBACK_MODAL:
Copy link
Contributor

Choose a reason for hiding this comment

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

I won't let it block this PR if this is the easiest way to get this working, but I'm not so sure about using data stores to show/hide modals. I wonder what the original reasons for doing this were.

If these are not needed outside of the app, I feel context might have been a better fit.

If data stores are necessary, I wonder if we could have more generic getters/setters. E.g., showModal( modalName ), hideModal( modalName ), isModalVisible( modalName ), etc.

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 concur with you. I followed the pattern we were using to not add more complexity to this part, but I think that it would be a really nice refactor to handle the visibility of the modals differently.

const recordScore = ( checked: string[], comments: string ) => {
recordEvent( 'product_mvp_feedback', {
action: 'disable',
checked: checked.join( ',' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

I was under the impression that tracks handled converting arrays automatically. Is this required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! I fixed it in the commit a01ffe6

@@ -28,6 +29,16 @@ public function __construct() {

add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
add_action( 'get_edit_post_link', array( $this, 'update_edit_product_link' ), 10, 2 );
if ( isset( $_GET['new-product-experience-disabled'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
TransientNotices::add(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we redirect removing new-product-experience-disabled from the URL so that this message does not appear if the user refreshes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I add it in the commit 7e43808

@octaedro octaedro force-pushed the add/survey_after_disabling_new_exp branch from 44b7e27 to 7e43808 Compare January 23, 2023 21:35
@github-actions github-actions bot removed the package: @woocommerce/customer-effort-score issues related to @woocommerce/customer-effort-score label Jan 23, 2023
@octaedro
Copy link
Contributor Author

Hey @joshuatf, I just addressed the suggestions you made.
Could you take another look at this PR?

Base automatically changed from add/feedback_modal_and_product_mvp_feedback_modal_components to trunk January 23, 2023 23:19
Copy link
Contributor

@joshuatf joshuatf left a comment

Choose a reason for hiding this comment

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

Added a couple more comments around the fixes, but hopefully pretty small fixes. Let me know if you have any questions 😄

@@ -22,6 +23,24 @@ class NewProductManagementExperience {
* Constructor
*/
public function __construct() {
$new_product_experience_param = 'new-product-experience-disabled';
if ( isset( $_GET[ $new_product_experience_param ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$url = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https://' : 'http://';
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 we can just use remove_query_arg( 'new-product-experience-disabled', $url ) to remove the arg here.

https://developer.wordpress.org/reference/functions/remove_query_arg/

$url = preg_replace( '/(&|\?)' . preg_quote( $new_product_experience_param ) . '=[^&]*$/', '', $url ); // phpcs:ignore WordPress.PHP.PregQuoteDelimiter.Missing
$url = preg_replace( '/(&|\?)' . preg_quote( $new_product_experience_param ) . '=[^&]*&/', '$1', $url ); // phpcs:ignore WordPress.PHP.PregQuoteDelimiter.Missing

wp_safe_redirect( $url );
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be a tiny bit safer to move this after the TransientNotices below and exit;.

@@ -22,6 +23,24 @@ class NewProductManagementExperience {
* Constructor
*/
public function __construct() {
$new_product_experience_param = 'new-product-experience-disabled';
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to move this logic out of the constructor and into a method. Something like $this->maybe_show_disabled_notice().

@octaedro octaedro force-pushed the add/survey_after_disabling_new_exp branch from b9f238e to 914a989 Compare January 23, 2023 23:47
Copy link
Contributor

@joshuatf joshuatf left a comment

Choose a reason for hiding this comment

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

Testing well and code looks great! Thanks, Fernando! 🚢

@octaedro octaedro merged commit c030b7d into trunk Jan 24, 2023
@octaedro octaedro deleted the add/survey_after_disabling_new_exp branch January 24, 2023 01:43
@github-actions github-actions bot added this to the 7.5.0 milestone Jan 24, 2023
@octaedro octaedro modified the milestones: 7.5.0, 7.4.0 Jan 24, 2023
github-actions bot pushed a commit that referenced this pull request Jan 24, 2023
* Add customer-score-tracks data

* Add callback after disabling new exp

* Add TransientNotice after filling out the survey

# Conflicts:
#	plugins/woocommerce/src/Admin/Features/NewProductManagementExperience.php

* Remove comments

* Remove NEW_PRODUCT_MANAGEMENT_FEEDBACK

* Add changelog

* Rename const

* Remove queryParam after showing notice

* Fix lint

* Fix lint 2.0

* Remove empty line

* Refactor `maybe_show_disabled_notice`

* Fix lint 3.0

Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
@jonathansadowski jonathansadowski modified the milestones: 7.4.0, 7.5.0 Jan 24, 2023
vedanshujain pushed a commit that referenced this pull request Jan 25, 2023
* Add customer-score-tracks data

* Add callback after disabling new exp

* Add TransientNotice after filling out the survey

# Conflicts:
#	plugins/woocommerce/src/Admin/Features/NewProductManagementExperience.php

* Remove comments

* Remove NEW_PRODUCT_MANAGEMENT_FEEDBACK

* Add changelog

* Rename const

* Remove queryParam after showing notice

* Fix lint

* Fix lint 2.0

* Remove empty line

* Refactor `maybe_show_disabled_notice`

* Fix lint 3.0

Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants