Merge pull request #1175 from Safelite/feature/CSR-1439
CSR-1439 email provided ga event
This commit is contained in:
commit
c1e8e5eaa7
4 changed files with 31 additions and 3 deletions
|
|
@ -1,13 +1,21 @@
|
|||
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, isFormData = false }) {
|
||||
callHttpClient({
|
||||
method,
|
||||
endpoint,
|
||||
payload,
|
||||
logApiCall = true,
|
||||
isFormData = false,
|
||||
additionalSuccessEventDataHandler,
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
|
||||
let payloadAndAnalyticsData = {};
|
||||
|
|
@ -31,10 +39,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
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ import { applicationConfig } from "../constants/application-config";
|
|||
|
||||
export default {
|
||||
methods: {
|
||||
getPageName() {
|
||||
return getPageNameByQueryString();
|
||||
},
|
||||
|
||||
logPageView(pageEvent) {
|
||||
const currentPageName = getPageNameByQueryString();
|
||||
var payload = {
|
||||
|
|
|
|||
|
|
@ -222,6 +222,12 @@ router.overrideNavigation = (
|
|||
next();
|
||||
};
|
||||
|
||||
router.getNextPage = () => nextPageName;
|
||||
|
||||
// PRIVATE VARIABLES
|
||||
|
||||
var nextPageName;
|
||||
|
||||
// PRIVATE FUNCTIONS
|
||||
|
||||
// Navigate to the next route, depending on the scenario.
|
||||
|
|
@ -245,6 +251,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(
|
||||
|
|
|
|||
|
|
@ -1391,6 +1391,8 @@ export const actions = {
|
|||
eon: order.eon,
|
||||
},
|
||||
},
|
||||
additionalSuccessEventDataHandler: (response) =>
|
||||
"Email provided: " + (order.customer.emailAddress ? "true" : "false"),
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue