Files
zeekay 3ca982343e rebrand: remove all compat aliases, zero posthog refs
- Remove Posthog = Insights alias from __init__.py
- Remove PosthogContextMiddleware alias from django.py
- Remove PostHogTracingProcessor alias from processor.py
- Change $lib from "posthog-python" to "insights-python"
- Change ingestion URLs from posthog.com to insights.hanzo.ai
- Rename all posthog_* kwargs to insights_* across AI wrappers
- Rename __posthog_exception_captured to __insights_exception_captured
- Rename posthog_context_stack contextvar to insights_context_stack
- Rename posthog🎏 Redis prefix to insights🎏
- Rename $$_posthog_redacted_* sentinels to $$_insights_redacted_*
- Remove POSTHOG_MW_* Django settings fallback, X-POSTHOG-* headers
- Rename Prompts(posthog=) param to Prompts(client=)
- Update APP_ENDPOINT to us.insights.hanzo.ai
- Update all tests, examples, docs, mypy config
2026-03-13 20:29:13 -07:00

1.4 KiB

Hanzo Insights Python SDK

Integrate Hanzo Insights into any Python application.

Installation

pip install hanzo-insights

Quick Start

from hanzo_insights import Insights

client = Insights('<your_project_api_key>', host='https://insights.hanzo.ai')

# Capture an event
client.capture('user_123', 'purchase', properties={'product': 'widget'})

# Feature flags
if client.feature_enabled('new-checkout', 'user_123'):
    show_new_checkout()

Module-level usage

import hanzo_insights

hanzo_insights.api_key = '<your_project_api_key>'
hanzo_insights.host = 'https://insights.hanzo.ai'

hanzo_insights.capture('movie_played', distinct_id='user_123', properties={'movie_id': '42'})
hanzo_insights.shutdown()

Python Version Support

SDK Version Python Versions Supported
7.3.1+ 3.10, 3.11, 3.12, 3.13, 3.14
7.0.0 - 7.0.1 3.10, 3.11, 3.12, 3.13
4.0.1 - 6.x 3.9, 3.10, 3.11, 3.12, 3.13

Development

We use uv.

uv python install 3.12
uv python pin 3.12
uv venv
source env/bin/activate
uv sync --extra dev --extra test
pre-commit install
make test

Running Tests

make test
# or run a specific test:
pytest -k test_no_api_key

License

MIT