From 4a0c92a0f776b9c6a0e8f15667361322fe7e89c8 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 18 Jan 2024 14:19:39 -0500 Subject: [PATCH 1/6] Clear state when erroring on nav to funnel start --- src/router/index.js | 14 ++++++++++---- src/router/router-constants/fmgPage-values.js | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 04c934769..2f30feb58 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -9,7 +9,7 @@ import { queryStrings } from "@/constants/query-strings"; import { getQuerystringParameter } from "@/helpers/querystring-helper"; import { getDeviceIdValue } from "@/helpers/heritage-integration/cookie-helper"; import { showFmgLoadingModal } from "@/helpers/loading-modal-helper"; -import { fmgPageValues, homepageName } from "@/router/router-constants/fmgPage-values"; +import { fmgPageValues, funnelStartPageName } from "@/router/router-constants/fmgPage-values"; // Heritage integration import { isSavedSessionStillActive } from "@/helpers/heritage-integration/session-helper"; @@ -17,6 +17,7 @@ import { updateOrCreateFunnelCookie, getFunnelCookie, updateSessionIdCookie, + deleteFunnelCookie, } from "@/helpers/heritage-integration/cookie-helper"; import { loadSessionIfPresent, saveSession } from "@/helpers/heritage-integration/order-helper"; import { @@ -54,7 +55,7 @@ const routes = [ // Intercept all navigation if a submitted order exists in storage if (store.getters.hasSubmittedOrder) { - if (to.query.fmgPage !== homepageName) { + if (to.query.fmgPage !== funnelStartPageName) { to.query.fmgPage = fmgPageValues.CONFIRMATION; } } @@ -141,6 +142,11 @@ const routes = [ } catch (error) { console.log(error); + if(to.query?.fmgPage === funnelStartPageName) { + deleteFunnelCookie(); + await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE); + } + // If we don't have a route, go to our 404 page. GoToFunnelStartOn404(next); } @@ -185,7 +191,7 @@ router.beforeEach(async (to, from, next) => { // Refresh page if navigating to self to prevent locking. // For now only carved out for vehicle; all modals are opened through anchor tags at the moment, // which also self navigate, but relied on the page remaining the same on self-navigation. - } else if (toQueryPage === fromQueryPage && toQueryPage === homepageName) { + } else if (toQueryPage === fromQueryPage && toQueryPage === funnelStartPageName) { router.go(0); } else { next(); @@ -399,7 +405,7 @@ function GoToFunnelStartOn404(next) { next({ path: "/", - query: { fmgPage: homepageName }, + query: { fmgPage: funnelStartPageName }, }); } diff --git a/src/router/router-constants/fmgPage-values.js b/src/router/router-constants/fmgPage-values.js index 3bd994ad3..d22dfb121 100644 --- a/src/router/router-constants/fmgPage-values.js +++ b/src/router/router-constants/fmgPage-values.js @@ -21,6 +21,6 @@ const fmgPageValues = { CONFIRMATION: "confirmation", }; -const homepageName = fmgPageValues.VEHICLE; +const funnelStartPageName = fmgPageValues.VEHICLE; -export { fmgPageValues, homepageName }; +export { fmgPageValues, funnelStartPageName }; From 10f1673622b9ab2fa14894d0e8ed5ba61b7abbbe Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 18 Jan 2024 14:40:01 -0500 Subject: [PATCH 2/6] Formatting --- src/router/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/router/index.js b/src/router/index.js index 2f30feb58..5ca2f33a4 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -142,7 +142,7 @@ const routes = [ } catch (error) { console.log(error); - if(to.query?.fmgPage === funnelStartPageName) { + if (to.query?.fmgPage === funnelStartPageName) { deleteFunnelCookie(); await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE); } From e793b6bf847d07c229050b4c8011f41a559cb774 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Fri, 19 Jan 2024 08:12:33 -0500 Subject: [PATCH 3/6] debug qa env logging debug qa env logging --- src/helpers/heritage-integration/session-helper.js | 3 +++ src/router/index.js | 11 ++++++++++- src/store/index.js | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/helpers/heritage-integration/session-helper.js b/src/helpers/heritage-integration/session-helper.js index 291ebfaf8..74cf323f1 100644 --- a/src/helpers/heritage-integration/session-helper.js +++ b/src/helpers/heritage-integration/session-helper.js @@ -30,7 +30,10 @@ export function isAnalyticsSessionStillActive() { export function isSavedSessionStillActive() { if (getFunnelCookie() !== null) { const savedSessionTimeStamp = new Date(getFunnelCookie().SavedSessionTimeoutDate); + console.log("savedSessionTimeStamp " + savedSessionTimeStamp); const isSavedSessionTimedOut = new Date(new Date().toUTCString()) > savedSessionTimeStamp; + console.log("utc date " + new Date(new Date().toUTCString())); + console.log("isSavedSessionTimedOut " + isSavedSessionTimedOut); return !isSavedSessionTimedOut; } diff --git a/src/router/index.js b/src/router/index.js index 5ca2f33a4..b11d0abf0 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -40,6 +40,7 @@ const routes = [ async beforeEnter(to, from, next) { // If we have no query string, or we don't have the FmgPage query string. try { + console.log("beforeEnter"); await analyticsMixin.methods.validateSession(); if (getFunnelCookie()?.SuppressConceptFunnel) { @@ -61,6 +62,7 @@ const routes = [ } // On entering the funnel "fresh", read cookie information, decide what to do next. else if (from.redirectedFrom === undefined) { + console.log("redirectFrom is undefined"); // clear the saveSessionPromise - if it exists in the vuex store but a new instance was created // the saveSessionPromise will no longer point to a valid promise baseMixin.methods.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE); @@ -68,6 +70,7 @@ const routes = [ if (!to.query.fmgPage.startsWith("payment")) { //payment pages used to return from safelitehop so exclude here // Remove the parameter after quote release + console.log("calling load session"); const loadSessionResponse = await loadSessionIfPresent( to.query.isInsurance != null ? to.query.isInsurance == "true" @@ -78,12 +81,13 @@ const routes = [ ); const pageToRedirectTo = await getPageToRouteExistingOrderTo(to); + console.log("load session complete...redirect to " + pageToRedirectTo); // Assign our fmgPage so it will load normally like the other pages. to.query.fmgPage = pageToRedirectTo; } } - + console.log("router run experiments"); await runExperiments(to.query.fmgPage); // Process funnel cookie. @@ -91,6 +95,7 @@ const routes = [ // If we already have our route, go to it. if (router.hasRoute(to.query.fmgPage)) { + console.log("has to page " + to.query.fmgPage); // Since our route is already in scope, we can grab the component from it and call the arePagePrerequisitesValid function. let component = router .getRoutes() @@ -102,6 +107,7 @@ const routes = [ } if (!arePagePrerequisitesValid(component)) { + console.log("go to start 404"); GoToFunnelStartOn404(next); } @@ -133,6 +139,8 @@ const routes = [ GoToFunnelStartOn404(next); } + console.log("next " + routeData[0].name + " "); + // Assign current query string parameters, as well as our fmgPage one. next({ name: routeData[0].name, @@ -143,6 +151,7 @@ const routes = [ console.log(error); if (to.query?.fmgPage === funnelStartPageName) { + console.log("router catch error"); deleteFunnelCookie(); await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE); } diff --git a/src/store/index.js b/src/store/index.js index f023bd708..253350d57 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1744,6 +1744,8 @@ export const actions = { ) { const order = context.state.order; + console.log("store load session " + savedSessionId + " " + referralNumber + " " + referralDate); + return globalMethods .callHttpClient({ method: endpoints.LoadSession.method, @@ -1769,6 +1771,8 @@ export const actions = { return glass; }); + console.log("load session success " + JSON.stringify(response.data)); + // clear the state if the existing EON does not equal what is returned from loadSession if (context.state.order.eon && context.state.order.eon != response.data.eon) { context.commit(storeMutations.RESET_STATE); @@ -1783,6 +1787,7 @@ export const actions = { return response; }, (error) => { + console.log("load session error " + JSON.stringify(error)); deleteFunnelCookie(); context.commit(storeMutations.RESET_STATE); } From 584ac268e470831fdb47232b76e6713b8f11aafa Mon Sep 17 00:00:00 2001 From: CarlNation Date: Fri, 19 Jan 2024 08:19:04 -0500 Subject: [PATCH 4/6] prettier :-( prettier :-( --- src/store/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 253350d57..b333bd56a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1744,7 +1744,9 @@ export const actions = { ) { const order = context.state.order; - console.log("store load session " + savedSessionId + " " + referralNumber + " " + referralDate); + console.log( + "store load session " + savedSessionId + " " + referralNumber + " " + referralDate + ); return globalMethods .callHttpClient({ From 708a9bbe8be97884de06373d560e9618f9a392d3 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Fri, 19 Jan 2024 10:35:52 -0500 Subject: [PATCH 5/6] Clear funnelsessioninfo when expired, insteaed of just state --- src/router/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/router/index.js b/src/router/index.js index b11d0abf0..8c304268c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -51,6 +51,7 @@ const routes = [ // If the saved session has timed out, clear the session, execute 404 logic. if (getFunnelCookie() !== null && !isSavedSessionStillActive()) { await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE); + deleteFunnelCookie(); GoToFunnelStartOn404(next); } From 91b55a3a71253cc9a998ab2fd32c7f839f02e1fe Mon Sep 17 00:00:00 2001 From: CarlNation Date: Fri, 19 Jan 2024 11:14:33 -0500 Subject: [PATCH 6/6] Revert "debug qa env logging" This reverts commit e793b6bf847d07c229050b4c8011f41a559cb774. --- src/helpers/heritage-integration/session-helper.js | 3 --- src/router/index.js | 11 +---------- src/store/index.js | 7 ------- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/helpers/heritage-integration/session-helper.js b/src/helpers/heritage-integration/session-helper.js index 74cf323f1..291ebfaf8 100644 --- a/src/helpers/heritage-integration/session-helper.js +++ b/src/helpers/heritage-integration/session-helper.js @@ -30,10 +30,7 @@ export function isAnalyticsSessionStillActive() { export function isSavedSessionStillActive() { if (getFunnelCookie() !== null) { const savedSessionTimeStamp = new Date(getFunnelCookie().SavedSessionTimeoutDate); - console.log("savedSessionTimeStamp " + savedSessionTimeStamp); const isSavedSessionTimedOut = new Date(new Date().toUTCString()) > savedSessionTimeStamp; - console.log("utc date " + new Date(new Date().toUTCString())); - console.log("isSavedSessionTimedOut " + isSavedSessionTimedOut); return !isSavedSessionTimedOut; } diff --git a/src/router/index.js b/src/router/index.js index 8c304268c..62818845f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -40,7 +40,6 @@ const routes = [ async beforeEnter(to, from, next) { // If we have no query string, or we don't have the FmgPage query string. try { - console.log("beforeEnter"); await analyticsMixin.methods.validateSession(); if (getFunnelCookie()?.SuppressConceptFunnel) { @@ -63,7 +62,6 @@ const routes = [ } // On entering the funnel "fresh", read cookie information, decide what to do next. else if (from.redirectedFrom === undefined) { - console.log("redirectFrom is undefined"); // clear the saveSessionPromise - if it exists in the vuex store but a new instance was created // the saveSessionPromise will no longer point to a valid promise baseMixin.methods.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE); @@ -71,7 +69,6 @@ const routes = [ if (!to.query.fmgPage.startsWith("payment")) { //payment pages used to return from safelitehop so exclude here // Remove the parameter after quote release - console.log("calling load session"); const loadSessionResponse = await loadSessionIfPresent( to.query.isInsurance != null ? to.query.isInsurance == "true" @@ -82,13 +79,12 @@ const routes = [ ); const pageToRedirectTo = await getPageToRouteExistingOrderTo(to); - console.log("load session complete...redirect to " + pageToRedirectTo); // Assign our fmgPage so it will load normally like the other pages. to.query.fmgPage = pageToRedirectTo; } } - console.log("router run experiments"); + await runExperiments(to.query.fmgPage); // Process funnel cookie. @@ -96,7 +92,6 @@ const routes = [ // If we already have our route, go to it. if (router.hasRoute(to.query.fmgPage)) { - console.log("has to page " + to.query.fmgPage); // Since our route is already in scope, we can grab the component from it and call the arePagePrerequisitesValid function. let component = router .getRoutes() @@ -108,7 +103,6 @@ const routes = [ } if (!arePagePrerequisitesValid(component)) { - console.log("go to start 404"); GoToFunnelStartOn404(next); } @@ -140,8 +134,6 @@ const routes = [ GoToFunnelStartOn404(next); } - console.log("next " + routeData[0].name + " "); - // Assign current query string parameters, as well as our fmgPage one. next({ name: routeData[0].name, @@ -152,7 +144,6 @@ const routes = [ console.log(error); if (to.query?.fmgPage === funnelStartPageName) { - console.log("router catch error"); deleteFunnelCookie(); await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE); } diff --git a/src/store/index.js b/src/store/index.js index b333bd56a..f023bd708 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1744,10 +1744,6 @@ export const actions = { ) { const order = context.state.order; - console.log( - "store load session " + savedSessionId + " " + referralNumber + " " + referralDate - ); - return globalMethods .callHttpClient({ method: endpoints.LoadSession.method, @@ -1773,8 +1769,6 @@ export const actions = { return glass; }); - console.log("load session success " + JSON.stringify(response.data)); - // clear the state if the existing EON does not equal what is returned from loadSession if (context.state.order.eon && context.state.order.eon != response.data.eon) { context.commit(storeMutations.RESET_STATE); @@ -1789,7 +1783,6 @@ export const actions = { return response; }, (error) => { - console.log("load session error " + JSON.stringify(error)); deleteFunnelCookie(); context.commit(storeMutations.RESET_STATE); }