Git Product home page Git Product logo

react-native-crashlytics's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.