Renamed cookie helper methods.
This commit is contained in:
parent
cb5c6dafcb
commit
de62fddeb2
2 changed files with 19 additions and 23 deletions
|
|
@ -5,31 +5,27 @@ import { useMainStore } from "@/store";
|
||||||
/*
|
/*
|
||||||
Will update the cookie if present, or create a new one if not.
|
Will update the cookie if present, or create a new one if not.
|
||||||
*/
|
*/
|
||||||
export function updateOrCreateFunnelCookie() {
|
export function updateOrCreateISSCookie() {
|
||||||
const wasClaimRegistrationDelayed = getFunnelCookie()?.HasDelayedClaimRegistration;
|
|
||||||
const shouldSuppressConceptFunnel = getFunnelCookie()?.SuppressConceptFunnel;
|
|
||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
|
|
||||||
// Set up cookie with all the props.
|
// Set up cookie with all the props.
|
||||||
setFunnelCookieProperties({
|
setISSCookieProperties({
|
||||||
LastTouched: new Date().toUTCString(),
|
LastTouched: new Date().toUTCString(),
|
||||||
SavedSessionTimeoutDate: store.applicationUser.savedSessionTimeout,
|
SavedSessionTimeoutDate: store.applicationUser.savedSessionTimeout,
|
||||||
DidHeritageFunnelUpdateLast: false,
|
DidHeritageISSUpdateLast: false,
|
||||||
ShouldResetState: false,
|
ShouldResetState: false,
|
||||||
ReferralNumber: store.order.referralNumber,
|
ReferralNumber: store.order.referralNumber,
|
||||||
ReferralDate: store.order.referralDate,
|
ReferralDate: store.order.referralDate,
|
||||||
ReferralCorrelationId: store.order.referralCorrelationId,
|
ReferralCorrelationId: store.order.referralCorrelationId,
|
||||||
ReferralParentAccountNumber: store.order.accountNumber,
|
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.
|
Returns null if cookie isn't valid JSON.
|
||||||
*/
|
*/
|
||||||
export function getFunnelCookie() {
|
export function getISSCookie() {
|
||||||
const cookieJson = document.cookie
|
const cookieJson = document.cookie
|
||||||
?.split("; ")
|
?.split("; ")
|
||||||
?.find((row) => row.startsWith(`${cookieNames.ISS_SESSION_INFO}=`))
|
?.find((row) => row.startsWith(`${cookieNames.ISS_SESSION_INFO}=`))
|
||||||
|
|
@ -45,7 +41,7 @@ export function getFunnelCookie() {
|
||||||
/*
|
/*
|
||||||
Removes cookie from browser.
|
Removes cookie from browser.
|
||||||
*/
|
*/
|
||||||
export function deleteFunnelCookie() {
|
export function deleteISSCookie() {
|
||||||
createOrUpdateCookie(cookieNames.ISS_SESSION_INFO, undefined, { maxAge: 0 });
|
createOrUpdateCookie(cookieNames.ISS_SESSION_INFO, undefined, { maxAge: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,12 +109,12 @@ export function updateSessionIdCookie() {
|
||||||
|
|
||||||
export function setCookieProperties(
|
export function setCookieProperties(
|
||||||
properties,
|
properties,
|
||||||
{ useDefaultFunnelCookieAttributes = true, maxAge, isSecure }
|
{ useDefaultISSCookieAttributes = true, maxAge, isSecure }
|
||||||
) {
|
) {
|
||||||
if (typeof properties == "object") {
|
if (typeof properties == "object") {
|
||||||
Object.keys(properties).forEach((key) => {
|
Object.keys(properties).forEach((key) => {
|
||||||
createOrUpdateCookie(key, properties[key], {
|
createOrUpdateCookie(key, properties[key], {
|
||||||
useDefaultFunnelCookieAttributes,
|
useDefaultISSCookieAttributes,
|
||||||
maxAge,
|
maxAge,
|
||||||
isSecure,
|
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.
|
Takes an object with properties to set. Will overwrite existing properties.
|
||||||
*/
|
*/
|
||||||
function setFunnelCookieProperties(properties) {
|
function setISSCookieProperties(properties) {
|
||||||
if (typeof properties == "object") {
|
if (typeof properties == "object") {
|
||||||
let cookie = getFunnelCookie();
|
let cookie = getISSCookie();
|
||||||
|
|
||||||
if (cookie !== null) {
|
if (cookie !== null) {
|
||||||
Object.keys(properties).forEach((key) => {
|
Object.keys(properties).forEach((key) => {
|
||||||
|
|
@ -153,16 +149,16 @@ function setFunnelCookieProperties(properties) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Used to create a cookie.
|
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(
|
function createOrUpdateCookie(
|
||||||
key,
|
key,
|
||||||
value = "",
|
value = "",
|
||||||
{ useDefaultFunnelCookieAttributes = true, maxAge, isSecure = true }
|
{ useDefaultISSCookieAttributes = true, maxAge, isSecure = true }
|
||||||
) {
|
) {
|
||||||
let cookieToAdd = `${key}=${value}; `;
|
let cookieToAdd = `${key}=${value}; `;
|
||||||
|
|
||||||
if (useDefaultFunnelCookieAttributes) {
|
if (useDefaultISSCookieAttributes) {
|
||||||
cookieToAdd += `path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()} `;
|
cookieToAdd += `path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()} `;
|
||||||
}
|
}
|
||||||
if (isSecure && !isLocalhost()) {
|
if (isSecure && !isLocalhost()) {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import { applicationConfig } from "@/constants/application-config";
|
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.
|
Method to determine if our analytics session has timed out or not.
|
||||||
Amount used for timeout is configurable in application-config.js
|
Amount used for timeout is configurable in application-config.js
|
||||||
*/
|
*/
|
||||||
export function isAnalyticsSessionStillActive() {
|
export function isAnalyticsSessionStillActive() {
|
||||||
if (getFunnelCookie() !== null) {
|
if (getISSCookie() !== null) {
|
||||||
const lastTouchedValue = getFunnelCookie().LastTouched;
|
const lastTouchedValue = getISSCookie().LastTouched;
|
||||||
const timeoutAmount = applicationConfig.ANALYTICS_SESSION_TIMEOUT_MINUTES;
|
const timeoutAmount = applicationConfig.ANALYTICS_SESSION_TIMEOUT_MINUTES;
|
||||||
|
|
||||||
const isMoreThanHalfHourAgo =
|
const isMoreThanHalfHourAgo =
|
||||||
|
|
@ -29,8 +29,8 @@ export function isAnalyticsSessionStillActive() {
|
||||||
Note: That time for saved session timeout is configurable in application-config.js
|
Note: That time for saved session timeout is configurable in application-config.js
|
||||||
*/
|
*/
|
||||||
export function isSavedSessionStillActive() {
|
export function isSavedSessionStillActive() {
|
||||||
if (getFunnelCookie() !== null) {
|
if (getISSCookie() !== null) {
|
||||||
const savedSessionTimeStamp = new Date(getFunnelCookie().SavedSessionTimeoutDate);
|
const savedSessionTimeStamp = new Date(getISSCookie().SavedSessionTimeoutDate);
|
||||||
const isSavedSessionTimedOut = new Date(new Date().toUTCString()) > savedSessionTimeStamp;
|
const isSavedSessionTimedOut = new Date(new Date().toUTCString()) > savedSessionTimeStamp;
|
||||||
|
|
||||||
return !isSavedSessionTimedOut;
|
return !isSavedSessionTimedOut;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue