Metadata-Version: 2.4
Name: outworx-hooks
Version: 0.1.0
Summary: Lightweight webhook monitoring SDK for Python
Author-email: Outworx <hello@outworx.io>
License: MIT
Project-URL: Homepage, https://github.com/abdallaemadeldin/outworx-hooks
Project-URL: Issues, https://github.com/abdallaemadeldin/outworx-hooks/issues
Keywords: webhook,monitoring,tracing,observability,stripe,fastapi,flask,django
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.20.0
Provides-Extra: fastapi
Requires-Dist: fastapi; extra == "fastapi"
Requires-Dist: starlette; extra == "fastapi"
Provides-Extra: flask
Requires-Dist: flask; extra == "flask"
Provides-Extra: django
Requires-Dist: django; extra == "django"

# Outworx Hooks Python SDK

Lightweight webhook monitoring SDK for Python. Know exactly when your webhooks break, how long they take, and what payload they received.

## Features

- 🚀 **Zero Latency**: Events are batched and sent in a background thread.
- 🛠️ **Framework Support**: Native integrations for FastAPI, Flask, and Django.
- 🔐 **Privacy First**: Sensitive headers are automatically redacted.
- 📦 **Lightweight**: Minimal dependencies, focus on performance.

## Installation

```bash
pip install outworx-hooks
```

## Quick Start

### 1. Initialize the SDK

```python
import outworx_hooks

outworx_hooks.init(api_key="your_api_key_here")
```

### 2. Framework Integrations

#### FastAPI

```python
from fastapi import FastAPI
from outworx_hooks.integrations.fastapi import OutworxHooksMiddleware
from outworx_hooks import TrackOptions

app = FastAPI()

app.add_middleware(
    OutworxHooksMiddleware,
    options=TrackOptions(provider="stripe")
)

@app.post("/webhook")
async def handle_webhook():
    return {"status": "ok"}
```

#### Flask

```python
from flask import Flask
from outworx_hooks.integrations.flask import with_webhook_monitoring
from outworx_hooks import TrackOptions

app = Flask(__name__)

@app.route("/webhook", methods=["POST"])
@with_webhook_monitoring(TrackOptions(provider="stripe"))
def handle_webhook():
    return {"status": "ok"}
```

#### Django

Add the middleware to your `MIDDLEWARE` setting:

```python
# settings.py
MIDDLEWARE = [
    ...
    'outworx_hooks.integrations.django.OutworxHooksMiddleware',
]

OUTWORX_HOOKS_OPTIONS = {
    'provider': 'stripe',
    'capture_body': True
}
```

## Advanced Configuration

You can pass various options to `TrackOptions`:

| Option | Type | Description |
| --- | --- | --- |
| `provider` | `str` | Name of the webhook provider (e.g., "stripe", "shopify"). |
| `event_type_header` | `str` | Header name to extract the event type from. |
| `event_type_field` | `str` | JSON field name to extract the event type from. |
| `capture_body` | `bool` | Whether to capture the response body (default: `False`). |
| `capture_headers` | `bool` | Whether to capture request headers (default: `True`). |
| `metadata` | `dict` | Custom metadata to attach to the event. |

## License

MIT
