Skip to content

Commit

Permalink
ref(js): Add note about react error boundary and CaptureConsole (#7592)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Aug 4, 2023
1 parent 00e160c commit 57a1957
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/includes/platforms/configuration/integrations/plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ Available options:

_Import name: `Sentry.Integrations.CaptureConsole`_

This integration captures all `Console API` calls and redirects them to Sentry using the SDK's `captureMessage` or `captureException` call, depending on the log level. It then re-triggers to preserve default native behavior:
This integration captures all `Console API` calls and redirects them to Sentry using the SDK's `captureMessage` or `captureException` call, depending on the log level. It then re-triggers to preserve default native behavior.

<PlatformSection supported={["javascript.react"]}>

<Alert level="warning" title="Note">

By default React [logs all errors to the console](https://github.com/facebook/react/blob/493f72b0a7111b601c16b8ad8bc2649d82c184a0/packages/react-reconciler/src/ReactFiberErrorLogger.js#L85), even if you are using an React error boundary. This means that Sentry will capture the error through the `CaptureConsole` integration and not through the error boundary. We recommend disabling logging the `error` level if using React error boundaries and the `CaptureConsole` integration.

</Alert>

</PlatformSection>

<PlatformContent includePath="configuration/capture-console" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ class App extends React.Component {
export default App;
```

<Alert level="warning" title="Note">

By default React [logs all errors to the console](https://github.com/facebook/react/blob/493f72b0a7111b601c16b8ad8bc2649d82c184a0/packages/react-reconciler/src/ReactFiberErrorLogger.js#L85), even if you are using a React error boundary. If you are using the `CaptureConsole` integration this means that Sentry will capture the error through the `CaptureConsole` integration and not through the error boundary.

</Alert>

## Options

The ErrorBoundary component exposes a variety of props that can be passed in for extra configuration. There are no required options, but we highly recommend that you set a fallback component.
Expand Down

1 comment on commit 57a1957

@vercel
Copy link

@vercel vercel bot commented on 57a1957 Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

docs.sentry.io
sentry-docs-git-master.sentry.dev
sentry-docs.sentry.dev

Please sign in to comment.