diff --git a/src/helpers/cookie-helper.js b/src/helpers/cookie-helper.js index 619d613c..3b6105b7 100644 --- a/src/helpers/cookie-helper.js +++ b/src/helpers/cookie-helper.js @@ -5,31 +5,27 @@ import { useMainStore } from "@/store"; /* Will update the cookie if present, or create a new one if not. */ -export function updateOrCreateFunnelCookie() { - const wasClaimRegistrationDelayed = getFunnelCookie()?.HasDelayedClaimRegistration; - const shouldSuppressConceptFunnel = getFunnelCookie()?.SuppressConceptFunnel; +export function updateOrCreateISSCookie() { const store = useMainStore(); // Set up cookie with all the props. - setFunnelCookieProperties({ + setISSCookieProperties({ LastTouched: new Date().toUTCString(), SavedSessionTimeoutDate: store.applicationUser.savedSessionTimeout, - DidHeritageFunnelUpdateLast: false, + DidHeritageISSUpdateLast: false, ShouldResetState: false, ReferralNumber: store.order.referralNumber, ReferralDate: store.order.referralDate, ReferralCorrelationId: store.order.referralCorrelationId, ReferralParentAccountNumber: store.order.accountNumber, - HasDelayedClaimRegistration: wasClaimRegistrationDelayed, - SuppressConceptFunnel: shouldSuppressConceptFunnel, }); } /* - Gets the current instance of the funnel cookie. + Gets the current instance of the ISS cookie. Returns null if cookie isn't valid JSON. */ -export function getFunnelCookie() { +export function getISSCookie() { const cookieJson = document.cookie ?.split("; ") ?.find((row) => row.startsWith(`${cookieNames.ISS_SESSION_INFO}=`)) @@ -45,7 +41,7 @@ export function getFunnelCookie() { /* Removes cookie from browser. */ -export function deleteFunnelCookie() { +export function deleteISSCookie() { createOrUpdateCookie(cookieNames.ISS_SESSION_INFO, undefined, { maxAge: 0 }); } @@ -113,12 +109,12 @@ export function updateSessionIdCookie() { export function setCookieProperties( properties, - { useDefaultFunnelCookieAttributes = true, maxAge, isSecure } + { useDefaultISSCookieAttributes = true, maxAge, isSecure } ) { if (typeof properties == "object") { Object.keys(properties).forEach((key) => { createOrUpdateCookie(key, properties[key], { - useDefaultFunnelCookieAttributes, + useDefaultISSCookieAttributes, maxAge, isSecure, }); @@ -133,12 +129,12 @@ export function setCookieProperties( */ /* - Used to set properties on the funnel cookie. + Used to set properties on the ISS cookie. Takes an object with properties to set. Will overwrite existing properties. */ -function setFunnelCookieProperties(properties) { +function setISSCookieProperties(properties) { if (typeof properties == "object") { - let cookie = getFunnelCookie(); + let cookie = getISSCookie(); if (cookie !== null) { Object.keys(properties).forEach((key) => { @@ -153,16 +149,16 @@ function setFunnelCookieProperties(properties) { /* Used to create a cookie. - `useDefaultFunnelCookieAttributes` will set the path and domain to our defaults + `useDefaultISSCookieAttributes` will set the path and domain to our defaults */ function createOrUpdateCookie( key, value = "", - { useDefaultFunnelCookieAttributes = true, maxAge, isSecure = true } + { useDefaultISSCookieAttributes = true, maxAge, isSecure = true } ) { let cookieToAdd = `${key}=${value}; `; - if (useDefaultFunnelCookieAttributes) { + if (useDefaultISSCookieAttributes) { cookieToAdd += `path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()} `; } if (isSecure && !isLocalhost()) { diff --git a/src/helpers/session-helper.js b/src/helpers/session-helper.js index 0f986b90..7349cb95 100644 --- a/src/helpers/session-helper.js +++ b/src/helpers/session-helper.js @@ -1,13 +1,13 @@ import { applicationConfig } from "@/constants/application-config"; -import { getFunnelCookie } from "@/helpers/cookie-helper.js"; +import { getISSCookie } from "@/helpers/cookie-helper.js"; /* Method to determine if our analytics session has timed out or not. Amount used for timeout is configurable in application-config.js */ export function isAnalyticsSessionStillActive() { - if (getFunnelCookie() !== null) { - const lastTouchedValue = getFunnelCookie().LastTouched; + if (getISSCookie() !== null) { + const lastTouchedValue = getISSCookie().LastTouched; const timeoutAmount = applicationConfig.ANALYTICS_SESSION_TIMEOUT_MINUTES; const isMoreThanHalfHourAgo = @@ -29,8 +29,8 @@ export function isAnalyticsSessionStillActive() { Note: That time for saved session timeout is configurable in application-config.js */ export function isSavedSessionStillActive() { - if (getFunnelCookie() !== null) { - const savedSessionTimeStamp = new Date(getFunnelCookie().SavedSessionTimeoutDate); + if (getISSCookie() !== null) { + const savedSessionTimeStamp = new Date(getISSCookie().SavedSessionTimeoutDate); const isSavedSessionTimedOut = new Date(new Date().toUTCString()) > savedSessionTimeStamp; return !isSavedSessionTimedOut;