Skip to content

feat(analytics): proxy posthog-js capture through /ingest - #26

Draft
posthog[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/featanalytics-proxy-posthog-js-capture-33a6cc
Draft

posthog[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/featanalytics-proxy-posthog-js-capture-33a6cc

Conversation

@posthog

@posthog posthog Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • Ad blockers can silently drop pageviews from www.lightcms.me. The traffic numbers are low by an unknown amount.
  • posthog-js sends events directly to us.i.posthog.com, and vercel.json has no rewrites. Thus no production event goes through a proxy.
  • On a developer-facing CMS, many visitors are likely to use ad blockers.

Origin

  • Health checks
  • Scout: signals-scout-general
  • First signal: 2026-10-23
  • Inbox report: open
  • Task started by: auto-start, after the report was rated P3 and ready to fix

Changes

  • Same-origin reverse proxy: the browser sends all PostHog traffic to /ingest on the site, and Vercel rewrites it to PostHog.
Path Destination
/ingest/static/* https://us-assets.i.posthog.com/static/*
/ingest/array/* https://us-assets.i.posthog.com/array/* (remote config bundle)
/ingest/* https://us.i.posthog.com/*
- api_host: "https://us.i.posthog.com",
+ api_host: "/ingest",
+ ui_host: "https://us.posthog.com",
  • The project token does not change.
  • vite.config.ts gets a matching server.proxy. Without it, vp dev would send capture requests to /ingest and get 404s.
  • Locale routing does not intercept /ingest. The Vercel rewrites apply before the SvelteKit function runs, and ingest is not a locale, so reroute and handleI18n do not change the path.

Warning

Vercel bills proxied traffic as Fast Data Transfer and Edge Requests. Current traffic is low, so the cost is small. If session replay volume grows, the PostHog managed reverse proxy has no data transfer cost.

How to verify

  • vp fmt --check and vp lint pass on the changed files.
  • vp test run: 9 files, 105 tests pass.
  • In vp dev, /ingest/static/array.js, /ingest/array/<token>/config.js and POST /ingest/flags return 200 through the proxy.
  • Preview deploy: the network tab shows /ingest/e/ and /ingest/flags requests with status 200, and no requests to *.i.posthog.com.
  • After production deploy: the proxied share of production pageviews goes from 0% to at least 90% in the first full 7 days. If production pageviews drop to zero, the proxy broke capture. Revert this PR.

Agent context

  • I did not test the Vercel rewrites themselves in the sandbox. The rewrite syntax follows the PostHog Vercel proxy guide. The preview deploy is the first real test.
  • I added the /ingest/array/* rule in addition to the two rules in the report, because posthog-js loads its remote config from that path.
  • The sandbox checkout has a broken static/llms.txt symlink (the static/skills submodule is not checked out). To load the Vite config, I added a temporary local stub. I did not commit it.
  • I did not run full vp check. On main, it already fails on unrelated files, so I ran format and lint on the changed files only.

Created with PostHog Desktop from this inbox report.

🤖 Generated with Claude Code

Add same-origin Vercel rewrites from /ingest to the PostHog US ingest and asset hosts. Set api_host to /ingest and ui_host to the PostHog app. Add a matching Vite dev-server proxy so that local capture continues to work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: 6ec7c1b0-ee13-449c-a6a4-17f92ad9c46b
@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lightcms Ready Ready Preview Nov 12, 2026 7:30am UTC

@posthog
posthog Bot requested a review from Pratyay360 November 12, 2026 07:27
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 35d7e1a5-8d1d-4ff0-ad97-802385dc698d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: 6ec7c1b0-ee13-449c-a6a4-17f92ad9c46b

This branch was successfully deployed

1 active deployment
Preview — 09b42b25 Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants