fix(api): send client error reports from production builds only - #557
Merged
Merged
Conversation
- 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>
✅ Deploy Preview for prunplanner-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
🟢 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 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.
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.
What and why
Unit tests that mock API failures sent real client error reports to
https://api.prunplanner.org/client-errors/:reportClientErrorposts with plainfetch, which the axios mocks don't catch. Vitest has noVITE_API_BASE_URL, soconfigfalls back to the prod API. The result was fake 500s and network errors in the prodclient_errordata in Axiom (#550). Local dev servers, which also talk to prod by default, polluted it the same way.Changes
reportClientErrorreturns early whenimport.meta.env.DEVis true, before the dedupe and cap bookkeeping. This is the same idiom asuseVersionCheck. Production builds, including the e2e stack, are unchanged:vite buildreplacesDEVwithfalse.clientErrorstests stubDEV=falsefor the send path and add a case proving nothing is sent whenDEV=true.How it was verified
DEVis true under both vitest configs and found no other unguarded network path to prod in unit tests.pnpm test && pnpm tsc && pnpm lint && pnpm knippass, andpnpm test:componentspasses too.Closes #550
🤖 Generated with Claude Code