home / skills / harborgrid-justin / lexiflow-premium / react-error-boundary-analytics

react-error-boundary-analytics skill

/frontend/.github-skills/react-error-boundary-analytics

This skill helps you capture and report runtime errors in React apps with component stack traces and user context for faster debugging.

npx playbooks add skill harborgrid-justin/lexiflow-premium --skill react-error-boundary-analytics

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
603 B
---
name: react-error-boundary-analytics
description: Capture and report runtime errors with component stack traces and user context.
---

# React Error Boundary Analytics

## Summary
Capture and report runtime errors with component stack traces and user context.

## Key Capabilities
- Catch render-phase errors.
- Send reports to logging service.
- Display fallback UI.

## PhD-Level Challenges
- Recover from errors gracefully.
- Group similar errors.
- Avoid infinite error loops.

## Acceptance Criteria
- Demonstrate catching a throw.
- Show the report payload.
- Reset the boundary successfully.

Overview

This skill captures and reports React runtime errors with component stack traces and user context to aid debugging and compliance reporting. It renders a configurable fallback UI and supports resetting error boundaries to allow recovery. The implementation is tuned for production workflows in legal and premium platforms where auditability and graceful degradation are critical.

How this skill works

The error boundary wraps React component trees and catches render-phase exceptions, extracting componentStack, error message, and optional user/session context. It assembles a structured payload and sends it to a logging or analytics endpoint, while rendering a fallback UI to the user. The boundary exposes reset controls and guards to prevent infinite error loops and supports grouping similar errors in the payload.

When to use it

  • Protect critical UI sections where failures must not crash the whole app
  • Capture detailed error telemetry including component stack traces for postmortems
  • Provide users with a safe fallback and a path to recover after an error
  • Collect contextual info (user id, route, form state) for legal/audit requirements
  • Group and deduplicate similar errors before alerting SRE or legal teams

Best practices

  • Include minimal, privacy-compliant user context fields and avoid PII unless explicitly required
  • Throttle or batch reports to avoid flooding the logging service during spikes
  • Provide a clear, non-technical fallback UI with an option to retry or report the issue
  • Implement a reset mechanism tied to user action or navigation to recover state safely
  • Guard report sending with circuit breakers to avoid infinite loops if the logger fails

Example use cases

  • Wrap transaction forms and document editors to capture render errors without losing user data
  • Send structured error reports to compliance logging for legal platform audits
  • Display a friendly fallback and let users retry a failed workflow after a boundary reset
  • Group identical component-stack errors into a single incident for easier root-cause analysis
  • Attach user session and route context to each error for faster incident triage

FAQ

How is sensitive user data handled in reports?

Only include non-identifying context by default; make PII optional and gated behind explicit consent and secure transport.

How do you avoid infinite error loops from the logger itself?

Use fail-safe guards: local storage flags, exponential backoff, batching, and a circuit breaker that halts reporting if the logger repeatedly fails.