CSR-762 Remove pushing GA on autoselect

This commit is contained in:
Katie 2022-10-14 15:07:59 -04:00
parent 054b3b2456
commit cbfd62e3a8
7 changed files with 48 additions and 58 deletions

View file

@ -11,48 +11,12 @@
</template> </template>
<script> <script>
// TODO KO glass-part-question has nested button questions import { handleChildFocus } from "@/helpers/analytics-helper"
// TODO KO selectedValues - make consistent for checkbox and radio if possible
export default { export default {
name: "app", name: "app",
data() {
return {
lastFocusedInputGroupName: "",
onFocusCallback: null,
};
},
methods: { methods: {
handleChildFocus(e) { handleChildFocus: handleChildFocus
const targetType = e.target.type; }
if (targetType !== "radio" && targetType !== "checkbox") {
this.handleInputFocus({
groupName: null,
});
}
},
handleInputFocus(e) {
if (
e &&
this.lastFocusedInputGroupName !== e.groupName &&
this.onFocusCallback
) {
this.onFocusCallback();
}
},
handleInputBlur(e) {
if (e) {
this.lastFocusedInputGroupName = e.groupName;
this.onFocusCallback = e.onFocusCallback;
}
},
},
watch: {
$route: {
handler() {
this.lastFocusedInputGroup = null;
},
},
},
}; };
</script> </script>

View file

