Skip to main content

Integrate PostHog into any python application.

Project description

PostHog Python

posthoglogo

pypi installs GitHub contributors GitHub commit activity GitHub closed issues

Please see the Python integration docs for details.

Python Version Support

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

Development

This repo requires all commits to be signed. To configure commit signing, see the PostHog handbook.

Testing Locally

We recommend using uv. It's super fast.

  1. Run uv venv env (creates virtual environment called "env")
    • or python3 -m venv env
  2. Run source env/bin/activate (activates the virtual environment)
  3. Run uv sync --extra dev --extra test (installs the package in develop mode, along with test dependencies)
    • or pip install -e ".[dev,test]"
  4. you have to run pre-commit install to have auto linting pre commit
  5. Run make test
  6. To run a specific test do pytest -k test_no_api_key

PostHog recommends uv so...

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 Locally

Assuming you have a local version of PostHog running, you can run python3 example.py to see the library in action.

Testing changes locally with the PostHog app

You can run make prep_local, and it'll create a new folder alongside the SDK repo one called posthog-python-local, which you can then import into the posthog project by changing pyproject.toml to look like this:

dependencies = [
    ...
    "posthoganalytics" #NOTE: no version number
    ...
]
...
[tools.uv.sources]
posthoganalytics = { path = "../posthog-python-local" }

This'll let you build and test SDK changes fully locally, incorporating them into your local posthog app stack. It mainly takes care of the posthog -> posthoganalytics module renaming. You'll need to re-run make prep_local each time you make a change, and re-run uv sync --active in the posthog app project.

Releasing

This repository uses Sampo for versioning, changelogs, and publishing to crates.io.

  1. When making changes, include a changeset: sampo add
  2. Create a PR with your changes and the changeset file
  3. Add the release label and merge to main
  4. Approve the release in Slack when prompted — this triggers version bump, crates.io publish, git tag, and GitHub Release

You can also trigger a release manually via the workflow's workflow_dispatch trigger (still requires pending changesets).

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

posthog-7.10.0.tar.gz (186.3 kB view details)

Uploaded Source

Built Distribution

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

posthog-7.10.0-py3-none-any.whl (215.7 kB view details)

Uploaded Python 3

File details

Details for the file posthog-7.10.0.tar.gz.

File metadata

  • Download URL: posthog-7.10.0.tar.gz
  • Upload date:
  • Size: 186.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for posthog-7.10.0.tar.gz
Algorithm Hash digest
SHA256 2f71a2ece4115bd9e4ee510749ed8f2d2930e8abd94963a48fce85f42fb4008c
MD5 1453815aa3a00a1e310c5ab323de2c7b
BLAKE2b-256 12a6b51f59d78927821c28051ff3763f216361ebd4c0d17b47931eecab366c0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for posthog-7.10.0.tar.gz:

Publisher: release.yml on PostHog/posthog-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file posthog-7.10.0-py3-none-any.whl.

File metadata

  • Download URL: posthog-7.10.0-py3-none-any.whl
  • Upload date:
  • Size: 215.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for posthog-7.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 559f1dfc8e5c4eedf2a2f6d7e35b30427a7246153d0d665fc841bed0d8765862
MD5 e69132f18670cf10ca49a77acd2914f6
BLAKE2b-256 aa38a423cd6f111a8e019d5e80b8e331f6dac104cde1fbba17cdf1c8b299323c

See more details on using hashes here.

Provenance

The following attestation bundles were made for posthog-7.10.0-py3-none-any.whl:

Publisher: release.yml on PostHog/posthog-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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