diff --git a/src/actions.js b/src/actions.js index 506aea73b1e5daac03a4c5e8fe52199c72bd5cf9..29609efe6278b1948968173be2cb36ff05b045b9 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" }); diff --git a/src/reducers/reducer.js b/src/reducers/reducer.js index 313a08c919d80bb8217220aafdfe57a57cd7a7e1..d5bc6bddc8c6af7e34840506a14674654f563cab 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: { @@ -176,47 +161,16 @@ const reducer = (state = intialState, action) => { error: action.msg, }, }; - case "QuestionRequested": - console.log('QuestionRequested'); + case "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 { ...state, complete: {