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
Conversation
Test Results SummaryCommit SHA: d34541e
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. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( ',' ), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
44b7e27
to
7e43808
Compare
Hey @joshuatf, I just addressed the suggestions you made. |
There was a problem hiding this 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://'; |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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()
.
# Conflicts: # plugins/woocommerce/src/Admin/Features/NewProductManagementExperience.php
b9f238e
to
914a989
Compare
There was a problem hiding this 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! 🚢
* 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>
* 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>
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.
It will be visible every time the user disables the new experience.
How to test the changes in this Pull Request:
localStorage.setItem( 'debug', 'wc-admin:*' );
Send feedback
button should be disabled until an option is selected or a text is added to the text area.6. Verify that the `Skip` button and the `X` to close the modal work as expected.
Other information:
pnpm --filter=<project> changelog add
?FOR PR REVIEWER ONLY: