ai-log-debugger-sdk
v1.0.0
Published
Node.js error tracking SDK — captures uncaught errors and reports them to your AI Log Debugger backend.
Maintainers
Readme
ai-log-debugger-sdk
Official Node.js SDK for AI Log Debugger — automatically captures uncaught errors and unhandled promise rejections from your Node.js application and reports them to your AI Log Debugger dashboard with AI-powered fix suggestions.
No manual error handling required. Install, initialize with 2 lines, and you're done.
How It Works
Your Node.js App
│
│ uncaughtException / unhandledRejection
▼
ai-log-debugger-sdk
│
│ POST /api/errors/report
▼
AI Log Debugger Dashboard
│
│ AI analyzes error → suggests fix
▼
You get notified (Slack / Email)Requirements
- Node.js 16 or higher
- An AI Log Debugger account
- Your API token (available in your dashboard after signup)
Installation
npm install ai-log-debugger-sdkQuick Start
Add these 2 lines at the very top of your main file (e.g. server.js, app.js, or index.js):
const aiDebugger = require('ai-log-debugger-sdk');
aiDebugger.init({
apiToken: 'your-api-token', // from your AI Log Debugger dashboard
endpoint: 'https://your-backend.com/api/errors/report',
});That's it. Every uncaught error and unhandled promise rejection in your app will now be automatically captured and reported to your dashboard.
Getting Your API Token
- Sign up at AI Log Debugger
- Go to Settings → API Token
- Copy your token and paste it into
init()
Usage Examples
Basic Node.js App
const aiDebugger = require('ai-log-debugger-sdk');
aiDebugger.init({
apiToken: 'your-api-token',
endpoint: 'https://your-backend.com/api/errors/report',
});
// From this point, all uncaught errors are automatically reported.
// Your app continues to work as normal.Express.js App
const express = require('express');
const aiDebugger = require('ai-log-debugger-sdk');
const app = express();
// Initialize at the top — before your routes
aiDebugger.init({
apiToken: 'your-api-token',
endpoint: 'https://your-backend.com/api/errors/report',
});
// Your routes
app.get('/', (req, res) => {
res.send('Hello World');
});
// Add error middleware at the very end — after all routes
app.use(aiDebugger.expressErrorHandler());
app.listen(3000);Manual Error Capture
Capture specific errors inside try/catch blocks:
try {
await riskyOperation();
} catch (err) {
// Report with default severity (MEDIUM)
aiDebugger.captureError(err);
// Or specify severity manually
aiDebugger.captureError(err, { severity: 'CRITICAL' });
}API Reference
aiDebugger.init(options)
Initializes the SDK and attaches global error hooks.
| Option | Type | Required | Description |
|--------|------|----------|-------------|
| apiToken | string | ✅ Yes | Your API token from the dashboard |
| endpoint | string | No | Your backend URL (defaults to the AI Log Debugger endpoint) |
aiDebugger.captureError(err, options?)
Manually capture and report any error.
| Parameter | Type | Description |
|-----------|------|-------------|
| err | Error | The error to capture |
| options.severity | string | LOW, MEDIUM, HIGH, or CRITICAL (default: MEDIUM) |
Returns a Promise<void>.
aiDebugger.expressErrorHandler()
Returns an Express error-handling middleware. Must be placed after all routes.
app.use(aiDebugger.expressErrorHandler());Severity Levels
| Level | When to use |
|-------|-------------|
| LOW | Minor issues, non-critical warnings |
| MEDIUM | Standard errors (default) |
| HIGH | Uncaught exceptions, serious failures |
| CRITICAL | Fatal crashes, data loss risk |
Severity values are case-insensitive — critical, Critical, and CRITICAL all work.
Default Severity by Error Type
| Error Type | Default Severity |
|------------|-----------------|
| uncaughtException | HIGH |
| unhandledRejection | MEDIUM |
| Express route error | HIGH |
| Manual captureError() | MEDIUM |
Error Reporting Payload
Each error is sent to your backend with this structure:
{
"api_token": "your-token",
"error_text": "Cannot read properties of undefined (reading 'id')",
"ai_fix": "Analyzing...",
"severity": "HIGH"
}The ai_fix field is populated by your AI Log Debugger backend — the SDK itself does not call any AI APIs.
Reliability
- Non-blocking — the SDK never slows down or crashes your app
- Retry on failure — automatically retries once if the network request fails
- Silent failure — if reporting fails after retry, a warning is logged but your app continues normally
- No dependencies — uses only Node.js built-in modules (
http,https)
Testing
npm testUses Node.js built-in test runner — no extra dependencies required.
Test coverage includes:
init()configuration and hook setup- Correct payload sent to backend (via mock HTTP server)
uncaughtExceptionandunhandledRejectionhook behavior- Severity auto-detection and normalization
- Network failure handling (no crash on failure)
- Express middleware behavior
Coming Soon
- 🐍 Python SDK —
pip install ai-log-debugger-sdk - 🐘 PHP SDK —
composer require ai-log-debugger/sdk - ☕ Java SDK
- 🟦 TypeScript types for this package
License
MIT — see LICENSE for details.
