Skip to content

Commit

Permalink
[DOCS-9644] Standalone Error Tracking for Mobile (#26569)
Browse files Browse the repository at this point in the history
* android

* Apply suggestions from code review

Co-authored-by: Sandra (neko) <[email protected]>

* add ET to each section

* clarification

* fix links

* fix links

* all other platforms

* ET for RUM also not supported for gov

* be even more clear

* Apply suggestions from code review

* kotlin steps

* change ordered list to bullets

* Apply suggestions from code review

Co-authored-by: Sandra (neko) <[email protected]>

* make sample sessions sections more consistent

* add slash

---------

Co-authored-by: Sandra (neko) <[email protected]>
  • Loading branch information
rtrieu and neko-dd authored Dec 13, 2024
1 parent 647bf41 commit 3eeafd0
Show file tree
Hide file tree
Showing 11 changed files with 435 additions and 294 deletions.
2 changes: 1 addition & 1 deletion content/en/real_user_monitoring/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,5 @@ Access triggered logs, errors, and performance information when troubleshooting
[13]: /real_user_monitoring/session_replay/browser/privacy_options/
[14]: /real_user_monitoring/session_replay/browser/developer_tools/
[15]: /real_user_monitoring/browser/setup/
[16]: /real_user_monitoring/mobile_and_tv_monitoring/setup
[16]: /real_user_monitoring/mobile_and_tv_monitoring/setup/
[17]: https://app.datadoghq.com/rum/optimization/inspect

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: RUM Expo Setup
title: Expo Setup
description: Monitor your React Native projects using Expo and Expo Go with Datadog.
aliases:
- /real_user_monitoring/reactnative/expo/
Expand All @@ -25,11 +25,13 @@ further_reading:

## Overview

The RUM React Native SDK supports Expo and Expo Go. To use it, install `expo-datadog` and `@datadog/mobile-react-native`.
This page describes how to instrument your applications for both [Real User Monitoring (RUM)][1] and [Error Tracking][2] with the React Native SDK. You can follow the steps below to instrument your applications for RUM (which includes Error Tracking) or Error Tracking if you have purchased it as a standalone product.

The React Native SDK also supports Expo and Expo Go. To use it, install `expo-datadog` and `@datadog/mobile-react-native`.

`expo-datadog` supports Expo starting from SDK 45 and the plugin's versions follow Expo versions. For example, if you use Expo SDK 45, use `expo-datadog` version `45.x.x`. Datadog recommends using **Expo SDK 45** as a minimum version; previous versions may require manual steps.

If you experience any issues setting up the Datadog SDK with an Expo application, you can see our [example application][1] as a reference.
If you experience any issues setting up the Datadog SDK with an Expo application, you can see our [example application][3] as a reference.

## Setup

Expand All @@ -47,7 +49,7 @@ yarn add expo-datadog @datadog/mobile-react-native

### Track view navigation

To see RUM sessions populate in Datadog, you need to implement view tracking, which can be initialized manually or automatically.
To see RUM or Error Tracking sessions populate in Datadog, you need to implement view tracking, which can be initialized manually or automatically.

#### Manual tracking

Expand All @@ -73,8 +75,8 @@ DdRum.stopView('<view-key>', { 'custom.bar': 42 }, Date.now());

Automatic view tracking is supported for the following modules:

- React Navigation: [@Datadog/mobile-react-navigation][2]
- React Native Navigation: [@Datadog/mobile-react-native-navigation][3]
- React Navigation: [`@Datadog/mobile-react-navigation`][4]
- React Native Navigation: [`@Datadog/mobile-react-native-navigation`][5]

In this Datadog example project, View Tracking is achieved through `@datadog/mobile-react-navigation` and is configured using the `NavigationContainer`:

Expand Down Expand Up @@ -125,7 +127,9 @@ await DdSdkReactNative.initialize(config);

#### Sample RUM sessions

To control the data your application sends to Datadog RUM, you can specify a sampling rate for RUM sessions while [initializing the RUM Expo SDK][4] as a percentage between 0 and 100. To set this rate, use the `config.sessionSamplingRate` parameter.
<div class="alert alert-warning">Configuring the session sample rate does not apply to Error Tracking.</div>

To control the data your application sends to Datadog RUM, you can specify a sampling rate for RUM sessions while [initializing the Expo SDK][6]. To set this rate, use the `config.sessionSamplingRate` parameter and specify a percentage between 0 and 100.

### Upload source maps on EAS builds

Expand Down Expand Up @@ -157,11 +161,11 @@ yarn add -D @datadog/datadog-ci

Run `eas secret:create` to set `DATADOG_API_KEY` to your Datadog API key, and `DATADOG_SITE` to the host of your Datadog site (for example, `datadoghq.com`).

For information about tracking Expo crashes, see [Expo Crash Reporting and Error Tracking][5].
For information about tracking Expo crashes, see [Expo Crash Reporting and Error Tracking][7].

## Tracking Expo Router screens

If you are using [Expo Router][6], track your screens in your `app/_layout.js` file:
If you are using [Expo Router][8], track your screens in your `app/_layout.js` file:

```javascript
import { useEffect } from 'react';
Expand All @@ -187,14 +191,14 @@ If you are using Expo Go, switch to development builds (recommended), or keep us

### Switch from Expo Go to development builds

Your application's [development builds][7] are debug builds that contain the `expo-dev-client` package.
Your application's [development builds][9] are debug builds that contain the `expo-dev-client` package.

1. Enable the [custom native code to run][8] with `expo run:android` and `expo run:ios`.
2. To start using your development application, run `expo install expo-dev-client` and `expo start --dev-client`. This installs and starts the [`expo-dev-client` package][9] to execute the added native code in dev mode.
1. Enable the [custom native code to run][10] with `expo run:android` and `expo run:ios`.
2. To start using your development application, run `expo install expo-dev-client` and `expo start --dev-client`. This installs and starts the [`expo-dev-client` package][11] to execute the added native code in dev mode.

### Develop with Expo Go

When your application runs inside of Expo Go, you are unable to add any custom native code that is not part of the Expo Go application. Because the RUM React Native SDK relies on some custom native code to run, you can develop your application inside Expo Go without Datadog, and use Datadog in your standalone builds.
When your application runs inside of Expo Go, you are unable to add any custom native code that is not part of the Expo Go application. Because the React Native SDK relies on some custom native code to run, you can develop your application inside Expo Go without Datadog, and use Datadog in your standalone builds.

Your application crashes in Expo Go when some native code (that is not included) is called. To use Datadog with your standalone application and continue using Expo Go in development, add the following TypeScript file to your project:

Expand Down Expand Up @@ -245,15 +249,15 @@ DdSdkReactNative.initialize(config);

## Sending data when device is offline

RUM ensures availability of data when your user device is offline. In case of low-network areas, or when the device battery is too low, all the RUM events are first stored on the local device in batches.
RUM ensures availability of data when your user device is offline. In case of low-network areas, or when the device battery is too low, all the events are first stored on the local device in batches.

Each batch follows the intake specification. They are sent as soon as the network is available, and the battery is high enough to ensure the Datadog SDK does not impact the end user's experience. If the network is not available while your application is in the foreground, or if an upload of data fails, the batch is kept until it can be sent successfully.

This means that even if users open your application while offline, no data is lost. To ensure the SDK does not use too much disk space, the data on the disk is automatically discarded if it gets too old.

## Troubleshooting

### App produces a lot of /logs RUM Resources
### App produces a lot of /logs Resources

When Resource tracking is enabled and SDK verbosity is set to `DEBUG`, each RUM Resource triggers a `/logs` call to the Expo dev server to print the log, which itself creates a new RUM resource, creating an infinite loop.
The most common patterns of Expo dev server host URL are filtered by the SDK, therefore, you may not encounter this error in most situations.
Expand All @@ -279,12 +283,14 @@ config.resourceEventMapper = event => {

{{< partial name="whats-next/whats-next.html" >}}

[1]: https://github.com/DataDog/dd-sdk-reactnative-examples/tree/main/rum-expo-react-navigation
[2]: https://www.npmjs.com/package/@datadog/mobile-react-navigation
[3]: https://www.npmjs.com/package/@datadog/mobile-react-native-navigation
[4]: /real_user_monitoring/mobile_and_tv_monitoring/setup/expo#initialize-the-library-with-application-context
[5]: /real_user_monitoring/error_tracking/mobile/expo/
[6]: https://expo.github.io/router/docs/
[7]: https://docs.expo.dev/development/introduction/
[8]: https://docs.expo.dev/workflow/customizing/#releasing-apps-with-custom-native-code-to
[9]: https://docs.expo.dev/development/getting-started/
[1]: /real_user_monitoring/
[2]: /error_tracking/
[3]: https://github.com/DataDog/dd-sdk-reactnative-examples/tree/main/rum-expo-react-navigation
[4]: https://www.npmjs.com/package/@datadog/mobile-react-navigation
[5]: https://www.npmjs.com/package/@datadog/mobile-react-native-navigation
[6]: /real_user_monitoring/mobile_and_tv_monitoring/setup/expo#initialize-the-library-with-application-context
[7]: /real_user_monitoring/error_tracking/mobile/expo/
[8]: https://expo.github.io/router/docs/
[9]: https://docs.expo.dev/development/introduction/
[10]: https://docs.expo.dev/workflow/customizing/#releasing-apps-with-custom-native-code-to
[11]: https://docs.expo.dev/development/getting-started/
Loading

0 comments on commit 3eeafd0

Please sign in to comment.