diff --git a/website/README.md b/website/README.md index 8d48ad4..195a7bb 100644 --- a/website/README.md +++ b/website/README.md @@ -10,6 +10,27 @@ cost calculator, and local documentation at `/docs/`. The production origin defaults to `https://profitctl.com`. Set it to the actual public origin before deploying elsewhere. - Cloudflare Pages: set `GO_VERSION=1.26.8` to match `go.mod`. +- `PUBLIC_OPENPANEL_CLIENT_ID`: the public ID of the ProfitCtl **write** client. + Set it in the Cloudflare Pages production build environment to enable analytics. + Leave it unset for development and previews. Never use the MCP read client or + put a client secret in a `PUBLIC_*` variable. + +## Analytics + +The shared layout loads the [official OpenPanel script](https://openpanel.dev/docs/sdks/script) +asynchronously on `profitctl.com` and `www.profitctl.com`. It records page views +and outgoing link clicks on the homepage and documentation. It does not identify +visitors by name or email, or enable custom attribute tracking. + +The script stays unloaded on local and preview domains, when the public client +ID is absent, and when Do Not Track or Global Privacy Control is enabled. +Browser blockers can also prevent collection. The MCP credentials in Doppler +are for reading reports and are never included in the website. + +Run `bun run test:analytics` for the domain, privacy, and duplicate-load checks. +These checks also run during the build. Local checks do not prove live event +receipt; verify a page view in ProfitCtl's OpenPanel project after an approved +production deployment. ## Run diff --git a/website/package.json b/website/package.json index e19b461..3782c0e 100644 --- a/website/package.json +++ b/website/package.json @@ -6,7 +6,8 @@ "packageManager": "bun@1.3.3", "scripts": { "dev": "node scripts/build-terminal-demo.mjs && astro dev", - "build": "node scripts/build-terminal-demo.mjs && bun scripts/check-terminal-demo.mjs && astro build && bun scripts/check-demo.mjs && node scripts/check-seo.mjs", + "build": "node scripts/check-analytics.mjs && node scripts/build-terminal-demo.mjs && bun scripts/check-terminal-demo.mjs && astro build && bun scripts/check-demo.mjs && node scripts/check-seo.mjs", + "test:analytics": "node scripts/check-analytics.mjs", "preview": "astro preview", "typecheck": "astro check && tsc --noEmit" }, diff --git a/website/scripts/check-analytics.mjs b/website/scripts/check-analytics.mjs new file mode 100644 index 0000000..f79465e --- /dev/null +++ b/website/scripts/check-analytics.mjs @@ -0,0 +1,58 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { runInNewContext } from "node:vm"; + +const layout = readFileSync(new URL("../src/layouts/ProductLayout.astro", import.meta.url), "utf8"); +const script = layout.match(/ + )}
Skip to content