analytics: consolidate everything onto one shared Plausible pa- script

All pcbjam properties now load the same new-format Plausible script
(https://plausible.io/js/pa-KjNS9YmidydULZTstsjRg.js — one dashboard,
segment by hostname) instead of per-domain data-domain sites:

- site: replace Vercel Analytics with the pa- snippet in BaseLayout
  (is:inline, prod-only, crossorigin="anonymous" for the COEP
  require-corp routes in vercel.json); drop @vercel/analytics dep.
  Legal pages (cookies/privacy) rewritten Vercel -> Plausible.
- standalone: initAnalytics() rewritten for the new script format
  (queue shim + plausible.init(), async, no data-domain). The gate is
  now VITE_PLAUSIBLE_SRC (script URL, deploy-time opt-in) — unset means
  no tracking, so dev checkouts and third-party GPL builds stay clean.
  VITE_PLAUSIBLE_DOMAIN is gone.
- deploy: build-demo/build-editor --plausible now takes the script URL;
  release.yml/deploy-demo.yml hardcode the (public) pa- URL, so the
  repo Actions variable PLAUSIBLE_DOMAIN is no longer used.

Verified: standalone tsc + vite build (pa- URL present with env, absent
without, crossOrigin kept); astro build has the snippet on all layout
pages and no vercel/insights references; astro dev stays untracked.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Istvan Matejcsok 2026-07-15 19:34:09 +02:00
commit 40b53ad530
14 changed files with 116 additions and 95 deletions

View file

@ -93,13 +93,13 @@ jobs:
# full KiCad library set is served read-only from libs/kicad/$LIB_TAG
# (published once by publish-libs.yml — run it first for a new lib tag).
- name: Build demo
# Plausible: set the repo Actions VARIABLE `PLAUSIBLE_DOMAIN` (e.g.
# demo.pcbjam.com) to enable analytics; unset ⇒ "" ⇒ build-demo leaves it off.
# Plausible: the shared pa- script covering all pcbjam properties
# (one dashboard, segment by hostname).
run: >
node scripts/deploy/build-demo.mjs --tag "${{ steps.tag.outputs.tag }}"
--cdn "$CDN" --lib-tag "$LIB_TAG"
${MODELS_TAG:+--models-tag "$MODELS_TAG"}
--plausible "${{ vars.PLAUSIBLE_DOMAIN }}"
--plausible "https://plausible.io/js/pa-KjNS9YmidydULZTstsjRg.js"
# 4) Ensure the Pages project exists (first deploy creates it; no-op after).
# Its production branch must equal PAGES_PROD_BRANCH or deploys land as

View file

@ -124,13 +124,13 @@ jobs:
# Standalone pinned to the CDN + this tag's manifest-<tag>.json (written by
# publish-wasm above) + the full library set at libs/kicad/$LIB_TAG.
- name: Build demo
# Plausible: set the repo Actions VARIABLE `PLAUSIBLE_DOMAIN` (e.g.
# demo.pcbjam.com) to enable analytics; unset ⇒ "" ⇒ build-demo leaves it off.
# Plausible: the shared pa- script covering all pcbjam properties
# (one dashboard, segment by hostname).
run: >
node scripts/deploy/build-demo.mjs --tag "${{ needs.meta.outputs.tag }}"
--cdn "$CDN" --lib-tag "$LIB_TAG"
${MODELS_TAG:+--models-tag "$MODELS_TAG"}
--plausible "${{ vars.PLAUSIBLE_DOMAIN }}"
--plausible "https://plausible.io/js/pa-KjNS9YmidydULZTstsjRg.js"
- name: Ensure Pages project exists
run: >
@ -171,13 +171,13 @@ jobs:
- name: Install standalone workspace
run: pnpm --dir web install --frozen-lockfile
# --plausible: the editor tracks as its OWN Plausible site (separate
# dashboard from the demo's vars.PLAUSIBLE_DOMAIN and the mgmt app's).
# --plausible: the shared pa- script covering all pcbjam properties
# (one dashboard, segment by hostname).
- name: Build editor (remote mode)
run: >
node scripts/deploy/build-editor.mjs --tag "$RELEASE_TAG"
--cdn "$CDN" --api-base "$EDITOR_API_BASE"
--plausible "editor.pcbjam.com"
--plausible "https://plausible.io/js/pa-KjNS9YmidydULZTstsjRg.js"
${MODELS_TAG:+--models-tag "$MODELS_TAG"}
- name: Ensure Pages project exists