Add environment variable to disable Google Analytics.

pull/70/head
Andrei Poenaru 8 years ago
parent f1952c3e88
commit 10c9d36661

@ -1,5 +1,7 @@
FROM node:latest FROM node:latest
MAINTAINER Alex Kern <alex@kern.io> MAINTAINER Alex Kern <alex@kern.io>
ENV DISABLE_GA no
COPY . ./ COPY . ./
RUN npm install && npm run build RUN npm install && npm run build

@ -5,9 +5,14 @@ import React from "react";
import SupportStore from "../stores/SupportStore"; import SupportStore from "../stores/SupportStore";
import { RouteHandler } from "react-router"; import { RouteHandler } from "react-router";
import ga from "react-google-analytics"; import ga from "react-google-analytics";
ga("create", "UA-62785624-1", "auto"); if (process.env.DISABLE_GA != 'yes') {
ga("send", "pageview"); 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 { export default class App extends React.Component {
constructor() { constructor() {
@ -89,7 +94,7 @@ export default class App extends React.Component {
</p> </p>
</footer> </footer>
<script>FilePizza()</script> <script>FilePizza()</script>
<ga.Initializer /> { process.env.DISABLE_GA != 'yes' && <ga.Initializer /> }
</body> </body>
</html> </html>
); );

@ -67,6 +67,9 @@
"webpack-dev-middleware": "^1.6.1", "webpack-dev-middleware": "^1.6.1",
"webrtcsupport": "^2.2.0", "webrtcsupport": "^2.2.0",
"winston": "^1.0.1", "winston": "^1.0.1",
"xkcd-password": "^1.2.0" "xkcd-password": "^1.2.0",
"noop-loader": "*",
"null-loader": "*",
"stylus": "^0.50.0"
} }
} }

@ -1,4 +1,5 @@
const nib = require("nib"); const nib = require("nib");
const webpack = require('webpack')
module.exports = { module.exports = {
entry: "./lib/client", entry: "./lib/client",
@ -26,11 +27,24 @@ module.exports = {
] ]
}, },
plugins: [
new webpack.DefinePlugin({
'process.env': {
'DISABLE_GA': process.env.DISABLE_GA,
}
})
],
node: { node: {
fs: "empty" fs: "empty"
}, },
stylus: { stylus: {
use: [nib()] use: [nib()]
} },
rules: [{
test: /react-google-analytics/,
use: process.env.DISABLE_GA ? 'null-loader' : 'noop-loader'
}]
}; };

Loading…
Cancel
Save