Metadata-Version: 2.5
Name: azfive-capture
Version: 0.1.0
Summary: Capture product-analytics events into AzFive from Python servers — events, identity, feature flags & experiments.
Author: AzFive
License: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Description-Content-Type: text/markdown

# azfive-capture (Python)

AzFive product analytics for Python servers — events, identity, super
properties, and feature flags/experiments. Zero dependencies (stdlib only).
See `sdk-spec/SPEC.md` in the AzFive repo for the cross-SDK contract.

## Install

```bash
pip install azfive-capture
```

Use a **secret** API key with the `events:write` scope (AzFive → Settings → API
Keys). Secret keys are also valid on `/v1/decide`, so server-side flag
evaluation needs no extra setup.

## Quickstart

```python
from azfive_capture import Client

azfive = Client("azfive_…", host="https://analytics.example.com", project="backend")

azfive.capture("invoice_paid", {"amount": 99}, distinct_id="user-42")
azfive.people.set({"plan": "pro"}, distinct_id="user-42")

# experiments / feature flags — get_flag() reports the exposure automatically,
# deduped per (distinct_id, flag, value)
variant = azfive.get_flag("user-42", "exp-checkout")   # 'control' | 'test' | False | None
if azfive.is_flag_enabled("user-42", "new-onboarding"):
    ...

azfive.flush()   # also flushed by the background thread and at exit
```

Batching: events queue in memory (batch 10 / 5 s / max 1000, oldest dropped)
and are delivered by a daemon thread; failed batches retry on the next tick.
`close()` (also registered via `atexit`) drains the queue.

## Tests

```bash
pip install -e '.[dev]' && pytest   # golden vectors from ../sdk-spec/vectors
```
