Multi-platform JavaScript SDK for Shipbook - remote logging and crash reporting.
| Package | Description | npm |
|---|---|---|
@shipbook/core |
Core SDK (platform-agnostic) | |
@shipbook/react-native |
React Native adapter | |
@shipbook/browser |
Browser/SPA adapter | |
@shipbook/node |
Node.js adapter |
Choose the package for your platform:
npm install @shipbook/react-native
# or
yarn add @shipbook/react-nativeNote: React Native also requires @react-native-async-storage/async-storage:
npm install @react-native-async-storage/async-storagenpm install @shipbook/browser
# or
yarn add @shipbook/browsernpm install @shipbook/node
# or
yarn add @shipbook/nodeThe API is identical across all platforms:
// Import from your platform's package
import Shipbook from '@shipbook/react-native'; // or @shipbook/browser, @shipbook/node
// Initialize with your credentials from shipbook.io
await Shipbook.start('YOUR_APP_ID', 'YOUR_APP_KEY');
// Get a logger for a specific tag/module
const log = Shipbook.getLogger('MyComponent');
// Log messages at different severity levels
log.e('Error message');
log.w('Warning message');
log.i('Info message');
log.d('Debug message');
log.v('Verbose message');
// Log with additional parameters (like console.log)
log.d('User data:', { id: 123, name: 'John' });
log.i('Items:', ['apple', 'banana', 'cherry']);
log.d('Processing:', 'count =', 42, 'status =', { active: true });
// Log with an error object (must be the last argument)
try {
// ...
} catch (error) {
log.e('Operation failed', error);
log.e('Failed with context:', { userId: 'user123' }, error);
}Track logs by user:
Shipbook.registerUser(
'user123', // userId (required)
'johndoe', // userName (optional)
'John Doe', // fullName (optional)
'john@example.com', // email (optional)
'+1234567890', // phoneNumber (optional)
{ plan: 'premium' } // additionalInfo (optional)
);Track screen views:
Shipbook.screen('HomeScreen');
Shipbook.screen('SettingsScreen');Force send pending logs:
Shipbook.flush();Clear user data and start a new session:
Shipbook.logout();await Shipbook.start('APP_ID', 'APP_KEY', {
appVersion: '1.0.0', // Optional: override app version
appBuild: '100' // Optional: override build number
});Enable internal SDK logging for debugging:
Shipbook.enableInnerLog(true);For enterprise deployments:
Shipbook.setConnectionUrl('https://your-shipbook-server.com/v1/');- Uses
@react-native-async-storage/async-storagefor persistence - Captures crashes via
ErrorUtils - Tracks app state changes (background/foreground)
- Supports stack trace symbolication in development
- Uses
localStoragefor persistence - Captures errors via
window.onerrorandunhandledrejection - Tracks page visibility changes
- Flushes logs on
beforeunload
- Uses filesystem storage with memory fallback (for serverless/PaaS)
- Captures errors via
uncaughtExceptionandunhandledRejection - Flushes logs on process exit signals (SIGINT, SIGTERM)
- Set
SHIPBOOK_STORAGE_PATHenv var to customize storage location
If you wrap Shipbook in your own logging class, the SDK will report your wrapper's filename and line number instead of the actual caller. To fix this, register your wrapper class:
// Pass the class itself (recommended - works with minification)
Shipbook.addWrapperClass(MyLogWrapper);
// Or pass a string (for third-party internals like Winston)
Shipbook.addWrapperClass('WinstonInternalClass');The SDK will skip any stack frames from registered classes when determining the caller location.
For cases where addWrapperClass isn't sufficient (e.g., deeply nested third-party wrappers in minified code), you can set a manual stack offset:
// Skip 1 additional stack frame beyond SDK internals
Shipbook.setStackOffset(1);You can also log without creating a logger instance:
import { Log } from '@shipbook/react-native';
Log.e('Static error message');
Log.i('Static info message');
Log.d('Static with params:', { key: 'value' });This is a monorepo using npm workspaces.
# Install dependencies
npm install
# Build all packages
npm run build
# Build specific package
npm run build:core
npm run build:react-native
npm run build:browser
npm run build:nodepackages/
├── core/ # Platform-agnostic core SDK
├── react-native/ # React Native adapter
├── browser/ # Browser adapter
└── node/ # Node.js adapter
MIT License - see LICENSE for details.