From 10c9d3666178afca290ed98f5b935b8be9494338 Mon Sep 17 00:00:00 2001
From: Andrei Poenaru
Date: Mon, 14 Aug 2017 18:48:06 +0000
Subject: [PATCH] Add environment variable to disable Google Analytics.
---
Dockerfile | 2 ++
lib/components/App.js | 13 +++++++++----
package.json | 5 ++++-
webpack.config.js | 16 +++++++++++++++-
4 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index a63a7b1..4fe1959 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,7 @@
FROM node:latest
MAINTAINER Alex Kern
+
+ENV DISABLE_GA no
COPY . ./
RUN npm install && npm run build
diff --git a/lib/components/App.js b/lib/components/App.js
index daabd7a..d82f230 100644
--- a/lib/components/App.js
+++ b/lib/components/App.js
@@ -5,9 +5,14 @@ import React from "react";
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.DISABLE_GA != 'yes') {
+ ga("create", "UA-62785624-1", "auto");
+ ga("send", "pageview");
+ console.log("Google Analytics ON");
+}
+else
+ console.log("Google Analytics OFF");
export default class App extends React.Component {
constructor() {
@@ -89,7 +94,7 @@ export default class App extends React.Component {
-
+ { process.env.DISABLE_GA != 'yes' && }