Skip to content

fix(api): send client error reports from production builds only - #557

Merged
jplacht merged 1 commit into
mainfrom
fix/client-errors-dev-guard
Oct 2, 2026
Merged

jplacht merged 1 commit into
mainfrom
fix/client-errors-dev-guard

Conversation

@jplacht

@jplacht jplacht commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

What and why

Unit tests that mock API failures sent real client error reports to https://api.prunplanner.org/client-errors/: reportClientError posts with plain fetch, which the axios mocks don't catch. Vitest has no VITE_API_BASE_URL, so config falls back to the prod API. The result was fake 500s and network errors in the prod client_error data in Axiom (#550). Local dev servers, which also talk to prod by default, polluted it the same way.

Changes

  • reportClientError returns early when import.meta.env.DEV is true, before the dedupe and cap bookkeeping. This is the same idiom as useVersionCheck. Production builds, including the e2e stack, are unchanged: vite build replaces DEV with false.
  • The clientErrors tests stub DEV=false for the send path and add a case proving nothing is sent when DEV=true.

How it was verified

  • QA review: PASS, no blocking findings. It confirmed DEV is true under both vitest configs and found no other unguarded network path to prod in unit tests.
  • DoD: pnpm test && pnpm tsc && pnpm lint && pnpm knip pass, and pnpm test:components passes too.
  • No user-visible change, so no screenshots.

Closes #550

🤖 Generated with Claude Code

- reportClientError returns early when import.meta.env.DEV is true, so
  vitest runs and dev servers no longer post fake reports to the
  production client-errors endpoint
- clientErrors tests stub DEV=false for the send path and cover the
  DEV=true no-op

Closes #550

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

netlify Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for prunplanner-preview ready!

Name Link
🔨 Latest commit 5182fd5
🔍 Latest deploy log https://app.netlify.com/projects/prunplanner-preview/deploys/6abf601b8a1a1a0007850675
😎 Deploy Preview https://deploy-preview-557--prunplanner-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codacy-production

codacy-production Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.00% coverage variation

Metric Results
Coverage variation ✅ +0.00% coverage variation (-1.00%)
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (bc2c082) 3714 3624 97.58%
Head commit (5182fd5) 3715 (+1) 3625 (+1) 97.58% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#557) 1 1 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jplacht
jplacht merged commit 3a9e1a8 into main Oct 2, 2026
11 checks passed
@jplacht
jplacht deleted the fix/client-errors-dev-guard branch October 2, 2026 07:43
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.

Unit tests send client error reports to the production API

1 participant