Skip to main content

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

Project description

Here's the cleaned-up and properly formatted version of your markdown:


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.0.tar.gz (12.5 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.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eventflows-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 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.0.tar.gz
Algorithm Hash digest
SHA256 973ed28f378f22998a2f8d9079d0128d115b83b3e3ecc9de887e0e3b1e3b14eb
MD5 f7ff482c494c36dcfb587b99cd7d1800
BLAKE2b-256 297383384edbaee18dd3b8558e6847a4681015d11620170a6b7a0a208bdbfb91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eventflows-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a80cc1965aeac3e6a1b44f575962810048c2ce4822cebb1fae63284b578016e9
MD5 ff4287da8986d9d459f08fbf473215ec
BLAKE2b-256 95ab84ea83baaaa381b5d49265f4227e80ee9917321fbba209774fe1231c3f9b

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