From cf04c3564b95959ea9b1f037d646c5c94005ce68 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Thu, 7 Nov 2019 23:02:50 -0500 Subject: [PATCH 1/3] Log GA event in actions --- src/actions.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/actions.js b/src/actions.js index 506aea73b..29609efe6 100644 --- a/src/actions.js +++ b/src/actions.js @@ -1,9 +1,15 @@ import axios from 'axios'; +import ReactGA from 'react-ga'; +import { initialQuestions } from './constants'; // asynchronous action creator export const verifyUser = (user) => { const blocLinkUrl = process.env.REACT_APP_BLOCLINK_URL; - console.log(blocLinkUrl) + ReactGA.event({ + category: 'Call to Action', + action: 'Button', + label: 'Verify User' + }); return (dispatch) => { dispatch({ type: "UserRequested" }); return axios.put( @@ -21,6 +27,11 @@ export const verifyUser = (user) => { // asynchronous action creator export const verifyToken = (user) => { const blocLinkUrl = process.env.REACT_APP_BLOCLINK_URL; + ReactGA.event({ + category: 'Call to Action', + action: 'Link', + label: 'Verify Token' + }); return (dispatch) => { dispatch({ type: "TokenRequested" }); return axios.put( @@ -38,7 +49,11 @@ export const verifyToken = (user) => { // asynchronous action creator export const submitBuilding = (data) => { const blocLinkUrl = process.env.REACT_APP_BLOCLINK_URL; - console.log(blocLinkUrl) + ReactGA.event({ + category: 'Call to Action', + action: 'Button', + label: 'Submit Building' + }); return (dispatch) => { dispatch({ type: "BuildingRequested" }); return axios.put( @@ -55,6 +70,16 @@ export const submitBuilding = (data) => { // asynchronous action creator export const submitAnswer = (data) => { + Object.keys(initialQuestions).forEach(question => { + const questionId = initialQuestions[question].id; + if (questionId!=null & parseInt(data.questionId)===questionId){ + ReactGA.event({ + category: 'Call to Action', + action: 'Button', + label: 'Submit Answer '+question + }); + } + }); const blocLinkUrl = process.env.REACT_APP_BLOCLINK_URL; return (dispatch) => { dispatch({ type: "AnswerRequested" }); @@ -71,6 +96,11 @@ export const submitAnswer = (data) => { } export const completeQuestionnaire = (user) => { + ReactGA.event({ + category: 'Call to Action', + action: 'Button', + label: 'Submit Questionnaire' + }); const blocLinkUrl = process.env.REACT_APP_BLOCLINK_URL; return (dispatch) => { dispatch({ type: "CompleteRequested" }); -- GitLab From a41195e31316c7bb7639ed1c524d09f03028e296 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Thu, 7 Nov 2019 23:03:28 -0500 Subject: [PATCH 2/3] Remove repeat values in reducer --- src/reducers/reducer.js | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/reducers/reducer.js b/src/reducers/reducer.js index 313a08c91..5a4d2296b 100644 --- a/src/reducers/reducer.js +++ b/src/reducers/reducer.js @@ -176,45 +176,16 @@ const reducer = (state = intialState, action) => { error: action.msg, }, }; - case "QuestionRequested": - console.log('QuestionRequested'); + case "CompleteRequested": + console.log('CompleteRequested'); return { ...state, - questions: { + complete: { ...state.questions, loading: true, error: false, }, }; - case "QuestionSucceeded": - console.log('QuestionSucceeded'); - return { - ...state, - questions: { - data: action.data.data, - loading: false, - error: false, - }, - }; - case "QuestionFailed": - console.log('QuestionFailed'); - return { - ...state, - questions: { - loading: false, - error: action.msg, - }, - }; - case "CompleteRequested": - console.log('CompleteRequested'); - return { - ...state, - complete: { - ...state.questions, - loading: true, - error: false, - }, - }; case "CompleteSucceeded": console.log('CompleteSucceeded'); return { -- GitLab From 6177b6adf0f42f0dd45fcaf14b6b7a36e6b3315e Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Fri, 8 Nov 2019 14:55:16 -0500 Subject: [PATCH 3/3] remove console log --- src/reducers/reducer.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/reducers/reducer.js b/src/reducers/reducer.js index 5a4d2296b..d5bc6bddc 100644 --- a/src/reducers/reducer.js +++ b/src/reducers/reducer.js @@ -24,7 +24,6 @@ const intialState = { const reducer = (state = intialState, action) => { switch (action.type) { case "UserRequested": - console.log('UserRequested'); return { ...state, user: { @@ -34,7 +33,6 @@ const reducer = (state = intialState, action) => { }, }; case "UserSucceeded": - console.log('UserSucceeded'); return { ...state, user: { @@ -44,7 +42,6 @@ const reducer = (state = intialState, action) => { }, }; case "UserFailed": - console.log('UserFailed'); return { ...state, user: { @@ -54,7 +51,6 @@ const reducer = (state = intialState, action) => { }, }; case "TokenRequested": - console.log('TokenRequested'); return { ...state, token: { @@ -64,7 +60,6 @@ const reducer = (state = intialState, action) => { }, }; case "TokenSucceeded": - console.log('TokenSucceeded'); return { ...state, token: { @@ -74,7 +69,6 @@ const reducer = (state = intialState, action) => { }, }; case "TokenFailed": - console.log('TokenFailed'); return { ...state, token: { @@ -84,7 +78,6 @@ const reducer = (state = intialState, action) => { }, }; case "BuildingRequested": - console.log('BuildingRequested'); return { ...state, buildings: { @@ -94,7 +87,6 @@ const reducer = (state = intialState, action) => { }, }; case "BuildingSucceeded": { - console.log('BuildingSucceeded'); const userBuildingId = action.data.data.data.userBuildingId; const buildings = state.buildings; buildings.data[userBuildingId] = {}; @@ -108,7 +100,6 @@ const reducer = (state = intialState, action) => { }; } case "BuildingFailed": - console.log('BuildingFailed'); return { ...state, buildings: { @@ -118,7 +109,6 @@ const reducer = (state = intialState, action) => { }, }; case "AnswerRequested": - console.log('AnswerRequested'); return { ...state, questions: { @@ -128,7 +118,6 @@ const reducer = (state = intialState, action) => { }, }; case "AnswerSucceeded": - console.log('AnswerSucceeded'); return { ...state, questions: { @@ -138,7 +127,6 @@ const reducer = (state = intialState, action) => { }, }; case "AnswerFailed": - console.log('AnswerFailed'); return { ...state, questions: { @@ -148,7 +136,6 @@ const reducer = (state = intialState, action) => { }, }; case "QuestionRequested": - console.log('QuestionRequested'); return { ...state, questions: { @@ -158,7 +145,6 @@ const reducer = (state = intialState, action) => { }, }; case "QuestionSucceeded": - console.log('QuestionSucceeded'); return { ...state, questions: { @@ -168,7 +154,6 @@ const reducer = (state = intialState, action) => { }, }; case "QuestionFailed": - console.log('QuestionFailed'); return { ...state, questions: { @@ -177,7 +162,6 @@ const reducer = (state = intialState, action) => { }, }; case "CompleteRequested": - console.log('CompleteRequested'); return { ...state, complete: { @@ -187,7 +171,6 @@ const reducer = (state = intialState, action) => { }, }; case "CompleteSucceeded": - console.log('CompleteSucceeded'); return { ...state, complete: { -- GitLab