Make portal exceptions readable: source maps + injected-script filter - #1024
Draft
posthog-eu[bot] wants to merge 1 commit into
Draft
Make portal exceptions readable: source maps + injected-script filter#1024posthog-eu[bot] wants to merge 1 commit into
posthog-eu[bot] wants to merge 1 commit into
Conversation
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
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.
Problem
Error: Cawhose 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.posthog.initruns exception autocapture with nobefore_sendfilter.Changes
vite.config.tsnow emitssourcemap: "hidden"(.mapfiles, nosourceMappingURLcomment in the served bundles). Each Vercel deploy workflow runsposthog-cli sourcemap process --delete-afterbetween build and deploy: it injects a chunk id, uploads the maps to PostHog, and strips the maps so they are never served.before_sendfilter (src/lib/errorTracking.ts) drops any$exceptionwhose every stack frame resolves to the document URL. Real errors keep frames that point at/assets/*.jsand pass through untouched. Events with no frames also pass through.Source map upload targets the PostHog project each environment reports into:
prod-deploy-vercel-portal/-dashboarddev-deploy-vercel-portal/-dashboardScope note
The reported signal is on the participant portal, but the frontend build and
posthog.initare shared with the dashboard. Both apps therefore get source maps and the filter. The upload step is added to all four deploy workflows so.mapfiles 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 witherror tracking write+organization read). The step iscontinue-on-error: true, so a missing secret or upload failure logs a warning and never blocks a deploy.Testing
src/lib/errorTracking.test.tscovers drop (document-only frame), keep (asset frame, mixed frames, no frames), and pass-through (non-exception, null). 6/6 pass.vite buildverified:.mapfiles emitted, nosourceMappingURLcomment in served JS.tsc --noEmitandbiome lintclean.Agent context
@posthog/rollup-plugininstead of the CLI step; rejected to avoid a lockfile change under--frozen-lockfileand to keep upload on the deploy path only, not local/preview builds.Created with PostHog Desktop from this inbox report.