From 39b759d636be5a30d4ce17c6f962e4984d818b16 Mon Sep 17 00:00:00 2001 From: "@permadeath.com" Date: Sat, 8 Aug 2026 15:48:27 -0400 Subject: [PATCH] feat: add cookieless PostHog analytics to the frontpage Load the PostHog snippet from the production Layout head, pointed at the EU-hosted project. persistence: "memory" keeps it cookieless, so no consent banner is needed; dev servers never load it. Co-Authored-By: Claude Fable 5 --- README.md | 6 +++ web/src/components/PostHog.astro | 66 ++++++++++++++++++++++++++++++++ web/src/layouts/Layout.astro | 3 ++ 3 files changed, 75 insertions(+) create mode 100644 web/src/components/PostHog.astro diff --git a/README.md b/README.md index 73f74df..0f8b522 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,12 @@ from `web/dist/` (CloudFront's `default_root_object` is `index.html`, so `/client-metadata.json`. The frontpage copy is intentionally `PLACEHOLDER-*` strings until real wording is written. +The frontpage (and only the frontpage — not the extension) reports analytics +to an EU-hosted PostHog project via `web/src/components/PostHog.astro`. +Tracking is cookieless (`persistence: "memory"`), and the snippet is only +included in production builds, so `astro dev` traffic never reaches PostHog +(`astro preview` serves the production build, so it does). + Build the frontpage before planning or applying — the site objects are read from the build output, and a plan-time precondition fails if `web/dist/index.html` is missing (otherwise an empty `fileset()` would diff --git a/web/src/components/PostHog.astro b/web/src/components/PostHog.astro new file mode 100644 index 0000000..2a9e40b --- /dev/null +++ b/web/src/components/PostHog.astro @@ -0,0 +1,66 @@ +--- +// PostHog analytics for the static frontpage only (the extension does not +// load this). EU-hosted project: https://eu.posthog.com/project/244032 +// +// persistence: "memory" keeps tracking cookieless — nothing is written to +// cookies or localStorage, so visitors are not recognized across visits and +// no consent banner is required. +--- + + diff --git a/web/src/layouts/Layout.astro b/web/src/layouts/Layout.astro index 5207177..38ea321 100644 --- a/web/src/layouts/Layout.astro +++ b/web/src/layouts/Layout.astro @@ -1,5 +1,6 @@ --- import "../styles/global.css"; +import PostHog from "../components/PostHog.astro"; interface Props { title: string; @@ -17,6 +18,8 @@ const { title, description } = Astro.props; {title} + {/* Production builds only, so dev servers don't pollute analytics. */} + {import.meta.env.PROD && } -- 2.51.2