Error Tracking
Capture exceptions with stack traces, user context, and metadata.
Error tracking captures runtime exceptions in your application and sends them to SeeStack with full stack traces, user context, and custom metadata. Errors are sent immediately (not buffered) because they represent urgent events.
Manual Capture
Use captureError to report a caught exception:
try {
await processOrder(orderId);
} catch (e) {
SeeStack.captureError(e, {
user: { id: 'usr_1234', email: '[email protected]' },
metadata: { orderId, route: '/checkout' },
});
}try:
process_order(order_id)
except Exception as e:
seestack.capture_error(e, context={
"user": {"id": "usr_1234", "email": "[email protected]"},
"metadata": {"order_id": order_id, "route": "/checkout"},
})if err := processOrder(orderID); err != nil {
seestack.CaptureError(err, &seestack.ErrorContext{
User: &seestack.User{ID: "usr_1234", Email: "[email protected]"},
Metadata: map[string]any{"orderID": orderID, "route": "/checkout"},
})
}Automatic Capture
You can opt into global error handler integration to catch unhandled exceptions automatically.
Browser:
// Captures unhandled exceptions and promise rejections
window.addEventListener('error', (event) => {
SeeStack.captureError(event.error);
});
window.addEventListener('unhandledrejection', (event) => {
SeeStack.captureError(event.reason);
});Node.js:
process.on('uncaughtException', (err) => {
SeeStack.captureError(err);
});
process.on('unhandledRejection', (reason) => {
SeeStack.captureError(reason);
});import sys
original_hook = sys.excepthook
def seestack_excepthook(exc_type, exc_value, exc_tb):
seestack.capture_error(exc_value)
original_hook(exc_type, exc_value, exc_tb)
sys.excepthook = seestack_excepthook// Go does not have global exception handlers.
// Use defer/recover in goroutines to capture panics:
func safeGo(fn func()) {
go func() {
defer func() {
if r := recover(); r != nil {
seestack.CaptureError(fmt.Errorf("panic: %v", r), nil)
}
}()
fn()
}()
}Context Object
The optional context parameter lets you attach additional information to an error.
Prop
Type
Error Levels
| Level | Use Case |
|---|---|
debug | Low-priority issues for investigation |
info | Informational errors that are expected |
warn | Potential problems that may need attention |
error | Application errors that need to be fixed (default) |
fatal | Critical errors that crash the application |
How It Works
When you call captureError, the SDK:
- Extracts the exception class name and message
- Captures the stack trace as an array of frame strings
- Attaches user context (if set globally via
setUseror passed in the context) - Attaches
environmentandreleasefrom the init config - Sends the payload immediately to the backend
Errors are deduplicated server-side by exception class and stack trace. You do not need to implement any deduplication logic — send every occurrence and the backend handles grouping.
If the backend returns a 401 Unauthorized response, the SDK disables itself for the remainder of the session. This indicates an invalid API key — check your configuration.