Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Send usage data from your Python code to PostHog.

License

NotificationsYou must be signed in to change notification settings

PostHog/posthog-python

Repository files navigation

PyPI

Please see thePython integration docs for details.

Development

Testing Locally

  1. Runpython3 -m venv env (creates virtual environment called "env")
    • oruv venv env
  2. Runsource env/bin/activate (activates the virtual environment)
  3. Runpython3 -m pip install -e ".[test]" (installs the package in develop mode, along with test dependencies)
    • oruv pip install -e ".[test]"
  4. Runmake test
  5. To run a specific test dopytest -k test_no_api_key

Running Locally

Assuming you have alocal version of PostHog running, you can runpython3 example.py to see the library in action.

Running the Django Sentry Integration Locally

There's a sample Django project included, calledsentry_django_example, which explains how to use PostHog with Sentry.

There's 2 places of importance (Changes required are all marked with TODO in the sample project directory)

  1. Settings.py

    1. Input your Sentry DSN
    2. Input your Sentry Org and ProjectID details intoPosthogIntegration()
    3. AddPOSTHOG_DJANGO to settings.py. This allows thePosthogDistinctIdMiddleware to get the distinct_ids
  2. urls.py

    1. This includes thesentry-debug/ endpoint, which generates an exception

To run things:make django_example. This installs the posthog-python library with the sentry-sdk add-on, and then runs the django app.Also start the PostHog app locally.Then navigate tohttp://127.0.0.1:8080/sentry-debug/ and you should get an event in both Sentry and PostHog, with links to each other.

Releasing Versions

Updated are released using GitHub Actions: after bumpingversion.py inmaster and adding toCHANGELOG.md, go toour release workflow's page and dispatch it manually, using workflow frommaster.

Questions?


[8]ページ先頭

©2009-2025 Movatter.jp