This commit is contained in:
Chloe Herd 2023-12-01 08:12:19 -05:00
parent edd8158148
commit 4510241bdd
3 changed files with 11 additions and 53 deletions

View file

@ -114,7 +114,7 @@ export function updateSessionIdCookie() {
export function getUserIdValue() {
const cookieValue = getCookieValueByName(cookieNames.FUNNEL_USER_ID);
if(cookieValue) {
if (cookieValue) {
return cookieValue;
}

View file

@ -138,45 +138,6 @@ export default {
};
},
// async initSession() {
// const sid = getSessionIdValue();
// const skey = getSessionKeyValue();
// const referrer =
// applicationConfig.CURRENT_ENVIRONMENT != "Localhost" ? document.referrer : null;
// var payload = {
// userId: getDeviceIdValue(),
// sessionId: sid,
// userAgent: navigator.userAgent,
// referrer: referrer,
// };
// const response = await baseMixin.methods.dispatchStoreAction(
// storeActions.INITIALIZE_SESSION,
// payload,
// false
// );
// if (response?.data) {
// if (response?.data.sessionKey && skey === 0) {
// setCookieProperties(
// { [cookieNames.SESSION_KEY]: response?.data.sessionKey },
// {
// useDefaultFunnelCookieAttributes: false,
// }
// );
// }
// if (response?.data.sessionId && sid === "00000000-0000-0000-0000-000000000000") {
// setCookieProperties(
// { [cookieNames.SESSION_ID]: response?.data.sessionId },
// {
// maxAge: 60 * 30, // 30 minutes
// }
// );
// }
// }
// },
async initSession() {
if (!isCookieSet(cookieNames.FUNNEL_USER_ID)) {
setCookieProperties(
@ -199,7 +160,8 @@ export default {
const deviceId = getDeviceIdValue(); // cookieNames.DXDEV
const sessionId = getSessionIdValue(); // cookieNames.SESSION_ID
const userAgent = navigator.userAgent; // navigator.userAgent
const refferer = applicationConfig.CURRENT_ENVIRONMENT != "Localhost" ? document.referrer : null; // see above
const refferer =
applicationConfig.CURRENT_ENVIRONMENT != "Localhost" ? document.referrer : null; // see above
const payload = {
userId: userId,
@ -209,31 +171,31 @@ export default {
refferer: refferer,
};
const response = await baseMixin.dispatchStoreAction(
const response = await baseMixin.methods.dispatchStoreAction(
storeActions.INITIALIZE_SESSION,
payload,
false
);
if(response?.data) {
if(response.data.sessionKey && !isCookieSet(cookieNames.FUNNEL_SESSION_KEY)) {
if (response?.data) {
if (response.data.sessionKey && !isCookieSet(cookieNames.FUNNEL_SESSION_KEY)) {
setCookieProperties(
{
[cookieNames.FUNNEL_SESSION_KEY]: response.data.sessionKey,
},
{
maxAge: 30 * 60
maxAge: 30 * 60,
}
);
}
if(response.data.sessionId && !isCookieSet(cookieNames.SESSION_ID)) {
if (response.data.sessionId && !isCookieSet(cookieNames.SESSION_ID)) {
setCookieProperties(
{
[cookieNames.SESSION_ID]: response.data.sessionId
[cookieNames.SESSION_ID]: response.data.sessionId,
},
{
maxAge: 30 * 60
maxAge: 30 * 60,
}
);
}

View file

@ -38,11 +38,7 @@ const routes = [
async beforeEnter(to, from, next) {
// If we have no query string, or we don't have the FmgPage query string.
try {
if (analyticsMixin.methods.noSession()) {
await analyticsMixin.methods.initSession();
} else {
updateSessionIdCookie();
}
await analyticsMixin.methods.validateSession();
if (getFunnelCookie()?.SuppressConceptFunnel) {
await navigateToHeritageFunnel({ shouldSaveSession: false });