Add environment variable to disable Google Analytics. #70

pull/87/head
Lucian I. Last 7 years ago
parent 41b2fcab0d
commit cbb7f4c800

@ -1,6 +1,8 @@
FROM node:latest
MAINTAINER Alex Kern <alex@kern.io>
ENV GA_ACCESS_TOKEN
COPY . ./
RUN npm install && npm run build

@ -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

@ -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 {
</p>
</footer>
<script>FilePizza()</script>
<ga.Initializer />
{ process.env.GA_ACCESS_TOKEN ? <ga.Initializer /> : <div></div> }
</body>
</html>
);

@ -53,6 +53,8 @@
"nib": "^1.1.0",
"node-uuid": "^1.4.3",
"nodemon": "^1.4.1",
"noop-loader": "^1.0.0",
"null-loader": "^0.1.1",
"react": "^0.13.0",
"react-frozenhead": "^0.3.0",
"react-google-analytics": "^0.2.0",

@ -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': {
'GA_ACCESS_TOKEN': JSON.stringify(process.env.GA_ACCESS_TOKEN),
}
})
],
node: {
fs: "empty"
},
stylus: {
use: [nib()]
}
},
rules: [{
test: /react-google-analytics/,
use: process.env.GA_ACCESS_TOKEN ? 'null-loader' : 'noop-loader'
}]
};

Loading…
Cancel
Save