Metadata-Version: 2.4
Name: coconnect
Version: 1.0.0
Summary: Send your platform's events to CoConnect Hub, in your own words. Server side.
License: MIT
Keywords: coconnect,quests,rewards,partner,events
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# coconnect

Send what users do on your platform to CoConnect Hub, named the way your platform already names it. CoConnect matches each event to the right task and rewards the member.

```bash
pip install coconnect
```

```python
import os
from coconnect import CoConnect

hub = CoConnect(token=os.environ["COCONNECT_TOKEN"])

# When a user signs up (cc_id is the cookie set by https://hub.coconnect.co/sdk.js on your site):
hub.send("user_registered", user="u_1001", cc_id=request.cookies.get("cc_id"))

# Anything else, in your own words, with whatever details you have:
hub.send("ftd", user="u_1001", amount=75, currency="USD", id="dep_10482")
hub.send("kyc_failed", user="u_1001", status="failed", reason="Document unreadable")
```

- **`user`** is required: your own ID for the user.
- **`cc_id`** links the user to their CoConnect account. Send it at least once per user.
- **`id`** is your reference for the event. If you leave it out, the SDK generates one, so a retried request is never counted twice.
- **Any other keyword arguments** are kept as details of the event. Emails and phone numbers are hashed by CoConnect on arrival.
- **Batching:** `send_batch([...])` sends up to 50 events at once.

The SDK also handles:
- **Retries:** network errors, 429 and 5xx responses are retried with backoff.
- **Errors:** a bad token or a malformed event raises `CoConnectError`.
- **No dependencies** beyond the standard library.

Keep your token on the server.
