Convert Figma logo to code with AI

getsentry logosentry-react-native

Official Sentry SDK for React Native

1,562
330
1,562
178

Top Related Projects

A framework for building native applications using React

React Native Notifications

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.

Workgroup for the New React Native Architecture

Quick Overview

Sentry-react-native is an official SDK for integrating Sentry error tracking and performance monitoring into React Native applications. It provides real-time error reporting, crash analytics, and performance insights to help developers identify and resolve issues in their React Native apps quickly and efficiently.

Pros

  • Seamless integration with React Native projects
  • Automatic error and crash reporting with detailed stack traces
  • Performance monitoring capabilities, including app start-up time and slow renders
  • Customizable event capturing and filtering options

Cons

  • May slightly increase app bundle size
  • Requires additional setup for certain features (e.g., native crash reporting)
  • Limited support for older React Native versions
  • Some advanced features may require a paid Sentry plan

Code Examples

  1. Basic Sentry initialization:
import * as Sentry from "@sentry/react-native";

Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
});
  1. Capturing a custom error:
try {
  someFunction();
} catch (error) {
  Sentry.captureException(error);
}
  1. Adding custom context to events:
Sentry.setTag("user_type", "premium");
Sentry.setExtra("cart_contents", ["item1", "item2"]);
  1. Wrapping a component with performance monitoring:
import { withProfiler } from "@sentry/react-native";

const MyComponent = () => {
  // Component code
};

export default withProfiler(MyComponent);

Getting Started

  1. Install the package:

    npm install --save @sentry/react-native
    
  2. Link the native libraries:

    npx react-native link @sentry/react-native
    
  3. Initialize Sentry in your app's entry point (e.g., App.js):

    import * as Sentry from "@sentry/react-native";
    
    Sentry.init({
      dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
    });
    
  4. Wrap your root component with Sentry's error boundary:

    import { ErrorBoundary } from "@sentry/react-native";
    
    const App = () => (
      <ErrorBoundary fallback={ErrorFallback}>
        {/* Your app components */}
      </ErrorBoundary>
    );
    

With these steps, Sentry will automatically capture unhandled errors and crashes in your React Native app.

Competitor Comparisons

A framework for building native applications using React

Pros of React Native

  • Larger community and ecosystem, with more third-party libraries and resources
  • More comprehensive documentation and official support from Facebook
  • Wider adoption in the industry, leading to better job prospects and knowledge sharing

Cons of React Native

  • Steeper learning curve for developers new to mobile development
  • More complex setup and configuration process
  • Larger bundle size and potentially slower performance for complex apps

Code Comparison

React Native (basic component):

import React from 'react';
import { View, Text } from 'react-native';

const MyComponent = () => (
  <View>
    <Text>Hello, React Native!</Text>
  </View>
);

Sentry React Native (error tracking):

import * as Sentry from '@sentry/react-native';

Sentry.init({
  dsn: 'YOUR_DSN_HERE',
});

// Capture an error
Sentry.captureException(new Error('Something went wrong'));

Summary

React Native is a comprehensive framework for building cross-platform mobile apps, while Sentry React Native is a specialized error tracking and monitoring solution for React Native applications. React Native offers a broader development experience but may be more complex, whereas Sentry React Native focuses on enhancing app stability and error reporting. The choice between them depends on whether you need a full mobile development framework or a dedicated error tracking solution for an existing React Native project.

React Native Notifications

Pros of react-native-notifications

  • More focused on notification handling and customization
  • Provides a unified API for both iOS and Android platforms
  • Offers more granular control over notification appearance and behavior

Cons of react-native-notifications

  • Limited to notification functionality, lacking broader error tracking features
  • May require additional setup for advanced notification scenarios
  • Less integrated with overall application monitoring and performance tracking

Code Comparison

react-native-notifications:

import { Notifications } from 'react-native-notifications';

Notifications.registerRemoteNotifications();

Notifications.events().registerNotificationReceivedForeground((notification, completion) => {
  console.log(`Notification received in foreground: ${notification.title}`);
  completion({alert: false, sound: false, badge: false});
});

sentry-react-native:

import * as Sentry from "@sentry/react-native";

Sentry.init({
  dsn: "YOUR_DSN_HERE",
});

Sentry.captureException(new Error("Something went wrong"));

Summary

While react-native-notifications excels in providing comprehensive notification handling capabilities, sentry-react-native offers a broader suite of error tracking and monitoring features. The choice between the two depends on whether the primary focus is on notification management or overall application stability and performance monitoring.

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.

Pros of react-native-firebase

  • Comprehensive Firebase integration with support for multiple Firebase services
  • Active community and frequent updates
  • Extensive documentation and examples

Cons of react-native-firebase

  • Larger bundle size due to multiple Firebase services
  • More complex setup process
  • Potential performance impact due to broader feature set

Code Comparison

sentry-react-native:

import * as Sentry from "@sentry/react-native";

Sentry.init({
  dsn: "YOUR_DSN_HERE",
});

react-native-firebase:

import firebase from '@react-native-firebase/app';
import '@react-native-firebase/analytics';

await firebase.initializeApp({
  // Your Firebase configuration
});

Summary

sentry-react-native focuses specifically on error tracking and performance monitoring, offering a streamlined solution for these tasks. It's easier to set up and has a smaller footprint.

react-native-firebase provides a full suite of Firebase services, including analytics, authentication, and database access. It's more versatile but requires more setup and can increase app size.

Choose sentry-react-native for dedicated error tracking and performance monitoring, or react-native-firebase for comprehensive Firebase integration in your React Native app.

Workgroup for the New React Native Architecture

Pros of react-native-new-architecture

  • Improved performance through the new Fabric renderer and TurboModules
  • Better integration with native components and APIs
  • Enhanced type safety and error handling

Cons of react-native-new-architecture

  • Steeper learning curve for developers familiar with the old architecture
  • Potential compatibility issues with existing third-party libraries
  • Ongoing development and potential instability during the transition period

Code Comparison

sentry-react-native:

import * as Sentry from "@sentry/react-native";

Sentry.init({
  dsn: "YOUR_DSN_HERE",
});

react-native-new-architecture:

import { TurboModuleRegistry } from 'react-native';

const NativeModule = TurboModuleRegistry.get('MyNativeModule');
NativeModule.someMethod();

The sentry-react-native library focuses on error tracking and monitoring, while react-native-new-architecture introduces a new way of interacting with native modules using TurboModules. The new architecture aims to improve overall performance and provide better integration with native components, but it may require more setup and adaptation for existing projects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Sentry

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

Build & Test npm version npm dm npm dt Discord Chat Runs with Expo

Requirements

  • react-native >= 0.65.0

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__",

  // Set tracesSampleRate to 1.0 to capture 100%
  // of transactions for performance monitoring.
  // We recommend adjusting this value in production
  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

  • Documentation
  • Discussions
  • Discord Chat
  • Stack Overflow
  • Code of Conduct
  • Twitter Follow

NPM DownloadsLast 30 Days