Metadata-Version: 2.4
Name: bugwatch-sdk-python
Version: 0.1.1
Summary: Official Python SDK for Bugwatch error tracking (stdlib only)
Author: Bugwatch
License: MIT License
        
        Copyright (c) 2026 Bugwatch
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://bugwatch-two.vercel.app
Project-URL: Documentation, https://bugwatch-two.vercel.app/help
Project-URL: Source, https://github.com/roomylabs/bugwatch
Keywords: error-tracking,monitoring,sentry-alternative,bugwatch,exceptions
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
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
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# bugwatch-sdk-python

Standalone Python client for sending exceptions and messages to a **Bugwatch**
instance. This package is independent of the JavaScript SDK.

- **No third-party dependencies** — standard library only.
- **Non-blocking** — network I/O runs in a daemon thread with an 8 s timeout.
- **HTTPS required** unless `allow_http=True`.
- **PII off by default** — email and IP are stripped unless
  `send_default_pii=True`.
- **`flush()`** waits for in-flight events (use this in short-lived scripts).

## Install

From the `python/` directory:

```bash
pip install .
```

Editable / development install:

```bash
pip install -e .
```

## Quick start

```python
import bugwatch_sdk

bugwatch_sdk.init(
    "https://bw_pk_your_key@bugwatch-api.loadmindx.com/api/1",
    environment="production",
    release="1.2.3",
    sample_rate=1.0,
)

# Capture the active exception.
try:
    1 / 0
except ZeroDivisionError:
    event_id = bugwatch_sdk.capture_exception()
    print("Exception sent:", event_id)

# Capture a message.
bugwatch_sdk.capture_message("Payment confirmed", level="info")

# Capture an explicit exception.
try:
    raise ValueError("invalid amount")
except ValueError as exc:
    bugwatch_sdk.capture_exception(exc, level="warning", tags={"module": "billing"})

# Wait for async sends (short-lived scripts).
bugwatch_sdk.flush()
```

## Global scope

```python
bugwatch_sdk.set_user({"id": "42", "email": "user@example.com"})
bugwatch_sdk.set_tag("feature", "checkout")
bugwatch_sdk.set_context({
    "request": {
        "method": "POST",
        "url": "/api/checkout",
        "headers": {"Content-Type": "application/json"},
    }
})

with bugwatch_sdk.configure_scope() as scope:
    scope.set_tag("tenant", "acme")
    scope.set_user({"id": "43"})
```

## API

| Function | Description |
| --- | --- |
| `init(dsn, environment=None, release=None, sample_rate=1.0)` | Configure the DSN and default context. |
| `capture_exception(exc=None, level="error", tags=None, user=None)` | Capture an exception (active exception if `exc` is `None`). Returns `event_id` or `None`. |
| `capture_message(message, level="info", tags=None, user=None)` | Capture a message. Returns `event_id` or `None`. |
| `set_user(user)` | Set the current user. |
| `set_tag(key, value)` | Add a current tag. |
| `set_context(context)` | Merge context (including an optional `request` key). |
| `flush(timeout=5.0)` | Wait for in-flight sends. |
| `configure_scope()` | Context manager for the current scope. |

`init` options: `debug=False`, `send_default_pii=False`, `allow_http=False`.

## DSN format

```
https://{public_key}@{host}/api/{project_id}
```

Variants without a port and/or without the `/api` segment are also accepted.
The SDK then `POST`s JSON to `{dsn}/store/` with header
`X-Bugwatch-Key: {public_key}`.
