mhashim6 / react-native-crashlytics

A react-native module for just Firebase Crashlytics

Home Page:https://www.npmjs.com/package/@elcoach/react-native-crashlytics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-crashlytics npm version

A simple module for just Firebase Crashlytics; in case you still can't update your firebase setup for God-knows-what reasons you might have.
Code is heavily inspired by invertase/react-native-firebase.

Installation

Follow Crashlytic's installation instructions for iOS and Android, then install the package:

yarn

$ yarn add @elcoach/react-native-crashlytics

npm

$ npm install @elcoach/react-native-crashlytics --save

Link the package (for RN < 60.0)

$ react-native link @elcoach/react-native-crashlytics

Versions

Versions used in this module:

Android

firebase-analytics: 17.5.0
firebase-crashlytics: 17.2.1

Usage

In a starting point of your app

import RnCrashlytics, { initCrashlytics } from '@elcoach/react-native-crashlytics';

const logDetails = () => {
    // log app version
    RnCrashlytics.setValueForKey('app_version', '2.0-alpha');
    RnCrashlytics.setValueForKey('some_other_key', 'some other value');
}

const cleanUp = () => {
    console.log('we crashed pretty hard');
}

initCrashlytics (
    userId = 'unique_user_id_goes_here',
    beforeLog = logDetails,
    afterLog = cleanUp
);

To test a crash

// you can be really creative here, sky is the limit.
RnCrashlytics.crash();

Fatal crashes

By default, js errors are reported as non-fatal exceptions, while native errors are reported as fatal exceptions.
If you want to force-report all erros as fatal you can use the forceFatal flag (default – false):

initCrashlytics (
    userId = ...,
    beforeLog = ...,
    afterLog = ...,
    forceFatal = true
);

About

A react-native module for just Firebase Crashlytics

https://www.npmjs.com/package/@elcoach/react-native-crashlytics

License:MIT License


Languages

Language:Java 38.9%Language:Objective-C 26.3%Language:JavaScript 25.3%Language:Ruby 9.5%