Python SDK
The official Python SDK for booboo.dev error tracking.
Installation
pip install booboo-sdk Quick start
import booboo
booboo.init("your-dsn-key") That's all you need. The SDK hooks into sys.excepthook to capture unhandled exceptions automatically.
API Reference
booboo.init(dsn, app=None, environment="")
Initialize booboo error tracking. Call this once at application startup.
| Parameter | Type | Description |
|---|---|---|
dsn | str | Required. Your project's DSN key from the dashboard. |
app | Flask/FastAPI | Pass your WSGI/ASGI app instance for framework-specific error handling. |
environment | str | Free-form environment name (e.g. "development", "staging", "production"). Attached to every event for filtering in the dashboard. |
Full example with all options:
from flask import Flask
import booboo
app = Flask(__name__)
booboo.init(
"your-dsn-key",
app=app, # Flask or FastAPI instance
environment="production", # Filter events by environment
)
# Set user context — attached to every subsequent event
booboo.set_user({
"id": "user-123",
"email": "alice@example.com",
"username": "alice",
}) The init() function:
- Hooks
sys.excepthookfor unhandled exceptions - Auto-detects Django via
django.core.signals.got_request_exception - Registers Flask/FastAPI error handlers when
appis provided
booboo.capture_exception(exc=None)
Manually capture an exception. Useful for errors you catch and handle.
| Parameter | Type | Description |
|---|---|---|
exc | Exception | The exception to capture. If None, uses sys.exc_info(). |
try:
do_something_risky()
except Exception:
booboo.capture_exception()
# handle the error gracefully booboo.set_user(user)
Set user context that is attached to every subsequent event. Useful for identifying which user experienced an error.
| Parameter | Type | Description |
|---|---|---|
user | dict | User data with keys like id, email, username, ip_address. |
What gets captured
Each error event sent to booboo.dev includes:
- Exception type — e.g.
ValueError,ConnectionError - Message — the string representation of the exception
- Stack trace — every frame with filename, function name, and line number
- Source context — 5 lines of code above and below the error line
- Local variables —
repr()of locals in each frame (truncated to 200 chars) - Request data — HTTP method and path (when available from framework integrations)
- Environment — the environment tag set during
init()(e.g."production")
Variable scrubbing
The SDK automatically scrubs sensitive local variables. Any variable whose name contains
password, secret, token, api_key,
auth, credential, or private is replaced with
[filtered]. Dunder variables (__name__, etc.) are excluded entirely.
How events are sent
Events are sent asynchronously in background threads so they never block your application.
Pending events are flushed on process exit via atexit.
The SDK sends events as HTTP POST requests to the ingestion endpoint with the
X-Booboo-DSN header set to your DSN key.
Django
Django is auto-detected — no app argument needed. The SDK connects to Django's
got_request_exception signal to capture errors from views automatically.
# settings.py (or manage.py, wsgi.py — anywhere before requests are served)
import booboo
booboo.init("your-dsn-key") settings.py for the simplest setup. The SDK will begin capturing errors immediately — no middleware or INSTALLED_APPS entry required.
Django errors automatically include the HTTP method and request path in the event data.
Flask
Pass your Flask app instance to booboo.init(). The SDK registers
an error handler that captures exceptions before they reach your error page.
from flask import Flask
import booboo
app = Flask(__name__)
booboo.init("your-dsn-key", app=app)
@app.route("/")
def hello():
return "Hello, world!" Flask errors include the HTTP method and request path in the event data.
FastAPI
Pass your FastAPI app instance to booboo.init(). The SDK registers
an async exception handler for all unhandled errors.
from fastapi import FastAPI
import booboo
app = FastAPI()
booboo.init("your-dsn-key", app=app)
@app.get("/")
def hello():
return {"message": "Hello, world!"} FastAPI errors include the HTTP method and request URL path in the event data.
Other Python frameworks
Even without explicit framework support, booboo.init() hooks
sys.excepthook to capture any unhandled exception in your Python process.
You can also use booboo.capture_exception() in try/except blocks for manual capture.
import booboo
booboo.init("your-dsn-key")
# In your error handling code:
try:
process_request()
except Exception:
booboo.capture_exception()
return {"error": "Something went wrong"}, 500