This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo Observe
A library that collects app performance metrics and user-defined events and dispatches them to Expo Observe.
Expo Observe includes 100,000 events per month on the Free plan and 500,000 on paid plans, roughly 10,000 and 50,000 monthly active users. Beyond that, pricing is usage-based. See Pricing for details.
expo-observe is a library that collects performance metrics and user-defined events from your app and dispatches them to Expo Observe, a performance monitoring service from Expo, or to your preferred OpenTelemetry (OTEL)-compliant backend. It measures real-world startup performance, such as Time to First Render (TTR) and Time to Interactive (TTI), from apps running in production.
Beyond app startup metrics, the library can also:
- Collect per-route navigation metrics with the Expo Router or React Navigation integration.
- Log user-defined events with
Observe.logEvent. - Track Expo Update download times automatically.
- Record JavaScript errors with
ObserveErrorBoundaryandObserve.reportError, and view them with symbolicated stack traces in the Expo Observe dashboard (in preview). - Let third-party packages register their own integrations with
Observe.registerIntegration.
expo-observeis not available in Expo Go. To use it, create a development build.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Configuration
In release builds, installing the expo-observe library is all that is needed to configure the library to start sending startup metrics (though you will need to follow the usage instructions below to call markInteractive to track TTI). The library will not dispatch events in debug builds, but you can change this and other config options such as sample rate, environment name and enabling integrations with the Observe.configure({}) call. For all available options, see the Expo Observe configuration guide.
Usage
Wrap your root layout with ObserveRoot to measure Time to First Render automatically. Then, call markInteractive when your app is ready for user interaction to record Time to Interactive:
For step-by-step instructions, including a complete splash screen example and how to handle apps with multiple entry screens, see the Expo Observe Get started guide. To send custom events from your app, see User-defined events.
API
import { Observe, ObserveRoot, useObserve } from 'expo-observe';
Components
Type: React.Component<AppMetricsErrorBoundaryProps, State>
A React error boundary that records render-phase errors as non-fatal js.exception log events (with
the React component stack) and renders a fallback in place of the subtree that threw.
Render-phase errors don't reach global.ErrorUtils, so a boundary is the only way to capture them
with the component stack. Place one around any subtree, or let AppMetricsRoot mount one via its
errorBoundaryFallback prop.
Type: React.Element<ObserveInteractiveMarkerProps>
Declarative wrapper around useObserve().markInteractive(...). Renders nothing
and calls markInteractive once when it first mounts, marking the moment the
screen becomes interactive (used to compute the tti metric). Render it once
the screen is ready for user interaction — for example, after its initial data
has loaded.
Because markInteractive is only sent on mount, the marker is fire-once: changing
params after the first render has no effect and warns in development. If you need
to attach attributes that are only known later, call useObserve().markInteractive(...)
imperatively instead.
Example
import { ObserveInteractiveMarker } from 'expo-observe'; function Feed({ items }) { if (!items) return <Spinner />; return ( <> <FeedList items={items} /> <ObserveInteractiveMarker params={{ cacheHit: true }} /> </> ); }
Type: React.Element<AppMetricsRootProps & {
children: ReactNode
}>
Static methods
Component methods
Hooks
{
markInteractive: (attributes: MetricAttributes) => void
}Interfaces
ExpoAppMetricsModuleType Methods
Promise<void>Records a log event against the current main session. The event is
persisted locally and dispatched on the next dispatchEvents() flush as an
OpenTelemetry log record sent to the /v1/logs endpoint.
Severity defaults to "info" when not provided.
voidSets attributes merged into every subsequent metric and log event.
Per-record keys win on collision. Pass null, undefined, or an empty
object to clear.
voidExample
AppMetrics.setGlobalAttributes({ subscription_tier: 'pro', experiment_variant: 'B', });
Extends: NativeModule<ObserveModuleEvents>
Configures how observability events are collected and dispatched at runtime, such as the environment label, dispatching behavior, sampling, and integrations.
voidExample
import { Observe } from 'expo-observe'; Observe.configure({ environment: 'production', dispatchingEnabled: true, });
Dispatches pending events to the server immediately.
Events are dispatched automatically when the app moves to the background. On Android, a background worker dispatches events once network connectivity is available. On iOS, dispatching happens when the app resigns active state or is about to terminate. Call this method to flush events manually, for example, during testing or to ensure events are sent before a specific point.
Promise<void>A promise that resolves once the events have been dispatched. A call made while another dispatch is running waits for it to finish first.
Example
import { Observe } from 'expo-observe'; await Observe.dispatchEvents();
Returns the integrations config from the most recent configure(...)
call, or an empty object if configure has not run yet.
ObserveIntegrationsConfigRecords a log event against the current main session. The event is
persisted locally and dispatched on the next dispatchEvents() flush.
Severity defaults to "info" when not provided.
voidMarks the first render of the app. Used to compute the cold_ttr and
warm_ttr metrics.
voidMarks the moment the app becomes interactive. Used to compute the tti
metric. Custom routeName and params can be attached via attributes.
Note: When the
expo-routeror@react-navigation/nativeintegration is active, preferuseObserve().markInteractive(...)— the hook fills inrouteNamefrom the current route, while this raw call does not.
voidRecords a span for an operation that you already measured. The result is the same as
startSpan followed immediately by end(), with the times that you supply.
Observe does not record the span when startTime or endTime is missing or is not in Unix
epoch milliseconds. The same applies when endTime is before startTime. In each case,
Observe logs a warning. A value from performance.now() is not a Unix epoch time, so use
Date.now(). This method never throws.
voidExample
import { Observe } from 'expo-observe'; const startTime = Date.now(); decodeImage(); Observe.recordSpan('image-decode', { startTime, endTime: Date.now() });
Invokes a callback once when the named integration configuration becomes available.
voidExample
Observe.registerIntegration('expo-router', config => { console.log(config); });
Reports an error your code caught and handled, recorded as a non-fatal exception event. Use it
to keep visibility into failures you recover from, which never reach the automatic global handler
or an error boundary.
The thrown value is normalized: an Error's name, message, and stack are captured; any
other value (a string, a plain object) is stringified as the message.
voidExample
try { await syncCart(); } catch (error) { Observe.reportError(error); }
Pushes JS-bundle-derived facts (process.env.NODE_ENV, __DEV__) into native
storage. Called automatically once when the package is first imported; should
not be called by host apps directly.
voidSets attributes merged into every subsequent metric and log event.
Per-record keys win on collision. Pass null, undefined, or an empty
object to clear.
voidExample
Observe.setGlobalAttributes({ subscription_tier: 'pro', experiment_variant: 'B', });
Starts a trace span for an operation that is underway, and returns the span. The span gets
its trace ID and span ID immediately, so you can pass it as parent to other spans before it
ends.
Observe saves the span when you call end(), and sends it with the next dispatch as part of
the current session. If you never call end(), Observe never sends the span.
This method never throws. When it cannot record the span, it logs a warning. The span that it returns still accepts every call.
SpanThe span. Call end() on it when the operation finishes.
Example
import { Observe } from 'expo-observe'; const span = Observe.startSpan('checkout', { attributes: { 'cart.items': 3 } }); span.addEvent('cart-validated'); span.end();
Runs callback inside a span. The span starts first and ends when the callback returns or its
promise settles.
When the callback throws or its promise rejects, the span ends with the 'error' status and
the error message. The returned promise then rejects with the same error, so your own error
handling still works. An error inside Observe never changes the result: the returned promise
settles the same way as the callback.
The callback receives the span. Use the span to add attributes and events, and pass it as
parent to nested spans. Observe does not nest spans automatically. A span that you start
inside the callback without parent begins its own trace.
Promise<T>A promise fulfilled with the result of the callback
Example
import { Observe } from 'expo-observe'; const receipt = await Observe.withSpan('checkout', async (span) => { await Observe.withSpan('validate-cart', () => validateCart(), { parent: span }); span.addEvent('cart-validated'); return submitOrder(); });
Extends: SharedObject
Represents an operation that you measure. startSpan returns a span, and withSpan passes one
to its callback. While the operation runs, the span collects attributes and events. Pass the
span as parent to start a nested span.
Calling end() saves the span. If you never call end(), Observe never sends the span.
Adds a point-in-time event to the span, such as a checkpoint inside the measured operation.
Observe drops the event and logs a warning when its name is empty, starts with the reserved
expo. prefix, or is longer than 256 characters. At most 32 events of a span reach the
server.
Has no effect after end().
voidExample
span.addEvent('cart-validated', { attributes: { 'cart.items': 3 } });
Ends the span and saves it. Observe sends the span with the next dispatch. Only the first call has an effect. Later calls log a warning and do nothing.
voidExample
try { await submitOrder(); span.end(); } catch (error) { span.end({ status: 'error', message: String(error) }); throw error; }
Adds attributes to the span. Setting a key again replaces its value. Attributes go through the
same validation as logEvent attributes: Observe drops empty keys and keys in the reserved
expo.* namespace, and logs a warning.
Has no effect after end().
voidExample
span.setAttributes({ 'cart.items': 3, 'payment.method': 'card' });
Types
Value types accepted in a log event's attributes map. Strings, numbers,
and booleans are stored as typed primitives; arrays and nested maps preserve
their structure. Other JS values (functions, Date, undefined, etc.) are
not supported and may be dropped by downstream consumers.
Type: string or number or boolean or object shaped as below:
Optional configuration accepted by logEvent. The event name is passed as
the first positional argument since it's required and the only field most
callers set.
Literal type: string
Severity of a log event, ordered from least to most severe:
"trace"— Fine-grained tracing, typically only useful while reproducing a specific issue."debug"— Diagnostic detail useful during development; usually filtered out in production."info"— Routine, expected events that record normal app behavior."warn"— Unexpected but recoverable conditions worth investigating."error"— An operation failed; the app continues running but is in a degraded state."fatal"— A severe failure, often immediately followed by app termination.
Acceptable values are: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'
Type: LogAttributeValue
Value types accepted as attribute values in setGlobalAttributes and the
other Observe APIs. Strings, numbers, and booleans are stored as typed
primitives; arrays and nested maps preserve their structure.
Type: Record<string, ObserveAttribute>
A map of attribute key to value, as accepted by setGlobalAttributes and
other Observe APIs that take a free-form attributes payload.
Literal type: string
Status of a completed span. Omitting the status leaves it unset, which is the usual choice for successful operations, per the OpenTelemetry conventions.
Acceptable values are: 'ok' | 'error'