CSR-1439 email provided ga event

This commit is contained in:
Matt Caimi 2023-06-22 09:22:57 -04:00
parent 34805e7910
commit bfdda1fcf0
4 changed files with 30 additions and 3 deletions

View file

@ -1,13 +1,20 @@
import axios from "axios";
import analyticsMixIn from "@/mixins/analytics-mixin.js";
import store from "@/store";
import router from "@/router";
import { applicationConfig } from "@/constants/application-config.js";
import { GaCategories, GaActions, GaLabels } from "@/constants/analytics";
import { headerKeys } from "@/constants/header-keys";
export default {
callHttpClient({ method, endpoint, payload, logApiCall = true }) {
callHttpClient({
method,
endpoint,
payload,
logApiCall = true,
additionalSuccessEventDataHandler,
}) {
return new Promise((resolve, reject) => {
const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
let payloadAndAnalyticsData = {};
@ -26,10 +33,16 @@ export default {
}).then(
(response) => {
if (logApiCall) {
let additionalEventData = "";
if (additionalSuccessEventDataHandler) {
additionalEventData = "_" + additionalSuccessEventDataHandler(response);
}
const pageName = analyticsMixIn.methods.getPageName();
const nextPageName = router.getNextPage() || pageName;
analyticsMixIn.methods.pushEventToGA(
GaCategories.API_RESPONSE,
GaActions.RESULT,
`${GaLabels.SUCCESS}_${endpoint}`,
`${nextPageName}_${endpoint}`,
`${GaLabels.SUCCESS}${additionalEventData}`,
true
);
}

View file

@ -23,6 +23,10 @@ import { applicationConfig } from "../constants/application-config";
export default {
methods: {
getPageName() {
return getPageNameByQueryString();
},
logPageView(pageEvent) {
const currentPageName = getPageNameByQueryString();
var payload = {

View file

@ -226,6 +226,12 @@ router.overrideNavigation = (
next();
};
router.getNextPage = () => nextPageName;
// PRIVATE VARIABLES
var nextPageName;
// PRIVATE FUNCTIONS
// Navigate to the next route, depending on the scenario.
@ -249,6 +255,8 @@ async function navigate(
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.
nextPageName = destinationFmgPageValue;
// 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);
baseMixin.methods.savePageDataToStore(

View file

@ -1093,6 +1093,8 @@ export const actions = {
eon: order.eon,
},
},
additionalSuccessEventDataHandler: (response) =>
"Email provided: " + (order.customer.emailAddress ? "true" : "false"),
});
},
loadSession(