Context
paweldregan.com is now deployed and the SEO/contrast layer just landed (#5, #6). Next step from the broader rollout plan: get our own analytics on it via @stacksjs/ts-analytics.
This is the first deployment of ts-analytics on a real public site, so it doubles as the reference impl that the cross-site rollout (stx docs, bunpress docs, ts-images docs, barista docs, …) will copy from.
Scope
- Add
@stacksjs/ts-analyticstodependenciesinpackage.json - Initialize the tracker in
layouts/default.stx(single load point — every page extends this layout, no per-page wiring needed) - Configure via
site.config.tsif ts-analytics has a config surface there (preferred), otherwise minimal inline config - Respect the existing dark/light theme + i18n behavior (no flash, no analytics call before the active locale is settled)
- SPA awareness: stx does view transitions on
<main>— make sure pageview events fire onstx:navigate, not just initial DOMContentLoaded - Verify in
bun run buildoutput that the tracker script lands once per page (no duplication from layout + components)
Acceptance
- One pageview event per route load (initial + each SPA navigation)
- No console errors in light or dark mode
- No layout shift / flash from the analytics script
- Works in en, de, pl
- Documented in repo README briefly so the next site that adopts ts-analytics can copy the integration
Related
- Reference impl for the cross-repo rollout tracker (separate issue on stacksjs/ts-analytics)