Sentry
Sentry is an error tracking and performance monitoring platform that helps you solve problems and continuously learn about your apps. The @amazon-devices/sentry__react-native library implements the React Native SDK for Sentry on the Vega platform.
During this phase, some of the Sentry features are not setup for Vega. You can post questions or report issues on the Vega Developer Forums.
Installation
-
Add the JavaScript library dependency in the
package.jsonfile.dependencies: { "@sentry/react-native": "npm:@amazon-devices/sentry__react-native@~1.0.10" } -
Install dependencies using the
npm installcommand.
Examples
Initialize Sentry on the top-level of your app, using the Sentry.init({...}) method. The only required parameter is dsn, short for Data Source Name. Find the dsn from the Sentry project's settings page.
import * as Sentry from '@sentry/react-native';
import React from 'react';
import {View, Button, Text} from 'react-native';
// init Sentry somewhere top-level outside of component
Sentry.init({
// set environment variable SENTRY_DSN to your project's dsn
// or inline your DSN here
dsn: process.env.SENTRY_DSN,
});
export function App() {
const captureMessage = () => {
// send message directly to Sentry
Sentry.captureMessage('SentryAppDemo message');
};
const captureException = () => {
// capture exception and send it to Sentry
Sentry.captureException(new Error('SentryAppDemo error'));
};
return (
<View
style={{
backgroundColor: '#181a1b',
padding: 32,
flex: 1,
flexDirection: 'column',
gap: 16,
}}>
<Text style={{fontSize: 32, color: 'white'}}>Sentry App Demo</Text>
<View style={{width: '25%'}}>
<Button onPress={captureMessage} title="Capture Message" />
</View>
<View style={{width: '25%'}}>
<Button onPress={captureException} title="Capture Exception" />
</View>
</View>
);
}
After initializing Sentry, all uncaught exceptions are found automatically and reported by Sentry. You don't need to send events manually.
You can add extra information to the Sentry events using Sentry.setContext() or Sentry.setUser(), as shown.
import * as Sentry from '@sentry/react-native';
import React from 'react';
import {View, Button, Text} from 'react-native';
// init Sentry somewhere top-level outside of component
Sentry.init({
// set environment variable SENTRY_DSN to your project's dsn
// or inline your DSN here
dsn: 'process.env.SENTRY_DSN',
});
export function App() {
const setContext = () => {
// add custom data to Sentry events
Sentry.setContext('ExampleContext', {
category: 'ExampleCategory',
message: 'ExampleMessage',
level: 'info',
});
};
const throwError = () => {
// throw error without catching - Sentry will report this for us
throw new Error('SentryAppDemo uncaught error');
};
return (
<View
style={{
backgroundColor: '#181a1b',
padding: 32,
flex: 1,
flexDirection: 'column',
gap: 16,
}}>
<Text style={{fontSize: 32, color: 'white'}}>Sentry App Demo</Text>
<View style={{width: '25%'}}>
<Button onPress={setContext} title="Set Context" />
</View>
<View style={{width: '25%'}}>
<Button onPress={throwError} title="Throw Error" />
</View>
</View>
);
}
API reference
| Methods | Description | Supported |
|---|---|---|
Sentry.init(options: ReactNativeOptions) |
Initializes Sentry. After calling it, all errors are reported by Sentry. If your application crashes or throws uncaught exceptions before the call to Sentry.init(), it won't be caught by Sentry. |
✅ Yes |
Sentry.nativeCrash() |
Triggers a native crash and tested/verified to work on Vega devices and simulators. | ✅ Yes |
Sentry.setUser(user: User) |
Sets user data, like username or email, that's included in Sentry events. |
✅ Yes |
Sentry.setContext(contextKey: string, contextData: Object) |
Sets custom data to be added under the passed contextKey that's included in Sentry events. |
✅ Yes |
Sentry.flush() |
Waits for all Sentry events to be sent. | ✅ Yes |
Sentry.captureMessage(message: string) |
Captures a message event and sends it to Sentry. | ✅ Yes |
Sentry.captureException(exception: Error) |
Captures an exception event and sends it to Sentry. | ✅ Yes |
sentry-wizard |
More information on GitHub: https://github.com/getsentry/sentry-wizard | ❌ No |
withSentryConfig |
Sentry's React Native Metro Plugin or Manual Upload | ❌ No |
| Tracing | Captures the timing and flow of requests and operations as they happen in your application. | ❌ No |
| Profiling | Helps you understand where time is being spent in your application at a function level. | ❌ No |
See Known issues and limitations for more information on API usage.
Additional configuration
Add readable stack traces to Sentry errors
In summary, after the app is built, you should notify Sentry about the app release name, version, and dist number and send sourcemaps of the JavaScript bundle and debug files. This ensures that Sentry catches events and correctly maps the information with readable stack traces.
After building the app, you might have a similar folder structure:
├── sentrydemoapp
│ ├── build
│ │ ├── lib
│ │ │ ├── rn-bundles
│ │ │ │ ├── Debug #use the path for debug build
│ │ │ │ ├── Release #use the path for release build
│ │ ├── x86_64-release
│ │ │ ├── debug #use the path for app meant for simulator for x86 machines
│ │ ├── armv7-release
│ │ │ ├── debug #use the path for app meant for Fire TV Stick
│ │ ├── aarch64-release
│ │ │ ├── debug #use the path for app meant for simulator for M-series machines
-
In the Sentry initialization, create a release version and a dist version. You need to define
$SENTRY_RELEASE_VERSION(for example,my-vega-project@2.3.12) and$SENTRY_DIST_NUMBER(for example52). See Sentry official docs for more information.Sentry.init({ release: process.env.SENTRY_RELEASE_VERSION, dist: process.env.SENTRY_DIST_NUMBER, }); -
Add Sentry Metro Serializer to
metro.config.jsand rebuild the application.... const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer'); ... const sentryMetroSerializer = createSentryMetroSerializer() const config = { serializer: { customSerializer(entryPoint, preModules, graph, options) { return sentryMetroSerializer(entryPoint, preModules, graph, options) }, }, }; module.exports = mergeConfig(getDefaultConfig(__dirname), config); -
Install
sentry-cli. See Sentry official docs for more information.curl -sL https://sentry.io/get-cli/ | sh -
Create a new Sentry release. Pass the previously defined
$SENTRY_RELEASE_VERSION. See Sentry official docs for more information.sentry-cli releases new $SENTRY_RELEASE_VERSION -
Upload source maps for JavaScript symbolication. Please note that
sentry-wizardis not yet supported. See Sentry official docs for more information.# inside Vega app directory # BUILD_TYPE is either Debug or Release # --release and --dist flags are optional when using Debug IDs sentry-cli sourcemaps upload "build/lib/rn-bundles/$BUILD_TYPE" --release "$SENTRY_RELEASE_VERSION" --dist "$SENTRY_DIST_NUMBER"
After sending the information to Sentry, you get precise information regarding where errors occur in your app.
Known issues and limitations
Sentry offline support isn't working on Vega.
| API | Current Behavior |
|---|---|
Sentry.addBreadcrumb() |
Does not perform any actions. |
Sentry.init(options: ReactNativeOptions) |
Certain options aren't supported. Please see the following table of ReactNativeOptions. |
Sentry.init() missing options
| Sentry.init Option | Current Behavior |
|---|---|
options.enableNativeCrashHandling |
Can't be disabled at the moment |
options.sessionTrackingIntervalMillis |
Not supported |
options.enableNdk |
NDK only works on Android |
options.enableNdkScopeSync |
NDK only works on Android |
options.attachThreads |
Android-only option |
options.sendDefaultPii |
Android-only option |
options.enableAutoPerformanceTracing |
performance monitoring isn't working |
options.enableWatchdogTerminationTracking |
iOS only option |
options.enableAppHangTracking |
iOS-only option |
options.appHangTimeoutInterval |
iOS-only option |
options.attachScreenshot |
Not supported |
options.attachViewHierarchy |
Not supported |
Supported versions
| Package Version | Based On | @amazon-devices/react-native-kepler version |
|---|---|---|
| 1.0.0 | 5.15.2 | 2.x.x |
Related topics
Supported Third-Party Libraries and Services.
Last updated: Sep 30, 2025

