https://github.com/odemolliens/react-native-logging-tools
Library which provides some tools to help logging and handle crashes
https://github.com/odemolliens/react-native-logging-tools
adobe android crashlytics firebase instabug ios log logging logging-library react-native sentry tealium
Last synced: 3 months ago
JSON representation
Library which provides some tools to help logging and handle crashes
- Host: GitHub
- URL: https://github.com/odemolliens/react-native-logging-tools
- Owner: odemolliens
- License: mit
- Created: 2020-02-24T10:09:49.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2024-09-06T10:21:56.000Z (almost 2 years ago)
- Last Synced: 2026-01-02T10:56:01.321Z (6 months ago)
- Topics: adobe, android, crashlytics, firebase, instabug, ios, log, logging, logging-library, react-native, sentry, tealium
- Language: TypeScript
- Homepage:
- Size: 1.32 MB
- Stars: 14
- Watchers: 5
- Forks: 1
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/imranMnts/react-native-logging-tools)


# 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](#getting-started)
- [Status of supported libraries](#status-of-supported-libraries)
- [Usage](#usage)
- [Imports](#imports)
- [Initialization](#initialization)
- [Features](#features)
- [Loggers](#loggers)
- [Debug Events](#debug-events)
- [Error Events](#error-events)
- [Reactotron](#reactotron)
- [JS Error handler](#js-error-handler)
- [Flipper](#flipper)
---
## 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|:white_check_mark:| \>= 6.0.0
|@react-native-firebase/crashlytics|:white_check_mark:| \>= 6.0.0
|@sentry/react-native|:white_check_mark:| \>= 1.3.0
|instabug-reactnative|:white_check_mark:| \>= 9.0.0
|@adobe/react-native-acpanalytics|:white_check_mark:| \>= 1.1.6
|@adobe/react-native-acpcore|:white_check_mark:| \>= 1.2.4
|tealium-react-native|:white_check_mark:| \>= 2.0.2
---
## Usage
### Imports
To start, you have to import methods from `react-native-logging-tools` which will be used.
```javascript
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`
```javascript
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`)
```javascript
init({
config: {
reportJSErrors: !__DEV__,
},
analytics: [createFirebaseLogger(analytics())],
errorReporters: [createCrashlyticsLogger(crashlytics())],
});
```
:information_source: Documentation and example about initialization steps can be found [here](./REFERENCE_API.md#init).
### 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
```javascript
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', ... });
```
:information_source: Documentation and example about logging event can be found [here](./REFERENCE_API.md#logEvent).
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)](https://reactnavigation.org/docs/navigation-events/)
##### 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
```javascript
recordError('EVENT_NAME', { your_key: 'value', ... });
```
:information_source: Documentation and example about error reporting can be found [here](./REFERENCE_API.md#recordError).
#### Reactotron
:information_source: Documentation and example about Reactotron can be found [here](./REFERENCE_API.md#setupreactotron).
#### JS Error handler
:information_source: Documentation and example about Reactotron can be found [here](./REFERENCE_API.md#init).
#### Flipper
:information_source: Documentation about Flipper can be found [here](./REFERENCE_API.md#flipper).