Merge pull request #2518 from Safelite/feature/cash-689

Cleanup timing for heritage-return session load
This commit is contained in:
chloeherdsafelite 2025-05-14 12:45:08 -04:00 committed by GitHub
commit 06057729e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 8 deletions

View file

@ -1,20 +1,18 @@
import { queryStrings } from "@/constants/query-strings";
import { sessionStorageKeyConstants } from "@/constants/session-storage"; import { sessionStorageKeyConstants } from "@/constants/session-storage";
import { import {
getFunnelCookie, getFunnelCookie,
updateOrCreateFunnelCookie, updateOrCreateFunnelCookie,
} from "@/helpers/heritage-integration/cookie-helper"; } from "@/helpers/heritage-integration/cookie-helper";
import { loadSessionIfPresent } from "@/helpers/heritage-integration/order-helper";
import { isSavedSessionStillActive } from "@/helpers/heritage-integration/session-helper"; import { isSavedSessionStillActive } from "@/helpers/heritage-integration/session-helper";
import analyticsMixin from "@/mixins/analytics-mixin"; import analyticsMixin from "@/mixins/analytics-mixin";
import { routeData, FUNNEL_START_PAGE } from "@/router/constants/routes"; import { routeData, FUNNEL_START_PAGE } from "@/router/constants/routes";
import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash";
import { runExperiments } from "@/router/methods/helpers/run-experiments"; import { runExperiments } from "@/router/methods/helpers/run-experiments";
import { bailout } from "@/router/methods/error"; import { bailout } from "@/router/methods/error";
import { checkPagePrerequisites } from "@/router/methods/page-prerequisites"; import { checkPagePrerequisites } from "@/router/methods/page-prerequisites";
import { checkLogParam } from "@/helpers/debug-log-helper"; import { checkLogParam } from "@/helpers/debug-log-helper";
import { debugLog } from "@/helpers/debug-log-helper"; import { debugLog } from "@/helpers/debug-log-helper";
import { handleHeritageReturn } from "@/router/methods/helpers/handle-heritage-return";
export async function beforeEach(to, from) { export async function beforeEach(to, from) {
try { try {
@ -52,11 +50,8 @@ export async function beforeEach(to, from) {
} }
} }
// If sent from heritage, need to load session. // Special logic when returning from insurance flow.
const fromHeritageFlag = consumeQueryFromStash(queryStrings.FROM_HERITAGE); await handleHeritageReturn(to, from);
if (fromHeritageFlag) {
await loadSessionIfPresent(true, routeData.SERVICE_LOCATION.name);
}
// prettier-ignore // prettier-ignore
{ {

View file

@ -0,0 +1,16 @@
import { queryStrings } from "@/constants/query-strings";
import { consumeReferralQuerystrings } from "@/router/methods/helpers/consume-referral-info";
import { loadSessionIfPresent } from "@/helpers/heritage-integration/order-helper";
import { routeData } from "@/router/constants/routes";
export async function handleHeritageReturn(to, from) {
const fromHeritageFlag = to.query[queryStrings.FROM_HERITAGE];
if (fromHeritageFlag) {
// Get new referral info from querystring in case passed there.
await consumeReferralQuerystrings();
// load session with new cookie
await loadSessionIfPresent(true, routeData.SERVICE_LOCATION.name);
}
}