From e546bad283757216b7d50cafaf8efa19f76b7040 Mon Sep 17 00:00:00 2001 From: Katie Date: Mon, 3 Oct 2022 13:18:08 -0400 Subject: [PATCH 1/2] CSR-762 GA WIP --- src/App.vue | 16 +- .../base-input-button/base-input-button.vue | 198 +++++++++--------- .../button-question/button-question.vue | 29 ++- src/constants/store-actions.js | 10 +- src/constants/store-mutations.js | 10 +- src/main.js | 2 - src/mixins/analytics-mixin.js | 2 + src/mixins/base-mixin.js | 15 +- src/store/gaState.js | 72 ------- src/store/index.js | 12 +- src/ux-components/button-main/button-main.vue | 2 - 11 files changed, 152 insertions(+), 216 deletions(-) delete mode 100644 src/store/gaState.js diff --git a/src/App.vue b/src/App.vue index 71b56feaf..501c46fd9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,11 +2,25 @@ - + + + diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index 8d3abb287..7099e6227 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -125,7 +125,8 @@ export default { data() { return { primaryValue: "", - lastFocusedInputGroup: "", + // lastFocusedInputGroup: "", + lastPushedGaEventValue: null, }; }, computed: { @@ -197,6 +198,9 @@ export default { }) ); }, + isValueSelectedOnClick() { + return this.isMultiSelect || this.selectingInitiatesLoad; + }, }, methods: { formatString(str) { @@ -222,31 +226,46 @@ export default { }, handleAnswerChange(primaryAnswerValue) { this.primaryValue = primaryAnswerValue; - console.log("hAC: ", primaryAnswerValue) + + this.pushClickEventToGA(null, primaryAnswerValue); + this.$emit("buttonQuestionChange", primaryAnswerValue); this.$emit("update:modelValue", primaryAnswerValue); }, pushClickEventToGA(e, value) { - this.pushEventToGA( - this.$route.query[queryStrings.FMG_PAGE], - this.GaActions.CLICKED, - value?.toString() ?? this.primaryValue?.toString(), - true, - this.valueToLogType - ); + const valueToPushToGa = + value?.toString() ?? this.primaryValue?.toString(); + console.log({ + valueToPushToGa, + lastPushedGaEventValue: this.lastPushedGaEventValue, + }); + if (valueToPushToGa !== this.lastPushedGaEventValue) { + this.lastPushedGaEventValue = valueToPushToGa; + this.pushEventToGA( + this.$route.query[queryStrings.FMG_PAGE], + this.GaActions.CLICKED, + valueToPushToGa, + true, + this.valueToLogType + ); + } }, - handleFocus() { - this.$root.handleFocus({ - groupName: this.groupName, - value: this.primaryValue - }) + onFocusCallbackForRoot() { + if (!this.isValueSelectedOnClick) { + this.pushClickEventToGA(); + } }, - handleBlur() { - this.$root.handleBlur({ + handleFocus(e) { + this.$root.handleInputFocus({ groupName: this.groupName, - value: this.primaryValue - }) - } + }); + }, + handleBlur(e) { + this.$root.handleInputBlur({ + groupName: this.groupName, + onFocusCallback: this.onFocusCallbackForRoot, + }); + }, }, components: { listButton, diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index 9e99307ee..d6a8ced7e 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -61,39 +61,39 @@ export default { state: serviceZipValidationResponse.data.state, }; }, - pushRadioClickEventIfNecessary() { - const { - firedGaClickEventValues, - currentlySelectedValues, - lastFocusedInputGroup, - wasLastFocusedInputMultiselect, - } = this.$store.getters.gaClickInformation; + // pushRadioClickEventIfNecessary() { + // const { + // firedGaClickEventValues, + // currentlySelectedValues, + // lastFocusedInputGroup, + // wasLastFocusedInputMultiselect, + // } = this.$store.getters.gaClickInformation; - // Keyboard navigation - if ( - !wasLastFocusedInputMultiselect && - currentlySelectedValues[lastFocusedInputGroup] && - firedGaClickEventValues[lastFocusedInputGroup] != - currentlySelectedValues[lastFocusedInputGroup] - ) { - const value = - currentlySelectedValues[lastFocusedInputGroup]?.toString(); - // this.dispatchStoreAction( - // gaStoreActions.UPDATE_FIRED_GA_CLICK_EVENT_VALUES, - // { - // groupName: lastFocusedInputGroup, - // value: value, - // } - // ); + // // Keyboard navigation + // if ( + // !wasLastFocusedInputMultiselect && + // currentlySelectedValues[lastFocusedInputGroup] && + // firedGaClickEventValues[lastFocusedInputGroup] != + // currentlySelectedValues[lastFocusedInputGroup] + // ) { + // const value = + // currentlySelectedValues[lastFocusedInputGroup]?.toString(); + // // this.dispatchStoreAction( + // // gaStoreActions.UPDATE_FIRED_GA_CLICK_EVENT_VALUES, + // // { + // // groupName: lastFocusedInputGroup, + // // value: value, + // // } + // // ); - this.pushEventToGA( - this.$route.query[queryStrings.FMG_PAGE], - this.GaActions.CLICKED, - value, - true - ); - } - }, + // this.pushEventToGA( + // this.$route.query[queryStrings.FMG_PAGE], + // this.GaActions.CLICKED, + // value, + // true + // ); + // } + // }, }, computed: { storeActions() {