diff --git a/src/helpers/heritage-integration/cookie-helper.js b/src/helpers/heritage-integration/cookie-helper.js index 71a1051f2..1e1db1f1e 100644 --- a/src/helpers/heritage-integration/cookie-helper.js +++ b/src/helpers/heritage-integration/cookie-helper.js @@ -114,7 +114,7 @@ export function updateSessionIdCookie() { export function getUserIdValue() { const cookieValue = getCookieValueByName(cookieNames.FUNNEL_USER_ID); - if(cookieValue) { + if (cookieValue) { return cookieValue; } diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index 65c77c44e..f793f4825 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -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, } ); } diff --git a/src/router/index.js b/src/router/index.js index e2188997a..7769d8a2d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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 });