> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gleap.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# React Native SDK: Network logs

> Capture network requests to investigate bug reports with the Gleap React Native SDK. Follow the integration code examples.

Gleap logs your app's network requests and attaches the most recent ones to every ticket, so you can see what went wrong.

Network logs for React Native **work out of the box**: enable **Network logs** in the **Developer options** of your project in the [Gleap dashboard](https://app.gleap.ai). You can also switch them on and off from code:

```javascript theme={null}
Gleap.startNetworkLogging();
Gleap.stopNetworkLogging(); // also wins over the dashboard setting
```

* **iOS**: the native SDK logs every request of the app, `fetch` and `XMLHttpRequest` (and libraries built on them, such as axios) as well as requests made by native modules.
* **Android**: `fetch` and `XMLHttpRequest` requests are logged in JavaScript and handed to the native SDK.

For each request Gleap logs the method, URL, request headers and body, response status, headers and body, the duration and, for failed, aborted or timed-out requests, the error. The last 30 requests are attached to a ticket. Text bodies are kept up to 150 KB; binary and streaming bodies (images, server-sent events) are left out.

<Note>
  This applies to SDK **v19.0.0** and newer. Older versions logged each `fetch` request twice, did not log failed requests with their error, and on Android frequently sent no network logs at all.
</Note>

## Filtering network logs

Gleap allows you to strip off specific key/value pairs from network logs. This empowers you to easily remove sensitive data like `tokens`, `passwords` or `usernames`.

### How does it work?

Open your project in the [Gleap dashboard](https://app.gleap.ai), go to **Developer options** and add the keys to exclude under **Network logs → Ignored keys**. The keys are loaded together with the widget configuration, and the SDK removes them on the device before a report is sent, so this data never leaves the client application:

* **Headers**: request and response headers with a matching name are removed (the name is matched case-insensitively).
* **JSON bodies**: matching keys are removed from request and response bodies at any depth, including objects inside arrays. A key with dots, like `user.password`, also removes exactly that path.
* **Form bodies and URL parameters**: matching `application/x-www-form-urlencoded` fields and query parameters are removed.

Independent of this list, the values of the `Authorization`, `Proxy-Authorization`, `Cookie` and `Set-Cookie` headers are always replaced by `[REDACTED]`.

<Note>
  Matching nested keys, form fields and URL parameters, and the masked credential headers, need SDK **v19.0.0** or newer. Older SDKs only remove top-level keys from headers and JSON bodies, and the Android SDK applied neither the ignored keys nor the blacklist before v19.0.0.
</Note>

#### Example

To remove an API key header and every `password` field, add `x-api-key` and `password` to the list.

### Set filter with code

It's also possible to set the network log filters by code. Each call replaces the previous list. The keys set in the dashboard apply in addition.

```javascript theme={null}
Gleap.setNetworkLogPropsToIgnore(["x-api-key", "password", "user.email"]);
```

## Blacklisting URLs

It is possible to blacklist URLs or parts of URLs. If a network request matches one of the entries in the blacklist, the network request won't be included in the network logs.

<Info>
  Requests to Gleap's own hosts (`gleap.io` and `gleap.ai`, the domain of the [US data region](/documentation/guides/data-regions)) are always excluded from the network logs, so you don't need to blacklist them yourself. The JavaScript SDK does this since **v18.0.0**, the iOS, Android, React Native, Flutter and Ionic Capacitor SDKs since **v19.0.0**.
</Info>

To add a new entry to the blacklist, open your project in the [Gleap dashboard](https://app.gleap.ai), go to **Developer options** and add the URLs under **Network logs → Excluded domains**.

### Set blacklist with code

It's also possible to set the network log blacklist by code. Each call replaces the previous list. The domains set in the dashboard apply in addition.

```javascript theme={null}
Gleap.setNetworkLogsBlacklist(["analytics.example.com", "..."]);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.