@ -26,6 +26,10 @@
import { useField } from "vee-validate"; import { useField } from "vee-validate";
import { toRef } from "vue"; import { toRef } from "vue";
import { queryStrings } from "@/constants/query-strings"; import { queryStrings } from "@/constants/query-strings";
import {
handleInputFocus,
handleInputBlur,
} from "@/helpers/analytics-helper";
import inputButtonWrapperMixin from "../../mixins/input-button-wrapper-mixin"; import inputButtonWrapperMixin from "../../mixins/input-button-wrapper-mixin";
export default { export default {
@ -59,7 +63,6 @@ export default {
isRequired: Boolean, isRequired: Boolean,
lastValuePushedToGa: [String, Number], lastValuePushedToGa: [String, Number],
setLastValuePushedToGa: Function, setLastValuePushedToGa: Function,
shouldPushClickEventToGAOnMount: Boolean,
}, },
data() { data() {
return { return {
@ -68,11 +71,7 @@ export default {
}, },
mounted() { mounted() {
if (this.isChecked) { if (this.isChecked) {
if (this.shouldPushClickEventToGAOnMount) { this.handleChange(this.modelValue);
this.handleEventAction(this.eventTypes.MOUNT)
} else {
this.handleChange(this.modelValue);
}
} }
}, },
methods: { methods: {
@ -92,7 +91,6 @@ export default {
case this.eventTypes.CLICK: case this.eventTypes.CLICK:
case this.eventTypes.ENTER: case this.eventTypes.ENTER:
case this.eventTypes.SPACE: case this.eventTypes.SPACE:
case this.eventTypes.MOUNT:
this.handleClick(e); this.handleClick(e);
this.handlePushClickEventToGACheck( this.handlePushClickEventToGACheck(
this.eventTypes.CLICK this.eventTypes.CLICK
@ -130,12 +128,12 @@ export default {
this.$emit("update:modelValue", this.valueToEmit); this.$emit("update:modelValue", this.valueToEmit);
}, },
handleFocus() { handleFocus() {
this.$root.handleInputFocus({ handleInputFocus({
groupName: this.groupName, groupName: this.groupName,
}); });
}, },
handleBlur() { handleBlur() {
this.$root.handleInputBlur({ handleInputBlur({
groupName: this.groupName, groupName: this.groupName,
onFocusCallback: this.handlePushClickEventToGACheck, onFocusCallback: this.handlePushClickEventToGACheck,
}); });
@ -192,7 +190,6 @@ export default {
ENTER: "enter", ENTER: "enter",
SPACE: "space", SPACE: "space",
CLICK: "click", CLICK: "click",
MOUNT: "mount"
}; };
}, },
}, },

View file

@ -52,7 +52,6 @@
:selectOnKeypress="selectOnKeypress" :selectOnKeypress="selectOnKeypress"
:lastValuePushedToGa="lastValuePushedToGa" :lastValuePushedToGa="lastValuePushedToGa"
:setLastValuePushedToGa="setLastValuePushedToGa" :setLastValuePushedToGa="setLastValuePushedToGa"
:shouldPushClickEventToGAOnMount="shouldPushClickEventToGAOnMount"
v-model="selectedValues" v-model="selectedValues"
/> />
<!-- For nested questions --> <!-- For nested questions -->
@ -122,7 +121,6 @@ export default {
type: Boolean, type: Boolean,
default: true, default: true,
}, },
shouldPushClickEventToGAOnMount: Boolean
}, },
data() { data() {
return { return {

View file

@ -0,0 +1,34 @@
let lastFocusedInputGroupName = "";
let onFocusCallback = null;
const handleChildFocus = (e) => {
const targetType = e.target.type;
if (targetType !== "radio" && targetType !== "checkbox") {
handleInputFocus({
groupName: null,
});
}
}
const handleInputFocus = (e) => {
if (
e &&
lastFocusedInputGroupName !== e.groupName &&
onFocusCallback
) {
onFocusCallback();
}
}
const handleInputBlur = (e) => {
if (e) {
lastFocusedInputGroupName = e.groupName;
onFocusCallback = e.onFocusCallback;
}
}
export {
handleChildFocus,
handleInputFocus,
handleInputBlur
}

View file

@ -27,9 +27,7 @@
isRequired isRequired
:groupName="`${glassLocation}-${glassName}-${selectedTint}`" :groupName="`${glassLocation}-${glassName}-${selectedTint}`"
:validationRules="partValidationRules" :validationRules="partValidationRules"
:shouldPushClickEventToGAOnMount=" />
shouldPushClickEventToGAOnMount
" />
</div> </div>
</div> </div>
</buttonQuestion> </buttonQuestion>
@ -57,7 +55,6 @@ export default {
glassColorQuestion: "", glassColorQuestion: "",
glassFeatureQuestion: "", glassFeatureQuestion: "",
selectedTint: "", selectedTint: "",
shouldPushClickEventToGAOnMount: true,
}; };
}, },
props: { props: {
@ -224,7 +221,6 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
if (this.modelValue !== undefined) { if (this.modelValue !== undefined) {
// Populate button-question model-value if parts data already exists in VueX // Populate button-question model-value if parts data already exists in VueX
this.shouldPushClickEventToGAOnMount = false;
this.selectedTint = this.modelValue?.color this.selectedTint = this.modelValue?.color
} }
}); });

View file

@ -48,6 +48,8 @@ export default {
pushEventToGA(category, action, label, pushToLogApp = false, valueToLogType = null) { pushEventToGA(category, action, label, pushToLogApp = false, valueToLogType = null) {
const currentPageName = getPageNameByQueryString(); const currentPageName = getPageNameByQueryString();
const labelToLog = getValueToLog(label, valueToLogType); const labelToLog = getValueToLog(label, valueToLogType);
console.log("PUSHING: ", labelToLog)
const eventToBePushed = { const eventToBePushed = {
'event': GaEvents.GENERIC_EVENT, 'event': GaEvents.GENERIC_EVENT,
'category': category, 'category': category,
@ -140,7 +142,7 @@ export default {
noSession() { noSession() {
return getSessionKeyValue() === 0 || getSessionIdValue() === '00000000-0000-0000-0000-000000000000'; return getSessionKeyValue() === 0 || getSessionIdValue() === '00000000-0000-0000-0000-000000000000';
} },
}, },
computed: { computed: {
analyticsPageEvents() { analyticsPageEvents() {

View file

@ -22,7 +22,6 @@ export default {
}, },
lastValuePushedToGa: [String, Number], lastValuePushedToGa: [String, Number],
setLastValuePushedToGa: Function, setLastValuePushedToGa: Function,
shouldPushClickEventToGAOnMount: Boolean,
}, },
computed: { computed: {
selectedValue: { selectedValue: {