Skip to main content

A robust, non-blocking server-side event tracking library.

Project description

EventFlows

A lightweight, robust, and privacy-first server-side tracking library for Python.

EventFlows acts as a universal router for your conversion events. You define your tracking event once, and EventFlows automatically cleans it, hashes sensitive PII, batches it in a background thread, and safely dispatches it to multiple external APIs (Meta, GA4, Reddit, TikTok) without slowing down your main application.


Key Features

  • Zero Latency: Events are dropped into a thread-safe memory queue instantly. Your users never wait for a tracking pixel to load.
  • Privacy by Design: Emails and phone numbers are automatically normalized and SHA-256 hashed before they ever leave your server.
  • Smart Payload Mapping: Send custom data freely. EventFlows dynamically formats it for "Open" APIs (like Meta) and strictly filters it for "Rigid" APIs (like Reddit).
  • Destination Filtering: Choose exactly which networks receive which events.
  • Resilient Networking: Built-in exponential backoff and retry logic for network blips or rate limits.

Installation

Currently, EventFlows is installed from source.

Using Poetry

poetry add git+https://github.com/YOUR_USERNAME/EventFlows.git

Using pip

pip install git+https://github.com/YOUR_USERNAME/EventFlows.git

Quickstart

Register your providers once at the start of your application, then use tracker.track anywhere.

import logging
from EventFlows import tracker, EventType
from EventFlows import ConsoleProvider, MetaProvider, RedditProvider, GA4Provider

# Setup logging to see EventFlows processing in the background
logging.basicConfig(level=logging.INFO)

# 1. Register your destinations (Providers)
tracker.add_provider(ConsoleProvider())  # Great for local debugging
tracker.add_provider(MetaProvider(pixel_id="123", access_token="abc"))
tracker.add_provider(GA4Provider(measurement_id="G-123", api_secret="abc"))

# 2. Track an event anywhere in your app
# This happens instantly. Hashing and API calls occur in a background thread.
tracker.track(
    name="ProSubscription",
    event_type=EventType.PURCHASE,
    user_data={
        "email": "  User@Example.com  ",  # Automatically trimmed, lowercased, and SHA-256 hashed
        "ip_address": "192.168.1.1"
    },
    properties={
        "value": 49.99,
        "currency": "USD",
        "plan_type": "annual"
    },
    event_id="ORD-9999"  # Used for server-side deduplication
)

# 3. Graceful Shutdown
# Essential for ensuring the memory queue is flushed before the process exits.
# Call this in your app's shutdown/cleanup hook.
tracker.shutdown()

Why use tracker.shutdown()?

EventFlows uses an internal queue to batch events and keep your application fast. If your script or server exits abruptly without calling shutdown(), events still in the queue may not be delivered.

  • FastAPI/Starlette: Use the @app.on_event("shutdown") decorator (or lifespan context manager).
  • Flask: Use atexit.register(tracker.shutdown).
  • Scripts: Call it as the final line of your execution.

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

eventflows-0.1.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

eventflows-0.1.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file eventflows-0.1.1.tar.gz.

File metadata

  • Download URL: eventflows-0.1.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for eventflows-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c4aa8f332cfd522e89507ad1ba66aa160ff48b4d639c3216000871e2ff50dd87
MD5 79a8713abb22b0ae46fe64e164fdbe34
BLAKE2b-256 c0359149022e0c3fb3b4598be60dc99ebf95b18f11fe6fa0fdc3f197f101e55d

See more details on using hashes here.

File details

Details for the file eventflows-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: eventflows-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for eventflows-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b370ca7c020e8380f6aab68189691b9735a23dc380098c97d30171aa85421efc
MD5 ec8e35c81da6b9d2c0a8fe739feef093
BLAKE2b-256 b5b5f81427a209aff2eb6e4ff5bd6a0c6575ce09364a336c5c9a43ce2128f935

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