diff --git a/backend/src/server.ts b/backend/src/server.ts index e61161c..c415bc3 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -14,6 +14,7 @@ const host = process.env.HOST || "localhost"; const port = parseInt(process.env.PORT || "") || 6119; const tlsPort = parseInt(process.env.TLS_PORT || "") || 6120; const useTLS = process.env.TLS ? true : false; +const analyticsEnabled = process.env.ANALYTICS ? true : false; const app = express(); @@ -27,7 +28,10 @@ function getQueryParams(req: Request): URLSearchParams { } app.get("/", (_, res) => { - res.render(appRoot.path + "/frontend/pages/index", { langs }); + res.render(appRoot.path + "/frontend/pages/index", { + langs, + analyticsEnabled, + }); }); for (const [lang, { aliases }] of Object.entries(langs)) { if (aliases) { @@ -46,6 +50,7 @@ app.get("/:lang", (req, res) => { } else if (langs[lang]) { res.render(appRoot.path + "/frontend/pages/app", { config: { id: lang, ...langs[lang] }, + analyticsEnabled, }); } else { res.send(`No such language: ${lang}`); diff --git a/frontend/pages/app.ejs b/frontend/pages/app.ejs index c6b046e..eb5f385 100644 --- a/frontend/pages/app.ejs +++ b/frontend/pages/app.ejs @@ -23,5 +23,8 @@ window.rijuConfig = <%- JSON.stringify(config) %>; + <% if (analyticsEnabled) { %> + + <% } %> diff --git a/frontend/pages/index.ejs b/frontend/pages/index.ejs index 2c75c0f..59d2ff2 100644 --- a/frontend/pages/index.ejs +++ b/frontend/pages/index.ejs @@ -26,5 +26,8 @@ on GitHub.

+ <% if (analyticsEnabled) { %> + + <% } %> diff --git a/scripts/riju-serve.bash b/scripts/riju-serve.bash index 123fbbf..2c45189 100755 --- a/scripts/riju-serve.bash +++ b/scripts/riju-serve.bash @@ -6,10 +6,11 @@ set -o pipefail TLS=1 TLS_PRIVATE_KEY="$(base64 /etc/letsencrypt/live/riju.codes/privkey.pem)" TLS_CERTIFICATE="$(base64 /etc/letsencrypt/live/riju.codes/fullchain.pem)" +ANALYTICS=1 # Do this separately so that errors in command substitution will crash # the script. -export TLS TLS_PRIVATE_KEY TLS_CERTIFICATE +export TLS TLS_PRIVATE_KEY TLS_CERTIFICATE ANALYTICS if [[ -t 1 ]]; then it=-it @@ -17,5 +18,5 @@ else it= fi -docker run ${it} -e TLS -e TLS_PRIVATE_KEY -e TLS_CERTIFICATE \ +docker run ${it} -e TLS -e TLS_PRIVATE_KEY -e TLS_CERTIFICATE -e ANALYTICS \ --rm -p 0.0.0.0:80:6119 -p 0.0.0.0:443:6120 -h riju riju:prod