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-152968] mWeb - Passing ECID to Branch.io banner - Implementation #2567

Merged
merged 11 commits into from
Jul 22, 2024

Conversation

drashti1712
Copy link
Contributor

@drashti1712 drashti1712 commented Jul 14, 2024

  • When a user who has opted into both analytics and advertising cookies and is using Android device, their unique ECID is passed to Branch.

Resolves: MWPW-152968

Test URLs:

Copy link
Contributor

aem-code-sync bot commented Jul 14, 2024

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

Copy link
Contributor

aem-code-sync bot commented Jul 14, 2024

Page Scores Audits Google
/drafts/drashti/milo-banner/branch-banner PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@drashti1712 drashti1712 added the needs-verification PR requires E2E testing by a reviewer label Jul 14, 2024
Copy link

codecov bot commented Jul 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.87%. Comparing base (c896518) to head (e0a9a84).
Report is 24 commits behind head on stage.

Additional details and impacted files
@@            Coverage Diff             @@
##            stage    #2567      +/-   ##
==========================================
+ Coverage   95.83%   95.87%   +0.03%     
==========================================
  Files         176      176              
  Lines       46122    46153      +31     
==========================================
+ Hits        44199    44247      +48     
+ Misses       1923     1906      -17     

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

Copy link
Contributor

This pull request is not passing all required checks. Please see this discussion for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR.

const performanceCookieConsent = cookieGrp.includes('C0002');
const advertisingCookieConsent = cookieGrp.includes('C0004');

if ( performanceCookieConsent && advertisingCookieConsent && isAndroid ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

const advertisingCookieConsent = cookieGrp.includes('C0004');

if ( performanceCookieConsent && advertisingCookieConsent && isAndroid ) {
branch.setBranchViewData({ data: { ecid: ecidVal }});
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it ok to set ecid: null ? I think you might want to check the value first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If ecid is null, branch.setBranchViewData will automatically not set the ecid value. So no need to check if it is null.

Comment on lines 62 to 69
const isAndroid = navigator.userAgent.includes('Android');

const cookieGrp = window.adobePrivacy?.activeCookieGroups();
const performanceCookieConsent = cookieGrp.includes('C0002');
const advertisingCookieConsent = cookieGrp.includes('C0004');

if ( performanceCookieConsent && advertisingCookieConsent && isAndroid ) {
branch.setBranchViewData({ data: { ecid: ecidVal }});
Copy link
Contributor

Choose a reason for hiding this comment

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

There's window.adobePrivacy - however waiting might affect performance.

image

Comment on lines 16 to 25
async function getECID() {
let ecid = null;
const cookiesArr = document.cookie.split(';');
const regex = /^AMCV_[A-F0-9]+%40AdobeOrg=MCMID\|\d+$/;
cookiesArr.some((el) => {
if (regex.test(el.trim())) [, ecid] = el.split('MCMID|');
return ecid;
});
return ecid;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can also use .find to directly retrieve the matching element.

Suggested change
async function getECID() {
let ecid = null;
const cookiesArr = document.cookie.split(';');
const regex = /^AMCV_[A-F0-9]+%40AdobeOrg=MCMID\|\d+$/;
cookiesArr.some((el) => {
if (regex.test(el.trim())) [, ecid] = el.split('MCMID|');
return ecid;
});
return ecid;
}
function getEcid() {
const cookiesArr = document.cookie.split(';');
const regex = /^AMCV_[A-F0-9]+%40AdobeOrg=MCMID\|\d+$/;
const cookie = cookiesArr.find((el) => regex.test(el.trim()));
return cookie ? cookie.split('MCMID|')[1] : null;
}

@spadmasa spadmasa self-assigned this Jul 17, 2024
@spadmasa spadmasa added verified PR has been E2E tested by a reviewer Ready for Stage and removed needs-verification PR requires E2E testing by a reviewer labels Jul 19, 2024
@milo-pr-merge milo-pr-merge bot merged commit 6943446 into stage Jul 22, 2024
21 checks passed
@milo-pr-merge milo-pr-merge bot deleted the branch-ecid branch July 22, 2024 15:12
@milo-pr-merge milo-pr-merge bot mentioned this pull request Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants