Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

error_explorer_django-1.1.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

error_explorer_django-1.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file error_explorer_django-1.1.0.tar.gz.

File metadata

  • Download URL: error_explorer_django-1.1.0.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

Hashes for error_explorer_django-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a58dbd3ce5810302ea09557fd0ce6d3eb5f34f117a2088ec61000001559c8a25
MD5 3c3b97e31d24435419e6b0a8a42d2812
BLAKE2b-256 bde29baec76a82a0cfe06390d26ebc11bf5c478e017e7935865c76522a6fbf53

See more details on using hashes here.

File details

Details for the file error_explorer_django-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for error_explorer_django-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f4ee106029e450fb0670195d40d8414e184c3c888df4723f99e88f0cadc7d56
MD5 f8558822bac918e56afb229b9d02133c
BLAKE2b-256 dafb12dc37d184e775ffc7a78a631ddd1508c09cee58df0fedcf914d07488f74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page