Skip to content

Stop reporting handled chat-context 4xx as exceptions; upload source maps - #1022

Draft
posthog-eu[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixerror-tracking-stop-reporting-0ed409
Draft

Stop reporting handled chat-context 4xx as exceptions; upload source maps#1022
posthog-eu[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixerror-tracking-stop-reporting-0ed409

Conversation

@posthog-eu

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

Copy link
Copy Markdown

Problem

  • The team's error tracking fills with issues that are really the backend telling a user "that conversation is already in this chat". The user flow is fine (clear toast, optimistic rollback), so this cost lands on triage, not users.
  • useAddChatContextMutation.onError calls posthog.captureException(error) as its first line, then rolls back and shows a toast built from the server's detail. So expected 400s from add_chat_context (already attached, too long, context budget exceeded) file as application exceptions. The delete and clear-context handlers repeat the shape.
  • No source-map upload is configured, so frames stay minified (IJ in /assets/index-*.js). The fingerprint churns on every deploy and each handled 400 reopens as a first-seen issue.

Changes

  • Report only unexpected failures. A new captureUnexpectedError helper reports 5xx responses, network errors, and non-Axios errors, and skips handled 4xx AxiosErrors. It replaces the four raw captureException calls in the add, delete, and clear chat-context handlers. Toasts and optimistic rollback are unchanged.
  • Upload source maps. vite build emits maps when POSTHOG_SOURCEMAPS=1. The two dashboard deploy workflows set that flag, then inject and upload maps to PostHog with @posthog/cli, then strip the maps from the deployed bundle. Frames symbolicate and fingerprints stay stable across deploys.
Error Before After
Handled 4xx (already attached, too long, budget) captured skipped, toast only
5xx response captured captured
Network / non-Axios error captured captured

Deploy setup

  • Add a POSTHOG_CLI_API_KEY repository secret: a PostHog personal API key with the error_tracking:write scope. Without it the upload step is a no-op (continue-on-error: true) and never blocks a deploy.
  • Source maps upload for the dashboard only. Preview and portal builds do not set POSTHOG_SOURCEMAPS, so they emit no maps.

Testing

  • tsc --noEmit and biome check pass on the changed files.
  • One pre-existing unrelated test failure (AgenticChatPanel "Recording limit reached") reproduces on main and is not touched by this change.
  • The source-map workflow steps run only on deploy and were not executed here.

Agent context

  • Considered the @posthog/rollup-plugin route (upload during vite build), but the frontend build runs through vercel build and the repo keeps secrets in GitHub Actions, not Vercel env. The CLI-in-CI route keeps the key and project id in the workflow.

Created with PostHog Desktop from this inbox report.

posthog-eu Bot added 2 commits September 1, 2026 08:30
…maps

The chat-context mutation handlers reported every failure to PostHog error
tracking, including expected 4xx rejections that already show the user a toast
with the server's `detail`. With no source-map upload, minified frames
re-fingerprinted on each deploy, so the same handled 400 kept reopening as a new
issue and flooded triage.

- Add `captureUnexpectedError`: report only 5xx, network, and non-Axios errors.
  Use it in the add, delete, and clear chat-context handlers. Toast and
  optimistic rollback are unchanged.
- Emit source maps when `POSTHOG_SOURCEMAPS=1`, set by the dashboard deploy
  workflows. Each workflow injects and uploads maps via @posthog/cli, then
  strips them from the bundle. Needs the `POSTHOG_CLI_API_KEY` repo secret.

Generated-By: PostHog Desktop
Task-Id: f39ee2a6-4317-440f-8a9f-b30451fc7b21
Adding the captureUnexpectedError helper shifted the line numbers of the
existing `t` calls in conversation/hooks/index.ts, so the lingui source
references drifted. Re-run extract and compile so ci-check-i18n-catalogs passes.
No msgids changed.

Generated-By: PostHog Desktop
Task-Id: f39ee2a6-4317-440f-8a9f-b30451fc7b21
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