Merge pull request #2893 from Safelite/nation/CASH-1637

Nation/cash 1637
This commit is contained in:
CarlNation 2025-10-15 13:51:57 -04:00 committed by GitHub
commit 65b435255a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 182 additions and 53 deletions

View file

@ -7,8 +7,6 @@ const analyticsPageEvents = {
const GaEvents = {
GENERIC_EVENT: "event",
PAGE_VIEW_EVENT: "logPageview",
FMG_DATA_EVENT_1: "logEvent1",
FMG_DATA_EVENT_2: "logEvent2",
};
const GaCategories = {
@ -16,7 +14,6 @@ const GaCategories = {
EVOX: "Evox",
APPOINTMENT: "Appointment",
SERVICE_LOCATION: "service-location",
FMG_SESSION_DATA: "fmg_session_data",
};
const GaActions = {

View file

@ -180,6 +180,10 @@ const endpoints = {
url: "/analytics/api/v1/analytics/digitalconsumer-log",
method: "POST",
},
LogFmgSessionData: {
url: "/analytics/api/v1/analytics/digitalconsumer-session-logging",
method: "POST",
},
GetExperimentsByUser: {
url: "/analytics/api/v1/analytics/get-experiments",
method: "GET",

View file

@ -64,6 +64,7 @@ const storeActions = {
INITIALIZE_SESSION: "initializeSession",
LOG_PART_QUESTIONS: "logPartQuestions",
LOG_DIGITALCONSUMER: "logDigitalConsumer",
LOG_FMG_SESSION_DATA: "logFmgSessionData",
// DEPENDENCY MUTATIONS
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleStateAndDependencies",

View file

@ -200,63 +200,91 @@ export default {
await this.logPageView(analyticsPageEvents.ENTRY);
},
async pushFmgDataToGA() {
// This sends session data to the session logging endpoint on the analytics service.
// From there, it uses aws kinesis data stream, DigitalConsumer-Session-Data-Stream,
// and aws FireHose stream, DigitalConsumer-Session-Firehose, to push data to an
// S3 bucket, safelite-dev-digitalconsumer-session-data-us-east-2/1.
// This bucket data is then picked up by snowflake for analytics use.
async pushFmgSessionData() {
const hasSubmittedOrder = baseMixin.methods.hasSubmittedOrder();
const submittedOrder = baseMixin.methods.getSubmittedOrder();
const order = hasSubmittedOrder ? submittedOrder : store.getters.order;
//event 1
var label = {};
label.carId = order?.vehicle?.carId;
label.hasVin = order?.vehicle?.vin ? true : false;
label.cashOrInsuranceAccountType = order?.payment?.isInsurance ? "Insurance" : "Cash";
label.damageType = order?.damage?.isRepair ? "Repair" : "Replace";
label.productType = order?.damage?.glassToReplace;
label.recalRequired = containsRecalParts(order?.lineItems);
label.recalType = getRecalPartNumbers(order?.lineItems?.glassParts);
label.serviceZipCode = order?.serviceLocation?.provider?.address?.zipCode
? order?.serviceLocation?.provider?.address?.zipCode
: order?.serviceLocation?.zipCode;
label.providerCtu = order?.serviceLocation?.provider?.address?.zipCodeCtu
? order?.serviceLocation?.provider?.address?.zipCodeCtu
: order?.serviceLocation?.zipCodeCtu;
label.subTotalPrice = getSubTotal(order?.lineItems);
label.totalPrice = getAmountDue(order?.lineItems);
const hasSubmittedApplicationUser = baseMixin.methods.hasSubmittedApplicationUser();
const submittedApplicationUser = baseMixin.methods.getSubmittedApplicationUser();
const applicationUser = hasSubmittedApplicationUser
? submittedApplicationUser
: store.getters.applicationUser;
await this.pushEventToGA(
GaCategories.FMG_SESSION_DATA,
GaEvents.FMG_DATA_EVENT_1,
JSON.stringify(label),
true,
null,
null
);
//event 2
const isEarlyBird = order?.lineItems?.supportingItems?.find(
(lineItem) => lineItem.partType == partTypeStrings.EARLY_BIRD
);
label = {};
label.serviceType = order?.serviceLocation?.appointmentType;
label.promoCodes = order?.lineItems?.promos;
label.hasTechnicianNotes = order?.serviceLocation?.techNotes ? true : false;
label.paymentMethod = order?.payment?.piaType;
label.isTextingOptedIn = order?.customer?.isSmsOptIn ? true : false;
label.isEarlyBird = isEarlyBird ? true : false;
label.insuranceCo = order?.policy?.insuranceCompanyName;
label.deductible = order?.policy?.currentDeductible;
label.isVerified = order?.payment?.insuranceCoverage?.isVerified;
label.isNoComp = order?.policy?.isNoComp;
label.isItac = order?.policy?.isItac;
const promoCodes = Array.isArray(order?.lineItems?.promos)
? order?.lineItems?.promos
.map((item) => item.promoCode)
.filter((code) => code)
.join(", ")
: null;
await this.pushEventToGA(
GaCategories.FMG_SESSION_DATA,
GaEvents.FMG_DATA_EVENT_2,
JSON.stringify(label),
true,
null,
null
const glassProducts = order?.damage?.glassToReplace?.map(
(part) => `${part.glassLocation}-${part.glassName}`
);
var sessionData = {};
sessionData.currentPage = getPageNameFromRouter();
sessionData.sid = getSessionIdValue();
sessionData.deviceId = getDeviceIdValue();
sessionData.fmgSessionId = applicationUser?.savedSessionId;
sessionData.userId = getUserIdValue();
sessionData.carId = order?.vehicle?.carId;
sessionData.vehicleYear = order?.vehicle?.year;
sessionData.vehicleMake = order?.vehicle?.make;
sessionData.vehicleModel = order?.vehicle?.model;
sessionData.vehicleStyle = order?.vehicle?.style;
sessionData.hasVin = order?.vehicle?.vin ? true : false;
sessionData.cashOrInsuranceAccountType = order?.payment?.isInsurance
? "Insurance"
: "Cash";
sessionData.damageType = order?.damage?.isRepair ? "Repair" : "Replace";
sessionData.productType = glassProducts;
sessionData.eon = order?.eon;
sessionData.referralNumber = order?.referralNumber;
sessionData.referralSequenceNumber = order?.referralSequenceNumber;
sessionData.referralDate = order?.referralDate;
sessionData.workOrderNumber = order?.workOrderNumber;
sessionData.workOrderId = order?.workOrderId;
sessionData.isPia = order?.payment?.isPia ?? false;
sessionData.piaType = order?.payment?.piaType;
sessionData.parentAccountNumber = order?.payment?.parentAccountNumber;
sessionData.settledTenderAmount = order?.settledTenderAmount;
sessionData.recalRequired = containsRecalParts(order?.lineItems);
sessionData.recalType = getRecalPartNumbers(order?.lineItems?.glassParts);
sessionData.serviceZipCode = order?.serviceLocation?.provider?.address?.zipCode
? order?.serviceLocation?.provider?.address?.zipCode
: order?.serviceLocation?.zipCode;
sessionData.providerCtu = order?.serviceLocation?.provider?.address?.zipCodeCtu
? order?.serviceLocation?.provider?.address?.zipCodeCtu
: order?.serviceLocation?.zipCodeCtu;
sessionData.appointmentDate = `${order?.schedule?.date} ${order?.schedule?.startTime}`;
sessionData.serviceType = order?.serviceLocation?.appointmentType;
sessionData.promoCodes = promoCodes;
sessionData.hasTechnicianNotes = order?.serviceLocation?.techNotes ? true : false;
sessionData.paymentMethod = order?.payment?.piaType;
sessionData.isTextingOptedIn = order?.customer?.isSmsOptIn ? true : false;
sessionData.isEarlyBird = isEarlyBird ? true : false;
sessionData.insuranceCo = order?.policy?.insuranceCompanyName;
sessionData.deductible = order?.policy?.currentDeductible;
sessionData.isVerified = order?.payment?.insuranceCoverage?.isVerified ?? false;
sessionData.isNoComp = order?.policy?.isNoComp;
sessionData.isItac = order?.policy?.isItac;
sessionData.subTotalPrice = getSubTotal(order?.lineItems);
sessionData.totalPrice = getAmountDue(order?.lineItems, true);
await baseMixin.methods.dispatchStoreAction(
storeActions.LOG_FMG_SESSION_DATA,
sessionData,
false
);
},

View file

@ -4,6 +4,9 @@ export async function afterEach(to, from) {
// digital consumer logging
analyticsMixin.methods.logDigitalConsumer();
// digital consumer fmg session logging to snowflake
analyticsMixin.methods.pushFmgSessionData();
// Push page view to GA
analyticsMixin.methods.pushPageViewToGA();
@ -12,7 +15,4 @@ export async function afterEach(to, from) {
// Push current order status to Data Layer
analyticsMixin.methods.pushOrderToDataLayer();
// Push session data GA events for Analytics
analyticsMixin.methods.pushFmgDataToGA();
}

View file

@ -1594,6 +1594,105 @@ export const actions = {
});
},
logFmgSessionData(
context,
{
currentPage,
sid,
deviceId,
fmgSessionId,
userId,
carId,
vehicleYear,
vehicleMake,
vehicleModel,
vehicleStyle,
hasVin,
cashOrInsuranceAccountType,
damageType,
productType,
eon,
referralNumber,
referralSequenceNumber,
referralDate,
workOrderNumber,
workOrderId,
isPia,
piaType,
parentAccountNumber,
settledTenderAmount,
recalRequired,
recalType,
serviceZipCode,
providerCtu,
appointmentDate,
serviceType,
promoCodes,
hasTechnicianNotes,
paymentMethod,
isTextingOptedIn,
isEarlyBird,
insuranceCo,
deductible,
isVerified,
isNoComp,
isItac,
subTotalPrice,
totalPrice,
}
) {
var payload = {
currentPage: currentPage,
sid: sid,
deviceId: deviceId,
fmgSessionId: fmgSessionId,
userId: userId,
carId: carId,
vehicleYear: vehicleYear,
vehicleMake: vehicleMake,
vehicleModel: vehicleModel,
vehicleStyle: vehicleStyle,
hasVin: hasVin,
cashOrInsuranceAccountType: cashOrInsuranceAccountType,
isVerified: isVerified,
damageType: damageType,
productType: productType,
eon: eon,
referralNumber: referralNumber,
referralSequenceNumber: referralSequenceNumber,
referralDate: referralDate,
workOrderNumber: workOrderNumber,
workOrderId: workOrderId,
isPia: isPia,
piaType: piaType,
parentAccountNumber: parentAccountNumber,
settledTenderAmount: settledTenderAmount,
recalRequired: recalRequired,
recalType: recalType,
serviceZipCode: serviceZipCode,
providerCtu: providerCtu,
appointmentDate: appointmentDate,
serviceType: serviceType,
promoCodes: promoCodes,
hasTechnicianNotes: hasTechnicianNotes,
paymentMethod: paymentMethod,
isTextingOptedIn: isTextingOptedIn,
isEarlyBird: isEarlyBird,
insuranceCo: insuranceCo,
deductible: deductible,
isNoComp: isNoComp,
isItac: isItac,
subTotalPrice: subTotalPrice,
totalPrice: totalPrice,
};
return globalMethods.callHttpClient({
method: endpoints.LogFmgSessionData.method,
endpoint: endpoints.LogFmgSessionData.url,
payload: payload,
});
},
// Misc Actions
setReferralInformation(context, { referralNumber, referralDate, referralCorrelationId, eon }) {
context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);