Reasonable provides an official JavaScript/TypeScript SDK to make it easy to integrate logging into your application.
Our SDK supports Node.js, browser, and React applications with full TypeScript support.
NPM Package Available
Install via npm: @reasonable-logging/js-sdk
View on NPM: @reasonable-logging/js-sdk
npm install @reasonable-logging/js-sdkimport { ReasonableLogger } from '@reasonable-logging/js-sdk';
// Initialize the logger
const logger = new ReasonableLogger({
projectId: 'your-project-id',
apiKey: 'your-api-key',
application: 'my-app'
});
// Start logging!
await logger.info('User logged in', { userId: '123' });
await logger.error('Payment failed', { error: 'card_declined' });
// Track custom events
await logger.userEvent('signup', 'user-123', { plan: 'pro' });
await logger.businessEvent('purchase', { amount: 99.99 });All logging methods return a Promise and accept optional metadata.
// Log levels: debug, info, warn, error, fatal
await logger.debug('Debug message', { context: 'debugging' });
await logger.info('User action', { userId: '123' });
await logger.warn('Rate limit approaching', { current: 95 });
await logger.error('Database error', { query: 'SELECT *' });
await logger.fatal('System crash', { exitCode: 1 });// User events
await logger.userEvent('signup', 'user-123', {
plan: 'pro',
source: 'organic'
});
// Business events
await logger.businessEvent('purchase', {
amount: 99.99,
currency: 'USD'
});
// Performance events
await logger.performanceEvent('page_load', {
loadTime: 1250,
route: '/dashboard'
});
// Custom events
await logger.customEvent('feature_used', {
feature: 'dark_mode',
enabled: true
});The SDK includes powerful features for production applications:
logger.setGlobalMeta({
version: '2.1.0',
environment: 'production',
region: 'us-west-2'
});const authLogger = logger.child({
component: 'auth',
module: 'login'
});
await authLogger.info('Login attempt');import { ReasonableLogger } from '@reasonable-logging/js-sdk';
const logger = new ReasonableLogger({
projectId: process.env.REACT_APP_PROJECT_ID,
apiKey: process.env.REACT_APP_API_KEY
});
function App() {
useEffect(() => {
logger.info('App initialized');
}, []);
const handleClick = async () => {
await logger.userEvent('button_click');
};
return <button onClick={handleClick}>Click me!</button>;
}Get started in minutes with our clean, well-documented API
Built with full TypeScript support for type safety and better DX
Lightweight with no external dependencies
Optimized for speed with async operations
Comprehensive error handling that won't crash your app
Works in Node.js, browsers, and edge environments
Currently, we only provide an official SDK for JavaScript/TypeScript. However, you can still use Reasonable with any language by making direct HTTP requests to our API.
We're considering SDKs for other popular languages based on user demand. If you'd like to see an SDK for your favorite language, please let us know!