Skip to main content

Python SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps

Project description

Aptabase Python SDK

PyPI downloads PyPI - Version Python versions

Python SDK for Aptabase - privacy-first analytics for mobile, desktop and web applications.

Features

  • 🚀 Fully async - Built with httpx and asyncio
  • 🔒 Privacy-first - No personal data collection
  • 🏃 Modern Python - Requires Python 3.11+
  • 🔄 Auto-batching - Efficient event batching and flushing
  • Lightweight - Minimal dependencies

Installation

uv add aptabase
# or
pip install aptabase

Quick Start

import asyncio
from aptabase import Aptabase

async def main():
    async with Aptabase("A-EU-1234567890") as client:
        # Track a simple event
        await client.track("app_started")

        # Track an event with properties
        await client.track("user_action", {
            "action": "button_click",
            "button_id": "login",
            "screen": "home"
        })

        # Events are automatically flushed, but you can force it
        await client.flush()

asyncio.run(main())

Samples

Configuration

client = Aptabase(
    app_key="A-EU-1234567890",          # Your Aptabase app key
    app_version="1.2.3",                # Your app version
    is_debug=False,                     # Enable debug mode
    max_batch_size=25,                  # Max events per batch (max 25)
    flush_interval=10.0,                # Auto-flush interval in seconds
    timeout=30.0                        # HTTP timeout in seconds
)

App Key Format

Your app key determines the server region:

  • A-EU-* - European servers
  • A-US-* - US servers

Get your app key from the Aptabase dashboard.

Event Tracking

Simple Events

await client.track("page_view")

Events with Properties

await client.track("purchase", {
    "product_id": "abc123",
    "price": 29.99,
    "currency": "USD"
})

Lifecycle

Context Manager

async with Aptabase("A-EU-1234567890") as client:
    await client.track("event")
    # Automatically handles start/stop and flushing

Manual

client = Aptabase("A-EU-1234567890")
await client.start()
try:
    await client.track("event")
finally:
    await client.stop()  # Ensures all events are flushed

Error Handling

from aptabase import Aptabase, AptabaseError, NetworkError

try:
    async with Aptabase("A-EU-1234567890") as client:
        await client.track("event")
except NetworkError as e:
    print(f"Network error: {e}, status: {e.status_code}")
except AptabaseError as e:
    print(f"Aptabase error: {e}")

Development

Install development dependencies:

uv sync --dev

Run tests:

uv run pytest

Code formatting:

uv run ruff check .

Type checking:

uv run mypy .

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aptabase-0.1.0.tar.gz (144.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aptabase-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file aptabase-0.1.0.tar.gz.

File metadata

  • Download URL: aptabase-0.1.0.tar.gz
  • Upload date:
  • Size: 144.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aptabase-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5831fff24e6a889873d15f9687869228f9a87d3b7cd52a0a2b4fb8506de1da4f
MD5 770bd50364360483c1a4cdbc67def7e5
BLAKE2b-256 b03aad490f13f9d6378d357411c498a96e513e76fdfa49e963ffafed52d37405

See more details on using hashes here.

Provenance

The following attestation bundles were made for aptabase-0.1.0.tar.gz:

Publisher: cd.yml on aptabase/aptabase-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aptabase-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aptabase-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aptabase-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9417178497f1d217ed0e41f1d2b95b759b7e5fa3583b0cbc302228ccd91e281
MD5 752b4844601719c2e67d82e3a13bb329
BLAKE2b-256 d55339484a36ac4bd5e0fa3d8f5ddebd12fc7d0247a58d30582e0a5dde394739

See more details on using hashes here.

Provenance

The following attestation bundles were made for aptabase-0.1.0-py3-none-any.whl:

Publisher: cd.yml on aptabase/aptabase-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page