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) { 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) { if(this.isMultiSelect && this.selectedValues) {
// Add or remove item to array of data to emit // 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 axios from "axios";
import { applicationConfig } from "@/constants/application-config.js"; 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 analyticsMixIn from "@/mixins/analytics-mixin.js";
import httpStatusCodes from "http-status-codes"; import httpStatusCodes from "http-status-codes";
@ -22,22 +22,24 @@ export default {
(response) => { (response) => {
if (response.status == httpStatusCodes.OK) { if (response.status == httpStatusCodes.OK) {
if (response.data == undefined) { 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 { } 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) => { (error) => {
console.error(error); console.error(error);
analyticsMixIn.methods.pushEventToGA(analyticsCategories.API_RESPONSE, analyticsActions.RESULT, analyticsMixIn.methods.pushEventToGA(GaCategories.API_RESPONSE, GaActions.RESULT,
`${analyticsLabels.ERROR}_${endpoint}`, true); `${GaLabels.ERROR}_${endpoint}`, true);
return reject(error.response); return reject(error.response);
} }

View file

@ -143,7 +143,7 @@ export default {
}, },
mounted(){ mounted(){
if(this.$store.getters.vehicle.imageVifNumber){ 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); this.$store.getters.vehicle.carId, true);
} }
}, },

View file

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