From be45bb9ff72ba376360e856dfd28420f22a3070b Mon Sep 17 00:00:00 2001 From: Katie Date: Fri, 15 Jul 2022 11:46:01 -0400 Subject: [PATCH 1/7] CSR-514 Initial implementation for runExperimentsForTrigger --- src/constants/application-config.js | 4 +- src/constants/endpoints.js | 4 ++ src/constants/experiments.js | 7 +++- src/constants/store-actions.js | 1 + src/constants/store-mutations.js | 4 ++ src/router/index.js | 10 +++++ src/store/index.js | 60 +++++++++++++++++++++++++++-- 7 files changed, 85 insertions(+), 5 deletions(-) diff --git a/src/constants/application-config.js b/src/constants/application-config.js index 0d173db19..3f1979f83 100644 --- a/src/constants/application-config.js +++ b/src/constants/application-config.js @@ -5,7 +5,9 @@ const applicationConfig = { ANALYTICS_SESSION_TIMEOUT_MINUTES: 30, SAVED_SESSION_TIMEOUT_DAYS: 45, COOKIE_PATH: "/", - CURRENT_ENVIRONMENT: process.env.VUE_APP_CURRENT_ENVIRONMENT // "Localhost", "Dev", "QA", and "Prod" + CURRENT_ENVIRONMENT: process.env.VUE_APP_CURRENT_ENVIRONMENT, // "Localhost", "Dev", "QA", and "Prod" + APPLICATION_NAME: "SafeliteDotCom", + SITE_ENTRY_TRIGGER_VALUE: "FixMyGlass" }; export { applicationConfig }; \ No newline at end of file diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index e7f856f40..3b3bc8bde 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -90,6 +90,10 @@ const endpoints = { GetExperimentsByUser: { url: "/analytics/api/v1/analytics/get-experiments", method: "GET", + }, + RunExperimentsForTrigger: { + url: "/experiments/api/v1/experiments/run", + method: "POST" } }; diff --git a/src/constants/experiments.js b/src/constants/experiments.js index cd2325a24..fdfa7acac 100644 --- a/src/constants/experiments.js +++ b/src/constants/experiments.js @@ -5,6 +5,11 @@ const experimentUniverses = { const experimentSettings = { GOOGLE_CUSTOM_DIMENSION_INDEX: 'Google Custom Dimension Index' } + +const experimentTriggers = { + SITE_ENTRY: "SiteEntry", + PAGE_ENTRY: "PageEntry" +}; -export { experimentUniverses, experimentSettings}; +export { experimentUniverses, experimentSettings, experimentTriggers }; \ No newline at end of file diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 87331daea..6d0fb1f6b 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -30,6 +30,7 @@ const storeActions = { LOG_CUSTOM_EVENT: "logCustomEvent", INITIALIZE_SESSION: "initializeSession", GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser", + RUN_EXPERIMENTS_FOR_TRIGGER: "runExperimentsForTrigger", CLEAR_VIN: "clearVin", // DEPENDENCY MUTATIONS diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 80697cc46..28dbb17bf 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -58,6 +58,10 @@ const storeMutations = { UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation", UPDATE_SAVE_ORDER_PROMISE: "updateSaveOrderPromise", UPDATE_LAST_PAGE_VISITED: "updateLastPageVisited", + + // EXPERIMENT MUTATIONS + UPDATE_EXPERIMENTS: "updateExperiments", + UPDATE_TRIGGERED_SITE_ENTRY: "updateTriggeredSiteEntry" }; export { storeMutations }; diff --git a/src/router/index.js b/src/router/index.js index b09f734a2..02ec313b8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -18,6 +18,8 @@ import baseMixin from "@/mixins/base-mixin"; import eventBus from "@/helpers/event-bus/event-bus"; import store from "@/store"; import analyticsMixin from "@/mixins/analytics-mixin"; +import { experimentTriggers } from "../constants/experiments"; +import { applicationConfig } from "../constants/application-config"; const routes = [ { @@ -35,6 +37,14 @@ const routes = [ return next(false); } + if (!store.getters.applicationUser.triggeredSiteEntry) { + await baseMixin.methods.dispatchStoreAction(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, { + userId: getDeviceIdValue(), + triggerEvent: experimentTriggers.SITE_ENTRY, + triggerValue: applicationConfig.SITE_ENTRY_TRIGGER_VALUE + }); + } + // If the saved session has timed out, clear the session, execute 404 logic. if (getFunnelCookie() !== null && !isSavedSessionStillActive()) { await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE); diff --git a/src/store/index.js b/src/store/index.js index bac95e3cf..0e766f3c3 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -5,6 +5,8 @@ import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/se import createPersistedState from "vuex-persistedstate"; import globalMethods from "@/global-methods"; import { storeActions } from "../constants/store-actions"; +import { applicationConfig } from "../constants/application-config"; +import { experimentTriggers } from "../constants/experiments"; // Export State const getDefaultState = () => { @@ -69,6 +71,8 @@ const getDefaultState = () => { saveQuoteId: null, crmCustomerId: null, lastPageVisited: null, + experiments: {}, + triggeredSiteEntry: false }, } }; @@ -313,6 +317,12 @@ export const mutations = { state.order.customer.emailAddress = orderInformation.customer.emailAddress; }, + updateExperiments(state, experiments) { + state.applicationUser.experiments = experiments; + }, + updateTriggeredSiteEntry(state, wasSiteEntryTriggered) { + state.applicationUser.triggeredSiteEntry = wasSiteEntryTriggered; + } } // Export Getters @@ -333,6 +343,30 @@ export const getters = { applicationUser: (state) => state.applicationUser, order: (state) => state.order, payment: (state) => state.order.payment, + experimentOrder: (state) => { + return { + vehicleYear: state.order.vehicle.year, + vehicleMake: state.order.vehicle.make, + vehicleModel: state.order.vehicle.model, + vehicleStyle: state.order.vehicle.style, + isRepair: state.order.damage.isRepair, + numberOfChips: state.order.damage.numberOfChips, + carId: state.order.vehicle.carId, + serviceCity: state.order.serviceLocation.city, + serviceState: state.order.serviceLocation.state, + serviceZipCode: state.order.serviceLocation.zipCode, + parentAccountNumber: state.order.accountNumber, + isCoverageVerified: state.order.payment.insuranceCoverage.isVerified, + orderPartNumbers: [...Object.values(state.order.lineItems.glassParts), ...Object.values(state.order.lineItems.otherParts)], + orderPartTypes: [...Object.keys(state.order.lineItems.glassParts), ...Object.keys(state.order.lineItems.otherParts)], + hasRecalibrationPart: Object.values(state.order.lineItems.glassParts).filter(x => x.requiresRecalibration)?.length > 0, + selectedMultiGlass: state.order.damage.glassToReplace.length > 1, + selectedWindshieldGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.WINDSHIELD), + selectedBackGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.BACK), + selectedDriverSideGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.DRIVER), + selectedPassengerSideGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.PASSENGER) + } + } } // Export Actions @@ -510,7 +544,7 @@ export const actions = { sessionKey: sessionKey, sessionId: sessionId, pageName: pageName, - applicationName: 'SafeliteDotCom', + applicationName: applicationConfig.APPLICATION_NAME, action: action, event: event, shouldUseSessionId: shouldUseSessionId @@ -529,7 +563,7 @@ export const actions = { sessionKey: sessionKey, sessionId: sessionId, pageName: pageName, - applicationName: 'SafeliteDotCom', + applicationName: applicationConfig.APPLICATION_NAME, category: category, action: action, label: label, @@ -546,7 +580,7 @@ export const actions = { }, initializeSession(context, { userId, sessionId, userAgent, referrer }) { var payload = { - applicationName: 'SafeliteDotCom', + applicationName: applicationConfig.APPLICATION_NAME, userId: userId, deviceId: userId, sessionId: sessionId, @@ -579,6 +613,26 @@ export const actions = { }); }, + runExperimentsForTrigger(context, { userId, triggerEvent, triggerValue }) { + if (triggerValue == experimentTriggers.SITE_ENTRY) { + context.commit(storeMutations.UPDATE_TRIGGERED_SITE_ENTRY, true); + } + + var payload = { + applicationName: applicationConfig.APPLICATION_NAME, + userId: userId, + triggerEvent: triggerEvent, + triggerValue: triggerValue, + experimentOrder: context.getters.experimentOrder + }; + + return globalMethods.callHttpClient({ + method: endpoints.RunExperimentsForTrigger.method, + endpoint: endpoints.RunExperimentsForTrigger.url, + payload: payload, + }); + }, + getEvoxImage(context, { relativeUrl }) { return globalMethods.callHttpClient({ method: endpoints.GetPageData.method, From a750a20e61fe587c189800eeae93477464ab6905 Mon Sep 17 00:00:00 2001 From: Katie Date: Mon, 18 Jul 2022 08:52:49 -0400 Subject: [PATCH 2/7] CSR-514 Add import --- src/store/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 0e766f3c3..3544622af 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -4,9 +4,10 @@ import { storeMutations } from "@/constants/store-mutations"; import { getDateForSavedSessionTimeout } from "@/helpers/heritage-integration/session-helper"; import createPersistedState from "vuex-persistedstate"; import globalMethods from "@/global-methods"; -import { storeActions } from "../constants/store-actions"; -import { applicationConfig } from "../constants/application-config"; -import { experimentTriggers } from "../constants/experiments"; +import { storeActions } from "@/constants/store-actions"; +import { applicationConfig } from "@/constants/application-config"; +import { experimentTriggers } from "@/constants/experiments"; +import { damageLocationsSelected } from "@/constants/damage-locations-selected"; // Export State const getDefaultState = () => { From cdfcec5257254482f92d7031a76a6ecb2b8243c5 Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 9 Aug 2022 12:36:10 -0400 Subject: [PATCH 3/7] CSR-514 Uncomment and fix parts of experimentOrder --- src/global-methods.js | 5 +++-- src/router/index.js | 9 +++++---- src/store/index.js | 18 +++++++++--------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/global-methods.js b/src/global-methods.js index c419eba45..0da6824ef 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -15,8 +15,9 @@ export default { [headerKeys.EXPERIMENT]: JSON.stringify(store.getters.experimentSettings) } - if (endpoint.includes("/vehicle/")) - cfDistroUrl = "https://localhost:44331" + if (endpoint.includes("/experiments/")) { + cfDistroUrl = "https://localhost:44372"; + } axios({ method: method, url: cfDistroUrl + endpoint, data: payloadAndAnalyticsData, crossDomain: true, responseType: {}, headers: headers }) .then((response) => { diff --git a/src/router/index.js b/src/router/index.js index d3688049f..2dcf104ea 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -37,13 +37,14 @@ const routes = [ return next(false); } - if (!store.getters.applicationUser.triggeredSiteEntry) { - await baseMixin.methods.dispatchStoreAction(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, { + // TODO CSR-514 UNCOMMENT CONDITION + // if (!store.getters.applicationUser.triggeredSiteEntry) { + baseMixin.methods.dispatchStoreAction(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, { userId: getDeviceIdValue(), triggerEvent: experimentTriggers.SITE_ENTRY, triggerValue: applicationConfig.SITE_ENTRY_TRIGGER_VALUE - }); - } + }) + // } // If the saved session has timed out, clear the session, execute 404 logic. if (getFunnelCookie() !== null && !isSavedSessionStillActive()) { diff --git a/src/store/index.js b/src/store/index.js index af4ab8de3..dbe18ef04 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -362,14 +362,14 @@ export const getters = { serviceZipCode: state.order.serviceLocation.zipCode, parentAccountNumber: state.order.accountNumber, isCoverageVerified: state.order.payment.insuranceCoverage.isVerified, - // orderPartNumbers: [...Object.values(state.order.lineItems.glassParts ?? {}), ...Object.values(state.order.lineItems.otherParts ?? {})], - // orderPartTypes: [...Object.keys(state.order.lineItems.glassParts ?? {}), ...Object.keys(state.order.lineItems.otherParts ?? {})], - // hasRecalibrationPart: Object.values(state.order.lineItems.glassParts ?? {}).filter(x => x.requiresRecalibration)?.length > 0, - // selectedMultiGlass: state.order.damage.glassToReplace.length > 1, - // selectedWindshieldGlass: Object.keys(state.order.damage.glassToReplace ?? []).map(x => x.split("-")[0]).includes(damageLocationsSelected.WINDSHIELD), - // selectedBackGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.BACK), - // selectedDriverSideGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.DRIVER), - // selectedPassengerSideGlass: Object.keys(state.order.damage.glassToReplace).map(x => x.split("-")[0]).includes(damageLocationsSelected.PASSENGER) + orderPartNumbers: [...Object.values(state.order.lineItems.glassParts ?? []), ...Object.values(state.order.lineItems.otherParts ?? [])], + orderPartTypes: [...Object.keys(state.order.lineItems.glassParts ?? []), ...Object.keys(state.order.lineItems.otherParts ?? [])], + hasRecalibrationPart: Object.values(state.order.lineItems.glassParts ?? []).filter(x => x.requiresRecalibration)?.length > 0, + selectedMultiGlass: state.order.damage.glassToReplace?.length > 1, + selectedWindshieldGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.WINDSHIELD), + selectedBackGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.REAR), + selectedDriverSideGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.DRIVER), + selectedPassengerSideGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.PASSENGER) } }, experimentSettings: (state) => state.applicationUser.experiments.map(x => x.settings).reduce((r, c) => Object.assign(r, c), {}) @@ -623,7 +623,7 @@ export const actions = { }, runExperimentsForTrigger(context, { userId, triggerEvent, triggerValue }) { - if (triggerValue == experimentTriggers.SITE_ENTRY) { + if (triggerEvent == experimentTriggers.SITE_ENTRY) { context.commit(storeMutations.UPDATE_TRIGGERED_SITE_ENTRY, true); } From 2167c240bbba9bebd38a99c7e92063bfe65f57be Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 9 Aug 2022 13:22:23 -0400 Subject: [PATCH 4/7] CSR-514 Fix experimentOrder --- src/global-methods.js | 4 +++- .../heritage-integration/order-helper.js | 8 ++++++++ src/store/index.js | 18 +++++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/global-methods.js b/src/global-methods.js index 0da6824ef..2717cbda9 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -18,7 +18,9 @@ export default { if (endpoint.includes("/experiments/")) { cfDistroUrl = "https://localhost:44372"; } - + else if (endpoint.includes("/order/")) + cfDistroUrl = "https://localhost:44346" + axios({ method: method, url: cfDistroUrl + endpoint, data: payloadAndAnalyticsData, crossDomain: true, responseType: {}, headers: headers }) .then((response) => { diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 870ee190b..4c18b660f 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -36,6 +36,14 @@ export async function loadOrderIfPresent() { update the cookie. */ export async function saveOrder() { + // TODO DELETE THIS, TEMP FOR TESTING + baseMixin.methods.dispatchStoreAction(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, { + userId: "test", + triggerEvent: "test", + triggerValue: "test" + }) + // END DELETE + var saveOrderPromise; if (store.getters.applicationUser.saveOrderPromise) { // queue newest request after current saveOrderPromise resolves diff --git a/src/store/index.js b/src/store/index.js index dbe18ef04..0ae01ad66 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -362,19 +362,23 @@ export const getters = { serviceZipCode: state.order.serviceLocation.zipCode, parentAccountNumber: state.order.accountNumber, isCoverageVerified: state.order.payment.insuranceCoverage.isVerified, - orderPartNumbers: [...Object.values(state.order.lineItems.glassParts ?? []), ...Object.values(state.order.lineItems.otherParts ?? [])], - orderPartTypes: [...Object.keys(state.order.lineItems.glassParts ?? []), ...Object.keys(state.order.lineItems.otherParts ?? [])], - hasRecalibrationPart: Object.values(state.order.lineItems.glassParts ?? []).filter(x => x.requiresRecalibration)?.length > 0, + orderPartNumbers: [...testHelper(state.order.lineItems.glassParts, "partNumber"), ...testHelper(state.order.lineItems.otherParts, "partNumber")], + orderPartTypes: [...testHelper(state.order.lineItems.glassParts, "recalibrationType"), ...testHelper(state.order.lineItems.otherParts, "recalibrationType")], + hasRecalibrationPart: (state.order.lineItems.glassParts ?? []).filter(x => x.requiresRecalibration)?.length > 0, selectedMultiGlass: state.order.damage.glassToReplace?.length > 1, - selectedWindshieldGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.WINDSHIELD), - selectedBackGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.REAR), - selectedDriverSideGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.DRIVER), - selectedPassengerSideGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.PASSENGER) + selectedWindshieldGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.WINDSHIELD), + selectedBackGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.REAR), + selectedDriverSideGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.DRIVER), + selectedPassengerSideGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.PASSENGER) } }, experimentSettings: (state) => state.applicationUser.experiments.map(x => x.settings).reduce((r, c) => Object.assign(r, c), {}) } +function testHelper(array, propertyName) { + return (array ?? []).map(x => x[propertyName]).filter(x => x); +} + // Export Actions export const actions = { From fdf17ce4bce492a410eefc00b8a9bff251a0ba71 Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 9 Aug 2022 13:27:46 -0400 Subject: [PATCH 5/7] CSR-514 Cleanup --- src/helpers/heritage-integration/order-helper.js | 8 -------- src/router/index.js | 5 ++--- src/store/index.js | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 4c18b660f..870ee190b 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -36,14 +36,6 @@ export async function loadOrderIfPresent() { update the cookie. */ export async function saveOrder() { - // TODO DELETE THIS, TEMP FOR TESTING - baseMixin.methods.dispatchStoreAction(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, { - userId: "test", - triggerEvent: "test", - triggerValue: "test" - }) - // END DELETE - var saveOrderPromise; if (store.getters.applicationUser.saveOrderPromise) { // queue newest request after current saveOrderPromise resolves diff --git a/src/router/index.js b/src/router/index.js index f1b9b2f0f..2e1bca1b1 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -37,14 +37,13 @@ const routes = [ return next(false); } - // TODO CSR-514 UNCOMMENT CONDITION - // if (!store.getters.applicationUser.triggeredSiteEntry) { + if (!store.getters.applicationUser.triggeredSiteEntry) { baseMixin.methods.dispatchStoreAction(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, { userId: getDeviceIdValue(), triggerEvent: experimentTriggers.SITE_ENTRY, triggerValue: applicationConfig.SITE_ENTRY_TRIGGER_VALUE }) - // } + } // If the saved session has timed out, clear the session, execute 404 logic. if (getFunnelCookie() !== null && !isSavedSessionStillActive()) { diff --git a/src/store/index.js b/src/store/index.js index 0ae01ad66..bcd787dd8 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -639,7 +639,7 @@ export const actions = { experimentOrder: context.getters.experimentOrder }; - return globalMethods.callHttpClient({ + globalMethods.callHttpClient({ method: endpoints.RunExperimentsForTrigger.method, endpoint: endpoints.RunExperimentsForTrigger.url, payload: payload, From 2a28fea2dd5f5a832e46d65e57e9eeada39e352a Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 10 Aug 2022 15:05:07 -0400 Subject: [PATCH 6/7] CSR-514 Cleanup --- src/global-methods.js | 8 +------- src/helpers/heritage-integration/order-helper.js | 5 +++++ src/store/index.js | 14 +++++++------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/global-methods.js b/src/global-methods.js index 2717cbda9..ffda1e77f 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -9,18 +9,12 @@ import { headerKeys } from "@/constants/header-keys"; export default { callHttpClient({ method, endpoint, payload, logApiCall = true }) { return new Promise((resolve, reject) => { - let cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; + const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass" }); const headers = { [headerKeys.EXPERIMENT]: JSON.stringify(store.getters.experimentSettings) } - if (endpoint.includes("/experiments/")) { - cfDistroUrl = "https://localhost:44372"; - } - else if (endpoint.includes("/order/")) - cfDistroUrl = "https://localhost:44346" - axios({ method: method, url: cfDistroUrl + endpoint, data: payloadAndAnalyticsData, crossDomain: true, responseType: {}, headers: headers }) .then((response) => { diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 870ee190b..2869c3358 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -36,6 +36,11 @@ export async function loadOrderIfPresent() { update the cookie. */ export async function saveOrder() { + store.dispatch(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, { + userId: "test", + triggerEvent: "test", + triggerValue: "test" + }) var saveOrderPromise; if (store.getters.applicationUser.saveOrderPromise) { // queue newest request after current saveOrderPromise resolves diff --git a/src/store/index.js b/src/store/index.js index 707fc61c1..64d451f63 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -377,20 +377,20 @@ export const getters = { serviceZipCode: state.order.serviceLocation.zipCode, parentAccountNumber: state.order.accountNumber, isCoverageVerified: state.order.payment.insuranceCoverage.isVerified, - orderPartNumbers: [...testHelper(state.order.lineItems.glassParts, "partNumber"), ...testHelper(state.order.lineItems.otherParts, "partNumber")], - orderPartTypes: [...testHelper(state.order.lineItems.glassParts, "recalibrationType"), ...testHelper(state.order.lineItems.otherParts, "recalibrationType")], + orderPartNumbers: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "partNumber"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "partNumber")], + orderPartTypes: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "recalibrationType"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "recalibrationType")], hasRecalibrationPart: (state.order.lineItems.glassParts ?? []).filter(x => x.requiresRecalibration)?.length > 0, selectedMultiGlass: state.order.damage.glassToReplace?.length > 1, - selectedWindshieldGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.WINDSHIELD), - selectedBackGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.REAR), - selectedDriverSideGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.DRIVER), - selectedPassengerSideGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.PASSENGER) + selectedWindshieldGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.WINDSHIELD), + selectedBackGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.REAR), + selectedDriverSideGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.DRIVER), + selectedPassengerSideGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.PASSENGER) } }, experimentSettings: (state) => state.applicationUser.experiments.map(x => x.settings).reduce((r, c) => Object.assign(r, c), {}) } -function testHelper(array, propertyName) { +function getAllValuesOfPropertyInArrayOfObjects(array, propertyName) { return (array ?? []).map(x => x[propertyName]).filter(x => x); } From c79f81a3443c273f0bf6fa606a683a85ddf293e0 Mon Sep 17 00:00:00 2001 From: Katie Date: Wed, 10 Aug 2022 15:06:10 -0400 Subject: [PATCH 7/7] CSR-514 Cleanup --- src/helpers/heritage-integration/order-helper.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 2869c3358..870ee190b 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -36,11 +36,6 @@ export async function loadOrderIfPresent() { update the cookie. */ export async function saveOrder() { - store.dispatch(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, { - userId: "test", - triggerEvent: "test", - triggerValue: "test" - }) var saveOrderPromise; if (store.getters.applicationUser.saveOrderPromise) { // queue newest request after current saveOrderPromise resolves