Commit b574546
feat(web): wire PostHog analytics into sqlritedb.com (SQLR-7) (#137)
- Add `@posthog/next` v0.4.x with `PostHogProvider` + `PostHogPageView`
in the root layout for autocapture and pageview tracking.
- Add `src/middleware.ts` running `postHogMiddleware({ proxy: true })`
to seed the anonymous identity cookie and reverse-proxy `/ingest/*`
to the PostHog ingest host (dodges ad-blockers).
- Gate both the provider and middleware on `NEXT_PUBLIC_POSTHOG_KEY`
so preview deploys without the secret still build and serve.
- Matcher includes `/ingest/:path*` explicitly (the file-extension
exclusion would otherwise block proxy paths like
`/ingest/static/array.js`) and excludes Next internals, dotted
paths (sitemap, robots, rss, images, fonts), and the dynamic
OG/Twitter image metadata routes to keep Vercel middleware
invocations bounded.
- `PostHogProvider` runs without `bootstrapFlags`, so it stays
static-render-safe: all 49 prerendered routes (`/`, `/docs`,
`/blog`, blog tags, RSS, OG images, sitemap, robots) keep static
generation under `next build`.
- README's "Deploying" section now documents the env vars, the
`NEXT_PUBLIC_*` build-time-baking gotcha, the analytics surface,
and the open EU-consent follow-up.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5551555 commit b574546
5 files changed
Lines changed: 591 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
229 | 271 | | |
230 | 272 | | |
231 | 273 | | |
| |||
0 commit comments