-
Notifications
You must be signed in to change notification settings - Fork 10.7k
CES exit prompt for product editing screens #35728
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
Conversation
Test Results SummaryCommit SHA: 104a1e3
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. |
| } | ||
| window.addEventListener( 'beforeunload', function ( event ) { | ||
| // Check if button disabled or triggered delete to see if user saved or deleted the product instead. | ||
| if ( checkIfSubmitButtonsDisabled() || triggeredDelete ) { |
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.
As the comment implies, it was hard to differentiate if the beforeunload was happening because a user was saving or deleting a product or if they were exiting.
These two checks were the main differentiator I could add to check against this.
4b85bcd to
d919d68
Compare
| export const SHOWN_FOR_ACTIONS_OPTION_NAME = | ||
| 'woocommerce_ces_shown_for_actions'; | ||
| export const ADMIN_INSTALL_TIMESTAMP_OPTION_NAME = | ||
| 'woocommerce_admin_install_timestamp'; |
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 couldn't find the place where these two const are being used.
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.
Aaah yeah, I kinda copy pasted them from another PR, that one is merged now, so all of them should be used in a couple other files now.
|
|
||
| let items = getExitPageData(); | ||
|
|
||
| items = items.filter( ( item ) => item !== pageId ); |
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'm not clear about this part. Why do we remove the item from the array and add it again?
Maybe we can check if the item is present in the array and add it if not.
It would look like this:
if ( ! items.find( ( pageExitedId ) => pageExitedId === pageId ) ) {
items.push( pageId );
}
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.
Simplicity mostly, but I can use your approach as well.
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.
Also to make sure we never have duplicates.
|
|
||
| let items = getExitPageData(); | ||
|
|
||
| items = items.filter( ( item ) => item !== pageId ); |
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.
What do you think about renaming item to pageExitedId or something less generic?
| } | ||
|
|
||
| /** | ||
| * checks the exit page list and triggers a CES survey for the first item in the list. |
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.
Really nitpick: it should start with a capital letter.
octaedro
left a comment
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.
Fantastic work @louwie17! The code looks good and it's testing pretty well here. I only left a couple of small comments and I saw something unexpected when I was saving the product.
049815d to
a8ee37c
Compare
|
Thanks for the review @octaedro, I addressed your PR feedback and fixed the issue you found. This should be ready for re-review. |
9ebe306 to
104a1e3
Compare
| isResolving( 'getOption', [ ALLOW_TRACKING_OPTION_NAME ] ); | ||
| ! hasFinishedResolution( 'getOption', [ | ||
| ALLOW_TRACKING_OPTION_NAME, | ||
| ] ); |
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.
Made use of hasFinishedResolution to fix a bug where if one of the above options was being retrieved again isResolving would be set to true again, which in turn set resolving to true and in turn caused this component to return null.
Once the resolving finished it would render the CustomerEffortScore again and in turn trigger a new notice, something we don't want.
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!
96eb9af to
104a1e3
Compare
octaedro
left a comment
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.
Thank you for adding the changes! LGTM 🚀
Good job @louwie17
* Add exit page tracker logic and implement it for product pages * Add changelog * Fix lint errors and add comments * Add ces_location prop * Add mock to fix broken test * Add CES exit page survey tests * Fix a bug with React pages redirects and update actions * Fix test * Fix lint * Add default inside location prop * Remove exit prefix within action * Address PR feedback and make sure its not triggered on save * Update copy of exit feedback notice * Add changelog * Update name of param * Fix lint error * Use hasFinishedResolution vs isResolved in customerEffortScoreTracks

All Submissions:
Changes proposed in this Pull Request:
This add's initial logic to make it easy to track if users leave pages with un-saved changes, for showing a feedback notice.
This would only be enabled if the user has enabled tracking.
Partially addresses #35126 .
Kapture.2022-11-25.at.11.16.31.mp4
How to test the changes in this Pull Request:
new-product-management-experiencefeature flag enabled (you can do so using the latest version of the Beta tester within the mono repo).We noticed you started editing a product, then left....wcadmin_ces_snackbar_view,wcadmin_ces_view, andwcadmin_ces_feedbackinclude theces_locationprop with theoutsidevalue.You may also want to try dismissing the notice and see if the prop has been added to
wcadmin_ces_snackbar_dismisswoocommerce_ces_shown_for_actionsoption and disable tracking under WooCommerce > Settings > Advanced > Woocommerce.comcustomer-effort-score-exit-pagein local storage does not get updated, but stays empty.Other information:
pnpm --filter=<project> changelog add?FOR PR REVIEWER ONLY: