Skip to content

feat(docs): add PostHog analytics for memory.svelte.page - #194

Merged
jaysin586 merged 3 commits into
mainfrom
feat/posthog-analytics
Oct 8, 2026
Merged

jaysin586 merged 3 commits into
mainfrom
feat/posthog-analytics

Conversation

@jaysin586

@jaysin586 jaysin586 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds PostHog product analytics and client-side exception capture to the docs site at https://memory.svelte.page. It uses the same pattern as svelte-motion's docs.

What changed

  • docs/src/hooks.client.ts (new): init() starts posthog-js with api_host set to the managed reverse proxy https://j.svelte.page (the Svelte.page org's dedicated proxy, which replaces the shared t.svelte.page; its DNS is still being set up), defaults: '2026-01-30', and capture_exceptions: true. handleError forwards client errors to posthog.captureException.
  • docs/wrangler.jsonc: adds the PUBLIC_POSTHOG_PROJECT_TOKEN and PUBLIC_POSTHOG_HOST vars. The project token is a public client SDK identifier, so it has a checkov skip comment.
  • docs/src/worker-configuration.d.ts: regenerated with pnpm cf-typegen.
  • docs/svelte.config.js: CSP now allows https://j.svelte.page in script-src (for lazy-loaded PostHog extensions) and connect-src (for ingestion). Every other directive is unchanged.
  • docs/package.json / pnpm-lock.yaml: adds posthog-js ^1.438.1 to the docs package only.
  • pnpm-workspace.yaml: adds core-js: false to allowBuilds. posthog-js pulls in core-js, and pnpm treats an unapproved build script as an error, so pnpm install --frozen-lockfile fails without this entry. The only thing core-js's postinstall does is print a funding banner, so it is denied.

PostHog project

Reports to the memory.svelte.page project (id 654044) in the Svelte.page PostHog org.

Analytics only start when both PUBLIC_POSTHOG_* env vars are set. Local dev without them sends nothing, and PostHog also filters localhost as test traffic.

Worker tooling

A separate commit bumps the docs package to the newest versions allowed by minimumReleaseAge (48h) and regenerates worker-configuration.d.ts with pnpm cf-typegen:

  • wrangler: 4.95.0 → 4.148.0
  • @sveltejs/adapter-cloudflare: 7.2.8 → 7.2.9. 8.0.0 needs @sveltejs/kit ^3, so it stays on 7.x.
  • @cloudflare/workers-types: 4.20260531.1 → 5.20261006.1 (major bump, types only)

@cloudflare/vite-plugin isn't a dependency, and the root package.json doesn't pin wrangler. compatibility_date/compatibility_flags are unchanged, and wrangler printed no warning about the compatibility date. The regenerated env types still include every var in wrangler.jsonc.

Verification

  • pnpm check in docs: 0 errors, 0 warnings. The library has to be built first (pnpm build at the root), the same as on main.
  • pnpm build in docs (the production build with adapter-cloudflare): passes, and the favicon check passes.
  • All checks were rerun after each follow-up commit (tooling bump, proxy host swap) and still pass.
  • trunk fmt and trunk check on the changed files: no issues.
  • phc_ tokens: the only ones are in wrangler.jsonc and the generated worker-configuration.d.ts. docs/src code has none, and there is no other PostHog init path.

🤖 Generated with Claude Code

Initialize posthog-js in hooks.client.ts (with exception capture via
handleError), add PUBLIC_POSTHOG_* vars to wrangler.jsonc, regenerate
worker types, and allow https://t.svelte.page in CSP script-src and
connect-src. Deny core-js's postinstall (funding banner, pulled in by
posthog-js) so frozen installs succeed under pnpm's build allowlist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jaysin586 jaysin586 added the skip-publish This is something important, but we dont want to publish it label Oct 8, 2026
jaysin586 and others added 2 commits October 8, 2026 18:11
…ypes

Bump wrangler 4.95.0 -> 4.148.0, @sveltejs/adapter-cloudflare 7.2.8 ->
7.2.9, and @cloudflare/workers-types 4.20260531.1 -> 5.20261006.1 (the
newest versions allowed by minimumReleaseAge), then regenerate
worker-configuration.d.ts with cf-typegen. compatibility_date and flags
are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Switch PUBLIC_POSTHOG_HOST and the CSP script-src/connect-src entries from
https://t.svelte.page to the org's dedicated proxy https://j.svelte.page,
and regenerate worker types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jaysin586
jaysin586 merged commit b328121 into main Oct 8, 2026
4 checks passed
@jaysin586
jaysin586 deleted the feat/posthog-analytics branch October 9, 2026 07:54

This branch was previously deployed

1 inactive deployment
docs — 91cb46bd Deployed Oct 8, 2026 by jaysin586 via Deploy #16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-publish This is something important, but we dont want to publish it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant