refactor(tracking): conditional pug include instead of injection (#96)

This commit is contained in:
Benedikt Rötsch
2018-02-01 12:01:18 +01:00
committed by GitHub
parent 7a8376c714
commit 80823484b4
3 changed files with 73 additions and 91 deletions

13
bin/vendor/deploy.sh vendored
View File

@@ -1,13 +0,0 @@
#!/bin/bash
set -e
analytics_file="../bin/vendor/analytics.html"
layout_file="$(dirname $0)/../../views/layout.pug"
# Replace analytics script in layout
distro=`uname`
if [[ $distro != 'Linux' ]]; then
sed -i '' 's,'"<!--ANALYTICS-->,include $analytics_file"',g' "$layout_file"
else # If running on macOS, the sed command has different syntax
sed -i 's,'"<!--ANALYTICS-->,include $analytics_file"',g' "$layout_file"
fi

View File

@@ -194,4 +194,5 @@ section.modal#about-this-modal
script(src='/scripts/index.js')
<!--ANALYTICS-->
if process.env.TRACKING
include ./tracking.pug

View File

@@ -1,15 +1,11 @@
<!-- Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-109296848-1"></script>
<script>
script(async src="https://www.googletagmanager.com/gtag/js?id=UA-109296848-1")
script.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-40725207-13');
</script>
<!-- Google Analytics end -->
<!-- Snowplow starts plowing -->
<script async>
script(async).
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
@@ -42,5 +38,3 @@
app_framework: 'nodejs'
}
});
</script>
<!-- Snowplow stops plowing -->