Integrate PostHog into any python application.
Project description
PostHog Python
Please see the Python integration docs for details.
Development
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 install
to 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.9.19
uv python pin 3.9.19
uv venv env
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.
Releasing Versions
Updates are released using GitHub Actions: after bumping version.py
in master
and adding to CHANGELOG.md
, go to our release workflow's page and dispatch it manually, using workflow from master
.
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
File details
Details for the file posthog-5.4.0.tar.gz
.
File metadata
- Download URL: posthog-5.4.0.tar.gz
- Upload date:
- Size: 88.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
701669261b8d07cdde0276e5bc096b87f9e200e3b9589c5ebff14df658c5893c
|
|
MD5 |
1f8224be2acb1b8601b45d5547505457
|
|
BLAKE2b-256 |
482060ae67bb9d82f00427946218d49e2e7e80fb41c15dc5019482289ec9ce8d
|
File details
Details for the file posthog-5.4.0-py3-none-any.whl
.
File metadata
- Download URL: posthog-5.4.0-py3-none-any.whl
- Upload date:
- Size: 105.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
284dfa302f64353484420b52d4ad81ff5c2c2d1d607c4e2db602ac72761831bd
|
|
MD5 |
d6689a7af70488eb20d0c209904ded86
|
|
BLAKE2b-256 |
4f98e480cab9a08d1c09b1c59a93dade92c1bb7544826684ff2acbfd10fcfbd4
|