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

MWPW-161289 Catalog CTA IMS country used in commerce calls #3136

Merged
merged 24 commits into from
Nov 13, 2024

Conversation

bozojovicic
Copy link
Contributor

@bozojovicic bozojovicic commented Nov 4, 2024

IMS country should not be used in https://www.adobe.com/web_commerce_artifact calls

When data-ims-country is updated, the /web_commerce_artifact call is triggered again with IMS country in query parameters. By removing that data attribute from observedAttributes I prevented that.
On catalog pages I found one hidden CTA where /web_commerce_artifact is called with IMS country even after this change so I had to add overrides.imsCountry = null to fix that case as well.

Test URL :
https://main--cc--adobecom.hlx.page/products/catalog?milolibs=mwpw161289ctaims--milo--bozojovicic

Resolves: MWPW-161289

Test URLs:

Copy link
Contributor

aem-code-sync bot commented Nov 4, 2024

Page Scores Audits Google
📱 /drafts/bozo/price-cta?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /drafts/bozo/price-cta?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.38%. Comparing base (45f953f) to head (7a29c6c).
Report is 5 commits behind head on stage.

Additional details and impacted files
@@            Coverage Diff             @@
##            stage    #3136      +/-   ##
==========================================
+ Coverage   96.37%   96.38%   +0.01%     
==========================================
  Files         245      245              
  Lines       56686    56688       +2     
==========================================
+ Hits        54630    54638       +8     
+ Misses       2056     2050       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bozojovicic bozojovicic marked this pull request as ready for review November 4, 2024 16:38
@@ -51,7 +51,6 @@ export class CheckoutLink extends HTMLAnchorElement {
'data-checkout-workflow',
'data-checkout-workflow-step',
'data-extra-options',
'data-ims-country',
Copy link
Contributor

Choose a reason for hiding this comment

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

this should stay, it will cause a re-render which is expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, if re-render is expected, I returned it back.
On re-render the line overrides.imsCountry = null will override the country from IMS, and the page country will be used and since offers for the page country are already loaded on the first render, we will not have another WCS call.

mockIms('CH');
const service = await initMasCommerceService();
const checkoutLink = mockCheckoutLink('abm');
await service.imsCountryPromise;
await delay(1);
await checkoutLink.onceSettled();
expect(checkoutLink.href).to.equal(
'https://commerce.adobe.com/store/email?items%5B0%5D%5Bid%5D=632B3ADD940A7FBB7864AA5AD19B8D28&cli=adobe_com&ctx=fp&co=CH&lang=en',
Copy link
Contributor

Choose a reason for hiding this comment

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

CH is expected here, what is NOT expect is an extra WCS call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests are fully reverted. So what I did is :
On initial render we use page country and there are no problems.
When IMS country is set in data-ims-country we have re-render and then before WCS offers are loaded I need to override IMS country with page country overrides.imsCountry = null
After WCS offers are loaded (no new WCS call is triggered since the WCS url is identical as in the first render)
and before checkout link is generated I need to set the country back to IMS country
options.country = this.dataset.imsCountry || options.country

Is it ok now?

Copy link
Contributor

@yesil yesil left a comment

Choose a reason for hiding this comment

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

LGTM, but have a question.

@@ -121,6 +121,7 @@ export class CheckoutLink extends HTMLAnchorElement {
if (countryCode) this.dataset.imsCountry = countryCode;
}, ignore);
}
overrides.imsCountry = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yesil Yes, this will annul the IMS country in options and then the "page country" will be used, the same country that was used in the first render. And since we already have offers loaded for that country, no new WCS call will be triggered.

@afmicka
Copy link
Contributor

afmicka commented Nov 8, 2024

@yesil @3ch023 @npeltier @bozojovicic
Even though this seems to be fixed for catalog page, for studio I still get placeholder-failed and ims RS. Could you please check? Do we need to separate jiras for catalog and studio in this matter?
https://main--mas--adobecom.hlx.page/studio.html?milolibs=mwpw161289ctaims--milo--bozojovicic#path=ccd&query=ccd

Screenshot 2024-11-08 at 12 48 08

@yesil
Copy link
Contributor

yesil commented Nov 8, 2024

@bozojovicic mas.js build is missing in your PR, can you rebuild and commit it please?

@yesil
Copy link
Contributor

yesil commented Nov 8, 2024

@afmicka thanks, @bozojovicic PR was missing mas.js build, asked him to rebuild it.
but on top, we need a small PR to mas to remove ims atribute at the end: https://github.com/adobecom/mas/blob/main/studio/src/aem/render-view.js#L51

@bozojovicic
Copy link
Contributor Author

@yesil new mas.js build pushed
but who will do this part ?
we need a small PR to mas to remove ims atribute at the end: https://github.com/adobecom/mas/blob/main/studio/src/aem/render-view.js#L51
This is "uncharted territory" for me.

@3ch023
Copy link
Contributor

3ch023 commented Nov 11, 2024

Checked on
https://main--cc--adobecom.hlx.live/products/photoshop?milolibs=mwpw161289ctaims--milo--bozojovicic
looks good with my DE user. WCS request country=US, CTA link country=DE
image

@yesil
Copy link
Contributor

yesil commented Nov 12, 2024

@bozojovicic @afmicka sorry, my message regarding the ims attribute, it was completely wrong, please discard it.

@afmicka
Copy link
Contributor

afmicka commented Nov 12, 2024

@bozojovicic @yesil @3ch023
this time, CTA placeholders are resolved in studio but on catalog page if i log in with the user with FR as ims country, the ctas resolve to US (the site locale and not user's ims). Does this need to be fixed in dexter (since these are twp modals)?
https://main--cc--adobecom.hlx.page/products/catalog?milolibs=mwpw161289ctaims--milo--bozojovicic#miniplans-buy-acrobat
Screenshot 2024-11-12 at 14 14 03

@afmicka
Copy link
Contributor

afmicka commented Nov 13, 2024

will log a separate jira for the issue mentioned above. Approving this one.

@afmicka afmicka added verified PR has been E2E tested by a reviewer Ready for Stage labels Nov 13, 2024
@milo-pr-merge milo-pr-merge bot merged commit 031b5d2 into adobecom:stage Nov 13, 2024
24 checks passed
@milo-pr-merge milo-pr-merge bot mentioned this pull request Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commerce Ready for Stage verified PR has been E2E tested by a reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants