Updates to the session logging logic.
This commit is contained in:
parent
e2e705f000
commit
1d459cdacd
3 changed files with 52 additions and 35 deletions
|
|
@ -23,3 +23,31 @@ export function getTopLevelGlassPartsWithRecal(glassParts) {
|
||||||
|
|
||||||
return glassParts.filter((gp) => isRecalPartOrHasChildRecalPart(gp));
|
return glassParts.filter((gp) => isRecalPartOrHasChildRecalPart(gp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getItemsWithoutRecalParts(lineItemsArray) {
|
||||||
|
if (!lineItemsArray || !Array.isArray(lineItemsArray)) return null;
|
||||||
|
const firstLevelFiltered = deepClone(lineItemsArray).filter((li) => !isRecalPart(li));
|
||||||
|
|
||||||
|
const childrenFiltered = firstLevelFiltered.map((li) => {
|
||||||
|
if (li.childParts && li.childParts.length > 0) {
|
||||||
|
li.childParts = getItemsWithoutRecalParts(li.childParts);
|
||||||
|
}
|
||||||
|
|
||||||
|
return li;
|
||||||
|
});
|
||||||
|
|
||||||
|
return childrenFiltered;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getRecalPartNumbers(glassPartsArray) {
|
||||||
|
if (glassPartsArray && glassPartsArray.length > 0) {
|
||||||
|
const topLevel = glassPartsArray.filter((gp) => isRecalPart(gp)).map((gp) => gp.partNumber);
|
||||||
|
|
||||||
|
const children = glassPartsArray.map((gp) => getRecalPartNumbers(gp.childParts)).flat();
|
||||||
|
|
||||||
|
return [...topLevel, ...children];
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,10 @@ import {
|
||||||
GaEvents,
|
GaEvents,
|
||||||
ValueToLogTypes
|
ValueToLogTypes
|
||||||
} from '@/constants/analytics';
|
} from '@/constants/analytics';
|
||||||
import { getCartTotal, getSubTotal } from '@/helpers/cart-helper';
|
import { getCartTotal, getSubtotal } from '@/helpers/cart-helper';
|
||||||
|
import { getRecalPartNumbers } from "@/helpers/recal-helper";
|
||||||
|
import coverageStatuses from '@/constants/coverage-statuses';
|
||||||
|
import coverageType from '@/constants/coverage-type';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
|
|
||||||
function pushToDataLayerIfDefined(data) {
|
function pushToDataLayerIfDefined(data) {
|
||||||
|
|
@ -222,17 +225,13 @@ export default {
|
||||||
const hasSubmittedOrder = store.hasSubmittedOrder();
|
const hasSubmittedOrder = store.hasSubmittedOrder();
|
||||||
const order = hasSubmittedOrder ? submittedOrder : store.order;
|
const order = hasSubmittedOrder ? submittedOrder : store.order;
|
||||||
const issConfig = store.issConfig;
|
const issConfig = store.issConfig;
|
||||||
|
const applicationUser = store.applicationUser;
|
||||||
|
|
||||||
// TODO: Find equivalent ISS methods for these:
|
/*
|
||||||
const hasSubmittedApplicationUser = baseMixin.methods.hasSubmittedApplicationUser();
|
|
||||||
const submittedApplicationUser = baseMixin.methods.getSubmittedApplicationUser();
|
|
||||||
const applicationUser = hasSubmittedApplicationUser
|
|
||||||
? submittedApplicationUser
|
|
||||||
: store.applicationUser;
|
|
||||||
|
|
||||||
const isEarlyBird = order?.lineItems?.supportingItems?.find(
|
const isEarlyBird = order?.lineItems?.supportingItems?.find(
|
||||||
(lineItem) => lineItem.partType == partTypeStrings.EARLY_BIRD
|
(lineItem) => lineItem.partType == partTypeStrings.EARLY_BIRD
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
const promoCodes = ""; /*Array.isArray(order?.lineItems?.promos)
|
const promoCodes = ""; /*Array.isArray(order?.lineItems?.promos)
|
||||||
? order?.lineItems?.promos
|
? order?.lineItems?.promos
|
||||||
|
|
@ -294,10 +293,7 @@ export default {
|
||||||
sessionData.hasVin = order?.vehicle?.vin ? true : false;
|
sessionData.hasVin = order?.vehicle?.vin ? true : false;
|
||||||
sessionData.cashOrInsuranceAccountType = "Insurance";
|
sessionData.cashOrInsuranceAccountType = "Insurance";
|
||||||
sessionData.damageType = order?.damage?.isRepair ? "Repair" : "Replace";
|
sessionData.damageType = order?.damage?.isRepair ? "Repair" : "Replace";
|
||||||
|
|
||||||
// TODO: Find equivalent ISS methods for these:
|
|
||||||
sessionData.productType = allParts;
|
sessionData.productType = allParts;
|
||||||
|
|
||||||
sessionData.eon = order?.eon;
|
sessionData.eon = order?.eon;
|
||||||
sessionData.referralNumber = order?.referralNumber;
|
sessionData.referralNumber = order?.referralNumber;
|
||||||
sessionData.referralSequenceNumber = order?.referralSequenceNumber;
|
sessionData.referralSequenceNumber = order?.referralSequenceNumber;
|
||||||
|
|
@ -306,17 +302,13 @@ export default {
|
||||||
sessionData.workOrderId = order?.workOrderId;
|
sessionData.workOrderId = order?.workOrderId;
|
||||||
|
|
||||||
// TODO: Find equivalent ISS methods for these:
|
// TODO: Find equivalent ISS methods for these:
|
||||||
sessionData.isPia = order?.payment?.isPia ?? false;
|
sessionData.isPia = false;//order?.payment?.isPia ?? false;
|
||||||
sessionData.piaType = order?.payment?.piaType;
|
sessionData.piaType = null;//order?.payment?.piaType;
|
||||||
|
|
||||||
sessionData.parentAccountNumber = order?.parentAccountNumber;
|
sessionData.parentAccountNumber = order?.parentAccountNumber;
|
||||||
sessionData.billToAccountNumber = issConfig.billToAccountNumber;
|
sessionData.billToAccountNumber = issConfig.billToAccountNumber;
|
||||||
|
sessionData.settledTenderAmount = order?.payment?.nextGenSettledAmount;
|
||||||
// TODO: Find equivalent ISS methods for these:
|
sessionData.recalRequired = store.hasRecalibrationPart;
|
||||||
sessionData.settledTenderAmount = order?.settledTenderAmount;
|
|
||||||
|
|
||||||
// TODO: Find equivalent ISS methods for these:
|
|
||||||
sessionData.recalRequired = containsRecalParts(order?.lineItems);
|
|
||||||
sessionData.recalType = getRecalPartNumbers(order?.lineItems?.glassParts);
|
sessionData.recalType = getRecalPartNumbers(order?.lineItems?.glassParts);
|
||||||
|
|
||||||
sessionData.serviceZipCode = order?.serviceLocation?.provider?.address?.zipCode
|
sessionData.serviceZipCode = order?.serviceLocation?.provider?.address?.zipCode
|
||||||
|
|
@ -329,29 +321,26 @@ export default {
|
||||||
sessionData.serviceType = order?.serviceLocation?.appointmentType;
|
sessionData.serviceType = order?.serviceLocation?.appointmentType;
|
||||||
sessionData.promoCodes = promoCodes;
|
sessionData.promoCodes = promoCodes;
|
||||||
sessionData.hasTechnicianNotes = order?.contactInfo?.notesForTechnician ? true : false;
|
sessionData.hasTechnicianNotes = order?.contactInfo?.notesForTechnician ? true : false;
|
||||||
|
sessionData.paymentMethod = order?.payment?.paymentMethod;
|
||||||
// TODO: Find equivalent ISS methods for these:
|
|
||||||
sessionData.paymentMethod = order?.payment?.piaType;
|
|
||||||
|
|
||||||
sessionData.isTextingOptedIn = order?.contactInfo?.requestTextUpdates ? true : false;
|
sessionData.isTextingOptedIn = order?.contactInfo?.requestTextUpdates ? true : false;
|
||||||
|
|
||||||
// TODO: Find equivalent ISS methods for these:
|
// TODO: Find equivalent ISS methods for these:
|
||||||
sessionData.isEarlyBird = isEarlyBird ? true : false;
|
sessionData.isEarlyBird = false;//isEarlyBird ? true : false;
|
||||||
|
|
||||||
sessionData.insuranceCo = issConfig.clientName;
|
sessionData.insuranceCo = issConfig.clientName;
|
||||||
sessionData.deductible = store.currentDeductible();
|
sessionData.deductible = store.currentDeductible ?? 0;
|
||||||
sessionData.isVerified = store.isVerified();
|
sessionData.isVerified = store.isVerified;
|
||||||
|
sessionData.coverageStatus = coverageStatuses.mapToApi(order?.insuranceCoverage.coverageStatus);
|
||||||
|
sessionData.coverageSubStatus = coverageType.mapToApi(order?.insuranceCoverage.coverageType);
|
||||||
|
|
||||||
// TODO: Need mappings here?
|
sessionData.isNoComp = store.isNoComp;
|
||||||
sessionData.coverageStatus = order?.payment?.insuranceCoverage?.coverageStatus;
|
sessionData.isItac = store.isITAC;
|
||||||
sessionData.coverageSubStatus = order?.payment?.insuranceCoverage?.coverageSubStatus;
|
sessionData.subTotalPrice = getSubtotal(order);
|
||||||
|
|
||||||
sessionData.isNoComp = store.isNoComp();
|
|
||||||
sessionData.isItac = store.isITAC();
|
|
||||||
sessionData.subTotalPrice = getSubTotal(order);
|
|
||||||
sessionData.totalPrice = getCartTotal(order);
|
sessionData.totalPrice = getCartTotal(order);
|
||||||
sessionData.userAgent = navigator.userAgent;
|
sessionData.userAgent = navigator.userAgent;
|
||||||
sessionData.cashPriceSubTotal = getSubTotal(order);
|
|
||||||
|
// Why does this need to be a string?
|
||||||
|
sessionData.cashPriceSubTotal = getSubtotal(order).toString();
|
||||||
|
|
||||||
store.logIssSessionData(sessionData);
|
store.logIssSessionData(sessionData);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ router.afterEach(async (to, from) => {
|
||||||
analyticsMixin.methods.logDigitalConsumer();
|
analyticsMixin.methods.logDigitalConsumer();
|
||||||
|
|
||||||
// digital consumer ISS session logging to snowflake
|
// digital consumer ISS session logging to snowflake
|
||||||
//analyticsMixin.methods.pushIssSessionData();
|
analyticsMixin.methods.pushIssSessionData();
|
||||||
|
|
||||||
// Push page view to GA
|
// Push page view to GA
|
||||||
analyticsMixin.methods.pushPageViewToGA();
|
analyticsMixin.methods.pushPageViewToGA();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue