Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 57 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 1 addition & 1 deletion specs
Submodule specs updated 33 files
+2 −0 .gitignore
+78 −0 AGENTS.md
+0 −21 HEARTBEAT.md
+19 −22 README.md
+0 −88 SOUL.md
+2 −14 http/SPEC.md
+5 −50 lakehouse/SPEC.md
+0 −0 product-analytics/CONSTANTS.md
+20 −75 product-analytics/SPEC.md
+0 −0 product-analytics/TEST_PLAN.md
+1 −1 product-analytics/fixtures/README.md
+14 −0 product-analytics/fixtures/alias_basic.json
+3 −9 product-analytics/fixtures/identify_basic.json
+7 −11 product-analytics/fixtures/track_basic.json
+20 −0 product-analytics/fixtures/track_null_properties.json
+0 −186 scripts/bootstrap-sdk-repo.sh
+0 −153 skills/bootstrap-sdk/SKILL.md
+0 −20 skills/build-product-analytics-sdk/fixtures/alias_basic.json
+0 −23 skills/build-product-analytics-sdk/fixtures/track_null_properties.json
+0 −143 skills/build-readme/SKILL.md
+0 −98 skills/maintainer-routine/SKILL.md
+0 −156 skills/release-sdk/SKILL.md
+0 −201 skills/review-pr/SKILL.md
+0 −127 skills/sync-repos/SKILL.md
+0 −1 skills/sync-repos/templates/.github/FUNDING.yml
+0 −47 skills/sync-repos/templates/.github/ISSUE_TEMPLATE/bug_report.yml
+0 −21 skills/sync-repos/templates/.github/ISSUE_TEMPLATE/feature_request.yml
+0 −13 skills/sync-repos/templates/.github/PULL_REQUEST_TEMPLATE.md
+0 −83 skills/sync-repos/templates/CODE_OF_CONDUCT.md
+0 −32 skills/sync-repos/templates/CONTRIBUTING.md
+0 −21 skills/sync-repos/templates/LICENSE
+0 −18 skills/sync-repos/templates/SECURITY.md
+0 −179 skills/triage-issues/SKILL.md
Loading