Migrate to advanced Fathom Analytics

Allow interpolating an arbitrary analytics tag.
This commit is contained in:
Radon Rosborough 2021-11-06 13:41:17 -07:00
parent 0d92a77922
commit b0210f8f4c
9 changed files with 17 additions and 17 deletions

View File

@ -73,7 +73,7 @@ else
SHELL_PORTS :=
endif
SHELL_ENV := -e Z -e CI -e TEST_PATIENCE -e TEST_CONCURRENCY -e TEST_TIMEOUT_SECS -e FATHOM_SITE_ID
SHELL_ENV := -e Z -e CI -e TEST_PATIENCE -e TEST_CONCURRENCY -e TEST_TIMEOUT_SECS -e ANALYTICS_TAG
ifeq ($(I),lang)
LANG_TAG := lang-$(L)

View File

@ -15,7 +15,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 fathomSiteId = process.env.FATHOM_SITE_ID || "";
const analyticsTag = process.env.ANALYTICS_TAG || "";
const langs = await langsPromise;
const app = express();
@ -27,7 +27,7 @@ app.get("/", (_, res) => {
if (Object.keys(langs).length > 0) {
res.render(path.resolve("frontend/pages/index"), {
langs,
fathomSiteId,
analyticsTag,
});
} else {
res
@ -61,7 +61,7 @@ app.get("/:lang", (req, res) => {
}
res.render(path.resolve("frontend/pages/app"), {
config: langs[lang],
fathomSiteId,
analyticsTag,
});
});
app.use("/css", express.static("frontend/styles"));

View File

@ -263,9 +263,9 @@ enable all the fun CloudFlare options you'd like.
## Set up analytics (optional)
Sign up for Fathom Analytics, enter your domain name, and get a site
ID. Set this as `FATHOM_SITE_ID` in your `.env` file, and build and
roll out a new web AMI.
Sign up for Fathom Analytics, enter your domain name, and get a tag
for embedding. Set this as `ANALYTICS_TAG` in your `.env` file (don't
forget the appropriate quoting), and build and roll out a new web AMI.
## Set up monitoring (optional)

View File

@ -22,8 +22,8 @@
window.rijuConfig = <%- JSON.stringify(config) %>;
</script>
<script src="/js/app.js" defer></script>
<% if (fathomSiteId) { %>
<script src="https://cdn.usefathom.com/script.js" data-site="<%= fathomSiteId %>" defer></script>
<% if (analyticsTag) { %>
<%= analyticsTag %>
<% } %>
</head>
<body>

View File

@ -30,8 +30,8 @@
<% } else { %>
<i>Riju is loading language configuration...</i>
<% } %>
<% if (fathomSiteId) { %>
<script src="https://cdn.usefathom.com/script.js" data-site="<%= fathomSiteId %>" defer></script>
<% if (analyticsTag) { %>
<%= analyticsTag %>
<% } %>
</body>
</html>

View File

@ -59,7 +59,7 @@ sudo sed -Ei 's|^#?PermitRootLogin .*|PermitRootLogin no|' /etc/ssh/sshd_config
sudo sed -Ei 's|^#?PasswordAuthentication .*|PasswordAuthentication no|' /etc/ssh/sshd_config
sudo sed -Ei 's|^#?PermitEmptyPasswords .*|PermitEmptyPasswords no|' /etc/ssh/sshd_config
sudo sed -Ei "s|\\\$AWS_REGION|${AWS_REGION}|" /etc/systemd/system/riju.service
sudo sed -Ei "s|\\\$FATHOM_SITE_ID|${FATHOM_SITE_ID:-}|" /etc/systemd/system/riju.service
sudo sed -Ei "s|\\\$ANALYTICS_TAG|${ANALYTICS_TAG:-}|" /etc/systemd/system/riju.service
sudo sed -Ei "s|\\\$S3_BUCKET|${S3_BUCKET}|" /etc/systemd/system/riju.service
sudo sed -Ei "s|\\\$SENTRY_DSN|${SENTRY_DSN:-}|" /etc/systemd/system/riju.service
sudo sed -Ei "s|\\\$SUPERVISOR_ACCESS_TOKEN|${SUPERVISOR_ACCESS_TOKEN}|" /etc/systemd/system/riju.service

View File

@ -11,7 +11,7 @@ ExecStart=riju-supervisor
Restart=always
RestartSec=5
Environment=AWS_REGION=$AWS_REGION
Environment=FATHOM_SITE_ID=$FATHOM_SITE_ID
Environment=ANALYTICS_TAG=ANALYTICS_TAG
Environment=S3_BUCKET=$S3_BUCKET
Environment=SENTRY_DSN=$SENTRY_DSN
Environment=SUPERVISOR_ACCESS_TOKEN=$SUPERVISOR_ACCESS_TOKEN

View File

@ -8,9 +8,9 @@ variable "aws_region" {
default = "${env("AWS_REGION")}"
}
variable "fathom_site_id" {
variable "analytics_tag" {
type = string
default = "${env("FATHOM_SITE_ID")}"
default = "${env("ANALYTICS_TAG")}"
}
variable "grafana_api_key" {
@ -116,7 +116,7 @@ build {
environment_vars = [
"ADMIN_PASSWORD=${var.admin_password}",
"AWS_REGION=${var.aws_region}",
"FATHOM_SITE_ID=${var.fathom_site_id}",
"ANALYTICS_TAG=${var.analytics_tag}",
"GRAFANA_API_KEY=${var.grafana_api_key}",
"S3_BUCKET=${var.s3_bucket}",
"SENTRY_DSN=${var.sentry_dsn}",

View File

@ -355,7 +355,7 @@ func (sv *supervisor) reload() error {
"-v", "/var/cache/riju:/var/cache/riju",
"-v", "/var/run/docker.sock:/var/run/docker.sock",
"-p", fmt.Sprintf("127.0.0.1:%d:6119", port),
"-e", "FATHOM_SITE_ID",
"-e", "ANALYTICS_TAG",
"-e", "RIJU_DEPLOY_CONFIG",
"-e", "SENTRY_DSN",
"--label", fmt.Sprintf("riju.deploy-config-hash=%s", deployCfgHash),