Only include analytics on production builds
This commit is contained in:
parent
3dd652e7cf
commit
5aba9d698b
@ -11,40 +11,42 @@
|
||||
<body>
|
||||
<!-- Heap SDK -->
|
||||
<script type="text/javascript">
|
||||
(window.heap = window.heap || []),
|
||||
(heap.load = function(e, t) {
|
||||
(window.heap.appid = e), (window.heap.config = t = t || {});
|
||||
var r = t.forceSSL || 'https:' === document.location.protocol,
|
||||
a = document.createElement('script');
|
||||
(a.type = 'text/javascript'),
|
||||
(a.async = !0),
|
||||
(a.src = (r ? 'https:' : 'http:') + '//cdn.heapanalytics.com/js/heap-' + e + '.js');
|
||||
var n = document.getElementsByTagName('script')[0];
|
||||
n.parentNode.insertBefore(a, n);
|
||||
for (
|
||||
var o = function(e) {
|
||||
return function() {
|
||||
heap.push([e].concat(Array.prototype.slice.call(arguments, 0)));
|
||||
};
|
||||
},
|
||||
p = [
|
||||
'addEventProperties',
|
||||
'addUserProperties',
|
||||
'clearEventProperties',
|
||||
'identify',
|
||||
'resetIdentity',
|
||||
'removeEventProperty',
|
||||
'setEventProperties',
|
||||
'track',
|
||||
'unsetEventProperty',
|
||||
],
|
||||
c = 0;
|
||||
c < p.length;
|
||||
c++
|
||||
)
|
||||
heap[p[c]] = o(p[c]);
|
||||
});
|
||||
heap.load('<%= htmlWebpackPlugin.options.heapAnalyticsId %>');
|
||||
if ('<%= htmlWebpackPlugin.options.environment %>' !== 'development') {
|
||||
(window.heap = window.heap || []),
|
||||
(heap.load = function(e, t) {
|
||||
(window.heap.appid = e), (window.heap.config = t = t || {});
|
||||
var r = t.forceSSL || 'https:' === document.location.protocol,
|
||||
a = document.createElement('script');
|
||||
(a.type = 'text/javascript'),
|
||||
(a.async = !0),
|
||||
(a.src = (r ? 'https:' : 'http:') + '//cdn.heapanalytics.com/js/heap-' + e + '.js');
|
||||
var n = document.getElementsByTagName('script')[0];
|
||||
n.parentNode.insertBefore(a, n);
|
||||
for (
|
||||
var o = function(e) {
|
||||
return function() {
|
||||
heap.push([e].concat(Array.prototype.slice.call(arguments, 0)));
|
||||
};
|
||||
},
|
||||
p = [
|
||||
'addEventProperties',
|
||||
'addUserProperties',
|
||||
'clearEventProperties',
|
||||
'identify',
|
||||
'resetIdentity',
|
||||
'removeEventProperty',
|
||||
'setEventProperties',
|
||||
'track',
|
||||
'unsetEventProperty',
|
||||
],
|
||||
c = 0;
|
||||
c < p.length;
|
||||
c++
|
||||
)
|
||||
heap[p[c]] = o(p[c]);
|
||||
});
|
||||
heap.load('<%= htmlWebpackPlugin.options.heapAnalyticsId %>');
|
||||
}
|
||||
</script>
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script
|
||||
@ -52,13 +54,15 @@
|
||||
src="https://www.googletagmanager.com/gtag/js?id=<%= htmlWebpackPlugin.options.googleAnalyticsId %>"
|
||||
></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
gtag('js', new Date());
|
||||
if ('<%= htmlWebpackPlugin.options.environment %>' !== 'development') {
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', '<%= htmlWebpackPlugin.options.googleAnalyticsId %>');
|
||||
gtag('config', '<%= htmlWebpackPlugin.options.googleAnalyticsId %>');
|
||||
}
|
||||
</script>
|
||||
<!-- End Google Analytics -->
|
||||
<div id="app"></div>
|
||||
|
@ -82,7 +82,10 @@ const config = {
|
||||
module.exports = (_env, argv) => {
|
||||
let plugins = [
|
||||
new CleanWebpackPlugin('public'),
|
||||
...pages.map(p => new HtmlWebpackPlugin(p)),
|
||||
...pages.map(p => {
|
||||
p.environment = argv.mode;
|
||||
return new HtmlWebpackPlugin(p);
|
||||
}),
|
||||
new CopyWebpackPlugin([
|
||||
{ from: 'assets/crawl.html', to: 'index.html' },
|
||||
{ from: 'assets/fonts', to: 'fonts' },
|
||||
|
32
yarn.lock
32
yarn.lock
@ -13461,16 +13461,6 @@ react-dom@^16.3.2:
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.0"
|
||||
|
||||
react-dom@^16.4.2:
|
||||
version "16.8.1"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.1.tgz#ec860f98853d09d39bafd3a6f1e12389d283dbb4"
|
||||
integrity sha512-N74IZUrPt6UiDjXaO7UbDDFXeUXnVhZzeRLy/6iqqN1ipfjrhR60Bp5NuBK+rv3GMdqdIuwIl22u1SYwf330bg==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.2"
|
||||
scheduler "^0.13.1"
|
||||
|
||||
react-dom@^16.5.2:
|
||||
version "16.5.2"
|
||||
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.5.2.tgz#b69ee47aa20bab5327b2b9d7c1fe2a30f2cfa9d7"
|
||||
@ -13528,8 +13518,8 @@ react-highlight@0xproject/react-highlight#react-peer-deps:
|
||||
dependencies:
|
||||
highlight.js "^9.11.0"
|
||||
highlightjs-solidity "^1.0.5"
|
||||
react "^16.5.2"
|
||||
react-dom "^16.5.2"
|
||||
react "^16.4.2"
|
||||
react-dom "^16.4.2"
|
||||
|
||||
react-hot-loader@^4.3.3:
|
||||
version "4.3.4"
|
||||
@ -13774,16 +13764,6 @@ react@^16.3.2:
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.0"
|
||||
|
||||
react@^16.4.2:
|
||||
version "16.8.1"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-16.8.1.tgz#ae11831f6cb2a05d58603a976afc8a558e852c4a"
|
||||
integrity sha512-wLw5CFGPdo7p/AgteFz7GblI2JPOos0+biSoxf1FPsGxWQZdN/pj6oToJs1crn61DL3Ln7mN86uZ4j74p31ELQ==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
prop-types "^15.6.2"
|
||||
scheduler "^0.13.1"
|
||||
|
||||
react@^16.5.2:
|
||||
version "16.5.2"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42"
|
||||
@ -14655,14 +14635,6 @@ schedule@^0.5.0:
|
||||
dependencies:
|
||||
object-assign "^4.1.1"
|
||||
|
||||
scheduler@^0.13.1:
|
||||
version "0.13.1"
|
||||
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.1.tgz#1a217df1bfaabaf4f1b92a9127d5d732d85a9591"
|
||||
integrity sha512-VJKOkiKIN2/6NOoexuypwSrybx13MY7NSy9RNt8wPvZDMRT1CW6qlpF5jXRToXNHz3uWzbm2elNpZfXfGPqP9A==
|
||||
dependencies:
|
||||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
|
||||
schema-utils@^0.4.4:
|
||||
version "0.4.7"
|
||||
resolved "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"
|
||||
|
Loading…
x
Reference in New Issue
Block a user