8000 ENB-7820: Add values for event95 by swamu · Pull Request #3782 · adobecom/milo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ENB-7820: Add values for e 8000 vent95 #3782

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

Merged
merged 6 commits into from
Mar 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions libs/martech/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@ function getOrGenerateUserId() {
};
}

function getUpdatedVisitAttempt() {
const { hostname } = window.location;
const secondVisitAttempt = Number(localStorage.getItem('secondHit')) || 0;

const isAdobeDomain = hostname === 'www.adobe.com' || hostname === 'www.stage.adobe.com';
const consentCookieValue = getCookie('OptanonConsent');
Copy link
Contributor
@sharmrj sharmrj Mar 7, 2025

Choose a reason for hiding this comment

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

We also have a function window.adobePrivacy.activeCookieGroups() in feds privacy for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@swamu - does this need to run before adobePrivacy gets loaded (it's set to load with a 3 seconds delay). If not, we should use the existing logic instead of duplicating code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const consentCookieValue = getCookie('OptanonConsent');
Here we just read existing cookie and we are not waiting for adobePrivacy as it delays the call.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we also check for OptanonAlertBoxClosed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be clear - this is how Privacy currently works, the OptanonAlertBoxClosed cookie is also checked in addition to OptanonConsent

Copy link
Contributor

Choose a reason for hiding this comment

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

@narcis-radu - We have not used OptanonAlertBoxClosed in Launch also.
We will review this as a separate request. Is that okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

@mokimo, Can we take this as a separate request and move ahead with the current PR. Since @narcis-radu is OOO, let us know your thoughts on this.
cc: @Bhim12 @swamu


if (consentCookieValue?.includes('C0002:1') && isAdobeDomain) {
const updatedVisitAttempt = secondVisitAttempt === 0 ? 1 : secondVisitAttempt + 1;
localStorage.setItem('secondHit', updatedVisitAttempt);
return updatedVisitAttempt;
}

return secondVisitAttempt;
}

function getPageNameForAnalytics({ locale }) {
const { host, pathname } = new URL(window.location.href);
const [modifiedPath] = pathname.split('/').filter((x) => x !== locale.prefix).join(':').split('.');
Expand Down Expand Up @@ -240,6 +256,7 @@ function createRequestPayload({ updatedContext, pageName, locale, env, hitType }
approach: 'martech-API',
edgeConfigIdLaunch: dataStreamId,
edgeConfigId: dataStreamId,
personalisation: 'hybrid',
},
},
},
Expand Down Expand Up @@ -269,6 +286,12 @@ function createRequestPayload({ updatedContext, pageName, locale, env, hitType }
data.web = { webPageDetails };
data.eventType = hitTypeEventTypeMap[hitType];

if (getUpdatedVisitAttempt() === 2) {
digitalData.adobe = {
libraryVersions: 'alloy-api',
experienceCloud: { secondVisits: 'setEvent' },
};
}
xdm.implementationDetails = {
name: 'https://ns.adobe.com/experience/alloy/reactor',
version: '1.0',
Expand Down Expand Up @@ -496,22 +519,17 @@ export const loadAnalyticsAndInteractionData = async (

const CURRENT_DATE = new Date();
const localTime = CURRENT_DATE.toISOString();

const timezoneOffset = CURRENT_DATE.getTimezoneOffset();
if (hybridPersEnabled) {
window.hybridPers = true;
}
const hitType = hybridPersEnabled ? 'pageView' : 'propositionFetch';

const pageName = getPageNameForAnalytics({ locale });

const updatedContext = getUpdatedContext({ ...getDeviceInfo(), localTime, timezoneOffset });

const requestUrl = createRequestUrl({
env,
hitType,
});

const requestPayload = { updatedContext, pageName, locale, env, hitType };
const requestBody = createRequestPayload(requestPayload);

Expand Down
Loading
0