Skip to main content

Official Python SDK for OpenTrace Analytics (https://github.com/del4pp/opentrace)

Project description

OpenTrace Python SDK

Official Python client for OpenTrace Analytics. Built for performance, privacy, and full marketing attribution.

Installation

pip install opentrace

Quick Start (Telegram Bot)

from opentrace import OpenTrace

ot = OpenTrace(host="https://your-analytics.com", project_id="ot_web_123")

# Track sub with auto-UTM resolution
ot.track_event(
    name="bot_start",
    bot_param=command.args, # Extracts metadata from ?start=utm_XXXX
    session_id=ot.get_user_hash(user_id) # Persistent privacy-first ID
)

User Identity & Persistence

To track a user’s journey over time (User Timeline), use a consistent session_id. For Telegram bots, we recommend hashing the User ID:

# Generate a short anonymous hash (e.g. 'a1b2c3d4e5f6')
user_hash = ot.get_user_hash(message.from_user.id)

# Every event sent with this hash will be linked in the dashboard
ot.track_event("purchase", session_id=user_hash, payload={"price": 10})

API Reference

OpenTrace(host, project_id=None, debug=False)

Initialize the client.

  • host: URL of your OpenTrace instance.
  • project_id: Default Resource UID for all events.
  • debug: Enable verbose logging.

.track_event(...)

Recommended for Server-side actions and Bots.

Parameter Type Description
name str Required. Event name.
bot_param str The start parameter from Telegram. Auto-resolves UTMs.
session_id str Unique user identity for Timeline tracking.
project_id str Resource UID (overrides default).
payload dict Custom metadata.
utm_source str Manual UTM Source.
utm_medium str Manual UTM Medium.
utm_campaign str Manual UTM Campaign.

.get_user_hash(user_id)

Creates a persistent 16-char anonymous hash for a raw ID.


.resolve_bot_param(param)

Manually fetch campaign metadata from the server.


Technical Features

  • Asynchronous Execution: Network requests are handled in background threads.
  • Zero Dependencies: Requires only the requests library.
  • Privacy First: Tools included to anonymize sensitive IDs before tracking.

License

MIT

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

opentrace-1.2.7.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

opentrace-1.2.7-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file opentrace-1.2.7.tar.gz.

File metadata

  • Download URL: opentrace-1.2.7.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for opentrace-1.2.7.tar.gz
Algorithm Hash digest
SHA256 d27e5be892d17ba60b3c061f892ac466df43520d1e6c75832b551d2ecf24f06a
MD5 ffcffb7231cc22fc6b35e3eb319845bd
BLAKE2b-256 eee08a8770efb91953c64106cd3594aff570522be514a8e0c4123a44802cde77

See more details on using hashes here.

File details

Details for the file opentrace-1.2.7-py3-none-any.whl.

File metadata

  • Download URL: opentrace-1.2.7-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for opentrace-1.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 34431a96875855af208146a085726ee6106451342bd2819fe49738f82192e872
MD5 63605c2b527e3f43c9d6ceb95e2a459b
BLAKE2b-256 19180b989006ad1600470f1ace45168e159e08aa9e1ea0450455facf72568e5f

See more details on using hashes here.

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