Skip to content

Make portal exceptions readable: source maps + injected-script filter - #1024

Draft
posthog-eu[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixfrontend-upload-source-maps-and-991cea
Draft

Make portal exceptions readable: source maps + injected-script filter#1024
posthog-eu[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixfrontend-upload-source-maps-and-991cea

Conversation

@posthog-eu

@posthog-eu posthog-eu Bot commented Sep 1, 2026

Copy link
Copy Markdown

Problem

  • Portal crashes reach error tracking minified and unattributable, so an injected mobile-browser error (a single Error: Ca whose only frame points at the document URL) looks exactly like a real crash. Portal session recording is off, so a minified frame is the only evidence.
  • Two gaps cause this: the frontend build emits no source maps and nothing uploads them, and posthog.init runs exception autocapture with no before_send filter.

Changes

  • Symbolicate real crashes. vite.config.ts now emits sourcemap: "hidden" (.map files, no sourceMappingURL comment in the served bundles). Each Vercel deploy workflow runs posthog-cli sourcemap process --delete-after between build and deploy: it injects a chunk id, uploads the maps to PostHog, and strips the maps so they are never served.
  • Drop injected-script noise. A before_send filter (src/lib/errorTracking.ts) drops any $exception whose every stack frame resolves to the document URL. Real errors keep frames that point at /assets/*.js and pass through untouched. Events with no frames also pass through.

Source map upload targets the PostHog project each environment reports into:

Workflow Deploy target PostHog project
prod-deploy-vercel-portal / -dashboard production 160282
dev-deploy-vercel-portal / -dashboard echo-next 197841

Scope note

The reported signal is on the participant portal, but the frontend build and posthog.init are shared with the dashboard. Both apps therefore get source maps and the filter. The upload step is added to all four deploy workflows so .map files are always uploaded and then deleted, never shipped.

Risk

Note

The upload step needs a new repo secret POSTHOG_CLI_API_KEY (a personal API key with error tracking write + organization read). The step is continue-on-error: true, so a missing secret or upload failure logs a warning and never blocks a deploy.

Testing

  • src/lib/errorTracking.test.ts covers drop (document-only frame), keep (asset frame, mixed frames, no frames), and pass-through (non-exception, null). 6/6 pass.
  • vite build verified: .map files emitted, no sourceMappingURL comment in served JS.
  • tsc --noEmit and biome lint clean.

Agent context

  • Considered @posthog/rollup-plugin instead of the CLI step; rejected to avoid a lockfile change under --frozen-lockfile and to keep upload on the deploy path only, not local/preview builds.

Created with PostHog Desktop from this inbox report.

Portal exceptions land in error tracking minified and unattributable, so
noise from injected mobile-browser scripts is indistinguishable from real
crashes. Two changes fix this:

- Emit hidden source maps from the frontend build and upload them to PostHog
  error tracking from each Vercel deploy workflow (inject + upload + delete),
  so real crashes symbolicate instead of arriving minified.
- Add a posthog-js before_send filter that drops $exception events whose every
  stack frame resolves to the document URL. These come from scripts that in-app
  browsers and extensions inject into the page, never from our bundled assets.

Generated-By: PostHog Desktop
Task-Id: 04e9717f-b1d1-4190-9b1f-fcbbf9c45e99
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