INSR-8884: Better null/undefined handling for analytics events
This commit is contained in:
parent
9a7b452b98
commit
746b45e372
3 changed files with 17 additions and 15 deletions
|
|
@ -44,7 +44,8 @@ export default {
|
|||
return this.modelValue;
|
||||
},
|
||||
set(selectedMethod) {
|
||||
this.pushEventToGA('submit_order', 'payment_type_selected', analyticsPaymentTypeMap.get(selectedMethod), true);
|
||||
const paymentMethod = analyticsPaymentTypeMap.get(this.piaType) ?? 'UNKNOWN';
|
||||
this.pushEventToGA('submit_order', 'payment_type_selected', paymentMethod, true);
|
||||
this.$emit('update:modelValue', selectedMethod);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ import widgetFields from '@/constants/cms-widget-fields';
|
|||
import MaskaFormattedMasks from '@/constants/maska-masks';
|
||||
import { containsRecalParts } from '@/helpers/recal-helper';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
import partTypeStrings from '@/constants/part-type-strings';
|
||||
|
||||
export default {
|
||||
name: 'payment-method',
|
||||
|
|
@ -511,26 +512,26 @@ export default {
|
|||
handleAnalyticsEventsOnMounted() {
|
||||
const mobileOrInshop = this.mainStore.isMobileAppointment ? 'mobile' : 'in_shop';
|
||||
const verifiedOrNotVerified = this.mainStore.isVerified ? 'verified' : 'not_verified';
|
||||
const repairOrReplace = this.mainStore.isRepair ? 'repair' : 'replace';
|
||||
const repairOrReplace = this.mainStore.damage.isRepair ? 'repair' : 'replace';
|
||||
this.pushEventToGA('order_summary', 'safelite', `${mobileOrInshop}_${repairOrReplace}_${verifiedOrNotVerified}`, true);
|
||||
|
||||
if (containsRecalParts(this.mainStore.lineItems)) {
|
||||
let coverageType = '';
|
||||
let coverageTypeForLabel = '';
|
||||
if (this.mainStore.isITAC) {
|
||||
coverageType = 'ITAC';
|
||||
coverageTypeForLabel = 'ITAC';
|
||||
} else if (this.mainStore.isNoComp) {
|
||||
coverageType = 'no_comp';
|
||||
coverageTypeForLabel = 'no_comp';
|
||||
} else if (this.mainStore.isVerified) {
|
||||
coverageType = 'verified';
|
||||
coverageTypeForLabel = 'verified';
|
||||
} else {
|
||||
coverageType = 'unverified';
|
||||
coverageTypeForLabel = 'unverified';
|
||||
}
|
||||
const recalibrationType = this.mainStore.lineItems.glassParts?.find((part) => part.requiresRecalibration)?.recalibrationType;
|
||||
this.pushEventToGA(`recalibration_added_${coverageType}`, this.mainStore.vehicle.carId, `recal_type_${recalibrationType}`.replace(/ /g, '_').toLowerCase(), true);
|
||||
this.pushEventToGA(`recalibration_added_${coverageTypeForLabel}`, this.mainStore.vehicle.carId, `recal_type_${recalibrationType}`.replace(/ /g, '_').toLowerCase(), true);
|
||||
}
|
||||
|
||||
const hasFrontWiper = this.mainStore.lineItems.vaps.some((part) => part.partType === partTypeStrings.FRONT_WIPER);
|
||||
const hasRearWiper = this.mainStore.lineItems.vaps.some((part) => part.partType === partTypeStrings.REAR_WIPER);
|
||||
const hasFrontWiper = this.mainStore.lineItems?.vaps?.some((part) => part.partType === partTypeStrings.FRONT_WIPER);
|
||||
const hasRearWiper = this.mainStore.lineItems?.vaps?.some((part) => part.partType === partTypeStrings.REAR_WIPER);
|
||||
const wiperEventLabel = `front_${hasFrontWiper ? 'advanced' : 'none'}_rear_${hasRearWiper ? 'advanced' : 'none'}`;
|
||||
this.pushEventToGA('wipers', 'attached_to_order', wiperEventLabel, true);
|
||||
},
|
||||
|
|
@ -538,7 +539,7 @@ export default {
|
|||
this.pushEventToGA('order_summary', 'edit', 'contact_details', true);
|
||||
let action;
|
||||
let label;
|
||||
switch (this.mainStore.coverageType) {
|
||||
switch (this.mainStore.insuranceCoverage.coverageType) {
|
||||
case coverageType.Deductible:
|
||||
action = 'Covered';
|
||||
label = this.mainStore.currentDeductible;
|
||||
|
|
|
|||
|
|
@ -207,8 +207,8 @@ export default {
|
|||
methods: {
|
||||
openModalAction(eventData) {
|
||||
this.$refs[eventData.route].openModal();
|
||||
const packageName = analyticsServicePackageMap.get(eventData.packageName);
|
||||
const modalName = analyticsVapsModalMap.get(eventData.route);
|
||||
const packageName = analyticsServicePackageMap.get(eventData.packageName) ?? 'UNKNOWN_PACKAGE';
|
||||
const modalName = analyticsVapsModalMap.get(eventData.route) ?? 'UNKNOWN_MODAL';
|
||||
this.pushEventToGA('service_package', 'modal_displayed', `${packageName}_${modalName}_modal_displayed`, true);
|
||||
},
|
||||
arePagePrerequisitesValid() {
|
||||
|
|
@ -239,8 +239,8 @@ export default {
|
|||
}
|
||||
store.updateVaps(this.selectedVaps);
|
||||
store.updateServicePackage(this.selectedPackageTier);
|
||||
|
||||
const packageName = analyticsServicePackageMap.get(this.selectedPackageTier);
|
||||
|
||||
const packageName = analyticsServicePackageMap.get(this.selectedPackageTier) ?? 'UNKNOWN_PACKAGE';
|
||||
this.pushEventToGA('service_package', 'attached_a_package', packageName, true);
|
||||
|
||||
const scenario = store.isMobileAppointment
|
||||
|
|
|
|||
Loading…
Reference in a new issue