Skip to main content

Add your description here

Project description

Unisights Python SDK

Unisights Python SDK provides a lightweight event collection endpoint for Python web frameworks. It allows your backend to receive analytics events from the Unisights client SDK and process them using a custom handler.

The package exposes a single POST API endpoint that receives event payloads and forwards them to your handler for processing.

Supported frameworks:

  • FastAPI
  • Flask
  • Django
  • ASGI-compatible frameworks (Starlette, Quart, etc.)

Features

  • Simple event ingestion endpoint
  • Works with multiple Python frameworks
  • Async + sync handler support
  • Framework-agnostic core
  • Easy integration with analytics pipelines (Kafka, DB, queue, etc.)

Installation

pip install unisights

Event Payload Example

The endpoint expects a JSON payload.

{
  "type": "event",
  "name": "page_view",
  "session_id": "abc123",
  "timestamp": 1710000000,
  "data": {
    "url": "/home",
    "referrer": "google.com"
  }
}

FastAPI Integration

from fastapi import FastAPI
from unisights.fastapi import unisights_fastapi

app = FastAPI()

async def handler(payload, request):
    print(payload)

app.include_router(
    unisights_fastapi("/collect/event", handler)
)

Start server:

uvicorn main:app --reload

Endpoint:

POST /collect/event

Flask Integration

from flask import Flask
from unisights.flask import unisights_flask

app = Flask(__name__)

async def handler(payload, request):
    print(payload)

app.register_blueprint(
    unisights_flask("/collect/event", handler)
)

app.run()

Endpoint:

POST /collect/event

Django Integration

Add the route in your Django project.

from django.urls import path
from unisights.django import unisights_django

async def handler(payload, request):
    print(payload)

urlpatterns = [
    path("collect/event", unisights_django(handler))
]

Endpoint:

POST /collect/event

Using with Message Queues or Databases

Your handler can forward events to any system.

Example: Kafka

async def handler(payload, request):
    kafka_producer.send("analytics-events", payload)

Example: Save to database

async def handler(payload, request):
    db.events.insert_one(payload)

Project Structure

unisights/
├── collector.py
├── fastapi.py
├── flask.py
├── django.py
└── asgi.py
  • collector.py → Core event processor
  • fastapi.py → FastAPI adapter
  • flask.py → Flask adapter
  • django.py → Django adapter
  • asgi.py → Generic ASGI middleware

Development

Clone repository:

git clone https://github.com/pradeeparul/unisights
cd unisights-python

Install dependencies:

pip install -e .

Build package:

python -m build

Publish to PyPI:

twine upload dist/*

License

MIT License


Links

GitHub https://github.com/pradeeparul/unisights

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

unisights-0.0.1b1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

unisights-0.0.1b1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file unisights-0.0.1b1.tar.gz.

File metadata

  • Download URL: unisights-0.0.1b1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for unisights-0.0.1b1.tar.gz
Algorithm Hash digest
SHA256 7c4836bae1ab6d34a6af3f35a6290e50b25157eaa6464a862bbd2011313b4f1a
MD5 4cafcbb40e5c727713578b467c8599ed
BLAKE2b-256 5a70fa75120d7f785046bf95423f3a7aa8f17006a8bf1d07d2f2c3ce8a9ed795

See more details on using hashes here.

File details

Details for the file unisights-0.0.1b1-py3-none-any.whl.

File metadata

  • Download URL: unisights-0.0.1b1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for unisights-0.0.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 056af27a0c4f3688658dbf3a07c565c9d69b9f6817a2e46e1063a3c2a38d88b5
MD5 4b6cbe37422913a0057bd311e0074867
BLAKE2b-256 ec35d0a324538f420bb3d62d6e25349b83a3d22ca927daa0095e36e190e93a70

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