Skip to content

fix(frontend): stop reporting Directus network blips at error level - #1023

Open
posthog-eu[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixfrontend-stop-reporting-directus-938d13
Open

fix(frontend): stop reporting Directus network blips at error level#1023
posthog-eu[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixfrontend-stop-reporting-directus-938d13

Conversation

@posthog-eu

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

Copy link
Copy Markdown

Problem

  • A few users on dashboard.dembrane.com turned "TypeError: Failed to fetch" into error-level exceptions — network blips, not real failures. The failing request only feeds the announcement bar and sidebar inbox, so no core flow breaks; the cost is noise in error tracking.
  • The announcement React Query hooks captured inside each queryFn try/catch and rethrew. With retry: 2, one offline moment reported the same failure up to three times.
  • The captured frame was minified (async queryFn in assets/index-<hash>.js), because the dashboard build ships no source maps — so every dashboard exception is hard to place.

Changes

Capture once, and below error level for network blips

  • Route capture through the existing global QueryCache / MutationCache onError handlers, which fire once, after retries are spent.

  • New requestErrorCapture helper classifies the failure:

    Failure Before After
    Connectivity blip (offline, dropped fetch) captureException per attempt (up to 3×), error level one low-severity request_network_error event, out of error tracking
    Application error (e.g. 500) captureException per attempt one captureException, tagged with request name + offline flag
  • Capture only runs for requests that opt in with meta.errorName, so this does not widen capture to every query in the app.

  • Removes the now-redundant per-request try/catch. The mutations already toast in onError, so this also removes a duplicate toast.

Source maps for the dashboard build

  • build.sourcemap: true in the Vite config.
  • A gated PostHog/upload-source-maps step in the dev and prod dashboard deploy workflows. It is skipped until the POSTHOG_CLI_API_KEY secret is set, so it never blocks a deploy.

Note

To activate the upload, add a POSTHOG_CLI_API_KEY repository secret (a personal API key with error tracking write + organization read). Until then, maps are still emitted and publicly served, which already lets PostHog symbolicate the public dashboard bundle.

Verification

  • tsc --noEmit, biome lint (0 errors), and vite build (58 maps emitted with sourceMappingURL) all pass.
  • New unit tests for the classifier, plus the announcement suite: 35 tests pass.

Agent context

  • This lives in Dembrane/echo (the dashboard frontend), not the site repo the task was filed against.
  • Considered a per-hook fix, but the global cache handler is the only place that fires once after retries; the meta.errorName opt-in keeps the blast radius to the announcement hooks.

Created with PostHog Desktop from this inbox report.

posthog-eu Bot added 2 commits September 1, 2026 08:30
The announcement React Query hooks captured each Directus failure inside the
queryFn try/catch and rethrew. A query with `retry: 2` therefore reported the
same failure up to three times, and a transient connectivity blip (fetch
rejects with a TypeError) landed in error tracking at error level as pure noise.

- Route capture through the existing global QueryCache / MutationCache error
  handlers, which fire once after retries are spent.
- Add `requestErrorCapture`: a bare network blip becomes a low-severity event
  and stays out of error tracking; any other failure is captured as an
  exception. Both carry the request name and an offline flag.
- Only requests that opt in with `meta.errorName` are captured, so the change
  does not widen capture to every query in the app.
- Drop the now-redundant per-request try/catch (the mutations already toast in
  onError, so this also removes a double toast).

Separately, emit build source maps and add a gated PostHog upload step to the
dashboard deploy workflows, so future dashboard exceptions arrive symbolicated
instead of as minified frames.

Generated-By: PostHog Desktop
Task-Id: e2bdde38-0dae-448d-80a9-63d27bfeff03
Removing the redundant per-mutation try/catch moved the `t` macro call sites,
so the catalog source-location references drifted. Re-run extract and compile;
only the `#:` references change, no msgids or translations.

Generated-By: PostHog Desktop
Task-Id: e2bdde38-0dae-448d-80a9-63d27bfeff03
@posthog-eu
posthog-eu Bot marked this pull request as ready for review September 1, 2026 08:50
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