-
Notifications
You must be signed in to change notification settings - Fork 21
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
Sync MC address during onboarding. #2653
base: feature/2509-consolidate-google-account-cards
Are you sure you want to change the base?
Sync MC address during onboarding. #2653
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/2509-consolidate-google-account-cards #2653 +/- ##
===============================================================================
- Coverage 62.7% 61.3% -1.5%
===============================================================================
Files 325 319 -6
Lines 5162 4958 -204
Branches 1265 1214 -51
===============================================================================
- Hits 3239 3038 -201
+ Misses 1746 1744 -2
+ Partials 177 176 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
@asvinb this is looking pretty good. Only a couple of critical issues to address.
@@ -89,6 +90,7 @@ const SetupAccounts = ( props ) => { | |||
isReady: isGoogleMCReady, | |||
} = useGoogleMCAccount(); | |||
const { hasFinishedResolution } = useGoogleAdsAccount(); | |||
const storeAddressSynced = useStoreAddressSynced(); |
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.
This hook cannot be used here until after the MC account is connected. Otherwise it will send an API request to /gla/mc/contact-information
which will result in a 401 error.
Either we need to incorporate useGoogleMCAccount()
into the useStoreAddressSynced()
hook so that it returns false
early if there is no MC account, or rely on a useState()
value that gets updated after the verification is 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.
Thanks @joemcgill . Completely missed that 🤦 . I've updated the useStoreAddressSynced
hook. Let me know what you think.
return false; | ||
} | ||
|
||
return data.address && ! Boolean( data.isMCAddressDifferent ); |
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.
Instead of checking data.address
here, which is only part of the address, it's probably better to check the data.isAddressFilled
property, which checks for all required address fields. See:
const isAddressFilled = ! missingRequiredFields.length; |
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.
With the recent changes in the hook, we are now using ! missingRequiredFields.length
directly @joemcgill
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.
refetch(); | ||
setSaving( true ); | ||
updateGoogleMCContactInformation() | ||
.then( refetch ) |
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.
Adding this refetch is unnecessary, because updateGoogleMCContactInformation()
returns the new data and updates the data store.
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.
👍
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.
Thanks @asvinb.
Overall, this is working as expected for the onboarding flow. However, the need to add an additional compactStyles
prop to render a style variation on the StoreAddressCard
component made me curious about where else this component was used, and whether we could avoid the need to the prop entirely.
Turns out, the other place this component is used is in the EditStoreAddress
flow that you can get to by visiting wp-admin/admin.php?page=wc-admin&subpath=%2Fedit-store-address&path=%2Fgoogle%2Fsettings
or by clicking the Edit button on the StoreAddressCardPreview
component shown in the settings screen after finishing onboarding.
In the develop
branch, when you visit the EditStoreAddress
flow, the Refresh button is used to update the component with fresh address data from the WC store that is shown in the lower Section.Card.Body
, and the the "Save details" CTA button for that flow is what syncs the address to MC. After these changes, the refresh button does the syncing but then stays continually stuck in an updating state, see this video:
Screen.Recording.2024-10-29.at.3.39.10.PM.mov
Currently in develop
the Refresh button similarly is used to update changes to the address that have been made in the WC store that aren't yet reflected in the component state and the address is synced to Google MC when that step of the onboarding flow is completed (see this code ref).
Suggestions
Here are my suggestions for how to address these concern. I can verify which option we want to go with, but would appreciate any ideas/feedback you have as well.
Updating the onboard flow
First, we should apply the new compact design everywhere to simplify the implementation and remove the new compactStyles
prop.
Next, we revert the changes to the Refresh button so they are used to update the component with local data rather than sync the data to MC for a consistent UI in all places it's used. We can sync the changes to MC when the first onboarding step is completed, as part of the callback passed to the onClick
prop of the AppButton
here.
During onboarding, we should still only show this component if we either don't have valid address info or the address info doesn't match MC. However, since we'll now sync the data automatically whenever someone finishes this step, we should only disable the Continue button if there are any validation errors for the address (e.g., ! address.isAddressFilled
) and show the validation errors in the StoreAddresCard
similar to how it's being done in the EditStoreAddress
flow:
<StoreAddressCard
showValidation={ ! address.isAddressFilled }
/>
Alternate: Update the settings screen
An alternative suggestion would be to move the updated StoreAddressCard
from this PR directly to the Settings screen—replacing the current ContactInformationPreview
component here. With this approach, we would always show the address info (not just when it's different from MC), and the Refresh button would be for the purpose of updating the MC data.
The EditStoreAddress
flow will no longer be needed and could be removed. The PhoneNumberCardPreview
and StoreAddressCardPreview
components could likely be removed entirely as well, because I don't think they're used anywhere else.
…ate/2602-sync-mc-address
…-settings 2602: Simplify address syncing in settings and remove phone info
After confirming with @fblascogarma earlier this week, the approach we decided to go with for resolving this concern is to update the UI on the settings screen to make use of the redesigned One additional issue that we've discovered is that currently when the onboarding flow is loaded, a request is made to |
@asvinb I've updated the rest of this PR after incorporating the changes from #2661 if you want to give it another look. @mikkamp could you review the PHP changes specific to @eason9487 this will still need QA, but would appreciate an early review since there are so many changes (mostly removal of unused components). |
Without introducing wider changes, whenever the merchant updates WC address, this whole mechanism always requires an action to display the address to be synchronized and maybe also display the errors to be resolved on this plugin page.
Replacing this action with the It's recommended to confirm if the concerns in #2653 (comment) are in the desired direction. I would suggest that the main direction could be to remove the phone number and merge step 3 into step 1, but to leave the original mechanism of address data (re)fetching and synchronization as unchanged as possible. Adjustments to this mechanism might be enough by rephrasing the text of the "Refresh to sync" button, or perhaps go one step further by automatically triggering a refetch of address data when the page regains focus. |
Thanks for flagging your concerns @eason9487. I've asked @fblascogarma and @MatthiasReinholz to review and help provide clarification. For what it's worth, I did meet with @fblascogarma last week to confirm these requirements, as mentioned in this comment. The decision when we spoke was to update this component so that clicking the "Refresh to sync" button would sync the address information to MC rather than updating the UI with fresh data from the WC store. In the interest of time, can I get the current implementation reviewed and we can make further adjustments to the acceptance criteria as part of the UAT review that will happen on this feature before it's merged to |
QA/Test Report- ✅Testing Environment -
Test Results - Tested PR based on the information and current Acceptance Criteria provided in connected GH issue. Sync flow is working as expected as described in requirement. Functional Demo / Screencast - Onboarding Screen Sync Flow: ✅ Recording.944.mp4If the store address matches with MC address: ✅ Recording.942.mp4Setting Screen Sync Flow: ✅ Recording.941.mp4 |
Change of plans here. After confirming with @fblascogarma and @MatthiasReinholz today, we're going to take a slightly different approach here. I've updated the AC in the issue, but the key changes are:
|
Changes proposed in this Pull Request:
Closes #2602 .
Replace this with a good description of your changes & reasoning.
Screenshots (Onboarding):
The store address is invalid (missing info)
The store address is not in sync with MC
The store address is in sync with MC
(nothing is shown during onboarding in this scenario)
Screenshots (Settings):
The store address is not in sync with MC
The store address is invalid (missing info)
The store address is in sync with MC
Detailed test instructions:
Additional details:
Changelog entry