Metadata-Version: 2.4
Name: pq-befu
Version: 0.1.0
Summary: Python SDK for the PQ Platform — error tracking, feedback, and ticketing.
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Provides-Extra: django
Requires-Dist: django>=3.2; extra == "django"
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.100.0; extra == "fastapi"
Requires-Dist: starlette>=0.27.0; extra == "fastapi"
Provides-Extra: flask
Requires-Dist: flask>=2.0; extra == "flask"
Provides-Extra: all
Requires-Dist: django>=3.2; extra == "all"
Requires-Dist: fastapi>=0.100.0; extra == "all"
Requires-Dist: starlette>=0.27.0; extra == "all"
Requires-Dist: flask>=2.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"

# PQ SDK

Python SDK for the PQ Platform — error tracking, feedback, and ticketing.

Zero dependencies. Works with Django, FastAPI, Flask, or any Python app.

## Install

```bash
pip install pq-sdk

# Or with framework extras
pip install "pq-sdk[django]"
pip install "pq-sdk[fastapi]"
pip install "pq-sdk[flask]"
```

## Quick Start

```python
from pq_sdk import PQClient

pq = PQClient(
    api_key="your_api_key",
    base_url="http://localhost:8000",
)

# Report an error
pq.capture_error(message="Something broke", error_type="ValueError")

# Report a caught exception
try:
    1 / 0
except Exception:
    pq.capture_exception()

# Submit feedback
pq.send_feedback(rating=5, comment="Great product!")

# Create a ticket
pq.create_ticket(title="Bug report", description="Login fails on mobile", ticket_type="bug")
```

## Auto-Capture

### Context Manager

```python
from pq_sdk.hooks import capture_exceptions

with capture_exceptions(pq, environment="production"):
    do_something_risky()  # exceptions auto-reported
```

### Decorator

```python
from pq_sdk.hooks import auto_capture

@auto_capture(pq, environment="production")
def my_view(request):
    ...
```

### Global Exception Hook

```python
from pq_sdk.hooks import install_hook

pq = PQClient(api_key="...", base_url="...")
install_hook(pq)  # unhandled exceptions auto-reported
```

## Framework Integrations

### Django

Add to `settings.py`:

```python
INSTALLED_APPS = [...]
MIDDLEWARE = [
    "pq_sdk.integrations.django.DjangoMiddleware",  # add this
    ...
]

PQ_SDK = {
    "api_key": "your_api_key",
    "base_url": "http://localhost:8000",
    "environment": "production",
}
```

### FastAPI

```python
from fastapi import FastAPI
from pq_sdk import PQClient
from pq_sdk.integrations.fastapi import FastAPIMiddleware

app = FastAPI()
pq = PQClient(api_key="your_key", base_url="http://localhost:8000")
app.add_middleware(FastAPIMiddleware, client=pq)
```

### Flask

```python
from flask import Flask
from pq_sdk import PQClient
from pq_sdk.integrations.flask import FlaskIntegration

app = Flask(__name__)
pq = PQClient(api_key="your_key", base_url="http://localhost:8000")
FlaskIntegration(app, pq)
```

## Configuration

| Parameter     | Default                      | Description                          |
|---------------|------------------------------|--------------------------------------|
| `api_key`     | (required)                   | API key from your product settings   |
| `base_url`    | `http://localhost:8000`       | Your PQ Platform URL                 |
| `timeout`     | `5`                          | HTTP timeout in seconds              |
| `async_send`  | `True`                       | Send reports in background threads   |

## Development

```bash
cd pq_sdk
pip install -e ".[dev]"
pytest
```
