Skip to content

Commit 1a2aab3

Browse files
lucas-zimermanantonpirker
authored andcommitted
feat(React Native): Add Logs documentation (#13934)
## BEFORE MERGE Check if version [7.0.0-beta.1](https://github.com/getsentry/sentry-react-native/tree/7.0.0-beta.1) was released. <!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR *Tell us what you're changing and why. If your PR **resolves an issue**, please link it so it closes automatically.* With the next beta version that wasn't released, we will introduce logging support for React Native. This PR adds all the changes and how to use logging on React Native. - Link to getsentry/sentry-react-native#4868 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent 08acfde commit 1a2aab3

File tree

7 files changed

+78
-5
lines changed

7 files changed

+78
-5
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Set Up Logs
3+
sidebar_title: Logs
4+
description: "Structured logs allow you to send, view and query logs sent from your applications within Sentry."
5+
sidebar_order: 5755
6+
---
7+
8+
<PlatformContent includePath="llm-rules-logs" />
9+
10+
<Include name="feature-stage-beta-logs.mdx" />
11+
12+
With Sentry Structured Logs, you can send text based log information from your applications to Sentry. Once in Sentry, these logs can be viewed alongside relevant errors, searched by text-string, or searched using their individual attributes.
13+
14+
## Requirements
15+
16+
<PlatformContent includePath="logs/requirements" />
17+
18+
## Setup
19+
20+
<PlatformContent includePath="logs/setup" />
21+
22+
## Usage
23+
24+
<PlatformContent includePath="logs/usage" />
25+
26+
## Integrations
27+
28+
<PlatformContent includePath="logs/integrations" />
29+
30+
## Options
31+
32+
<PlatformContent includePath="logs/options" />

docs/product/explore/logs/getting-started/index.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ To set up Sentry Logs, use the links below for supported SDKs. After it's been s
198198
label="Flutter"
199199
url="/platforms/dart/guides/flutter/logs/"
200200
/>
201+
- <LinkWithPlatformIcon
202+
platform="react-native"
203+
label="React Native"
204+
url="/platforms/react-native/logs/"
205+
/>
201206

202207
### PHP
203208

@@ -250,11 +255,6 @@ We're actively working on adding Log functionality to additional SDKs. Check out
250255
label="Elixir"
251256
url="https://github.com/getsentry/sentry-elixir/issues/886"
252257
/>
253-
- <LinkWithPlatformIcon
254-
platform="react-native"
255-
label="React Native"
256-
url="https://github.com/getsentry/sentry-react-native/issues/4820"
257-
/>
258258
- <LinkWithPlatformIcon
259259
platform="dotnet"
260260
label=".NET"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<Include name="logs/javascript-console-logging-integration.mdx" />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#### beforeSendLog
2+
3+
To filter logs, or update them before they are sent to Sentry, you can use the `_experiments.beforeSendLog` option.
4+
5+
```js
6+
Sentry.init({
7+
dsn: "___PUBLIC_DSN___",
8+
_experiments: {
9+
enableLogs: true,
10+
beforeSendLog: (log) => {
11+
if (log.level === "info") {
12+
// Filter out all info logs
13+
return null;
14+
}
15+
16+
return log;
17+
},
18+
},
19+
});
20+
```
21+
22+
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.
23+
24+
The log object has the following properties:
25+
26+
- `level`: (string - one of `trace`, `debug`, `info`, `warn`, `error`, `fatal`) The log level.
27+
- `message`: (string) The message to be logged.
28+
- `timestamp`: (number) The timestamp of the log.
29+
- `attributes`: (object) The attributes of the log.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Logs for React Native are supported in Sentry React Native SDK version `7.0.0-beta.1` and above.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
To enable logging, you need to initialize the SDK with the `_experiments.enableLogs` option set to `true`.
2+
3+
```js
4+
Sentry.init({
5+
dsn: "___PUBLIC_DSN___",
6+
// Enable logs to be sent to Sentry
7+
_experiments: { enableLogs: true },
8+
});
9+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<Include name="logs/javascript-usage.mdx" />

0 commit comments

Comments
 (0)