adjusted endpoint and logic

This commit is contained in:
FrankRua 2022-05-03 15:08:19 -04:00
parent a14e3ca682
commit a42600f24c
6 changed files with 16 additions and 10 deletions

View file

@ -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",
}
};

View file

@ -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",

View file

@ -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: {} })

View file

@ -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;

View file

@ -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 = {}) => {

View file

@ -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: {}
});
},