From 83b19e86ae95aa25bae089cc619676b8373c17a6 Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 11 Mar 2026 20:51:57 +0100 Subject: [PATCH 1/2] chore: update altertable-client-specs submodule to v0.10.0 --- specs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs b/specs index ef983f0..3a1195e 160000 --- a/specs +++ b/specs @@ -1 +1 @@ -Subproject commit ef983f0c2e8ff3859e0a11f360ba0721d89b5e6d +Subproject commit 3a1195e48e40c4f629f11e7181ae098b5d330ecd From 07eb5d3e5774ffb9b51bf4aa2668d9821c087569 Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 12 Mar 2026 09:48:18 +0100 Subject: [PATCH 2/2] docs: normalize README structure --- README.md | 94 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index e5e3424..4db84b9 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,90 @@ # Altertable Python SDK -Official Python SDK for Altertable Product Analytics. +You can use this SDK to send Product Analytics events to Altertable from Python applications. -## Installation - -You can install the package via `pip`: +## Install ```bash pip install altertable ``` -Or using `poetry`: +## Quick start -```bash -poetry add altertable +```python +from altertable import Altertable + +client = Altertable("your_api_key") + +client.track( + event="button_clicked", + distinct_id="user_123", + options={"properties": {"button_id": "signup_btn", "page": "home"}}, +) ``` -## Usage +## API reference ### Initialization -```python -from altertable import Altertable +`Altertable(api_key: str)` + +Creates a client instance authenticated with your project API key. +```python client = Altertable("your_api_key") ``` -### Tracking Events +### Tracking + +`track(event: str, distinct_id: str, options: dict | None = None)` + +Sends an event for a user. ```python -client.track( - event="button_clicked", - distinct_id="user_123", - options={ - "properties": { - "button_id": "signup_btn", - "page": "home" - } - } -) +client.track("purchase", "user_123", options={"properties": {"amount": 42}}) ``` -### Identifying Users +### Identity + +`identify(distinct_id: str, options: dict | None = None)` + +Associates traits with a user. ```python -client.identify( - distinct_id="user_123", - options={ - "traits": { - "email": "user@example.com", - "name": "John Doe" - }, - "anonymous_id": "previous_anon_id" - } -) +client.identify("user_123", options={"traits": {"email": "user@example.com"}}) ``` ### Alias +`alias(distinct_id: str, new_user_id: str)` + +Merges an anonymous identifier into a known user identifier. + ```python -client.alias( - distinct_id="previous_anonymous_id", - new_user_id="new_user_id" -) +client.alias("anon_123", "user_123") +``` + +## Configuration + +| Option | Type | Default | Description | +|---|---|---|---| +| `base_url` | `str` | `"https://api.altertable.ai"` | API base URL used for requests. | +| `environment` | `str` | `"production"` | Environment tag attached to events. | +| `request_timeout` | `int` | `5` | HTTP timeout in seconds. | +| `release` | `str \| None` | `None` | Application release version. | +| `debug` | `bool` | `False` | Enables debug logging output. | +| `on_error` | `callable \| None` | `None` | Callback invoked on SDK errors. | + +## Development + +Prerequisites: Python 3.9+ and `pip`. + +```bash +pip install -e ".[dev]" +pytest +ruff check . ``` ## License -The package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). +See [LICENSE](LICENSE). \ No newline at end of file