Python SDK
Error tracking SDK for Python applications.
Python 3.7+
Flask
Django
Installation
pip install alertiqo
Basic Setup
from alertiqo import Alertiqo
alertiqo = Alertiqo(
api_key="your-api-key",
endpoint="https://alertiqo.io",
environment="production",
release="1.0.0",
)
alertiqo.init()
Usage
Capture Exceptions
try:
raise ValueError("Something went wrong")
except Exception as e:
alertiqo.capture_exception(e)
Capture Messages
alertiqo.capture_message("User completed checkout", level="info")
Add Breadcrumbs
alertiqo.add_breadcrumb(
message="User clicked button",
category="user-action",
level="info",
data={"button_id": "submit-btn"}
)
Set User Context
alertiqo.set_user(
user_id="12345",
email="[email protected]",
username="johndoe"
)
Set Tags
alertiqo.set_tag("page", "checkout")
alertiqo.set_tags({
"feature": "payments",
"version": "2.1.0"
})
Flask Integration
from flask import Flask
from alertiqo import Alertiqo, alertiqo_middleware
app = Flask(__name__)
alertiqo = Alertiqo(
api_key="your-api-key",
endpoint="https://alertiqo.io",
)
alertiqo.init()
# Add middleware
app.wsgi_app = alertiqo_middleware(alertiqo)(app.wsgi_app)
@app.route('/')
def hello():
return 'Hello World'
if __name__ == '__main__':
app.run()
Django Integration
# settings.py
ALERTIQO_API_KEY = "your-api-key"
ALERTIQO_ENDPOINT = "https://alertiqo.io"
# In your app's apps.py or __init__.py
from django.conf import settings
from alertiqo import Alertiqo
alertiqo = Alertiqo(
api_key=settings.ALERTIQO_API_KEY,
endpoint=settings.ALERTIQO_ENDPOINT,
)
alertiqo.init()
Configuration Options
alertiqo = Alertiqo(
# Required
api_key="your-api-key",
endpoint="https://alertiqo.io",
# Optional
environment="production", # Default: PYTHON_ENV or 'production'
release="1.0.0",
tags={"app": "myapp"},
capture_unhandled=True, # Auto-capture uncaught exceptions
# Filter/modify errors before sending
before_send=lambda report: report # Return None to skip
)
API Reference
| Method | Description |
|---|---|
init() |
Initialize error handlers |
capture_exception(error, additional_data=None) |
Capture an exception |
capture_message(message, level="info") |
Capture a message |
add_breadcrumb(message, category, level, data) |
Add a breadcrumb |
set_user(user_id, email, username) |
Set user context |
set_tag(key, value) |
Set a single tag |
set_tags(tags) |
Set multiple tags |