# errorgap for Python / Django

See [index.md](./index.md) for API details and the placeholder values (`ERRORGAP_API_KEY`, `ERRORGAP_ENDPOINT`, `ERRORGAP_PROJECT_SLUG`).

SDK source: `github.com/errorgaphq/errorgap-python` · current version: `0.1.1`.

## Install

```sh
pip install "errorgap[django]"
```

Add `errorgap[django]` to `requirements.txt` / `pyproject.toml`.

## Configure

At the bottom of `settings.py`:

```python
import os
import errorgap

errorgap.init(
    endpoint=os.environ["ERRORGAP_ENDPOINT"],
    project_slug=os.environ["ERRORGAP_PROJECT_SLUG"],
    api_key=os.environ["ERRORGAP_API_KEY"],
)
```

Then register the middleware near the top of `MIDDLEWARE`:

```python
MIDDLEWARE = [
    "errorgap.django.ErrorgapMiddleware",
    # ... existing middleware ...
]
```

Do not hardcode the key.

## Trigger a test error

From `python manage.py shell`:

```python
raise Exception("Errorgap test error")
```

If the shell exception isn't reported, add a temporary view that raises, or call `errorgap.notify(Exception("Errorgap test error"))`.

## Verify

Run the verification curl from [index.md](./index.md) and confirm HTTP 201 with a `group_id`. Then trigger the test error above and confirm the errorgap onboarding screen advances.
