Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions docs/platforms/react-native/integrations/console-logging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,49 @@ description: "Capture console API calls as Sentry logs in React Native."

<Alert level="info" title="Sentry Logs">

Enable the Sentry Logs feature with `enableLogs: true` in your `Sentry.init` call to unlock Sentry's full logging power. With Sentry Logs, you can search, filter, and analyze logs from across your entire application in one place.
Sentry Logs are enabled by default. Calls to `Sentry.logger.*` are sent without any extra configuration. With Sentry Logs, you can search, filter, and analyze logs from across your entire application in one place.

</Alert>

Console Logging integration is enabled by default which means calls to the `console` API will be captured as logs in Sentry. By default the integration instruments `console.debug`, `console.info`, `console.warn`, `console.error`, `console.log`, `console.trace`, and `console.assert`.
The Console Logging integration captures calls to the `console` API as logs in Sentry. By default the integration instruments `console.debug`, `console.info`, `console.warn`, `console.error`, `console.log`, `console.trace`, and `console.assert`.

## Disabling Console Logging Integration
## Enabling Console Logging Integration

To disable the integration, filter it out from the integrations array:
The integration is opt-in and must be added explicitly to the `integrations` array of your `Sentry.init` call:

```js
import * as Sentry from "@sentry/react-native";

Sentry.init({
...,
integrations(integrations) {
return integrations.filter(i => i.name !== 'ConsoleLogs');
},
...
})
dsn: "___PUBLIC_DSN___",
integrations: [Sentry.consoleLoggingIntegration()],
});
```

You can pass a `levels` option to limit which `console` methods are instrumented:

```js
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [
Sentry.consoleLoggingIntegration({ levels: ["error", "warn"] }),
],
});
```

You can also filter out the automatically captured logs in `beforeSendLog`:
## Filtering Console Logs

If you want to drop specific console-originated logs, use `beforeSendLog`:

```js
Sentry.init({
...,
dsn: "___PUBLIC_DSN___",
integrations: [Sentry.consoleLoggingIntegration()],
beforeSendLog: (log) => {
if (log.attributes?.['sentry.origin'] === 'auto.log.console') {
if (log.attributes?.["sentry.origin"] === "auto.log.console") {
return null;
}
return log;
},
...
})
});
```
1 change: 0 additions & 1 deletion platform-includes/logs/options/react-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ To filter logs, or update them before they are sent to Sentry, you can use the `
```js
Sentry.init({
dsn: "___PUBLIC_DSN___",
enableLogs: true,
beforeSendLog: (log) => {
if (log.level === "info") {
// Filter out all info logs
Expand Down
10 changes: 7 additions & 3 deletions platform-includes/logs/setup/react-native.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
To enable logging, you need to initialize the SDK with the `enableLogs` option set to `true`.
Logs are enabled by default. Once the SDK is initialized, calls to `Sentry.logger.*` are sent to Sentry without any extra configuration.

To explicitly disable log capturing, set the `enableLogs` option to `false`:

```js
Sentry.init({
dsn: "___PUBLIC_DSN___",
Comment on lines 5 to 7
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The documentation for React Native logging is inconsistent. While one file states logs are enabled by default, others still show enableLogs: true as a required setup step.
Severity: LOW

Suggested Fix

Update all React Native documentation files, including docs/platforms/react-native/index.mdx and docs/platforms/react-native/manual-setup/expo.mdx, to remove the enableLogs: true option from setup examples. Ensure all related documentation consistently reflects that logs are enabled by default.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: platform-includes/logs/setup/react-native.mdx#L5-L7

Potential issue: The pull request updates
`platform-includes/logs/setup/react-native.mdx` to state that Sentry Logs are enabled by
default, removing the need for `enableLogs: true`. However, other documentation files,
specifically `docs/platforms/react-native/index.mdx` and
`docs/platforms/react-native/manual-setup/expo.mdx`, still instruct users to add
`enableLogs: true` as part of the setup. This creates a direct contradiction in the
documentation, which will mislead users following the main React Native onboarding path
into believing the option is still required.

Also affects:

  • docs/platforms/react-native/index.mdx
  • docs/platforms/react-native/manual-setup/expo.mdx

Did we get this right? 👍 / 👎 to inform future reviews.

// Enable logs to be sent to Sentry
enableLogs: true,
// Disable logs from being sent to Sentry
enableLogs: false,
});
```

Integrations that automatically capture logs from third-party APIs (such as the [Console logging integration](/platforms/react-native/integrations/console-logging/)) are opt-in. Add them explicitly to the `integrations` array if you want them.
Loading