From a42600f24cf7d2fc062facff0a7f69ac91b1fb24 Mon Sep 17 00:00:00 2001 From: FrankRua Date: Tue, 3 May 2022 15:08:19 -0400 Subject: [PATCH] adjusted endpoint and logic --- src/constants/endpoints.js | 4 ++-- src/constants/store-actions.js | 2 +- src/global-methods.js | 5 ++++- src/mixins/analytics-mixin.js | 2 +- src/router/index.js | 7 +++++-- src/store/index.js | 6 +++--- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index ca1555e7b..13ad55b34 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -75,8 +75,8 @@ const endpoints = { url: "/analytics/api/v1/analytics/activity", method: "POST", }, - GetExperimentsByUserForGa: { - url: "/analytics/api/v1/analytics/get-experiments-for-GA", + GetExperimentsByUser: { + url: "/analytics/api/v1/analytics/get-experiments", method: "GET", } }; diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 74dac5043..fe100d5e3 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -20,7 +20,7 @@ const storeActions = { VALIDATE_ZIP: "validateZip", LOG_EXPERIMENT_EXPOSURE: "logExperimentExposure", LOG_ACTIVITY: "logActivity", - GET_EXPERIMENTS_BY_USER_FOR_GA: "getExperimentsByUserForGa", + GET_EXPERIMENTS_BY_USER: "GetExperimentsByUser", // DEPENDENCY MUTATIONS RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies", diff --git a/src/global-methods.js b/src/global-methods.js index 5e4d04ea3..71f153bdf 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -7,7 +7,10 @@ import { GaCategories, GaActions, GaLabels } from "@/constants/analytics"; export default { callHttpClient({ method, endpoint, payload, logApiCall = true }) { return new Promise((resolve, reject) => { - const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; + let cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; + if(endpoint.includes("analytics")){ + cfDistroUrl = 'https://localhost:44324'; + } const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass" }); axios({ method: method, url: cfDistroUrl + endpoint, data: payloadAndAnalyticsData, crossDomain: true, responseType: {} }) diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index 85402c8cb..d4cf7ccd1 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -62,7 +62,7 @@ export default { }, pushExperimentsToDataLayer(experiments) { - experiments?.data?.forEach(exp => { + experiments?.forEach(exp => { // Set Google Dimension Index based on experiment settings. let googleDimensionIndex = 99; diff --git a/src/router/index.js b/src/router/index.js index 1af18ec1b..f11bd4228 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -127,8 +127,11 @@ router.afterEach(async (to, from) => { // Push page view to GA analyticsMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]); - const assignedExperiments = await baseMixin.methods.dispatchStoreAction(storeActions.GET_EXPERIMENTS_BY_USER_FOR_GA, { userId: getDeviceIdValue() }); - analyticsMixin.methods.pushExperimentsToDataLayer(assignedExperiments); + baseMixin.methods.dispatchStoreAction(storeActions.GET_EXPERIMENTS_BY_USER, { userId: getDeviceIdValue() }) + .then( (response) => { + analyticsMixin.methods.pushExperimentsToDataLayer(response.data); + }); + }); router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => { diff --git a/src/store/index.js b/src/store/index.js index 66005abd5..c12caff07 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -459,10 +459,10 @@ export const actions = { }); }, - getExperimentsByUserForGa(context, { userId }){ + GetExperimentsByUser(context, { userId }){ return globalMethods.callHttpClient({ - method: endpoints.GetExperimentsByUserForGa.method, - endpoint: `${endpoints.GetExperimentsByUserForGa.url}/${userId}`, + method: endpoints.GetExperimentsByUser.method, + endpoint: `${endpoints.GetExperimentsByUser.url}/${userId}`, payload: {} }); },