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));
|
||||
}
|
||||
|
||||
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,
|
||||
ValueToLogTypes
|
||||
} 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';
|
||||
|
||||
function pushToDataLayerIfDefined(data) {
|
||||
|
|
@ -222,17 +225,13 @@ export default {
|
|||
const hasSubmittedOrder = store.hasSubmittedOrder();
|
||||
const order = hasSubmittedOrder ? submittedOrder : store.order;
|
||||
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(
|
||||
(lineItem) => lineItem.partType == partTypeStrings.EARLY_BIRD
|
||||
);
|
||||
*/
|
||||
|
||||
const promoCodes = ""; /*Array.isArray(order?.lineItems?.promos)
|
||||
? order?.lineItems?.promos
|
||||
|
|
@ -294,10 +293,7 @@ export default {
|
|||
sessionData.hasVin = order?.vehicle?.vin ? true : false;
|
||||
sessionData.cashOrInsuranceAccountType = "Insurance";
|
||||
sessionData.damageType = order?.damage?.isRepair ? "Repair" : "Replace";
|
||||
|
||||
// TODO: Find equivalent ISS methods for these:
|
||||
sessionData.productType = allParts;
|
||||
|
||||
sessionData.eon = order?.eon;
|
||||
sessionData.referralNumber = order?.referralNumber;
|
||||
sessionData.referralSequenceNumber = order?.referralSequenceNumber;
|
||||
|
|
@ -306,17 +302,13 @@ export default {
|
|||
sessionData.workOrderId = order?.workOrderId;
|
||||
|
||||
// TODO: Find equivalent ISS methods for these:
|
||||
sessionData.isPia = order?.payment?.isPia ?? false;
|
||||
sessionData.piaType = order?.payment?.piaType;
|
||||
sessionData.isPia = false;//order?.payment?.isPia ?? false;
|
||||
sessionData.piaType = null;//order?.payment?.piaType;
|
||||
|
||||
sessionData.parentAccountNumber = order?.parentAccountNumber;
|
||||
sessionData.billToAccountNumber = issConfig.billToAccountNumber;
|
||||
|
||||
// TODO: Find equivalent ISS methods for these:
|
||||
sessionData.settledTenderAmount = order?.settledTenderAmount;
|
||||
|
||||
// TODO: Find equivalent ISS methods for these:
|
||||
sessionData.recalRequired = containsRecalParts(order?.lineItems);
|
||||
sessionData.settledTenderAmount = order?.payment?.nextGenSettledAmount;
|
||||
sessionData.recalRequired = store.hasRecalibrationPart;
|
||||
sessionData.recalType = getRecalPartNumbers(order?.lineItems?.glassParts);
|
||||
|
||||
sessionData.serviceZipCode = order?.serviceLocation?.provider?.address?.zipCode
|
||||
|
|
@ -329,29 +321,26 @@ export default {
|
|||
sessionData.serviceType = order?.serviceLocation?.appointmentType;
|
||||
sessionData.promoCodes = promoCodes;
|
||||
sessionData.hasTechnicianNotes = order?.contactInfo?.notesForTechnician ? true : false;
|
||||
|
||||
// TODO: Find equivalent ISS methods for these:
|
||||
sessionData.paymentMethod = order?.payment?.piaType;
|
||||
|
||||
sessionData.paymentMethod = order?.payment?.paymentMethod;
|
||||
sessionData.isTextingOptedIn = order?.contactInfo?.requestTextUpdates ? true : false;
|
||||
|
||||
// TODO: Find equivalent ISS methods for these:
|
||||
sessionData.isEarlyBird = isEarlyBird ? true : false;
|
||||
sessionData.isEarlyBird = false;//isEarlyBird ? true : false;
|
||||
|
||||
sessionData.insuranceCo = issConfig.clientName;
|
||||
sessionData.deductible = store.currentDeductible();
|
||||
sessionData.isVerified = store.isVerified();
|
||||
sessionData.deductible = store.currentDeductible ?? 0;
|
||||
sessionData.isVerified = store.isVerified;
|
||||
sessionData.coverageStatus = coverageStatuses.mapToApi(order?.insuranceCoverage.coverageStatus);
|
||||
sessionData.coverageSubStatus = coverageType.mapToApi(order?.insuranceCoverage.coverageType);
|
||||
|
||||
// TODO: Need mappings here?
|
||||
sessionData.coverageStatus = order?.payment?.insuranceCoverage?.coverageStatus;
|
||||
sessionData.coverageSubStatus = order?.payment?.insuranceCoverage?.coverageSubStatus;
|
||||
|
||||
sessionData.isNoComp = store.isNoComp();
|
||||
sessionData.isItac = store.isITAC();
|
||||
sessionData.subTotalPrice = getSubTotal(order);
|
||||
sessionData.isNoComp = store.isNoComp;
|
||||
sessionData.isItac = store.isITAC;
|
||||
sessionData.subTotalPrice = getSubtotal(order);
|
||||
sessionData.totalPrice = getCartTotal(order);
|
||||
sessionData.userAgent = navigator.userAgent;
|
||||
sessionData.cashPriceSubTotal = getSubTotal(order);
|
||||
|
||||
// Why does this need to be a string?
|
||||
sessionData.cashPriceSubTotal = getSubtotal(order).toString();
|
||||
|
||||
store.logIssSessionData(sessionData);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ router.afterEach(async (to, from) => {
|
|||
analyticsMixin.methods.logDigitalConsumer();
|
||||
|
||||
// digital consumer ISS session logging to snowflake
|
||||
//analyticsMixin.methods.pushIssSessionData();
|
||||
analyticsMixin.methods.pushIssSessionData();
|
||||
|
||||
// Push page view to GA
|
||||
analyticsMixin.methods.pushPageViewToGA();
|
||||
|
|
|
|||
Loading…
Reference in a new issue