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
$ yarn add react-native-logging-tools
or
$ npm install react-native-logging-tools
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 | ✅ | >= 2.0.2 |
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';
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.
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)
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.
ℹ️ Documentation and example about Reactotron can be found here.
ℹ️ Documentation and example about Reactotron can be found here.
ℹ️ Documentation about Flipper can be found here.