Integrate PostHog into any python application.
Project description
PostHog Python
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.
- Run
uv venv env(creates virtual environment called "env")- or
python3 -m venv env
- or
- Run
source env/bin/activate(activates the virtual environment) - Run
uv sync --extra dev --extra test(installs the package in develop mode, along with test dependencies)- or
pip install -e ".[dev,test]"
- or
- you have to run
pre-commit installto have auto linting pre commit - Run
make test - 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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file posthog-7.11.1.tar.gz.
File metadata
- Download URL: posthog-7.11.1.tar.gz
- Upload date:
- Size: 189.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3a5cb3b2488e6d30a79d9f79f076632a075f8d390bd35c8158a4e4b42caeeb1
|
|
| MD5 |
69c8b0143a025ba748f8c3cb195f36ee
|
|
| BLAKE2b-256 |
6679ce0f5af1679bcfd3b5d70072f5824759e2076b0da2b941b94bcfd9850abb
|
Provenance
The following attestation bundles were made for posthog-7.11.1.tar.gz:
Publisher:
release.yml on PostHog/posthog-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
posthog-7.11.1.tar.gz -
Subject digest:
b3a5cb3b2488e6d30a79d9f79f076632a075f8d390bd35c8158a4e4b42caeeb1 - Sigstore transparency entry: 1293801463
- Sigstore integration time:
-
Permalink:
PostHog/posthog-python@c3f097f72f5ef6c1ecd25ade7d3ba08e57765eaf -
Branch / Tag:
refs/heads/master - Owner: https://github.com/PostHog
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c3f097f72f5ef6c1ecd25ade7d3ba08e57765eaf -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file posthog-7.11.1-py3-none-any.whl.
File metadata
- Download URL: posthog-7.11.1-py3-none-any.whl
- Upload date:
- Size: 220.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa92568b3ebfc2c97733452cf1cb5ef6acfeeb48efcf5e934f1b595d12034bcc
|
|
| MD5 |
a5921544f32f70d8a1305e3183e9c110
|
|
| BLAKE2b-256 |
12ccddec4c8bfa52d966c4f8447422758c1a4f03c3a6e7f0ddccca0dadc107b8
|
Provenance
The following attestation bundles were made for posthog-7.11.1-py3-none-any.whl:
Publisher:
release.yml on PostHog/posthog-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
posthog-7.11.1-py3-none-any.whl -
Subject digest:
aa92568b3ebfc2c97733452cf1cb5ef6acfeeb48efcf5e934f1b595d12034bcc - Sigstore transparency entry: 1293801495
- Sigstore integration time:
-
Permalink:
PostHog/posthog-python@c3f097f72f5ef6c1ecd25ade7d3ba08e57765eaf -
Branch / Tag:
refs/heads/master - Owner: https://github.com/PostHog
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c3f097f72f5ef6c1ecd25ade7d3ba08e57765eaf -
Trigger Event:
workflow_dispatch
-
Statement type: