Skip to content

Commit

Permalink
Improve: ignore analytics tracking in development
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaewoook committed Aug 25, 2020
1 parent ebea8e2 commit e91f7bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 0 additions & 4 deletions public/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga("create", "UA-108816190-2", "auto");
ga("set", "checkProtocolTask", null);
ga("send", "pageview", "/");
13 changes: 12 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import React from "react";
import { render } from "react-dom";
import { App } from "./App";
import { getRuntime } from "./utils";
import { getRuntime, getEnv } from "./utils";
import { AddressManager } from "./AddressManager";
import { SettingsManager, Settings, DEFAULT_SETTINGS } from "./SettingsManager";

// inject NODE_ENV variable into window object
window.__ENV__ = {
NODE_ENV: process.env.REACT_APP_ENV as string,
};

// initialize google analytics only in production
if (getEnv() === "production") {
window.ga("create", "UA-108816190-2", "auto");
window.ga("set", "checkProtocolTask", null);
window.ga("send", "pageview", "/");
} else {
console.info("Google Analytics disabled because runtime does not running in production.");
window.ga = function() {};
}

let settings = null;

if (getRuntime() === "extension") {
Expand Down

0 comments on commit e91f7bc

Please sign in to comment.