From b70fc85ab91eda55a8ac34c54a2c869e3225b863 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 17 Dec 2025 22:30:10 -0500 Subject: feat: add goatcounter analytics to PodcastItLater - Add goatcounter NixOS service to Biz.nix (SQLite backend, port 8081) - Add tracking script to UI.py PageLayout component - Configure for proxy mode (behind Caddy) --- Biz.nix | 8 ++++++++ Biz/PodcastItLater/UI.py | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/Biz.nix b/Biz.nix index 676fac8..ab79c1b 100755 --- a/Biz.nix +++ b/Biz.nix @@ -36,4 +36,12 @@ bild.os { package = packages.biz-deployer; manifestPackage = packages.deploy-manifest; }; + + # GoatCounter analytics - SQLite backend + services.goatcounter = { + enable = true; + address = "127.0.0.1"; + port = 8081; + proxy = true; # Running behind Caddy reverse proxy + }; } diff --git a/Biz/PodcastItLater/UI.py b/Biz/PodcastItLater/UI.py index d4b60a9..87b087e 100644 --- a/Biz/PodcastItLater/UI.py +++ b/Biz/PodcastItLater/UI.py @@ -128,6 +128,15 @@ def create_bootstrap_js() -> html.script: ) +def create_goatcounter_script() -> html.script: + """Load GoatCounter analytics script.""" + return html.script( # type: ignore[call-arg] + data_goatcounter="https://podcastitlater.goatcounter.com/count", + async_=True, + src="//gc.zgo.at/count.js", + ) + + class PageLayoutAttrs(Attrs): """Attributes for PageLayout component.""" @@ -310,6 +319,7 @@ class PageLayout(Component[AnyChildren, PageLayoutAttrs]): html.title(page_title), *meta_tags, create_htmx_script(), + create_goatcounter_script(), ), html.body( create_bootstrap_styles(), -- cgit v1.2.3