Skip to content

feat(reporter): add pluggable error reporter with noop default#242

Merged
ezedike-evan merged 4 commits into
ezedike-evan:mainfrom
Abdulrasaq1515:feat/pluggable-error-reporter
Jun 1, 2026
Merged

feat(reporter): add pluggable error reporter with noop default#242
ezedike-evan merged 4 commits into
ezedike-evan:mainfrom
Abdulrasaq1515:feat/pluggable-error-reporter

Conversation

@Abdulrasaq1515
Copy link
Copy Markdown
Contributor

@Abdulrasaq1515 Abdulrasaq1515 commented May 29, 2026

  • Add lib/reporter.ts with reportError, configureReporter, resetReporter
  • Wire SepError constructor to auto-call reportError with code + httpStatus
  • Add tests covering noop default, mock reporter, Sentry-compatible pattern

Closes #184

Summary

Linked issue

Closes #184

Changes

Testing notes

Automated

  • npm run typecheck · ⏳ not run / ✅ green / ❌ failing
  • npm run lint · ⏳ not run / ✅ green / ❌ failing
  • npm run test · ⏳ not run / ✅ green / ❌ failing
  • npm run build · ⏳ not run / ✅ green / ❌ failing

New / modified tests

Manual verification (if applicable)

Screenshots / recordings

Before After

Checklist

Correctness

  • The PR title follows Conventional Commits (auto-linted)
  • One logical change; unrelated cleanup was split into a separate PR
  • npm run typecheck passes
  • npm run lint passes with zero new warnings (we run --max-warnings 0 in CI)
  • npm run test passes; new behaviour has a test
  • npm run build passes

Data integrity

  • No fabricated rates, stub prices, or placeholder exchange rates (see issue.md #005)
  • No isMock, // MOCK, // TODO: replace with real data, or commented-out real code
  • If touching an anchor: the anchor's stellar.toml is publicly resolvable at https://{domain}/.well-known/stellar.toml and contains TRANSFER_SERVER_SEP0024
  • If touching SEP-10: network passphrase assertion is intact (mainnet only)
  • If touching SEP-24: the 10s AbortController timeout is intact on anchor fetches
  • If touching the status poll: terminal states (completed | refunded | error) still stop the SWR loop

Security & non-custody (see docs/NON_CUSTODY.md once it lands)

  • No new code path holds user keys, user funds, or long-lived anchor JWTs
  • Every signing action is performed by the user's wallet (Freighter today)
  • No secrets committed; .env.local is unchanged; new env vars are added to .env.example

Docs

  • User-facing behaviour change → CHANGELOG.md entry under [Unreleased]
  • API / schema change → relevant docs/*.md updated in the same PR
  • Architecture change → docs/ARCHITECTURE.md updated (file map, diagram, or invariants as applicable)
  • Public-facing feature → screenshot added to docs/showcase/images/ when relevant
  • New env var → .env.example + README env table updated

Release hygiene

  • If this touches a wave deliverable, the matching [ ] in docs/ROADMAP.md is updated
  • No dependency added without justification in the PR description
  • No breaking change hidden inside a non-breaking commit

Breaking changes

None.

For reviewers

@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

@Abdulrasaq1515 is attempting to deploy a commit to the ezedikeevan's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Owner

@ezedike-evan ezedike-evan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation in lib/reporter.ts is clean and well-structured — the noop default, the configureReporter/reportError/resetReporter API, and the Sentry-compatible doc example are all good patterns. Tests are solid too.

Two things need fixing before this can merge:

1. No linked issue.
Closes #pluggable-error-reporter is a text string, not a GitHub issue number. Every PR in this project must close a tracked issue. If no issue exists yet for this feature, open one first, then reference it here with Closes #<number>. The PR template's "Linked issue" section is also left blank and the checklist is unchecked — please fill those in.

2. Auto-reporting in the SepError constructor is too aggressive.

// lib/stellar/errors.ts
reportError(this, { code, httpStatus })  // fires on every SepError construction

parseSepErrorBody is called whenever any anchor returns a non-2xx response — 404s, 400s, rate limits, validation errors. Wiring reportError unconditionally into the constructor means a Sentry-configured reporter would receive an alert for every routine anchor error. In production, a single user session hitting a throttled anchor could generate dozens of Sentry events.

The fix is straightforward: remove the auto-call from the constructor and instead call reportError at the specific call sites where the error is genuinely unexpected (e.g., a 5xx from the anchor, a timeout, a network failure). Let the caller decide what is worth reporting:

// In the caller that handles a real server error:
try {
  await submitChallenge(...)
} catch (err) {
  if (err instanceof SepError && err.httpStatus >= 500) {
    reportError(err, { anchorDomain })
  }
  throw err
}

The reporter module itself is good — just fix the issue link and the wiring point, and this is ready to merge.

@Abdulrasaq1515 Abdulrasaq1515 force-pushed the feat/pluggable-error-reporter branch from 4fe5a1e to 537f52c Compare June 1, 2026 14:59
- Add lib/reporter.ts with reportError, configureReporter, resetReporter
- SepError constructor left clean; callers decide what is worth reporting
- reportError called at call sites for genuine failures (5xx) only
- Tests cover noop default, mock reporter, Sentry-compatible pattern,
  reset behavior, and call-site 5xx filtering pattern

Closes ezedike-evan#184
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@Abdulrasaq1515 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@ezedike-evan ezedike-evan merged commit 6e4cdb9 into ezedike-evan:main Jun 1, 2026
1 check failed
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.

[#093] pluggable error reporter (Sentry-compatible)

2 participants