Wondering what’s next for npm?Check out our public roadmap! »

react-native-logging-toolsTypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

Build Status npm GitHub

React Native Logging Tools

A react native module that lets you:

  • Connect your app to reactotron easily
  • Send logs to multiple services in one time
  • Send crash/error reports to multiple services in one time
  • Register a global error handler which will capture fatal JS exceptions and send a report to your crash reporter libraries
  • Can be plugged to Flipper to display all events sent to different service.

and all this, as easily as possible


Getting started

$ yarn add react-native-logging-tools

or

$ npm install react-native-logging-tools


Status of supported libraries

Library Supported Supported versions
@react-native-firebase/analytics >= 6.0.0
@react-native-firebase/crashlytics >= 6.0.0
@sentry/react-native >= 1.3.0
instabug-reactnative >= 9.0.0
@adobe/react-native-acpanalytics >= 1.1.6
@adobe/react-native-acpcore >= 1.2.4
tealium-react-native >= 1.0.10

Usage

Imports

To start, you have to import methods from react-native-logging-tools which will be used.

import {
  init,
  createFirebaseLogger,
  createCrashlyticsLogger,
  createSentryLogger,
  createTealiumLogger,
  createAdobeLogger,
  setupReactotron,
  logEvent,
} from 'react-native-logging-tools';

And the others external libraries to plug to react-native-logging-tools

import Reactotron from 'reactotron-react-native';
import { reactotronRedux } from 'reactotron-redux';
import Instabug from 'instabug-reactnative';
import analytics from '@react-native-firebase/analytics';
import crashlytics from '@react-native-firebase/crashlytics';
import * as Sentry from "@sentry/react-native";
import AsyncStorage from '@react-native-community/async-storage';
import { ACPCore } from '@adobe/react-native-acpcore';
import { addPlugin } from 'react-native-flipper';

Initialization

Before any call to react-native-logging-tools's features, you have to initialize it (eg. in your App.ts or store.ts)

init({
  config: {
    reportJSErrors: !__DEV__,
  },
  analytics: [createFirebaseLogger(analytics())],
  errorReporters: [createCrashlyticsLogger(crashlytics())],
});

ℹ️ Documentation and example about initialization steps can be found here.

Features

Loggers

Debug Events

You can call this function where do you want/need to send logs to each plugged libraries to analytics during the initialization step

logEvent('EVENT_NAME', { your_key: 'value', ... });
logDebugEvent('EVENT_NAME', { your_key: 'value', ... });
logWarningEvent('EVENT_NAME', { your_key: 'value', ... });
logNetworkEvent('EVENT_NAME', { your_key: 'value', ... });
logErrorEvent('EVENT_NAME', { your_key: 'value', ... });

ℹ️ Documentation and example about logging event can be found here.

If you use react-navigation and you want send to analytics navigation events e.g, you can add logEvent to his event handler (React-navigation docs)

Error Events

You can call this function where do you want/need to send logs to each plugged libraries to errorReporters during the initialization step

recordError('EVENT_NAME', { your_key: 'value', ... });

ℹ️ Documentation and example about error reporting can be found here.

Reactotron

ℹ️ Documentation and example about Reactotron can be found here.

JS Error handler

ℹ️ Documentation and example about Reactotron can be found here.

Flipper

ℹ️ Documentation about Flipper can be found here.

Install

npm i react-native-logging-tools

DownloadsWeekly Downloads

177

Version

1.2.3

License

MIT

Unpacked Size

37.2 kB

Total Files

36

Last publish

Collaborators

  • avatar