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.

Development

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.9.19
uv python pin 3.9.19
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.

Releasing Versions

Updates are released automatically using GitHub Actions when version.py is updated on master. After bumping version.py in master and adding to CHANGELOG.md, the release workflow will automatically trigger and deploy the new version.

If you need to check the latest runs or manually trigger a release, you can 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

posthog-6.1.0.tar.gz (92.7 kB view details)

Uploaded Source

Built Distribution

posthog-6.1.0-py3-none-any.whl (109.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: posthog-6.1.0.tar.gz
  • Upload date:
  • Size: 92.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for posthog-6.1.0.tar.gz
Algorithm Hash digest
SHA256 c3426841743d1f65679563df25920a7ac1e8e028391063faf0d04b8fdc5338be
MD5 deb5433be2d79dec59717e850c9c9d66
BLAKE2b-256 0fe7027706e2ef332f7b47e8364c8ac78ef69f1d086e7b2716f8764abb54ea66

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for posthog-6.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d653b3c122f102e8f3d8573fca528d580dba78366e33c0c4b828ae8b2975870
MD5 20a98337bbbfa0f4d168fd69a940bf7b
BLAKE2b-256 e6549594816fe7597780c2a86f4c77fd9975be0aee07fe62787670a445715cd4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page