CASH-48: front end work to call new log-part-questions endpoint
This commit is contained in:
parent
3891dc5aea
commit
e6df30696b
4 changed files with 82 additions and 4 deletions
|
|
@ -168,6 +168,10 @@ const endpoints = {
|
|||
url: "/analytics/api/v1/analytics/initialize",
|
||||
method: "POST",
|
||||
},
|
||||
LogPartQuestions: {
|
||||
url: "/analytics/api/v1/analytics/log-part-questions",
|
||||
method: "POST",
|
||||
},
|
||||
GetExperimentsByUser: {
|
||||
url: "/analytics/api/v1/analytics/get-experiments",
|
||||
method: "GET",
|
||||
|
|
|
|||
|
|
@ -42,10 +42,6 @@ const storeActions = {
|
|||
VALIDATE_ZIP: "validateZip",
|
||||
PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA: "priceOrderItemsAndSaveServerData",
|
||||
TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA: "taxOrderItemsAndSaveServerData",
|
||||
LOG_EXPERIMENT_EXPOSURE: "logExperimentExposure",
|
||||
LOG_PAGE_VIEW: "logPageView",
|
||||
LOG_CUSTOM_EVENT: "logCustomEvent",
|
||||
INITIALIZE_SESSION: "initializeSession",
|
||||
GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser",
|
||||
RUN_EXPERIMENTS_FOR_TRIGGER: "runExperimentsForTrigger",
|
||||
CLEAR_VIN: "clearVin",
|
||||
|
|
@ -57,6 +53,13 @@ const storeActions = {
|
|||
GET_BILL_TO_ACCOUNT_NUMBER: "getBillToAccountNumber",
|
||||
GET_RECAL_PARTS_AND_SAVE_TO_LINE_ITEMS: "getRecalPartsAndSaveToLineItems",
|
||||
|
||||
// Analytics
|
||||
LOG_EXPERIMENT_EXPOSURE: "logExperimentExposure",
|
||||
LOG_PAGE_VIEW: "logPageView",
|
||||
LOG_CUSTOM_EVENT: "logCustomEvent",
|
||||
INITIALIZE_SESSION: "initializeSession",
|
||||
LOG_PART_QUESTIONS: "logPartQuestions",
|
||||
|
||||
// DEPENDENCY MUTATIONS
|
||||
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleStateAndDependencies",
|
||||
RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies",
|
||||
|
|
|
|||
|
|
@ -114,6 +114,43 @@ export default {
|
|||
async beforeRouteEnter(to, from, next) {
|
||||
const hasRecalPriceRemoveExperiment = await store.getters.shouldHideRecalibration;
|
||||
|
||||
// send part question data to SPS API for logging
|
||||
const orderFromStore = await deepClone(store.getters.order);
|
||||
const applicationUserFromStore = await deepClone(store.getters.applicationUser);
|
||||
const ctu = orderFromStore.workOrderNumber?.split("-")[0];
|
||||
const partsOrQuestions = applicationUserFromStore.pageData["part-questions"].partsOrQuestions;
|
||||
const onlyPartsWithQuestions = partsOrQuestions.filter((part) => {
|
||||
return part.partQuestions?.length > 0;
|
||||
});
|
||||
|
||||
onlyPartsWithQuestions.forEach(part => {
|
||||
const payloadPartQuestions = [];
|
||||
part.partQuestions.forEach(question => {
|
||||
payloadPartQuestions.push({
|
||||
questionSeq: question.questionSequence,
|
||||
questionText: question.questionText,
|
||||
answerText: question.answerSelected.split("|")[3],
|
||||
basePart: question.answerSelected.split("|")[2],
|
||||
});
|
||||
});
|
||||
const payload = {
|
||||
eon: orderFromStore.eon,
|
||||
ctu: ctu,
|
||||
workOrderId: orderFromStore.workOrderId,
|
||||
workOrderNumber: orderFromStore.workOrderNumber,
|
||||
carId: orderFromStore.vehicle.carId,
|
||||
glassLocation: part.glassLocation,
|
||||
partQuestions: payloadPartQuestions,
|
||||
};
|
||||
|
||||
baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.LOG_PART_QUESTIONS,
|
||||
payload,
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
// Create order
|
||||
await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_ORDER); // This nulls the Store order
|
||||
|
||||
// Call APIs
|
||||
|
|
|
|||
|
|
@ -1437,6 +1437,40 @@ export const actions = {
|
|||
});
|
||||
},
|
||||
|
||||
logPartQuestions(
|
||||
context,
|
||||
{
|
||||
eon,
|
||||
ctu,
|
||||
workOrderId,
|
||||
workOrderNumber,
|
||||
carId,
|
||||
glassLocation,
|
||||
partQuestions,
|
||||
userAgent,
|
||||
}
|
||||
) {
|
||||
|
||||
var payload = {
|
||||
applicationName: applicationConfig.ANALYTICS_APPLICATION_NAME,
|
||||
eon: eon,
|
||||
ctu: ctu,
|
||||
workOrderId: workOrderId,
|
||||
workOrderNumber: workOrderNumber,
|
||||
carId: carId,
|
||||
glassLocation: glassLocation,
|
||||
partQuestions: partQuestions,
|
||||
userAgent: navigator.userAgent
|
||||
};
|
||||
|
||||
return globalMethods
|
||||
.callHttpClient({
|
||||
method: endpoints.LogPartQuestions.method,
|
||||
endpoint: endpoints.LogPartQuestions.url,
|
||||
payload: payload,
|
||||
});
|
||||
},
|
||||
|
||||
// Misc Actions
|
||||
setReferralInformation(context, { referralNumber, referralDate, referralCorrelationId, eon }) {
|
||||
context.commit(storeMutations.UPDATE_REFERRAL_NUMBER, referralNumber);
|
||||
|
|
|
|||
Loading…
Reference in a new issue