connecting posthog

This guide walks through connecting twig to your PostHog account so you can access analytics while you develop.

prerequisites

  • A PostHog account (sign up at posthog.com if needed)
  • A project in PostHog with data
  • Twig installed and running

authentication

Twig uses OAuth to connect to PostHog securely.

signing in

  1. Open twig settings (gear icon or preferences menu)
  2. Go to the PostHog section
  3. Click "connect to PostHog"
  4. You'll be redirected to PostHog in your browser
  5. Review the permissions and click "authorize"
  6. Return to twig - your account is now connected

what permissions does twig request?

Twig requests access to:

  • Read your projects and organizations
  • Read analytics data (events, insights, dashboards)
  • Read feature flag configurations

Twig does not request write access - it can read your data but cannot modify your PostHog configuration.

selecting a project

After connecting, select which PostHog project to use:

  1. Go to settings > PostHog
  2. Choose your organization (if you have multiple)
  3. Select the project you're working on

The selected project should match the codebase you're working with.

verifying the connection

To confirm everything is working:

  1. Open the agent chat
  2. Ask a simple question about your data:
    how many events were recorded today?
    
  3. The agent should return a count from your PostHog project

If you get an error, see troubleshooting.

switching projects

To work with a different PostHog project:

  1. Go to settings > PostHog
  2. Select a different project
  3. The agent will now query data from the new project

disconnecting

To remove the PostHog connection:

  1. Go to settings > PostHog
  2. Click "disconnect"
  3. Confirm the action

You can reconnect at any time by signing in again.

multiple organizations

If you belong to multiple PostHog organizations:

  • You can connect to one at a time
  • Switch organizations in settings when needed
  • Each organization has its own set of projects

security notes

  • OAuth tokens are stored securely on your machine
  • No data is stored - analytics data is queried on demand
  • Your permissions apply - twig can only access what your PostHog account can access
  • Revoke access anytime from PostHog account settings

next steps

With PostHog connected:

troubleshooting

Having issues? See connection troubleshooting.