errortracksdk
v1.0.4
Published
Lightweight error tracking SDK for Node.js applications
Maintainers
Readme
🚀 ErrorTrack SDK
Lightweight, production-ready error tracking SDK for Node.js applications. Automatically capture crashes, unhandled promise rejections, and custom events, then send them to your ErrorTrack server for monitoring and debugging.
✨ Features
- ⚡ Zero configuration setup
- 🚀 Lightweight and fast
- 🔥 Automatic exception tracking
- 🛡 Captures uncaught exceptions
- 📌 Captures unhandled promise rejections
- 📝 Manual exception reporting
- 💬 Custom log messages
- 🏷 Attach metadata to errors
- 🌍 Environment support
- 🔒 API Key authentication
- 📦 Zero runtime dependencies
- 📊 Works seamlessly with the ErrorTrack Dashboard
📦 Installation
Using npm
npm install errortracksdkUsing yarn
yarn add errortracksdkUsing pnpm
pnpm add errortracksdk⚡ Quick Start
const ErrorTrack = require("errortracksdk");
const client = ErrorTrack.init({
apiKey: process.env.ERRORTRACK_API_KEY,
endpoint: "https://your-domain.com/api/sdk/ingest",
environment: "production",
});That's it.
The SDK automatically starts listening for:
- Uncaught Exceptions
- Unhandled Promise Rejections
No additional setup required.
📖 Basic Example
const ErrorTrack = require("errortracksdk");
const client = ErrorTrack.init({
apiKey: process.env.ERRORTRACK_API_KEY,
});
function divide(a, b) {
if (b === 0) {
throw new Error("Division by zero");
}
return a / b;
}
try {
divide(10, 0);
} catch (err) {
client.captureException(err);
}🚨 Automatic Error Tracking
ErrorTrack automatically captures application crashes.
throw new Error("Something went wrong");or
Promise.reject(new Error("Promise failed"));Both will automatically appear in your ErrorTrack Dashboard.
📝 Manual Exception Tracking
try {
riskyOperation();
} catch (error) {
client.captureException(error);
}📌 Exception With Metadata
Metadata helps you identify exactly where an error occurred.
client.captureException(error, {
userId: "user_123",
orderId: "ORD-12093",
paymentMethod: "Stripe",
feature: "Checkout",
});Dashboard Output
Error:
Database Connection Failed
Metadata
userId : user_123
orderId : ORD-12093
paymentMethod : Stripe
feature : Checkout💬 Capture Custom Messages
Not every important event is an exception.
You can also send informational messages.
client.captureMessage("Cache cleared successfully", "INFO");Another example
client.captureMessage("Payment completed", "INFO");🎯 Supported Log Levels
| Level | Description | |---------|------------| | INFO | Informational message | | DEBUG | Debug information | | WARNING | Warning message | | ERROR | Error message |
Example
client.captureMessage("Redis Connected", "INFO");
client.captureMessage("Disk usage is high", "WARNING");
client.captureMessage("API request failed", "ERROR");🌍 Environment Configuration
Specify the environment to better organize errors.
const client = ErrorTrack.init({
apiKey: process.env.ERRORTRACK_API_KEY,
environment: "production",
});Available values
- development
- testing
- staging
- production
⚙ Configuration
| Option | Type | Required | Default | Description | |----------|----------|-----------|------------|----------------------------| | apiKey | string | ✅ | — | Your Project API Key | | endpoint | string | ❌ | Default Server | Backend ingest endpoint | | environment | string | ❌ | production | Environment name |
Example
const client = ErrorTrack.init({
apiKey: "project_api_key",
endpoint:
"https://api.example.com/sdk/ingest",
environment: "production",
});📚 API Reference
ErrorTrack.init()
Initialize the SDK.
const client = ErrorTrack.init(config);Returns
ErrorTrackClientclient.captureException()
Capture an exception manually.
client.captureException(error);With metadata
client.captureException(error, {
userId: "101",
tenantId: "company-1",
});client.captureMessage()
Capture a custom message.
client.captureMessage(
"Background worker started",
"INFO"
);📂 Complete Example
const ErrorTrack = require("errortracksdk");
const client = ErrorTrack.init({
apiKey: process.env.ERRORTRACK_API_KEY,
endpoint: "https://api.example.com/sdk/ingest",
environment: "production",
});
async function main() {
throw new Error("Database Connection Failed");
}
main();Dashboard
✔ Error Captured
Message
Database Connection Failed
Environment
production
Timestamp
2026-07-24T18:30:21Z
Node Version
v22.17.0
Platform
linux
Stack Trace
...📦 What Gets Captured?
Each event contains
- ✅ Error Message
- ✅ Stack Trace
- ✅ Timestamp
- ✅ Environment
- ✅ Platform
- ✅ Node.js Version
- ✅ Hostname
- ✅ Metadata
- ✅ Severity
- ✅ SDK Version
🔄 Error Lifecycle
Application
│
▼
ErrorTrack SDK
│
▼
Captures Error
│
▼
Sends Event
│
▼
ErrorTrack Backend
│
▼
Dashboard📈 Dashboard
Once events are received, you'll be able to
- 📊 View all errors
- 🔍 Search errors
- 🏷 Filter by environment
- 📌 View stack traces
- 👤 View metadata
- ⏰ View occurrence history
Dashboard screenshots can be added here after publishing.
🚀 Best Practices
✔ Use environment variables for API Keys.
apiKey: process.env.ERRORTRACK_API_KEY✔ Send useful metadata
client.captureException(error, {
userId,
tenantId,
feature: "Checkout",
});✔ Keep environments separated
development
staging
production🛣 Roadmap
- ✅ Exception Tracking
- ✅ Automatic Crash Detection
- ✅ Promise Rejection Tracking
- ✅ Metadata Support
- ✅ Dashboard
- ⏳ Express Middleware
- ⏳ NestJS Integration
- ⏳ Fastify Plugin
- ⏳ Source Maps
- ⏳ Session Replay
- ⏳ Performance Monitoring
- ⏳ Browser SDK
- ⏳ React SDK
🤝 Contributing
Contributions are welcome!
git clone https://github.com/yourusername/errortracksdk.git
cd errortracksdk
npm install
npm run devPlease open an Issue before submitting major changes.
📄 License
MIT License
❤️ Support
If you find this project useful, consider giving it a ⭐ on GitHub.
It helps others discover the project and motivates future development.
Made with ❤️ by the ErrorTrack Team
