Skip to content

Feature/error boundary - #107

Open
yahia008 wants to merge 12 commits into
GruftNet:mainfrom
yahia008:feature/error-boundary
Open

Feature/error boundary#107
yahia008 wants to merge 12 commits into
GruftNet:mainfrom
yahia008:feature/error-boundary

Conversation

@yahia008

@yahia008 yahia008 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Title

feat(frontend): implement issue #99 - Error Boundary and Sentry Monitoring
Closes #99

Description

This PR implements the Error Boundary & Monitoring system (Issue #99) to safeguard the application against React
component-level crashes, integrate automated error tracking using Sentry, classify errors, scrub sensitive user
information/credentials before logging, and present a premium user fallback UI.

Additionally, this PR fixes a few pre-existing syntax/compilation errors in the frontend workspace files to ensure
clean compilation.

Key Changes

  1. Sentry SDK Integration & Configuration:
    • Integrated @sentry/nextjs into the React application workspace.
    • Configured Sentry client, server, and edge configuration files ( sentry.client.config.ts , sentry.server.
    config.ts , and sentry.edge.config.ts ).
    • Hooked Sentry webpack compilation into next.config.js to enable source maps while hiding them from public
    bundles in production.
  2. Error Categorization & Standardized Logger:
    • Created ErrorCategory ( USER , BUG , NETWORK , WALLET ) and AppError subclass supporting details and
    user-facing notifications.
    • Created logError utility in src/lib/error.ts to automatically assign scopes, categories, and report to
    Sentry.
  3. Data Scrubbing & Sanitization:
    • Implemented sanitizeString and sanitizeObject utility functions to automatically filter sensitive fields
    from messages, stack traces, and contexts before reaching Sentry.
    • Specifically filters out Stellar secret keys (56-char uppercase keys starting with S ), 64-character hex
    keys/private keys, email addresses, JWT tokens, and sensitive request headers ( authorization , cookie , set-
    cookie , x-api-key ).
  4. Premium Error Overlay UI:
    • Redesigned ErrorBoundary component to capture rendering crashes and show a responsive glassmorphic card
    with ambient background glows, warning icons, a sanitized error code block, and buttons to reload ("Try again")
    or navigate home.
    • Redesigned Next.js global route error.tsx page to log crashes automatically and render matching premium
    glassmorphic actions.
  5. Pre-existing Codebase Fixes:
    • Corrected a duplicate code block and missing closing bracket in the governance/[id]/page.tsx page.
    • Resolved a TypeScript JSX compiler error in useLeaderboard.test.ts (a .ts file containing JSX code) by
    converting the wrapper implementation to use React.createElement .

──────

Technical Specs & Testing

Wrote 14 comprehensive unit tests in two suites matching /src/components/ui/tests :

• ErrorBoundary.test.tsx : Verifies crash catching, logging to Sentry handler, fallback rendering, reload button
click handler, and navigation.
• error.test.ts : Verifies full regex redacting/scrubbing for Stellar secrets, hex keys, emails, JWT tokens, and
nested objects, as well as verifying correct Sentry logging scope tag mapping.

Test Run Results:

PASS components src/components/ui/__tests__/error.test.ts
PASS components src/components/ui/__tests__/ErrorBoundary.test.tsx

Test Suites: 2 passed, 2 total
Tests:       14 passed, 14 total
Snapshots:   0 total
Time:        5.249 s
──────

Checklist

[✓] Error boundaries catch all component errors
[✓] Sentry SDK integrated on client, server, and edge runtimes
[✓] Stack traces captured safely with source maps configured
[✓] Sensitive user data (Stellar private seeds, hex keys, JWTs, emails) filtered from logs
[✓] Users shown responsive glassmorphism warning card
[✓] Comprehensive unit tests passing for boundaries and sanitization utilities***

───────────────────────────────────────────────

image

yahia008 added 12 commits July 17, 2026 23:54
- Split into parallel jobs: lint, typecheck, test, build
- Add --forceExit --ci to jest to prevent CI hangs from open handles
- Add --no-lint to next build (lint runs as separate dedicated job)
- Add NEXT_TELEMETRY_DISABLED=1 to build step
- Add workflow file itself to paths trigger
- Add branches: [main, develop] to push trigger
.babelrc was forcing Next.js to use Babel instead of SWC, causing:
- next/font incompatibility (requires SWC)
- Babel failing to parse class private methods in Sentry/node deps

Jest transforms already use ts-jest and babel-jest with configFile:false
so .babelrc was not needed by tests.
- Wrap useSearchParams() in Suspense boundary on / and /leaderboard
  (required by Next.js 14 app router for static page generation)
- Move router.push() in /create from render time into useEffect
  to avoid ReferenceError: location is not defined during SSR
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.

Implement Error Boundary & Monitoring

1 participant