Metadata-Version: 2.4
Name: watchup
Version: 1.0.0
Summary: Watchup SDK for Python - Error and event tracking
Home-page: https://github.com/watchupltd/watchup-python
Author: Watchup Ltd
Author-email: support@watchup.com
Classifier: Development Status :: 5 - Production/Stable
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.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
Requires-Dist: black>=22.0.0; extra == "dev"
Requires-Dist: flake8>=4.0.0; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-python
Dynamic: summary

# Watchup Python SDK

Official Python SDK for Watchup incident tracking.

## Installation

```bash
pip install watchup
```

## Quick Start

```python
import watchup

# Initialize the client
watchup.init(
    api_key="your-api-key",
    project_id="your-project-id",
    environment="production"
)

# Capture an error
try:
    risky_operation()
except Exception as e:
    watchup.capture_error(e)

# Capture a message
watchup.capture_message("User completed checkout", level="info")

# Set user context
watchup.set_user({
    "id": "user-123",
    "email": "user@example.com",
    "username": "john_doe"
})

# Add breadcrumbs
watchup.add_breadcrumb({
    "message": "User clicked checkout button",
    "category": "user-action",
    "level": "info"
})

# Set tags
watchup.set_tag("version", "1.2.3")
watchup.set_tags({
    "browser": "chrome",
    "os": "windows"
})

# Flush events before exit
watchup.flush()
```

## Configuration

```python
watchup.init(
    api_key="your-api-key",              # Required
    project_id="your-project-id",        # Required
    endpoint="https://api.watchup.com/api/v1/events",  # Optional
    environment="production",             # Optional
    release="1.2.3",                     # Optional
    server_name="web-server-01",         # Optional
    batch_interval=5000,                 # Optional (ms)
    max_batch_size=10,                   # Optional
    max_queue_size=100,                  # Optional
    max_retries=3,                       # Optional
    retry_backoff=1000,                  # Optional (ms)
    enabled=True,                        # Optional
    debug=False,                         # Optional
    sample_rate=1.0,                     # Optional (0.0-1.0)
    before_send=lambda event: event,     # Optional
    before_breadcrumb=lambda bc: bc      # Optional
)
```

## Decorator Usage

```python
@watchup.capture_errors
def risky_function():
    # Errors will be automatically captured
    raise ValueError("Something went wrong")
```

## Context Manager

```python
with watchup.configure_scope() as scope:
    scope.set_user({"id": "123"})
    scope.set_tag("version", "1.0")
    scope.capture_message("Custom message")
```

## Framework Integration

### Flask

```python
from flask import Flask
import watchup

app = Flask(__name__)

watchup.init(
    api_key="your-api-key",
    project_id="your-project-id"
)

@app.errorhandler(Exception)
def handle_exception(e):
    watchup.capture_error(e)
    return "Internal Server Error", 500
```

### Django

```python
# settings.py
import watchup

watchup.init(
    api_key="your-api-key",
    project_id="your-project-id"
)

# middleware.py
class WatchupMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response
    
    def __call__(self, request):
        return self.get_response(request)
    
    def process_exception(self, request, exception):
        watchup.capture_error(exception)
        return None

# settings.py
MIDDLEWARE = [
    'yourapp.middleware.WatchupMiddleware',
    # ... other middleware
]
```

## API Reference

### `init(api_key, project_id, **options)`
Initialize the Watchup client.

### `capture_error(error, context=None)`
Capture an exception. Returns event ID or None.

### `capture_message(message, level="info", context=None)`
Capture a message. Returns event ID or None.

### `set_user(user)`
Set user context. Pass `None` to clear.

### `add_breadcrumb(breadcrumb)`
Add a breadcrumb to the timeline.

### `set_tag(key, value)`
Set a single tag.

### `set_tags(tags)`
Set multiple tags.

### `set_extra(key, value)`
Set extra context data.

### `set_extras(extras)`
Set multiple extra context data.

### `flush(timeout=5.0)`
Flush all queued events. Returns True if successful.

### `close(timeout=5.0)`
Close the client and cleanup resources.

## License

MIT License
