Full Integration for React-Native Logs
About Shipbook
ShipBook gives you the power to remotely gather, search and analyze your user logs and exceptions in the cloud, on a per-user & session basis.
Requirements
React Native version 0.63.0 and up.
Installation
ShipBookSDK is available through: NPM
npm i @shipbook/react-native
Integrating ShipBook into your code
To initialize, add the following:
import shipbook from '@shipbook/react-native';
shipbook.start("YOUR_APP_ID", "YOUR_APP_KEY");
You can optionally provide app information:
shipbook.start("YOUR_APP_ID", "YOUR_APP_KEY", {
appVersion: "1.0.0",
appBuild: "123"
});
To have a log on each class you need to create a logger:
import shipbook from '@shipbook/react-native';
let log = shipbook.getLogger("MODULE_NAME");
The usage of the log:
log.e("the log message"); // Error log
log.w("the log message"); // Warning log
log.i("the log message"); // Info log
log.d("the log message"); // Debug log
log.v("the log message"); // Verbose log
Enable Shipbook debug logging
If your logs weren't uploaded to Shipbook, or you're experiencing some other issue with Shipbook, you can enable Shipbook debug logging to track down the problem.
shipbook.enableInnerLog(true);
Linking ShipBook to a user’s information
The SDK allows the option to associate each session with specific user information.
Register user:
The best practice is to set registerUser before ShipBook.start. It will also work after this point however, it will require an additional api request.
shipbook.registerUser("USER_ID", "USER_NAME", "USER NAME", "USER_EMAIL", "USER_PHONE_NUMBER", "STRING DICTIONARY OF KEY VALUE");
The only required parameter is userId.
Logout
To logout the user, add the following code to your app’s logout function.
shipbook.logout();