From e6df30696b9ec9b43dca4fb838b07cc8d9f6d2ba Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Tue, 28 Jan 2025 09:59:00 -0500 Subject: [PATCH 1/2] CASH-48: front end work to call new log-part-questions endpoint --- src/constants/endpoints.js | 4 +++ src/constants/store-actions.js | 11 ++++--- src/layouts/confirmation/confirmation.vue | 37 +++++++++++++++++++++++ src/store/index.js | 34 +++++++++++++++++++++ 4 files changed, 82 insertions(+), 4 deletions(-) diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index c972d8118..43bf8c926 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -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", diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 45a18bace..aee8d705f 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -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", diff --git a/src/layouts/confirmation/confirmation.vue b/src/layouts/confirmation/confirmation.vue index 90886a9b7..26c0fd4a5 100644 --- a/src/layouts/confirmation/confirmation.vue +++ b/src/layouts/confirmation/confirmation.vue @@ -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 diff --git a/src/store/index.js b/src/store/index.js index f423fb58d..ede3955cc 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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); From 833d6f248a483a88a4113449a390ce5289a4197c Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Tue, 28 Jan 2025 19:14:43 -0500 Subject: [PATCH 2/2] CASH-48: update application name value --- src/store/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index c45fe7eee..fa83032d5 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1458,9 +1458,8 @@ export const actions = { userAgent, } ) { - var payload = { - applicationName: applicationConfig.ANALYTICS_APPLICATION_NAME, + applicationName: applicationConfig.APPLICATION_NAME, eon: eon, ctu: ctu, workOrderId: workOrderId,