What is @sentry/react-native?
@sentry/react-native is a comprehensive error tracking and performance monitoring tool for React Native applications. It helps developers capture and report errors, monitor application performance, and gain insights into issues affecting their apps.
What are @sentry/react-native's main functionalities?
Error Tracking
This feature allows you to capture and report errors in your React Native application. The code sample initializes Sentry with a DSN and captures an exception.
import * as Sentry from '@sentry/react-native';
Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
});
try {
throw new Error('Test error');
} catch (error) {
Sentry.captureException(error);
}
Performance Monitoring
This feature allows you to monitor the performance of your application. The code sample initializes Sentry with a DSN and a traces sample rate, then starts and finishes a transaction.
import * as Sentry from '@sentry/react-native';
Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
tracesSampleRate: 1.0,
});
const transaction = Sentry.startTransaction({
name: 'test-transaction',
});
setTimeout(() => {
transaction.finish();
}, 2000);
Breadcrumbs
Breadcrumbs are used to record events that lead up to an error. The code sample initializes Sentry and adds a breadcrumb for a user login event.
import * as Sentry from '@sentry/react-native';
Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
});
Sentry.addBreadcrumb({
category: 'auth',
message: 'User logged in',
level: Sentry.Severity.Info,
});
User Feedback
This feature allows users to provide feedback when an error occurs. The code sample initializes Sentry and shows a report dialog for user feedback.
import * as Sentry from '@sentry/react-native';
Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
});
Sentry.showReportDialog({
title: 'Feedback',
subtitle: 'Please describe what you were doing when the error occurred.',
labelName: 'Name',
labelEmail: 'Email',
labelComments: 'Comments',
labelSubmit: 'Submit',
successMessage: 'Thank you for your feedback!',
});
Other packages similar to @sentry/react-native
bugsnag-react-native
Bugsnag provides error monitoring and crash reporting for React Native applications. It offers similar functionalities to Sentry, such as error tracking, performance monitoring, and user feedback. Bugsnag is known for its user-friendly interface and detailed error reports.
instabug-reactnative
Instabug provides comprehensive bug and crash reporting for React Native applications. It offers similar functionalities to Sentry, including error tracking, performance monitoring, and user feedback. Instabug is known for its in-app feedback and bug reporting capabilities, which allow users to report issues directly from the app.
Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us Check out our open positions
Sentry SDK for React Native
Releases
This repo uses the following ways to release SDK updates:
Pre-release
: We create pre-releases (alpha, beta, RC,…) for larger and potentially more impactful changes, such as new features or major versions.Latest
: We continuously release major/minor/hotfix versions from the main
branch. These releases go through all our internal quality gates and are very safe to use and intended to be the default for most teams.Stable
: We promote releases from Latest
when they have been used in the field for some time and in scale, considering time since release, adoption, and other quality and stability metrics. These releases will be indicated on the releases page with the Stable
suffix.
Requirements
Features
- Automatic JS Error Tracking (using @sentry/browser)
- Automatic Native Crash Error Tracking (using sentry-cocoa & sentry-android under the hood)
- Offline storage of events
- On Device symbolication for JS (in Debug)
- Autolinking
- Events with enriched device data
- RAM bundle support
- Hermes support
- Expo support
- RN New Architecture support
Installation and Usage
To install the package and setup your project:
npx @sentry/wizard -s -i reactNative
How to use it:
import * as Sentry from "@sentry/react-native";
Sentry.init({
dsn: "__DSN__",
tracesSampleRate: 1.0,
});
Sentry.setTag("myTag", "tag-value");
Sentry.setExtra("myExtra", "extra-value");
Sentry.addBreadcrumb({ message: "test" });
Sentry.captureMessage("Hello Sentry!");
Upgrade
If you are coming from react-native-sentry
which was our SDK < 1.0
you should follow the upgrade guide and then follow the install steps.
Blog posts
Introducing Mobile Screenshots and Suspect Commits.
Tips for Optimizing React Native Application Performance - Part 2: Using Sentry SDK for Performance Monitoring.
Tips for Optimizing React Native Application Performance: Part 1.
Tracking Stability in a Bluetooth Low Energy-Based React-Native App.
Mobile Vitals - Four Metrics Every Mobile Developer Should Care About.
Performance Monitoring Support for React Native.
Resources