Rename consts

This commit is contained in:
FrankRua 2022-04-28 18:39:11 -04:00
parent a6f8a6289e
commit a638f63cdd
6 changed files with 54 additions and 44 deletions

View file

@ -135,7 +135,7 @@ export default {
},
handleCheckedChanged(val) {
this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.analyticsActions.CLICKED, val.value, true);
this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.GaActions.CLICKED, val.value, true);
if(this.isMultiSelect && this.selectedValues) {
// Add or remove item to array of data to emit

View file

@ -1,22 +0,0 @@
const analyticsPageEvents = {
ENTRY: "ENTRY",
EVENT: "EVENT"
};
const analyticsCategories = {
API_RESPONSE: 'Api_Response',
EVOX: 'Evox'
};
const analyticsActions = {
RESULT: 'Result',
CLICKED: 'Clicked',
VIF: 'vif'
};
const analyticsLabels = {
SUCCESS: 'Success',
ERROR: 'Error'
};
export { analyticsPageEvents, analyticsCategories, analyticsActions, analyticsLabels};

View file

@ -0,0 +1,29 @@
const analyticsPageEvents = {
ENTRY: "ENTRY",
EVENT: "EVENT"
};
// GA Constants
const GaEvents = {
GENERIC_EVENT: 'ga_Event',
PAGE_VIEW_EVENT : 'logPageview'
};
const GaCategories = {
API_RESPONSE: 'Api_Response',
EVOX: 'Evox'
};
const GaActions = {
RESULT: 'Result',
CLICKED: 'Clicked',
VIF: 'vif'
};
const GaLabels = {
SUCCESS: 'Success',
ERROR: 'Error'
};
export { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents};

View file

@ -1,6 +1,6 @@
import axios from "axios";
import { applicationConfig } from "@/constants/application-config.js";
import { analyticsCategories, analyticsActions,analyticsLabels} from "@/constants/analytics-events";
import { GaCategories, GaActions, GaLabels } from "@/constants/analytics";
import analyticsMixIn from "@/mixins/analytics-mixin.js";
import httpStatusCodes from "http-status-codes";
@ -22,23 +22,25 @@ export default {
(response) => {
if (response.status == httpStatusCodes.OK) {
if (response.data == undefined) {
analyticsMixIn.methods.pushEventToGA(analyticsCategories.API_RESPONSE, analyticsActions.RESULT,
`${analyticsLabels.ERROR}_${endpoint}`, true);
return reject(response);
analyticsMixIn.methods.pushEventToGA(GaCategories.API_RESPONSE, GaActions.RESULT,
`${GaLabels.ERROR}_${endpoint}`, true);
reject(response);
} else {
analyticsMixIn.methods.pushEventToGA(analyticsCategories.API_RESPONSE, analyticsActions.RESULT,
`${analyticsLabels.SUCCESS}_${endpoint}`, true);
return resolve(response);
analyticsMixIn.methods.pushEventToGA(GaCategories.API_RESPONSE, GaActions.RESULT,
`${GaLabels.SUCCESS}_${endpoint}`, true);
resolve(response);
}
}
},
(error) => {
console.error(error);
analyticsMixIn.methods.pushEventToGA(analyticsCategories.API_RESPONSE, analyticsActions.RESULT,
`${analyticsLabels.ERROR}_${endpoint}`, true);
analyticsMixIn.methods.pushEventToGA(GaCategories.API_RESPONSE, GaActions.RESULT,
`${GaLabels.ERROR}_${endpoint}`, true);
return reject(error.response);
}
);

View file

@ -143,7 +143,7 @@ export default {
},
mounted(){
if(this.$store.getters.vehicle.imageVifNumber){
this.pushEventToGA(this.analyticsCategories.EVOX, `${this.analyticsActions.VIF}_${this.$store.getters.vehicle.imageVifNumber}`,
this.pushEventToGA(this.GaCategories.EVOX, `${this.GaActions.VIF}_${this.$store.getters.vehicle.imageVifNumber}`,
this.$store.getters.vehicle.carId, true);
}
},

View file

@ -1,8 +1,8 @@
import { storeActions } from "@/constants/store-actions";
import { getDeviceIdValue, getSessionIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
import { queryStrings } from "@/constants/query-strings";
import { analyticsPageEvents, analyticsCategories, analyticsActions, analyticsLabels } from "@/constants/analytics-events";
import { experimentSettings } from "@/constants/experiments";
import { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents } from "@/constants/analytics";
import baseMixin from "@/mixins/base-mixin";
@ -33,7 +33,7 @@ export default {
pushEventToGA(category, action, label, pushToLogApp = false) {
const eventToBePushed = {
'event': 'ga_event',
'event': GaEvents.GENERIC_EVENT,
'category': category,
'action': action,
'label': label,
@ -46,18 +46,19 @@ export default {
if (pushToLogApp) {
this.logEvent(currentPageName, undefined, category, action, label, undefined);
}
},
pushPageViewToGA() {
const pageViewEvent = {
'event': 'logPageview',
'event': GaEvents.PAGE_VIEW_EVENT,
'pagePath': `/fmg/?${queryStrings.FMG_PAGE}=${currentPageName}`,
'pageTitle': currentPageName
};
pushToDataLayerIfDefined(pageViewEvent);
this.logEvent(currentPageName, analyticsPageEvents.ENTRY);
//this.logEvent(currentPageName, analyticsPageEvents.ENTRY);
},
pushExperimentsToDataLayer(experiments){
@ -86,14 +87,14 @@ export default {
analyticsPageEvents() {
return analyticsPageEvents;
},
analyticsCategories() {
return analyticsCategories;
GaCategories() {
return GaCategories;
},
analyticsActions() {
return analyticsActions;
GaActions() {
return GaActions;
},
analyticsLabels() {
return analyticsLabels;
GaLabels() {
return GaLabels;
}
}
};