Error Explorer SDK for Django - Automatic error tracking and monitoring
Project description
Error Explorer Django SDK
Automatic error tracking and monitoring for Django applications.
Installation
pip install error-explorer-django
Quick Start
1. Add to INSTALLED_APPS
# settings.py
INSTALLED_APPS = [
...
'error_explorer_django',
]
2. Add Middleware
# settings.py
MIDDLEWARE = [
'error_explorer_django.middleware.ErrorExplorerMiddleware',
... # Should be early in the list to catch all errors
]
3. Configure
# settings.py
ERROR_EXPLORER = {
'token': 'your_project_token',
'environment': 'production', # or 'staging', 'development'
'release': '1.0.0',
}
That's it! Errors will be automatically captured and sent to Error Explorer.
Configuration Options
ERROR_EXPLORER = {
# Required
'token': 'your_project_token',
# Optional - Environment & Release
'environment': 'production',
'release': '1.0.0',
'project': 'my-django-app',
# Optional - HMAC Authentication
'endpoint': 'https://your-server.com/api/v1/webhook',
'hmac_secret': 'your_hmac_secret',
# Optional - Behavior
'debug': False, # Enable debug mode
'sample_rate': 1.0, # 0.0 to 1.0 (100%)
'max_breadcrumbs': 50, # Max breadcrumbs to keep
'attach_stacktrace': True, # Include stack traces
'send_default_pii': False, # Include PII (email, etc.)
# Optional - Capture Settings
'capture_user': True, # Capture authenticated user
'capture_signals': True, # Capture Django signals
'capture_logging': True, # Capture log messages
'capture_404': False, # Capture 404 errors
'capture_403': False, # Capture 403 errors
'capture_cli': False, # Capture in management commands
# Optional - Data Scrubbing
'scrub_fields': [
'password',
'secret',
'token',
'api_key',
'credit_card',
],
}
Logging Integration
Capture log messages as breadcrumbs and errors:
# settings.py
LOGGING = {
'version': 1,
'handlers': {
'error_explorer': {
'class': 'error_explorer_django.logging.ErrorExplorerHandler',
'level': 'WARNING',
},
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django': {
'handlers': ['console', 'error_explorer'],
'level': 'INFO',
},
'myapp': {
'handlers': ['console', 'error_explorer'],
'level': 'DEBUG',
},
},
}
Manual Usage
You can also use Error Explorer manually:
from error_explorer import ErrorExplorer, Breadcrumb, User
# Add custom breadcrumb
ErrorExplorer.add_breadcrumb(Breadcrumb(
message="User clicked checkout",
category="user.action",
data={"cart_total": 99.99},
))
# Set user context (overrides auto-detected user)
ErrorExplorer.set_user(User(
id="user_123",
email="user@example.com",
plan="pro",
))
# Set tags for filtering
ErrorExplorer.set_tags({
"feature": "checkout",
"ab_test": "new_flow",
})
# Capture exception manually
try:
process_payment()
except PaymentError as e:
ErrorExplorer.capture_exception(e)
# Capture message
ErrorExplorer.capture_message("Payment processed", level="info")
What's Captured Automatically
Request/Response
- HTTP method, path, query string
- Response status code
- Safe headers (User-Agent, Referer, etc.)
- Client IP address
User Context
- User ID
- Username
- Full name
- Email (if
send_default_pii=True)
Django Signals
- User login/logout
- Failed login attempts
- Database connections
Breadcrumbs
- All incoming requests
- All responses
- Log messages (if logging handler is configured)
- Auth events
Testing
Disable Error Explorer in tests:
# settings.py or conftest.py
ERROR_EXPLORER = {
'token': 'test_token',
'capture_signals': False,
'capture_logging': False,
}
Or in pytest:
# conftest.py
@pytest.fixture(autouse=True)
def reset_error_explorer():
from error_explorer import ErrorExplorer
ErrorExplorer.reset()
yield
ErrorExplorer.reset()
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file error_explorer_django-1.1.1.tar.gz.
File metadata
- Download URL: error_explorer_django-1.1.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19e8f1af95a311590c3f6b526c916d137d1e244c00ee5c2e36bf681eaaf897ae
|
|
| MD5 |
9e9fe2ac62dc066c2a2a39708538549e
|
|
| BLAKE2b-256 |
7d653e13019be7179c8f7cc8f8453aa65353724b87e8fa37ff52623e58b6e0c0
|
File details
Details for the file error_explorer_django-1.1.1-py3-none-any.whl.
File metadata
- Download URL: error_explorer_django-1.1.1-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0c66832ed74a78333f7db3b76ad7a8983e7a7fb5777d69bd33d1e80d8f376c5
|
|
| MD5 |
dfbb37f7e8e2128f4f9fcf3968b03a74
|
|
| BLAKE2b-256 |
4b80c03c3c6e995487805d90167d94e98895fb6beb3cdb2276ed4928bd0f6fe9
|