Merge pull request #257 from mozilla/jsconfig

add a dynamic js script for page config
This commit is contained in:
Danny Coates 2017-07-19 14:10:03 -07:00 committed by GitHub
commit 3bb6a6fa44
5 changed files with 15 additions and 28 deletions

View File

@ -69,9 +69,15 @@ app.use('/l20n', express.static(L20N));
app.use('/locales', express.static(LOCALES)); app.use('/locales', express.static(LOCALES));
app.get('/', (req, res) => { app.get('/', (req, res) => {
res.render('index', { res.render('index');
});
app.get('/jsconfig.js', (req, res) => {
res.set('Content-Type', 'application/javascript');
res.render('jsconfig', {
trackerId: conf.analytics_id, trackerId: conf.analytics_id,
dsn: conf.sentry_id dsn: conf.sentry_id,
layout: false
}); });
}); });

View File

@ -0,0 +1,6 @@
{{#if dsn}}
window.dsn = '{{{dsn}}}';
{{/if}}
{{#if trackerId}}
window.trackerId = '{{{trackerId}}}';
{{/if}}

View File

@ -2,15 +2,10 @@
<html> <html>
<head> <head>
<title>Firefox Send</title> <title>Firefox Send</title>
{{#if dsn}} <script src="/jsconfig.js"></script>
{{> sentry dsn=dsn}}
{{/if}}
<script src="/bundle.js"></script> <script src="/bundle.js"></script>
<link rel="stylesheet" type="text/css" href="/main.css" /> <link rel="stylesheet" type="text/css" href="/main.css" />
<link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css"> <link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css">
{{#if trackerId}}
{{> analytics trackerId=trackerId}}
{{/if}}
<meta name="defaultLanguage" content="en-US"> <meta name="defaultLanguage" content="en-US">
<meta name="availableLanguages" content="en-US"> <meta name="availableLanguages" content="en-US">

View File

@ -1,17 +0,0 @@
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(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', '{{{trackerId}}}', 'auto');
if (window.URL && document.referrer) {
ga("set", "referrer", (new URL(document.referrer)).origin);
} else {
ga("set", "referrer", "");
}
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>

View File

@ -1,3 +0,0 @@
<script>
window.dsn = '{{{dsn}}}';
</script>