Repository navigation
feat(docs): add PostHog analytics for memory.svelte.page - #194
Merged
Merged
Conversation
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>
…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>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()startsposthog-jswithapi_hostset to the managed reverse proxyhttps://j.svelte.page(the Svelte.page org's dedicated proxy, which replaces the sharedt.svelte.page; its DNS is still being set up),defaults: '2026-01-30', andcapture_exceptions: true.handleErrorforwards client errors toposthog.captureException.docs/wrangler.jsonc: adds thePUBLIC_POSTHOG_PROJECT_TOKENandPUBLIC_POSTHOG_HOSTvars. The project token is a public client SDK identifier, so it has a checkov skip comment.docs/src/worker-configuration.d.ts: regenerated withpnpm cf-typegen.docs/svelte.config.js: CSP now allowshttps://j.svelte.pageinscript-src(for lazy-loaded PostHog extensions) andconnect-src(for ingestion). Every other directive is unchanged.docs/package.json/pnpm-lock.yaml: addsposthog-js^1.438.1 to the docs package only.pnpm-workspace.yaml: addscore-js: falsetoallowBuilds.posthog-jspulls incore-js, and pnpm treats an unapproved build script as an error, sopnpm install --frozen-lockfilefails without this entry. The only thingcore-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 regeneratesworker-configuration.d.tswithpnpm 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-pluginisn't a dependency, and the rootpackage.jsondoesn't pin wrangler.compatibility_date/compatibility_flagsare unchanged, and wrangler printed no warning about the compatibility date. The regenerated env types still include every var inwrangler.jsonc.Verification
pnpm checkin docs: 0 errors, 0 warnings. The library has to be built first (pnpm buildat the root), the same as on main.pnpm buildin docs (the production build with adapter-cloudflare): passes, and the favicon check passes.trunk fmtandtrunk checkon the changed files: no issues.phc_tokens: the only ones are inwrangler.jsoncand the generatedworker-configuration.d.ts.docs/srccode has none, and there is no other PostHog init path.🤖 Generated with Claude Code