Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-crash-reporter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-crash-reporter

`react-native-crash-reporter` is a small library that hooks into the JavaScript error system and reports the unrolled stack trace to the native side. On the native side a callback will be called where the error information can be forwarded to a crash repo

  • 0.5.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

react-native-crash-reporter

react-native-crash-reporter is a small library that hooks into the JavaScript error system and reports the unrolled stack trace to the native side. On the native side a callback will be called where the error information can be forwarded to a crash reporting system of choice. To be able to unroll the error it uses the sourcemap, which is automatically created while the React Native bundle is generated

Getting started

$ npm install react-native-crash-reporter --save

Mostly automatic installation

$ react-native link react-native-crash-reporter

Manual installation

iOS
  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-crash-reporter and add MSRCrashReporter.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libMSRCrashReporter.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<
Android
  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import net.mischneider.MSRCrashReporterPackage; to the imports at the top of the file
  • Add new MSRCrashReporterPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-crash-reporter'
    project(':react-native-crash-reporter').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-crash-reporter/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-crash-reporter')
    

Usage

First is to define how the native part should handle crash reports. On Android register a listener on the MSRCrashReporterModule:

MSRCrashReporterModule.getInstance().setOnRecordCustomExceptionCallback(new MSRCrashReporterModule.OnCrashReporterRecordCustomExceptionCallback() {
    @Override
    public void recordCustomException(Exception e) {
        // TODO: Handle the exception
    }
});

On iOS register a listener block on the MSRCrashReporter singleton:

[MSRCrashReporter sharedReporter].recordCustomExceptionHandler = ^(NSString * _Nonnull name, NSString * _Nonnull reason, NSArray<MSRCrashReporterStackFrame *> * _Nonnull frameArray) {
    // TODO: Handle crash
};

Initialize the crash reporter usually in your index.js of your app:

import { init as initCrashReporting } from 'react-native-crash-reporter';

initCrashReporting({ captureOnDebugMode: false });

Keywords

FAQs

Package last updated on 08 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc