React Native SDK observability reference

The LaunchDarkly observability features are available for early access

Observability features in the LaunchDarkly UI are publicly available in early access.

The SDK observability plugins are designed for use with the in-app observability features. They are currently in available in Early Access and APIs are subject to change until a 1.x version is released.

If you are interested participating in the Early Access Program for upcoming observability plugins for additional SDKs, sign up here.

Overview

This topic documents how to get started with the LaunchDarkly observability plugins for the React Native SDK.

The React Native SDK supports the observability plugin for error monitoring, logging, and tracing.

SDK quick links

LaunchDarkly’s SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:

ResourceLocation
SDK API documentationObservability plugin API docs
GitHub repository@launchdarkly/observability-react-native
Published modulenpm

Prerequisites and dependencies

This reference guide assumes that you are somewhat familiar with the LaunchDarkly React Native SDK.

The observability plugin is compatible with the React Native SDK, version 10.10.0 and later.

The React Native SDK version 10.x is compatible with Expo. Only iOS and Android platforms are supported. Web is not supported. The React Native SDK v10.x is compatible with React Native 0.72, 0.73, 0.74, 0.76, and with Expo 51, Expo 52. Not all React Native and Expo versions have been tested with the observability plugin, as it is still in Early Access.

Get started

Follow these steps to get started:

Install the plugin

LaunchDarkly uses a plugin to the React Native SDK to provide observability.

The first step is to make both the SDK and the observability plugin available as dependencies.

Here’s how:

$ npm install @launchdarkly/react-native-client-sdk
> npm install @launchdarkly/observability-react-native

Then, import the plugin into your code:

Import, React Native SDK v10.10+
1import { ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk';
2import { Observability, LDObserve } from '@launchdarkly/observability-react-native';

Initialize the client

Next, initialize the SDK and the plugin.

To initialize, you need your LaunchDarkly environment’s mobile key. This authorizes your application to connect to a particular environment within LaunchDarkly. To learn more, read Initialize the client and identify a context in the React Native SDK reference guide.

Here’s how to initialize the SDK and plugin:

Initialize, React Native SDK v10.10+
1const client = new ReactNativeLDClient(
2 'mobile-key-123abc',
3 AutoEnvAttributes.Enabled,
4 {
5 plugins: [
6 new Observability()
7 ],
8 }
9);

Configure the plugin options

You can configure options for the observability plugin when you initialize the SDK. The plugin constructor takes an optional object with the configuration details.

Here is an example:

Plugin options, React Native SDK v10.10+
1const client = new ReactNativeLDClient(
2 'mobile-key-123abc',
3 AutoEnvAttributes.Enabled,
4 {
5 plugins: [
6 new Observability({
7 serviceName: 'example-service',
8 // we recommend setting service_version to the latest deployed git SHA
9 serviceVersion: 'example-sha'
10 })
11 ],
12 }
13);

For more information on plugin options, read Configuration for client-side observability.

Explore supported features

The observability plugins supports the following features. After the SDK and plugins are initialized, you can access these from within your application:

Review observability data in LaunchDarkly

After you initialize the SDK and observability plugin, your application automatically starts sending observability data back to LaunchDarkly, including errors and logs. You can review this information in the LaunchDarkly user interface. To learn how, read Observability.