From cb8196ea7e5274738838df541339acb3a0f9c8ea Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Fri, 13 Dec 2019 12:17:29 -0500 Subject: [PATCH 1/2] Add new environment variable to discern between prod, staging, and development environments. --- .env.default | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.default b/.env.default index 0a4b9471a..8407bf87f 100644 --- a/.env.default +++ b/.env.default @@ -5,3 +5,4 @@ ENVIRONMENT REACT_APP_BLOCLINK_URL REACT_APP_MAILCHIMP_URL REACT_APP_BLOCPOWER_CONTACT +REACT_APP_ENVIRONMENT -- GitLab From 48890bba12b4ad6a5df6aaac0ca1a88cc926c0be Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Fri, 13 Dec 2019 12:18:52 -0500 Subject: [PATCH 2/2] Move GA initialization out of render function since it might log too many events and conditionally use GA only in prod. --- src/App.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/App.js b/src/App.js index f2ce82797..7042bbe75 100644 --- a/src/App.js +++ b/src/App.js @@ -592,7 +592,12 @@ class App extends React.Component { }; } - componentDidMount() { } + componentDidMount() { + if(process.env.REACT_APP_ENVIRONMENT==='production'){ + ReactGA.initialize('UA-67611405-11'); + ReactGA.pageview('/intake'); + } + } nextQuestion = (question, answer, value) => { const questionAnswers = {}; @@ -862,9 +867,6 @@ class App extends React.Component { } render() { - ReactGA.initialize('UA-67611405-11'); - ReactGA.pageview('/intake'); - const building = this.props.building; // const questions = this.props.questions; const contact = this.props.contact; -- GitLab