diff --git a/src/constants/analytics.js b/src/constants/analytics.js index b5b24660d..2b0fc1a8f 100644 --- a/src/constants/analytics.js +++ b/src/constants/analytics.js @@ -12,6 +12,7 @@ const GaEvents = { const GaCategories = { API_RESPONSE: "Api_Response", EVOX: "Evox", + FUNNEL_ENTRY: "funnel_entry", }; const GaActions = { @@ -20,6 +21,7 @@ const GaActions = { VIF: "vif", SUBMITTED: "Submitted", DISPLAYED: "Displayed", + ZIP_CODE_PROVIDED: "zip_code_provided", }; const GaLabels = { diff --git a/src/layouts/vehicle-damage/vehicle-damage.spec.js b/src/layouts/vehicle-damage/vehicle-damage.spec.js index 28b85bf00..30e144310 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.spec.js +++ b/src/layouts/vehicle-damage/vehicle-damage.spec.js @@ -52,6 +52,7 @@ jest.mock("@/store", () => ({ damage: { glassToReplace: [], }, + order: { serviceLocation: { zipCode: "11111" } }, }, })); @@ -133,6 +134,7 @@ describe("vehicle-damage.vue", () => { getters: { vehicle: {}, payment: { insuranceCoverage: { isVerified: false } }, + order: { serviceLocation: { zipCode: "11111" } }, }, }, }, @@ -175,7 +177,7 @@ describe("vehicle-damage.vue", () => { expect(wrapper.vm.selectedGlassToReplace()).toEqual(expectedGlassToReplace); expect(baseMixin.methods.dispatchStoreAction).toBeCalledWith( storeActions.GET_DAMAGE_OPTIONS, - { carId: "C00000000" } + { carId: "C00000000", zipCode: "11111" } ); }); @@ -241,6 +243,7 @@ describe("vehicle-damage.vue", () => { getters: { vehicle: {}, payment: { insuranceCoverage: { isVerified: false } }, + order: { serviceLocation: { zipCode: "11111" } }, }, }, }, @@ -270,11 +273,10 @@ describe("vehicle-damage.vue", () => { expect(wrapper.vm.selectedGlassToReplace()).toEqual(expectedGlassToReplace); expect(baseMixin.methods.dispatchStoreAction).toBeCalledWith( storeActions.GET_DAMAGE_OPTIONS, - { carId: "C00000000" } + { carId: "C00000000", zipCode: "11111" } ); }); }); - describe("alert", () => { test("when displayVehicleChangeAlert router params is true, the alert: 'vehicleChangeAlert' should be rendered", () => { // Arrange & Act @@ -321,7 +323,6 @@ describe("vehicle-damage.vue", () => { expect(wrapper.findComponent({ ref: "vehicleChangeAlert" }).exists()).toBe(false); }); }); - describe("glass selections and corresponding variables", () => { test("isWindshieldDamageLocation is true when windshield is selected", async () => { //Arrange @@ -453,7 +454,6 @@ describe("vehicle-damage.vue", () => { expect(wrapper.vm.isPassengerSideReplace).toEqual(true); }); }); - describe("state validations", () => { test("CarId set, arePagePrerequisitesValid should be true ", async () => { //Arrange @@ -474,7 +474,6 @@ describe("vehicle-damage.vue", () => { expect(arePagePrerequisitesValid).toBe(true); }); }); - describe("input validations", () => { // THE FOLLOWING TEST IS NOT NECESSARILY REQUIRED FOR COVERAGE // BUT KEEP FOR AN EXAMPLE OF A VALIDATION TEST @@ -501,7 +500,6 @@ describe("vehicle-damage.vue", () => { }); }); }); - describe("get glass options from store", () => { const damageLocations = [ ["Windshield", [damageLocationsSelected.WINDSHIELD]], @@ -528,6 +526,7 @@ describe("vehicle-damage.vue", () => { eventBusItem: jest.fn(), damage: { glassToReplace: [{ glassLocation: damageLocation }] }, isRepair: true, + order: { serviceLocation: { zipCode: "11111" } }, }; var glassSelections = wrapper.vm.getDamageLocationsFromStore(); @@ -605,6 +604,7 @@ describe("vehicle-damage.vue", () => { isRepair: isRepair, numberOfChips: 2, }, + order: { serviceLocation: { zipCode: "11111" } }, }; var windshieldSelections = wrapper.vm.getWindshieldOptionsFromStore(); @@ -641,6 +641,7 @@ describe("vehicle-damage.vue", () => { glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }], }, isRepair: true, + order: { serviceLocation: { zipCode: "11111" } }, }; var glassSelections = wrapper.vm.getDriverSideReplaceOptionsFromStore(); @@ -677,6 +678,7 @@ describe("vehicle-damage.vue", () => { glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }], }, isRepair: true, + order: { serviceLocation: { zipCode: "11111" } }, }; var glassSelections = wrapper.vm.getPassengerSideReplaceOptionsFromStore(); @@ -711,6 +713,7 @@ describe("vehicle-damage.vue", () => { glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }], }, isRepair: true, + order: { serviceLocation: { zipCode: "11111" } }, }; var glassSelections = wrapper.vm.getRearReplaceOptionsFromStore(); @@ -720,7 +723,6 @@ describe("vehicle-damage.vue", () => { } ); }); - describe("hide back button", () => { test("if claim registration is delayed => should hide back button", () => { // Arrange @@ -744,6 +746,7 @@ describe("vehicle-damage.vue", () => { getters: { vehicle: {}, payment: { insuranceCoverage: { isVerified: true } }, + order: { serviceLocation: { zipCode: "11111" } }, }, }, }, @@ -784,6 +787,7 @@ function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData, funnelCo isVerified: false, }, }, + order: { serviceLocation: { zipCode: "11111" } }, }, }, }; diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index ae89a61e6..6ea4fe81d 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -81,7 +81,7 @@ import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper"; import store from "@/store"; import baseMixin from "@/mixins/base-mixin"; - +import { queryStrings } from "@/constants/query-strings"; // DEFINE VALIDATION RULES defineRule("replace-options-required", required(errorMessages.REPLACE_OPTIONS_REQUIRED)); @@ -90,9 +90,20 @@ export default { async beforeRouteEnter(to, from, next) { // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + const lowerCaseParams = new URLSearchParams(); + for (const [name, value] of urlParams) { + lowerCaseParams.append(name.toLowerCase(), value); + } + + const zip = lowerCaseParams.get(queryStrings.ZIP_CODE) + ? lowerCaseParams.get(queryStrings.ZIP_CODE) + : store.getters.order.serviceLocation.zipCode; + const damageOptionsPromise = baseMixin.methods.dispatchStoreAction( storeActions.GET_DAMAGE_OPTIONS, - { carId: store.getters.vehicle.carId } + { carId: store.getters.vehicle.carId, zipCode: zip } ); // Settle promises and get results @@ -135,6 +146,7 @@ export default { }, selectedWindshieldOptions: this.getWindshieldOptionsFromStore(), selectedRearReplaceOptions: this.getRearReplaceOptionsFromStore(), + serviceZipCode: this.getZipFromStore() ?? this.$route.query.zipcode, }; }, mounted() { @@ -157,6 +169,18 @@ export default { true ); } + if (this.serviceZipCode) { + this.pushEventToGA( + this.GaCategories.FUNNEL_ENTRY, + this.GaActions.ZIP_CODE_PROVIDED, + this.serviceZipCode, + true + ); + } + }, + + getZipFromStore() { + return this.$store.getters.order.serviceLocation.zipCode; }, backButtonAction() { diff --git a/src/store/index.js b/src/store/index.js index c3c9fc8a0..abefc2b5d 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -740,11 +740,12 @@ export const actions = { }); }, - getDamageOptions(context, { carId }) { + getDamageOptions(context, { carId, zipCode }) { return globalMethods.callHttpClient({ methods: endpoints.GetDamageOptions.method, endpoint: `${endpoints.GetDamageOptions.url}/${carId}`, payload: {}, + additionalSuccessEventDataHandler: (response) => "QueryStringZip: " + zipCode, }); },