Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
To filter out all SDK-generated logs and keep only your application logs, use the following snippet:

```js
Sentry.init({
dsn: "___PUBLIC_DSN___",
enableLogs: true,
beforeSendLog: (log) => {
if (log.attributes?.["sentry.origin"] !== undefined) {
return null;
}
return log;
},
});
```
11 changes: 11 additions & 0 deletions platform-includes/logs/default-attributes/react-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ The React Native SDK automatically sets several default attributes on all log en
<Include name="logs/default-attributes/mobile-desktop-native" />

<Include name="logs/default-attributes/integration" />

<Include name="logs/default-attributes/integration-filter-example/javascript" />
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Should I also add this to the other JavaScript Projects? The same snippet works for them.


### Log Object Properties

The log object has the following properties:

- `level`: (string - one of `trace`, `debug`, `info`, `warn`, `error`, `fatal`) The log level.
- `message`: (string) The message to be logged.
- `timestamp`: (number) The timestamp of the log.
- `attributes`: (object) The attributes of the log.
7 changes: 0 additions & 7 deletions platform-includes/logs/options/react-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,3 @@ Sentry.init({
```

The `beforeSendLog` function receives a log object, and should return the log object if you want it to be sent to Sentry, or `null` if you want to discard it.

The log object has the following properties:

- `level`: (string - one of `trace`, `debug`, `info`, `warn`, `error`, `fatal`) The log level.
- `message`: (string) The message to be logged.
- `timestamp`: (number) The timestamp of the log.
- `attributes`: (object) The attributes of the log.
Loading