posthog

The official PostHog SDK for sending events, feature flags, and session data from any Python application.

SDK
PyPI
v7.60.1
61 stars
Custom / Unknown

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
82 /100 Excellent
Development Activity 100
Maintenance 100
Community 56
Maturity 60
Momentum 12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 80
Code Quality 82
Innovation 70
Learning Curve 80

posthog-python is the official Python client for PostHog, the open-source product analytics platform. It provides a simple API for capturing events, identifying users, evaluating feature flags, and recording session data, batching and sending them to a PostHog instance (cloud or self-hosted).

The SDK includes framework-specific integration guides for Django and Flask, an OpenFeature provider for standardized feature-flag evaluation, and optional LangChain integration for tracking LLM application usage. It supports Python 3.10 through 3.14 and ships as a production-stable package maintained directly by the PostHog team.

What You Get

  • A simple capture() API for sending custom events and user properties to PostHog
  • Feature flag evaluation, including local evaluation for low-latency flag checks
  • An OpenFeature provider for standardized feature-flag access via the OpenFeature Python SDK
  • Built-in integration guides and helpers for Django and Flask applications
  • Optional LangChain integration for tracking LLM application usage and costs
  • Automatic batching and asynchronous delivery of events to reduce application-side latency

Common Use Cases

  • Instrumenting a Python backend to send product analytics events to a PostHog project
  • Evaluating feature flags server-side to control rollout of new functionality
  • Tracking LLM application usage and cost metrics via the LangChain integration
  • Using OpenFeature-standard flag evaluation with PostHog as the backing provider

Under The Hood

Architecture - The posthog/ package (147 Python files) organizes functionality into a core client, a feature-flags evaluation module supporting both remote and local flag evaluation, and dedicated integration modules for Django, Flask, LangChain, and OpenFeature; a separate openfeature-provider/ directory implements the OpenFeature spec adapter, and sdk_compliance_adapter/ supports cross-SDK compliance testing shared across PostHog’s client libraries. Tech Stack - Pure Python (3.10-3.14) using requests for HTTP delivery, backoff for retry logic, distro for OS/platform detection, and typing-extensions for backward-compatible type hints; optional extras include langchain for LLM tracking and an opt-in zstd compression extra for request payload compression. Code Quality - The repository includes 78 test files covering unit and integration scenarios (integration_tests/), a mypy-baseline.txt for gradual type-checking adoption, and an e2e_test.sh script for end-to-end validation against a live PostHog instance; commit activity is very high (86 commits/month) reflecting active maintenance by the PostHog team. API Design - The client exposes a minimal posthog.capture()/posthog.identify() surface that mirrors PostHog’s other language SDKs for consistency, while advanced use cases (local flag evaluation, OpenFeature, LangChain) are opt-in via separate imports/extras, keeping the default install lightweight; official docs at posthog.com/docs/libraries/python provide framework-specific quick starts.

Used by 19 apps in this directory

TypeScript
56%
Other

agenta

AI Development · Developer Tools · Devops

4,788

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript 56%
Python 39%
Updated 5 days ago
Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 4 days ago
Python
66%
Other

AutoGPT

AI Assistants · Automation · Productivity

187,596

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python 66%
TypeScript 33%
Updated 4 days ago
Python
68%
Other

Baserow

Databases · No Code Platforms

6,012

Open-source no-code platform to build databases, apps, automations, and AI agents — self-hosted or cloud, with full data ownership.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Python 68%
JavaScript 16%
Vue 11%
Updated 5 days ago
Python
47%
MIT

Docs

CMS · File Storage

16,868

Open-source collaborative knowledge platform with real-time editing, AI writing tools, and full self-hosting control — built by the French and German governments.

View details
88
Repo Health
81
Technical
68
Dependency
Built with
Python 47%
TypeScript 45%
Updated 4 days ago
HTML
85%
Apache 2.0

Elementary

Analytics · Data Engineering · Monitoring

2,414

The dbt-native data observability CLI that turns your existing dbt tests and metadata into anomaly detection, lineage graphs, and Slack/Teams alerts — no separate platform required.

View details
81
Repo Health
75
Technical
79
Dependency
Built with
HTML 85%
Python 15%
Updated 5 days ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,182

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
70
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 2 weeks ago
Python
64%
Other

Keep

Automation · Devops · Monitoring

12,359

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
89
Repo Health
79
Technical
66
Dependency
Built with
Python 64%
TypeScript 36%
Updated 1 weeks ago
Python
51%
AGPL 3.0

Khoj

AI Assistants · Knowledge Management · Productivity

37,526

A self-hostable AI second brain that chats with your documents, searches the web, builds custom agents, and runs entirely on your own LLM.

View details
63
Repo Health
82
Technical
66
Dependency
Built with
Python 51%
TypeScript 36%
Updated 2 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers