npm.io
0.0.9 • Published 6 years ago

@elcoach/react-native-crashlytics

Licence
MIT
Version
0.0.9
Deps
1
Size
3.3 MB
Vulns
0
Weekly
0

react-native-crashlytics

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

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

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);

Keywords