> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usekestrel.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# PostHog

> Connect PostHog for product analytics triggers, session replay, and error investigation in workflows

The PostHog integration connects Kestrel to your PostHog instance, enabling product analytics events to trigger workflows and giving AI agents access to session recordings, error data, and event queries for investigation.

## Prerequisites

* **Organization Admin** role in Kestrel
* PostHog account with API access
* PostHog **API key** (Personal API Key) and **Project ID**

## Setup

<Steps>
  <Step title="Get your PostHog credentials">
    1. In PostHog, go to **Settings → Project → Project API Key** and copy your **Project ID**
    2. Go to **Settings → User → Personal API Keys** and create a new key
    3. Copy the generated API key
  </Step>

  <Step title="Connect in Kestrel">
    1. Navigate to **Integrations → PostHog** in your Kestrel dashboard
    2. Click **Connect**
    3. Paste your **API Key** and **Project ID**
    4. Enter your PostHog instance URL (e.g., `https://app.posthog.com` or your self-hosted URL)
    5. Click **Connect PostHog**
  </Step>
</Steps>

## How It's Used

### In Workflows

**Trigger blocks:**

* **Session Error/Exception** — fires when PostHog captures an unhandled exception in a session
* **Console Error** — fires on console error patterns matching your filter
* **Rage Click** — fires when a user exhibits rage click behavior
* **Any PostHog Event** — fires on any PostHog event matching your configured criteria
* **Log Error Alert** — fires when PostHog log error patterns exceed your configured threshold

**Action blocks:**

* **Get Session Summary** — retrieve an AI-generated summary of a user session
* **Get Session Recording** — fetch session recording details and metadata
* **Query Events** — run PostHog event queries with filters and date ranges
* **List Session Recordings** — list session recordings matching specified filters
* **Get Error Issue** — retrieve error group details and exception information

Example: A workflow triggers on a spike in rage clicks, queries the relevant session recordings, summarizes the user experience issue, and creates a Linear issue with the findings.

## Disconnecting

1. Navigate to **Integrations → PostHog**
2. Click **Disconnect**
3. Confirm the disconnection
