CASH-1637
CASH-1637 call fmg session data logging endpoint
This commit is contained in:
parent
7f28449d1f
commit
a6df3a6ff6
6 changed files with 178 additions and 54 deletions
|
|
@ -7,8 +7,6 @@ const analyticsPageEvents = {
|
||||||
const GaEvents = {
|
const GaEvents = {
|
||||||
GENERIC_EVENT: "event",
|
GENERIC_EVENT: "event",
|
||||||
PAGE_VIEW_EVENT: "logPageview",
|
PAGE_VIEW_EVENT: "logPageview",
|
||||||
FMG_DATA_EVENT_1: "logEvent1",
|
|
||||||
FMG_DATA_EVENT_2: "logEvent2",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const GaCategories = {
|
const GaCategories = {
|
||||||
|
|
@ -16,7 +14,6 @@ const GaCategories = {
|
||||||
EVOX: "Evox",
|
EVOX: "Evox",
|
||||||
APPOINTMENT: "Appointment",
|
APPOINTMENT: "Appointment",
|
||||||
SERVICE_LOCATION: "service-location",
|
SERVICE_LOCATION: "service-location",
|
||||||
FMG_SESSION_DATA: "fmg_session_data",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const GaActions = {
|
const GaActions = {
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,10 @@ const endpoints = {
|
||||||
url: "/analytics/api/v1/analytics/digitalconsumer-log",
|
url: "/analytics/api/v1/analytics/digitalconsumer-log",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
},
|
},
|
||||||
|
LogFmgSessionData: {
|
||||||
|
url: "/analytics/api/v1/analytics/digitalconsumer-session-logging",
|
||||||
|
method: "POST",
|
||||||
|
},
|
||||||
GetExperimentsByUser: {
|
GetExperimentsByUser: {
|
||||||
url: "/analytics/api/v1/analytics/get-experiments",
|
url: "/analytics/api/v1/analytics/get-experiments",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ const storeActions = {
|
||||||
INITIALIZE_SESSION: "initializeSession",
|
INITIALIZE_SESSION: "initializeSession",
|
||||||
LOG_PART_QUESTIONS: "logPartQuestions",
|
LOG_PART_QUESTIONS: "logPartQuestions",
|
||||||
LOG_DIGITALCONSUMER: "logDigitalConsumer",
|
LOG_DIGITALCONSUMER: "logDigitalConsumer",
|
||||||
|
LOG_FMG_SESSION_DATA: "logFmgSessionData",
|
||||||
|
|
||||||
// DEPENDENCY MUTATIONS
|
// DEPENDENCY MUTATIONS
|
||||||
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleStateAndDependencies",
|
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleStateAndDependencies",
|
||||||
|
|
|
||||||
|
|
@ -200,39 +200,22 @@ export default {
|
||||||
await this.logPageView(analyticsPageEvents.ENTRY);
|
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 hasSubmittedOrder = baseMixin.methods.hasSubmittedOrder();
|
||||||
const submittedOrder = baseMixin.methods.getSubmittedOrder();
|
const submittedOrder = baseMixin.methods.getSubmittedOrder();
|
||||||
const order = hasSubmittedOrder ? submittedOrder : store.getters.order;
|
const order = hasSubmittedOrder ? submittedOrder : store.getters.order;
|
||||||
|
|
||||||
//event 1
|
const hasSubmittedApplicationUser = baseMixin.methods.hasSubmittedApplicationUser();
|
||||||
var label = {};
|
const submittedApplicationUser = baseMixin.methods.getSubmittedApplicationUser();
|
||||||
label.carId = order?.vehicle?.carId;
|
const applicationUser = hasSubmittedApplicationUser
|
||||||
label.hasVin = order?.vehicle?.vin ? true : false;
|
? submittedApplicationUser
|
||||||
label.cashOrInsuranceAccountType = order?.payment?.isInsurance ? "Insurance" : "Cash";
|
: store.getters.applicationUser;
|
||||||
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, true);
|
|
||||||
|
|
||||||
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(
|
const isEarlyBird = order?.lineItems?.supportingItems?.find(
|
||||||
(lineItem) => lineItem.partType == partTypeStrings.EARLY_BIRD
|
(lineItem) => lineItem.partType == partTypeStrings.EARLY_BIRD
|
||||||
);
|
);
|
||||||
|
|
@ -242,28 +225,66 @@ export default {
|
||||||
.map((item) => item.promoCode)
|
.map((item) => item.promoCode)
|
||||||
.filter((code) => code)
|
.filter((code) => code)
|
||||||
.join(", ")
|
.join(", ")
|
||||||
: "";
|
: null;
|
||||||
|
|
||||||
label = {};
|
const glassProducts = order?.damage?.glassToReplace?.map(
|
||||||
label.serviceType = order?.serviceLocation?.appointmentType;
|
(part) => `${part.glassLocation}-${part.glassName}`
|
||||||
label.promoCodes = promoCodes;
|
);
|
||||||
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;
|
|
||||||
|
|
||||||
await this.pushEventToGA(
|
var sessionData = {};
|
||||||
GaCategories.FMG_SESSION_DATA,
|
sessionData.currentPage = getPageNameFromRouter();
|
||||||
GaEvents.FMG_DATA_EVENT_2,
|
sessionData.sid = getSessionIdValue();
|
||||||
JSON.stringify(label),
|
sessionData.deviceId = getDeviceIdValue();
|
||||||
true,
|
sessionData.fmgSessionId = applicationUser?.savedSessionId;
|
||||||
null,
|
sessionData.userId = getUserIdValue();
|
||||||
null
|
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
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ export async function afterEach(to, from) {
|
||||||
// digital consumer logging
|
// digital consumer logging
|
||||||
analyticsMixin.methods.logDigitalConsumer();
|
analyticsMixin.methods.logDigitalConsumer();
|
||||||
|
|
||||||
|
// digital consumer fmg session logging to snowflake
|
||||||
|
analyticsMixin.methods.pushFmgSessionData();
|
||||||
|
|
||||||
// Push page view to GA
|
// Push page view to GA
|
||||||
analyticsMixin.methods.pushPageViewToGA();
|
analyticsMixin.methods.pushPageViewToGA();
|
||||||
|
|
||||||
|
|
@ -12,7 +15,4 @@ export async function afterEach(to, from) {
|
||||||
|
|
||||||
// Push current order status to Data Layer
|
// Push current order status to Data Layer
|
||||||
analyticsMixin.methods.pushOrderToDataLayer();
|
analyticsMixin.methods.pushOrderToDataLayer();
|
||||||
|
|
||||||
// Push session data GA events for Analytics
|
|
||||||
analyticsMixin.methods.pushFmgDataToGA();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1594,6 +1594,107 @@ export const actions = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
logFmgSessionData(
|
||||||
|
context,
|
||||||
|
{
|
||||||
|
currentPage,
|
||||||
|
sid,
|
||||||
|
deviceId,
|
||||||
|
fmgSessionId,
|
||||||
|
userId,
|
||||||
|
carId,
|
||||||
|
vehicleYear,
|
||||||
|
vehicleMake,
|
||||||
|
vehicleModel,
|
||||||
|
vehicleStyle,
|
||||||
|
hasVin,
|
||||||
|
cashOrInsuranceAccountType,
|
||||||
|
currentDeductible,
|
||||||
|
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,
|
||||||
|
currentDeductible: currentDeductible,
|
||||||
|
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
|
// Misc Actions
|
||||||
setReferralInformation(context, { referralNumber, referralDate, referralCorrelationId, eon }) {
|
setReferralInformation(context, { referralNumber, referralDate, referralCorrelationId, eon }) {
|
||||||
context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
|
context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue