feat: export markErrorCaptured for custom error boundaries - #66
Closed
sindrerh2 wants to merge 7 commits into
Closed
feat: export markErrorCaptured for custom error boundaries#66sindrerh2 wants to merge 7 commits into
sindrerh2 wants to merge 7 commits into
Conversation
## 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>
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Teams with their own React error boundary (instead of
ApmErrorBoundaryfrom@nais/apm/react) can now callmarkErrorCaptured(error)fromgetDerivedStateFromError, then report viacaptureExceptionincomponentDidCatch. This preventsNaisConsoleInstrumentationfrom reporting the same error a second time, since React 19 logs every caught error viaconsole.error(the defaultonCaughtError) beforecomponentDidCatchruns — previously onlyApmErrorBoundaryhad access to this dedupe mechanism internally.Why
A team maintains their own custom
ErrorBoundaryand wants to usecaptureExceptiondirectly without double-reporting via the console instrumentation.Changes
src/internal.ts:markErrorCapturedJSDoc updated for public consumption (usage + ordering requirements)src/index.ts: exportmarkErrorCapturedsrc/console.test.ts,src/index.test.ts— cover the mark → console.error → captureException dedupe flow end-to-endREADME.md: documented the pattern with an exampleTesting
pnpm test— all 232 tests pass (22 test files)pnpm typecheck— passes