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' && } ); diff --git a/package.json b/package.json index 405b616..dff1104 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,9 @@ "webpack-dev-middleware": "^1.6.1", "webrtcsupport": "^2.2.0", "winston": "^1.0.1", - "xkcd-password": "^1.2.0" + "xkcd-password": "^1.2.0", + "noop-loader": "*", + "null-loader": "*", + "stylus": "^0.50.0" } } diff --git a/webpack.config.js b/webpack.config.js index 172ee70..92ab598 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,5 @@ const nib = require("nib"); +const webpack = require('webpack') module.exports = { entry: "./lib/client", @@ -26,11 +27,24 @@ module.exports = { ] }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + 'DISABLE_GA': process.env.DISABLE_GA, + } + }) + ], + node: { fs: "empty" }, stylus: { use: [nib()] - } + }, + + rules: [{ + test: /react-google-analytics/, + use: process.env.DISABLE_GA ? 'null-loader' : 'noop-loader' + }] };