-
Notifications
You must be signed in to change notification settings - Fork 169
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
Conversation
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
|
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
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 ) { |
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.
no need for {
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.
Done
const advertisingCookieConsent = cookieGrp.includes('C0004'); | ||
|
||
if ( performanceCookieConsent && advertisingCookieConsent && isAndroid ) { | ||
branch.setBranchViewData({ data: { ecid: ecidVal }}); |
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.
Is it ok to set ecid: null
? I think you might want to check the value first
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.
If ecid is null, branch.setBranchViewData will automatically not set the ecid value. So no need to check if it is null.
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 }}); |
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.
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; | ||
} |
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.
You can also use .find
to directly retrieve the matching element.
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; | |
} |
Validation done on the below flows in url : |
Resolves: MWPW-152968
Test URLs: