Skip to content

Commit a159692

Browse files
author
Sébastien Henau
committed
Merge branch 'feature/react-flare-error-boundary-callback-improvements' into feature/flare-react-error-handler
2 parents 8697515 + 81b7c4f commit a159692

File tree

4 files changed

+74
-147
lines changed

4 files changed

+74
-147
lines changed

.claude/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,4 @@ promise rejections, async errors, component errors, etc.).
9696
## Publishing
9797

9898
- Update `version` in the package's `package.json`
99-
- Run `npm publish` from the individual package directory
99+
- Run `npm publish` from the individual package directory

.claude/docs/react-improvements.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ That's about it. There's room to grow.
1212

1313
---
1414

15-
## What Competitors Actually Capture
16-
17-
| Feature | Sentry | Datadog | Bugsnag | Rollbar | LogRocket |
18-
|--------------------------------|---------------------------------|------------------------|---------|---------|--------------|
19-
| Component stack | Yes (linked via `error.cause`) | Yes | Yes | Yes | No |
20-
| Component names in breadcrumbs | Yes (Babel plugin) | Yes (context provider) | No | No | Click only |
21-
| Component props/state | **No** | **No** | **No** | **No** | **No** |
22-
| Redux/store state | Separate pkg | No | No | No | Separate pkg |
23-
| React Router integration | v3-v7 + TanStack | Yes (RumRoute) | No | Manual | No |
24-
| React 19 root error handlers | Yes | Yes | No | No | No |
25-
| Component interaction trail | Via Babel annotations | Yes (context provider) | No | No | No |
26-
| `beforeCapture` scope hook | Yes | No | No | No | No |
27-
| User feedback dialog | Yes | No | No | No | No |
28-
| Component profiling | Yes (mount/render/update spans) | No | No | No | No |
15+
## Industry Landscape
16+
17+
| Feature | Industry standard | Flare |
18+
|--------------------------------|-------------------|---------|
19+
| Component stack | Yes | Yes |
20+
| Component names in breadcrumbs | Some (via plugins)| No |
21+
| Component props/state | **No** | **No** |
22+
| Redux/store state | Some | No |
23+
| React Router integration | Some | No |
24+
| React 19 root error handlers | Emerging | No |
25+
| Component interaction trail | Rare | No |
26+
| `beforeCapture` scope hook | Rare | No |
27+
| User feedback dialog | Rare | No |
28+
| Component profiling | Rare | No |
2929

3030
**Key finding: Nobody automatically captures component props or state.** Despite the theoretical possibility via React
3131
fiber internals, every tool either ignores these or provides manual hooks. Reasons: serialization complexity (circular
@@ -40,32 +40,32 @@ refs, functions, React elements), performance cost of fiber tree traversal, and
4040
1. **Better component stack formatting and sourcemap-decoded display** -- currently just splitting by newline. Could
4141
parse into structured data (component name, file, line) for better Flare dashboard rendering.
4242

43-
2. **`beforeCapture` callback on ErrorBoundary** -- like Sentry's `beforeCapture(scope, error, componentStack)`. Lets
43+
2. **`beforeCapture` callback on ErrorBoundary** -- a `beforeCapture(scope, error, componentStack)` hook. Lets
4444
users attach custom tags, component props, or state to the error before it's sent. This is the pragmatic answer to "
4545
how do we capture state" -- let the developer decide what to include.
4646

4747
3. **React 19 `createRoot` error handlers** -- provide a `flareReactErrorHandler()` function for the new
48-
`onCaughtError`/`onUncaughtError`/`onRecoverableError` hooks. Only Sentry and Datadog support this today. Gets you
48+
`onCaughtError`/`onUncaughtError`/`onRecoverableError` hooks. Few tools support this today. Gets you
4949
error capture *without* requiring an ErrorBoundary wrapper.
5050

5151
### Tier 2 -- Differentiating features (moderate effort)
5252

53-
4. **Component name annotation via build plugin** -- Sentry uses a Babel plugin to inject `data-sentry-component` and
54-
`data-sentry-source-file` attributes onto DOM nodes at build time. These survive minification. Since Flare already
53+
4. **Component name annotation via build plugin** -- inject component name and source file attributes onto DOM nodes at
54+
build time (e.g. `data-flare-component`, `data-flare-source-file`). These survive minification. Since Flare already
5555
has `@flareapp/vite`, this could be a Vite plugin addition or a separate Babel plugin. Component names would then
5656
appear in breadcrumbs/glows.
5757

5858
5. **React Router integration** -- capture parameterized route names (`/users/:id` instead of `/users/12345`) as
5959
context. Add navigation breadcrumbs on route changes. Support React Router v6/v7 and TanStack Router.
6060

6161
6. **State management integration** -- provide a Redux middleware and/or Zustand middleware that attaches store state
62-
snapshots to error reports. Sentry does this with `createReduxEnhancer()` with `stateTransformer` for sanitization.
62+
snapshots to error reports. Use a `stateTransformer` for sanitization.
6363
This is where "capture state" actually becomes practical -- at the store level, not the component level.
6464

6565
### Tier 3 -- Nice-to-have (higher effort)
6666

67-
7. **Component interaction breadcrumbs** -- like Datadog's `RumComponentContextProvider`, track which components the
68-
user interacted with before the error. This gives a "user journey through components" trail.
67+
7. **Component interaction breadcrumbs** -- track which components the user interacted with before the error. This gives
68+
a "user journey through components" trail.
6969

7070
8. **Component profiling** -- `withProfiler()` HOC / `useProfiler()` hook that tracks mount/render/update timing. Useful
7171
for correlating errors with performance, but requires a tracing infrastructure.
@@ -74,7 +74,7 @@ refs, functions, React elements), performance cost of fiber tree traversal, and
7474

7575
## What's NOT Worth Pursuing
7676

77-
- **Automatic props/state via fiber internals** -- no competitor does this. Internal API instability across React
77+
- **Automatic props/state via fiber internals** -- no tool does this reliably. Internal API instability across React
7878
versions, serialization nightmares, privacy risks, performance cost. The fiber tree (`memoizedProps`, `memoizedState`)
7979
is unstable and undocumented.
8080
- **`captureOwnerStack()`** -- React 19 API that returns `null` in production. Development-only, useless for error
@@ -88,7 +88,7 @@ refs, functions, React elements), performance cost of fiber tree traversal, and
8888
For the `@flareapp/react` package specifically:
8989

9090
1. `beforeCapture` callback on `FlareErrorBoundary` -- quick win, gives users control
91-
2. React 19 `createRoot` error handler utility -- forward-looking, puts Flare ahead of Bugsnag/Rollbar
91+
2. React 19 `createRoot` error handler utility -- forward-looking, few tools support this yet
9292
3. Structured component stack parsing -- better data for the Flare dashboard
9393
4. Vite/Babel plugin for component name annotations -- builds on existing `@flareapp/vite`
9494
5. React Router integration (v6/v7)

0 commit comments

Comments
 (0)