alitycs-python
Official Alitycs analytics SDK for Python servers. Zero runtime dependencies —
HTTP uses urllib.request from the standard library.
Install
pip install alitycs
Quickstart
from alitycs import Alitycs
client = Alitycs(api_key="pk_...")
client.track("checkout_completed", {"plan": "pro", "mrr": 49})
client.identify("user-123", {"email": "user@example.com"})
client.page("settings")
# Deliver everything queued before your process exits:
client.shutdown()
For a client shared by concurrent server requests, scope identity to each event
instead of changing ambient state with identify():
client.track("checkout_started", user_id=request.user_id)
client.capture_error("checkout_failed", {"code": "E_CARD"}, user_id=request.user_id)
The same user_id keyword is accepted by track_revenue() and page() and
does not change the identity used by any other call.
With batching enabled (the default), events are queued and dispatched on a daemon flusher thread,
so track does not block on network I/O. With batching=False, each track call sends inline and
can block up to the configured request/retry limits. Batches flush when flush_size (default 20)
events are queued, every flush_interval seconds (default 2.0), or when you call flush() /
shutdown() explicitly. shutdown() waits up to 30 seconds by default; pass
join_timeout=None only when an unbounded drain is appropriate. On process exit a safety net
drains live instances; SIGTERM and SIGINT also trigger a best-effort drain before the default
termination disposition is restored (registered from the main thread only).
Configuration
Alitycs(
api_key="pk_...", # required
endpoint="https://api.alitycs.com/events",
flush_size=20, # events per batch
flush_interval=2.0, # seconds; None disables the timer
debug=False,
max_queue_size=1000,
max_retries=3, # exponential backoff from retry_backoff_base
session_timeout=1800.0,
batching=True, # False sends each event inline
request_timeout=10.0,
retry_backoff_base=1.0,
persistence_path=None, # optional exact in-flight batch WAL file
)
Delivery guarantees
- Honest results:
flush()returnsTrueonly when every event was delivered. Transient failures re-queue survivors at the head without persistence; withpersistence_path, the exact serialized in-flight batch remains on disk for restart. Permanent refusals are dropped loudly. - No silent loss: delivery failures and local rejections are logged at warn level
(never hidden behind
debug) and counted — seepending,rejected_locally, plusdelivered_total/requeued_total/lost_totalon the batch manager. - Split-on-rejection: an HTTP 400 can mean one event poisoned a whole batch, so the SDK splits that response in half to isolate valid events, with a hard cap of 64 sends. Authentication, authorization, redirect, and other permanent responses are never split.
- Retries reuse the exact batch body so
batchIdstays stable for server-side dedup. - SDK-generated exponential backoff is capped at 10 seconds. A server
Retry-Afterreplaces that generated delay and is capped at one hour to keep delivery bounded. - A new process using the same
persistence_pathreplays retained bodies onflush()(or an unbounded shutdown) and honors any remaining persistedRetry-Afterdeadline. If a finite shutdown deadline expires first, queued events are appended to the WAL in FIFO order. The WAL starts immediately before the first network attempt and is capped atmax_queue_sizeretained events. Each path is exclusively owned by one live client; a same-process registry and a POSIX advisory lock reject overlapping owners. After a fork, the child drops its copy of the parent-owned queue and detaches from the inherited WAL; create a fresh client with a child-specific path when child delivery also needs durability.
Ingestion limits
Events violating these limits are rejected locally at build time — never queued, never sent, never truncated (they would cause the server to reject the whole batch):
| Limit | Value |
|---|---|
| Properties per event | ≤ 50 |
| Property key length | ≤ 100 chars |
| Property value length | ≤ 1000 chars |
| Estimated event size | ≤ 64 KB |
| Required fields | non-blank name AND (userId or anonymousId) |
| Timestamp | epoch milliseconds, ≤ 7 days past, none future |
Revenue payloads (trusted ingestion, requires a key with revenue:write) validate
their per-kind fields strictly:
from alitycs import RevenuePayload
RevenuePayload.transaction(fact_id="inv-1", amount="19.99", currency="USD")
RevenuePayload.mrr_snapshot(
fact_id="snap-1", subscription_id="sub-1",
customer_id="cus-1", mrr_amount="250.00", currency="USD",
)
RevenuePayload.mrr_baseline_complete(fact_id="base-1", currency="USD", expected_active_subscriptions=120)
client.track_revenue(RevenuePayload.transaction(fact_id="inv-2", amount="9.99", currency="EUR"))
Development
pytest tests/unit # unit tests, no network
scripts/e2e_run.py # end-to-end against a local stack (Docker)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alitycs-1.0.0.tar.gz.
File metadata
- Download URL: alitycs-1.0.0.tar.gz
- Upload date:
- Size: 93.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44abcd0dea46261ba7981ad0ed6f81c0171c94cbbf587a8179a04250b4233abb
|
|
| MD5 |
4aef6cf4b4b4066e2fcf257978d29fd2
|
|
| BLAKE2b-256 |
8de440a009c3e2f3d62d6ea5969737e2286936e560dd7abde408d32ca0f195e1
|
Provenance
The following attestation bundles were made for alitycs-1.0.0.tar.gz:
Publisher:
release.yml on alitycs/alitycs-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alitycs-1.0.0.tar.gz -
Subject digest:
44abcd0dea46261ba7981ad0ed6f81c0171c94cbbf587a8179a04250b4233abb - Sigstore transparency entry: 2650310704
- Sigstore integration time:
-
Permalink:
alitycs/alitycs-sdk-python@8e272ef3506a820098b25af4ae0f45fab26e7e62 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/alitycs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8e272ef3506a820098b25af4ae0f45fab26e7e62 -
Trigger Event:
push
-
Statement type:
File details
Details for the file alitycs-1.0.0-py3-none-any.whl.
File metadata
- Download URL: alitycs-1.0.0-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d8cd8d98568a98c65c8275a1f39761fd979ef3031029ca056f662655db245d2
|
|
| MD5 |
7e8f8577ab6e7da629177d1a2f040e20
|
|
| BLAKE2b-256 |
19ea90001d4d522fc285db68a0ea1383fb23dba55a1539e7c0425f5b97623453
|
Provenance
The following attestation bundles were made for alitycs-1.0.0-py3-none-any.whl:
Publisher:
release.yml on alitycs/alitycs-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alitycs-1.0.0-py3-none-any.whl -
Subject digest:
2d8cd8d98568a98c65c8275a1f39761fd979ef3031029ca056f662655db245d2 - Sigstore transparency entry: 2650310759
- Sigstore integration time:
-
Permalink:
alitycs/alitycs-sdk-python@8e272ef3506a820098b25af4ae0f45fab26e7e62 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/alitycs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8e272ef3506a820098b25af4ae0f45fab26e7e62 -
Trigger Event:
push
-
Statement type: