diff --git a/src/constants/analytics.js b/src/constants/analytics.js index f6f6ff82e..a3f057150 100644 --- a/src/constants/analytics.js +++ b/src/constants/analytics.js @@ -26,6 +26,7 @@ const GaLabels = { ERROR: 'Error', LICENSE_PLATE_LOOKUP: 'License_Plate_Look_Up', VIN_LOOKUP: 'Vin_Look_Up', + ADDRESS_LOOKUP: 'Address_Look_up', }; diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index 445bddf16..f6e0d2b3d 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -150,6 +150,16 @@ export default { this.$route ); }, + attachCustomEvents() { + this.prependActionToMethod(this, this.forwardButtonAction, () => { + this.pushEventToGA( + this.$route.query[this.queryStrings.FMG_PAGE], + this.GaActions.SUBMITTED, + this.GaLabels.ADDRESS_LOOKUP, + true + ); + }); + }, getRegistrationAddressFromStore() { return store.getters.vehicle.registration.address; }, @@ -356,6 +366,9 @@ export default { } } }, + mounted() { + this.attachCustomEvents(); + }, computed: { AlertNonServiceableZipHeader(){ const zipCode = this.serviceZipCode ? this.serviceZipCode : this.customerQuestions.addressQuestions.zipCode; diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js index 9afd7e39a..281947ae4 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.spec.js +++ b/src/layouts/license-plate-lookup/license-plate-lookup.spec.js @@ -86,7 +86,6 @@ describe("license-plate-lookup.vue", () => { //Assert expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); - }); }); diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index 3d65717cf..17aa1b632 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -229,12 +229,12 @@ export default { }, attachCustomEvents() { this.prependActionToMethod(this, this.forwardButtonAction, () => { - this.pushEventToGA( + this.pushEventToGA( this.$route.query[this.queryStrings.FMG_PAGE], this.GaActions.SUBMITTED, this.GaLabels.LICENSE_PLATE_LOOKUP, true - ); + ); }); }, getLicensePlateFromStore() { diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 56da4301d..e19a86e68 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -200,6 +200,9 @@ export default { vinPopulatedOnPageLoad: this.getVinFromStore()?.length > 0, }; }, + mounted() { + this.attachCustomEvents(); + }, watch: { vin() { this.$refs.funnelFooter.updateButtonText( @@ -272,12 +275,12 @@ export default { getZipFromStore(){ return store.getters.order.serviceLocation.zipCode; }, - attachCustomEvents() { + attachCustomEvents() { this.prependActionToMethod(this, this.forwardButtonAction, () => { this.pushEventToGA( this.$route.query[this.queryStrings.FMG_PAGE], this.GaActions.SUBMITTED, - this.GaLabels.VINLOOKUP, + this.GaLabels.VIN_LOOKUP, true ); }); diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index d13e1b222..133187797 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -97,8 +97,9 @@ export default { }, prependActionToMethod(object, method, actionToPrepend) { - const baseMethod = object[method.name]; - object[method.name] = function () { + const baseMethodName = method.name.startsWith('bound ') ? method.name.substring(6) : method.name ; + const baseMethod = object[baseMethodName]; + object[baseMethodName] = function () { actionToPrepend.apply(this, arguments); return baseMethod.apply(object, arguments); }; diff --git a/src/mixins/analytics-mixin.spec.js b/src/mixins/analytics-mixin.spec.js index e63778466..8dd49045d 100644 --- a/src/mixins/analytics-mixin.spec.js +++ b/src/mixins/analytics-mixin.spec.js @@ -107,4 +107,17 @@ describe("analyticsMixin.js", () => { }]); }); + + test("Obj is not null after action prepended", () => { + //Arrange + const obj = {baseMethodName:"testMethodName", data:"testData"}; + const method = {name:"testMethodName", data:"testData" } + const action = "testAction"; + + //Act + analyticsMixin.methods.prependActionToMethod(obj, method, action); + + //Assert + expect(obj!=null); + }); }); \ No newline at end of file