Page containing the full index of all React Native Logging Tools reference API types
Library initializer, to be used before anything
It take an object as parameter initialization(init: IInit):
init is an object which take three keys/values:
-
config: object: library's config object (optional)-
Reactotron: Reactotron library from reactotron-react-native (optional) (mandatory if you want plug Reactotron to your store) -
AsyncStorage: from @react-native-community/async-storage ie (optional) -
reportJSErrors: boolean: set to true if you want turn on automatic fetch and send js crash toerrorReporters(optional) -
isSensitiveBuild: boolean: set to true if you want defined some logEvent as sensitive and not send log for this one (optional) -
useFlipperPlugin: boolean: set to true if you want use flipper plugin More details (optional) -
addPlugin: addPlugin fromreact-native-flipperMore details (optional) (mandatory ifuseFlipperPluginis true) -
excludeLogs: object: to exclude log types to not send to libraries which have been set (optional)- `adobe: Array<number>`: add to an array, the log types which should *NOT* sent to adobe (optional) - `crashlytics: Array<number>`: add to an array, the log types which should *NOT* sent to crashlytics (optional) - `firebase: Array<number>`: add to an array, the log types which should *NOT* sent to firebase (optional) - `instabug: Array<number>`: add to an array, the log types which should *NOT* sent to instabug (optional) - `sentry: Array<number>`: add to an array, the log types which should *NOT* sent to sentry (optional) - `tealium: Array<number>`: add to an array, the log types which should *NOT* sent to tealium (optional)
(0 = DEBUG, 1 = WARNING, 2 = NETWORK, 3 = ERROR)
-
-
analytics: Array<Function>: functions imported from this library (ie:createFirebaseLogger) to send log/analytics when you will calllogEvent(optional) -
errorReporters: Array<Function>: functions imported from this library (ie:createCrashlyticsLogger) to send errors when you will callrecordErroror when app crashed with a JS error (only ifreportJSErrorsis true anderrorReportersnot empty) (optional)
With Reactotron Redux, Instabug, Firebase analytics, crashlytics & handle fatal JS error to send to crash services in release mode
init({
config: { Reactotron, AsyncStorage, reportJSErrors: !__DEV__ },
analytics: [createFirebaseLogger(analytics(), true), createInstabugLogger(Instabug)],
errorReporters: [createCrashlyticsLogger(crashlytics())],
});Only Sentry with only Reactotron
init({
config: { Reactotron },
analytics: [createSentryLogger(sentry, { dsn: 'dsn' })],
errorReporters: [createCrashlyticsLogger(crashlytics())],
});With Sentry, Reactotron and Flipper
init({
config: {
Reactotron,
useFlipperPlugin: __DEV__,
addPlugin: addPlugin,
},
analytics: [createSentryLogger(sentry, { dsn: 'dsn' })],
errorReporters: [createCrashlyticsLogger(crashlytics())],
});To plug Adobe to send event later.
Two parameters:
adobeAnalytics: ACPAnalytics module from@adobe/react-native-acpanalyticsadobeLogger: ACPCore module from@adobe/react-native-acpcoreprintLogs: boolean: to print or not firebase event's errors (optional)(default: false)
init({
analytics: [createAdobeLogger(ACPAnalytics, ACPCore, true)],
});To plug Firebase crashlytics to send event later.
Two parameters:
crashlytics(): crashlytics() function from@react-native-firebase/crashlyticsprintLogs: boolean: to print or not firebase event's errors (optional)(default: false)
init({
errorReporters: [createCrashlyticsLogger(crashlytics(), true)],
});To plug Firebase analytics to send event later.
Two parameters:
analytics(): analytics() function from@react-native-firebase/analyticsprintLogs: boolean: to print or not firebase event's errors (optional)(default: false)
init({
analytics: [createFirebaseLogger(analytics(), true)],
});To plug Instabug to send event later.
Two parameters:
instabug: Instabug module frominstabug-reactnativeconfig: object which take one key/value:token: string: your application's tokeninvocationEvent: here (default:Instabug.invocationEvent.shake)
printLogs: boolean: to print or not instabug event's errors (optional)(default: false)
init({
analytics: [createInstabugLogger(Instabug, { token: 'APP_TOKEN', invocationEvent: 'invocationEvent' }, true)],
});To plug Reactotron to send event later.
Two parameters:
reactotron: Reactotron module fromreactotron-react-nativeprintLogs: boolean: to print or not reactotron event's errors (optional)(default: false)
init({
analytics: [createReactotronLogger(Reactotron, true)],
});To plug Sentry to send event later.
Two parameters:
sentry: Sentry module from@sentry/react-nativeconfig: object which take one key/value:dsn: string: project DSN, to take from Sentry dashboard
printLogs: boolean: to print or not sentry event's errors (optional)(default: false)
init({
analytics: [createSentryLogger(Sentry, { dsn: 'dsn' }, true)],
});To plug Tealium to send event later.
Two parameters:
tealium: Tealium module fromtealium-react-nativeconfig: object which take keys/values: Official docaccount: string: Tealium account nameprofile: string: Tealium profile nameenvironment: string: Tealium environment nameiosDatasource: string: Tealium iOS data source key (optional)androidDatasource: string: Tealium Android data source key (optional)instance: boolean: Tealium instance name (optional)(default: "MAIN")isLifecycleEnabled: boolean: To enable lifecycle tracking (optional)(default: true)
printLogs: boolean: to print or not firebase event's errors (optional)(default: false)
init({
analytics: [
createTealiumLogger(Tealium, { account: 'accountName', profile: 'profileName', environment: 'environment' }, true),
],
});To plug Reactotron to your redux store.
Reactotron should be already initialized in init function
One parameter:
config: any: the config of the reactotron (optional)plugins: Array<Function>: plugins which will be uses with reactotron (max 5) (optional)
Minimum required in init to plug reactotron
init({
config: {
Reactotron,
...,
},
...,
});Usage
const store = createStore(
rootReducer,
compose(
setupReactotron({ name: 'APP_NAME', host: '192.0.0.0' }, [reactotronRedux(), sagaPlugin({})]).createEnhancer()
...,
)
);To send an event to analytics services
Two parameters:
event: string: event's title to send to analyticsparams: object: keys/values to send to analytics (default:{})sensitiveData: boolean: set true if is sensitive data which will be sent to disable for the store build eg (isSensitiveBuildshould be set to true during initialization too for the build which will be sent to store) (default:false)
logEvent('EVENT_NAME', { your_key: 'value' }, true);To send an event to analytics services, it's the same as logEvent but it will
-
Automatically prefix the event name with
D/to facilitate the reading -
Do not send the log to excluded services during the init step
eg. You use
react-native-logging-toolswith adobe, firebase and instabug, and you dont want to send debug messages to instabug, you have to:
import {
init,
DEBUG_LOG,
} from 'react-native-logging-tools';
init(
{
excludeLogs: {
instabug: [DEBUG_LOG],
},
...,
},
...,
)logDebugEvent takes three parameters:
event: string: event's title to send to analyticsparams: object: keys/values to send to analytics (default:{})sensitiveData: boolean: set true if is sensitive data which will be sent to disable for the store build eg (isSensitiveBuildshould be set to true during initialization too for the build which will be sent to store) (default:false)
logDebugEvent('EVENT_NAME', { your_key: 'value' }, true);To send an event to analytics services, it's the same as logEvent but it will:
-
Automatically prefix the event name with
W/to facilitate the reading -
Do not send the log to excluded services during the init step
eg. You use
react-native-logging-toolswith adobe, firebase and instabug, and you dont want to send debug AND warning messages to instabug AND adobe, you have to:
import {
init,
DEBUG_LOG,
WARNING_LOG,
} from 'react-native-logging-tools';
init(
{
excludeLogs: {
instabug: [DEBUG_LOG, WARNING_LOG],
adobe: [DEBUG_LOG, WARNING_LOG],
},
...,
},
...,
)logWarningEvent takes three parameters:
event: string: event's title to send to analyticsparams: object: keys/values to send to analytics (default:{})sensitiveData: boolean: set true if is sensitive data which will be sent to disable for the store build eg (isSensitiveBuildshould be set to true during initialization too for the build which will be sent to store) (default:false)
logWarningEvent('EVENT_NAME', { your_key: 'value' }, true);To send an event to analytics services, it's the same as logEvent but it will:
-
Automatically prefix the event name with
N/to facilitate the reading -
Do not send the log to excluded services during the init step
eg. You use
react-native-logging-toolswith adobe, firebase and instabug, and you dont want to send network messages to firebase, you have to:
import {
init,
NETWORK_LOG,
} from 'react-native-logging-tools';
init(
{
excludeLogs: {
firebase: [NETWORK_LOG],
},
...,
},
...,
)logNetworkEvent takes three parameters:
event: string: event's title to send to analyticsparams: object: keys/values to send to analytics (default:{})sensitiveData: boolean: set true if is sensitive data which will be sent to disable for the store build eg (isSensitiveBuildshould be set to true during initialization too for the build which will be sent to store) (default:false)
logNetworkEvent('EVENT_NAME', { your_key: 'value' }, true);To send an event to analytics services, it's the same as logEvent but it will:
-
Automatically prefix the event name with
E/to facilitate the reading -
Do not send the log to excluded services during the init step
eg. You use
react-native-logging-toolswith adobe, firebase and instabug, and you dont want to send error messages to instabug, you have to:
import {
init,
DEBUG_LOG,
} from 'react-native-logging-tools';
init(
{
excludeLogs: {
instabug: [ERROR_LOG],
},
...,
}
)logErrorEvent takes three parameters:
event: string: event's title to send to analyticsparams: object: keys/values to send to analytics (default:{})sensitiveData: boolean: set true if is sensitive data which will be sent to disable for the store build eg (isSensitiveBuildshould be set to true during initialization too for the build which will be sent to store) (default:false)
logErrorEvent('EVENT_NAME', { your_key: 'value' }, true);To send an error report to error reporter services
Two parameters:
event: string: event's title to send to error reportersparams: object: keys/values to send to error reporters
recordError('EVENT_NAME', { your_key: 'value' });You can display all events sent to different service on Flipper desktop app.
Follow plugin's documentation to install it link, set useFlipperPlugin to true and add addPlugin from react-native-flipper during initialization to be able to use it.
Need to add @adobe/react-native-acpcore and @adobe/react-native-acpanalytics to your project and follow their documentations to setup them properly.
To be able to send log to adobe each time when you will call our logEvent, you need to add createAdobeLogger to our init function's analytics array.
ℹ️ Please refer to createAdobeLogger to know how to init it
Need to add @react-native-firebase/app and @react-native-firebase/analytics to your project and follow their documentations to setup them properly.
To be able to send log to firebase analytics each time when you will call our logEvent, you need to add createFirebaseLogger to our init function's analytics array.
ℹ️ Please refer to createFirebaseLogger to know how to init it
Need to add @react-native-firebase/app and @react-native-firebase/crashlytics to your project and follow their documentations to setup them properly.
To be able to send error to firebase crashlytics each time when you will call our recordError, you need to add createCrashlyticsLogger to our init function's errorReporters array.
ℹ️ Please refer to createCrashlyticsLogger to know how to init it
Need to add instabug-reactnative to your project and follow their documentations to setup them properly.
To be able to send log to instabug each time when you will call our logEvent, you need to add createInstabugLogger to our init function's analytics array.
ℹ️ Please refer to createInstabugLogger to know how to init it
Need to add reactotron-react-native to your project and follow their documentations to setup them properly.
To be able to send log to reactotron each time when you will call our logEvent, you need to add createReactotronLogger to our init function's analytics array.
ℹ️ Please refer to createReactotronLogger to know how to init it
Need to add @sentry/react-native to your project and follow their documentations to setup them properly.
To be able to send log to sentry each time when you will call our logEvent, you need to add createSentryLogger to our init function's analytics array.
ℹ️ Please refer to createSentryLogger to know how to init it
Need to add tealium-react-native to your project and follow their documentations to setup them properly.
To be able to send log to instabug each time when you will call our logEvent, you need to add createTealiumLogger to our init function's analytics array.
ℹ️ Please refer to createTealiumLogger to know how to init it
If you decided to use the crash handler, it will catch all fatal JS errors and sent a report to libraries added to recordErrors during the initialization