From cbb7f4c800fae511b13f7481dbfb055156dc8add Mon Sep 17 00:00:00 2001
From: "Lucian I. Last"
Date: Fri, 16 Nov 2018 15:06:00 +0100
Subject: [PATCH] Add environment variable to disable Google Analytics. #70
---
Dockerfile | 4 +++-
README.md | 2 ++
lib/components/App.js | 8 +++++---
package.json | 2 ++
webpack.config.js | 16 +++++++++++++++-
5 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index a63a7b1..96890f9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,8 @@
FROM node:latest
MAINTAINER Alex Kern
-
+
+ENV GA_ACCESS_TOKEN
+
COPY . ./
RUN npm install && npm run build
diff --git a/README.md b/README.md
index 00992c3..39d1944 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,8 @@ You can also use [zeit/now](https://zeit.co/now):
If you'd like to use [Twilio's STUN/TURN service](https://www.twilio.com/stun-turn) for better connectivity behind NATs, you can specify your SID and token using the `TWILIO_SID` and `TWILIO_TOKEN` environment variables, respectively.
+If you want to use [Google Analytics](https://marketingplatform.google.com/about/analytics/), you can specify your UA code using the `GA_ACCESS_TOKEN="UA-00000000-1"` environment variable.
+
## Development
$ git clone https://github.com/kern/filepizza.git
diff --git a/lib/components/App.js b/lib/components/App.js
index daabd7a..ca40ec0 100644
--- a/lib/components/App.js
+++ b/lib/components/App.js
@@ -6,8 +6,10 @@ import SupportStore from "../stores/SupportStore";
import { RouteHandler } from "react-router";
import ga from "react-google-analytics";
-ga("create", "UA-62785624-1", "auto");
-ga("send", "pageview");
+if (process.env.GA_ACCESS_TOKEN) {
+ ga("create", process.env.GA_ACCESS_TOKEN, "auto");
+ ga("send", "pageview");
+}
export default class App extends React.Component {
constructor() {
@@ -89,7 +91,7 @@ export default class App extends React.Component {
-
+ { process.env.GA_ACCESS_TOKEN ? : }