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

@@ -126,72 +126,73 @@ html
a(href='https://github.com/contentful' target='_blank' rel='noopener') a(href='https://github.com/contentful' target='_blank' rel='noopener')
svg svg
use(xlink:href='/icons/icons.svg#github') use(xlink:href='/icons/icons.svg#github')
section.modal#about-this-modal section.modal#about-this-modal
.modal__overlay.close .modal__overlay.close
.modal__wrapper .modal__wrapper
h1.modal__title= translate("modalTitle", currentLocale.code) h1.modal__title= translate("modalTitle", currentLocale.code)
.modal__content .modal__content
p p
| #{translate("modalIntro", currentLocale.code)}&nbsp; | #{translate("modalIntro", currentLocale.code)}&nbsp;
a(href="https://github.com/contentful/the-example-app.nodejs" target="_blank" rel="noopener") Github a(href="https://github.com/contentful/the-example-app.nodejs" target="_blank" rel="noopener") Github
| . | .
p p
| #{translate("modalSpaceIntro", currentLocale.code)}&nbsp; | #{translate("modalSpaceIntro", currentLocale.code)}&nbsp;
a(href="https://github.com/contentful/content-models/blob/master/the-example-app/README.md " target="_blank" rel="noopener") #{translate("modalSpaceLinkLabel", currentLocale.code)} a(href="https://github.com/contentful/content-models/blob/master/the-example-app/README.md " target="_blank" rel="noopener") #{translate("modalSpaceLinkLabel", currentLocale.code)}
| . | .
p= translate("modalPlatforms", currentLocale.code) p= translate("modalPlatforms", currentLocale.code)
ul ul
li li
img(src='/images/icon-nodejs.svg') img(src='/images/icon-nodejs.svg')
br br
a(href=`https://the-example-app-nodejs.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code) a(href=`https://the-example-app-nodejs.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code)
br br
a(href="https://github.com/contentful/the-example-app.nodejs" rel="noopener" target="_blank") GitHub a(href="https://github.com/contentful/the-example-app.nodejs" rel="noopener" target="_blank") GitHub
li li
img(src='/images/icon-dotnet.svg') img(src='/images/icon-dotnet.svg')
br br
a(href=`https://the-example-app-csharp.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code) a(href=`https://the-example-app-csharp.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code)
br br
a(href="https://github.com/contentful/the-example-app.csharp" rel="noopener" target="_blank") GitHub a(href="https://github.com/contentful/the-example-app.csharp" rel="noopener" target="_blank") GitHub
li li
img(src='/images/icon-ruby.svg') img(src='/images/icon-ruby.svg')
br br
a(href=`https://the-example-app-rb.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code) a(href=`https://the-example-app-rb.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code)
br br
a(href="https://github.com/contentful/the-example-app.rb" rel="noopener" target="_blank") GitHub a(href="https://github.com/contentful/the-example-app.rb" rel="noopener" target="_blank") GitHub
li li
img(src='/images/icon-php.svg') img(src='/images/icon-php.svg')
br br
a(href=`https://the-example-app-php.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code) a(href=`https://the-example-app-php.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code)
br br
a(href="https://github.com/contentful/the-example-app.php" rel="noopener" target="_blank") GitHub a(href="https://github.com/contentful/the-example-app.php" rel="noopener" target="_blank") GitHub
li li
img(src='/images/icon-python.svg') img(src='/images/icon-python.svg')
br br
a(href=`https://the-example-app-py.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code) a(href=`https://the-example-app-py.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code)
br br
a(href="https://github.com/contentful/the-example-app.py" rel="noopener" target="_blank") GitHub a(href="https://github.com/contentful/the-example-app.py" rel="noopener" target="_blank") GitHub
li li
img.inactive(src='/images/icon-swift.svg') img.inactive(src='/images/icon-swift.svg')
br br
= translate("comingSoonLabel", currentLocale.code) = translate("comingSoonLabel", currentLocale.code)
li li
img(src='/images/icon-java.svg') img(src='/images/icon-java.svg')
br br
a(href=`https://the-example-app-java.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code) a(href=`https://the-example-app-java.herokuapp.com/${queryStringSettings}` rel="noopener" target="_blank")= translate("hostedLabel", currentLocale.code)
br br
a(href="https://github.com/contentful/the-example-app.java" rel="noopener" target="_blank") GitHub a(href="https://github.com/contentful/the-example-app.java" rel="noopener" target="_blank") GitHub
li li
img.inactive(src='/images/icon-android.svg') img.inactive(src='/images/icon-android.svg')
br br
= translate("comingSoonLabel", currentLocale.code) = translate("comingSoonLabel", currentLocale.code)
.modal__cta-wrapper .modal__cta-wrapper
a.modal__cta.close(href="#")= translate("modalCTALabel", currentLocale.code) a.modal__cta.close(href="#")= translate("modalCTALabel", currentLocale.code)
.modal__close-wrapper .modal__close-wrapper
a.modal__close-button.close(href="#") a.modal__close-button.close(href="#")
svg svg
use(xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/icons/icons.svg#cross") use(xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/icons/icons.svg#cross")
script(src='/scripts/index.js') 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 async src="https://www.googletagmanager.com/gtag/js?id=UA-109296848-1"></script> script.
<script>
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);} function gtag(){dataLayer.push(arguments);}
gtag('js', new Date()); gtag('js', new Date());
gtag('config', 'UA-40725207-13'); gtag('config', 'UA-40725207-13');
</script> script(async).
<!-- Google Analytics end -->
<!-- Snowplow starts plowing -->
<script async>
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; ;(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.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; };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
@@ -29,9 +25,9 @@
}); });
snowplow('trackPageView'); snowplow('trackPageView');
snowplow('enableLinkClickTracking') snowplow('enableLinkClickTracking')
const space_id = decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent('space_id').replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null; const space_id = decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent('space_id').replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
snowplow('trackSelfDescribingEvent', { snowplow('trackSelfDescribingEvent', {
@@ -42,5 +38,3 @@
app_framework: 'nodejs' app_framework: 'nodejs'
} }
}); });
</script>
<!-- Snowplow stops plowing -->