Skip to content

feat: export markErrorCaptured for custom error boundaries - #66

Closed
sindrerh2 wants to merge 7 commits into
betafrom
feat/export-mark-error-captured
Closed

feat: export markErrorCaptured for custom error boundaries#66
sindrerh2 wants to merge 7 commits into
betafrom
feat/export-mark-error-captured

Conversation

@sindrerh2

Copy link
Copy Markdown

What

Teams with their own React error boundary (instead of ApmErrorBoundary from @nais/apm/react) can now call markErrorCaptured(error) from getDerivedStateFromError, then report via captureException in componentDidCatch. This prevents NaisConsoleInstrumentation from reporting the same error a second time, since React 19 logs every caught error via console.error (the default onCaughtError) before componentDidCatch runs — previously only ApmErrorBoundary had access to this dedupe mechanism internally.

Why

A team maintains their own custom ErrorBoundary and wants to use captureException directly without double-reporting via the console instrumentation.

Changes

  • src/internal.ts: markErrorCaptured JSDoc updated for public consumption (usage + ordering requirements)
  • src/index.ts: export markErrorCaptured
  • Tests: src/console.test.ts, src/index.test.ts — cover the mark → console.error → captureException dedupe flow end-to-end
  • README.md: documented the pattern with an example

Testing

  • pnpm test — all 232 tests pass (22 test files)
  • pnpm typecheck — passes

Starefossen and others added 7 commits September 10, 2026 08:33
## Summary
- create a reviewable sync PR from main to beta after each main push
- run the ci-ok check for pull requests targeting beta
- document beta synchronization and protection requirements

## Validation
- actionlint
- git diff --check

The beta ruleset could not be created from this session because GitHub
API write operations are blocked by the sandbox.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
## Summary
- restrict beta manual publishing to workflow dispatches run from the
beta branch
- document the required beta-branch dispatch

Supersedes #46, which conflicts because #45 was squash-merged.

## Validation
- actionlint
- git diff --check

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
## Summary
- document stable-only and beta-first release flows
- document how to resolve beta synchronization release-state conflicts
- restore repository scoping and explicit GitHub CLI failure handling in
the beta sync workflow

## Validation
- actionlint
- git diff --check

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
## Summary
- configure the beta Release Please workflow with target-branch: beta
- prevent beta release runs from using main release state or updating
main Release PRs

## Validation
- actionlint
- git diff --check

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
## Summary
- configure Release Please's prerelease versioning strategy for beta
releases
- retain the beta prerelease GitHub Release flag and beta version
identifier

## Validation
- JSON validation
- git diff --check

Supersedes beta Release PR #57, which generated a plain version because
the versioning strategy was omitted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
## Summary
- accept both valid Release Please beta suffix forms: -beta and -beta.N
- correct beta release version examples in the release guide

## Validation
- actionlint
- git diff --check
- exercised guard matching for beta, beta.1, and stable versions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Teams with their own React error boundary (instead of ApmErrorBoundary
from @nais/apm/react) can now call markErrorCaptured(error) from
getDerivedStateFromError before reporting via captureException in
componentDidCatch. This prevents NaisConsoleInstrumentation from
reporting the same error a second time when React 19 logs it via
console.error ahead of componentDidCatch — the same dedupe mechanism
ApmErrorBoundary already relies on internally.

Documented usage and ordering requirements in the README and in the
function's JSDoc. Added test coverage in console.test.ts (console
instrumentation skips a marked error) and index.test.ts (end-to-end:
mark -> console.error -> captureException reports exactly once).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sindrerh2

Copy link
Copy Markdown
Author

Superseded by #71 — rebuilt cleanly on top of the current beta (this branch had drifted/conflicted after #68 was merged).

@sindrerh2 sindrerh2 closed this Sep 14, 2026
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.

2 participants