CSR-1439 email provided ga event
This commit is contained in:
parent
34805e7910
commit
bfdda1fcf0
4 changed files with 30 additions and 3 deletions
|
|
@ -1,13 +1,20 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import analyticsMixIn from "@/mixins/analytics-mixin.js";
|
import analyticsMixIn from "@/mixins/analytics-mixin.js";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
import router from "@/router";
|
||||||
|
|
||||||
import { applicationConfig } from "@/constants/application-config.js";
|
import { applicationConfig } from "@/constants/application-config.js";
|
||||||
import { GaCategories, GaActions, GaLabels } from "@/constants/analytics";
|
import { GaCategories, GaActions, GaLabels } from "@/constants/analytics";
|
||||||
import { headerKeys } from "@/constants/header-keys";
|
import { headerKeys } from "@/constants/header-keys";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
callHttpClient({ method, endpoint, payload, logApiCall = true }) {
|
callHttpClient({
|
||||||
|
method,
|
||||||
|
endpoint,
|
||||||
|
payload,
|
||||||
|
logApiCall = true,
|
||||||
|
additionalSuccessEventDataHandler,
|
||||||
|
}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
|
const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
|
||||||
let payloadAndAnalyticsData = {};
|
let payloadAndAnalyticsData = {};
|
||||||
|
|
@ -26,10 +33,16 @@ export default {
|
||||||
}).then(
|
}).then(
|
||||||
(response) => {
|
(response) => {
|
||||||
if (logApiCall) {
|
if (logApiCall) {
|
||||||
|
let additionalEventData = "";
|
||||||
|
if (additionalSuccessEventDataHandler) {
|
||||||
|
additionalEventData = "_" + additionalSuccessEventDataHandler(response);
|
||||||
|
}
|
||||||
|
const pageName = analyticsMixIn.methods.getPageName();
|
||||||
|
const nextPageName = router.getNextPage() || pageName;
|
||||||
analyticsMixIn.methods.pushEventToGA(
|
analyticsMixIn.methods.pushEventToGA(
|
||||||
GaCategories.API_RESPONSE,
|
GaCategories.API_RESPONSE,
|
||||||
GaActions.RESULT,
|
`${nextPageName}_${endpoint}`,
|
||||||
`${GaLabels.SUCCESS}_${endpoint}`,
|
`${GaLabels.SUCCESS}${additionalEventData}`,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,10 @@ import { applicationConfig } from "../constants/application-config";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
|
getPageName() {
|
||||||
|
return getPageNameByQueryString();
|
||||||
|
},
|
||||||
|
|
||||||
logPageView(pageEvent) {
|
logPageView(pageEvent) {
|
||||||
const currentPageName = getPageNameByQueryString();
|
const currentPageName = getPageNameByQueryString();
|
||||||
var payload = {
|
var payload = {
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,12 @@ router.overrideNavigation = (
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
router.getNextPage = () => nextPageName;
|
||||||
|
|
||||||
|
// PRIVATE VARIABLES
|
||||||
|
|
||||||
|
var nextPageName;
|
||||||
|
|
||||||
// PRIVATE FUNCTIONS
|
// PRIVATE FUNCTIONS
|
||||||
|
|
||||||
// Navigate to the next route, depending on the scenario.
|
// Navigate to the next route, depending on the scenario.
|
||||||
|
|
@ -249,6 +255,8 @@ async function navigate(
|
||||||
if (destinationFmgPageValue !== undefined) {
|
if (destinationFmgPageValue !== undefined) {
|
||||||
// We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our fmgPage one.
|
// We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our fmgPage one.
|
||||||
|
|
||||||
|
nextPageName = destinationFmgPageValue;
|
||||||
|
|
||||||
// Update page data to the store for next page if provided. Otherwise, keep existing page data or set to empty object
|
// Update page data to the store for next page if provided. Otherwise, keep existing page data or set to empty object
|
||||||
const existingPageDataForPage = store.getters.pageData(destinationFmgPageValue);
|
const existingPageDataForPage = store.getters.pageData(destinationFmgPageValue);
|
||||||
baseMixin.methods.savePageDataToStore(
|
baseMixin.methods.savePageDataToStore(
|
||||||
|
|
|
||||||
|
|
@ -1093,6 +1093,8 @@ export const actions = {
|
||||||
eon: order.eon,
|
eon: order.eon,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
additionalSuccessEventDataHandler: (response) =>
|
||||||
|
"Email provided: " + (order.customer.emailAddress ? "true" : "false"),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadSession(
|
loadSession(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue