Corsair
PluginsPostHog

PostHog

Integrate PostHog analytics and event tracking

Quick Start

Install the plugin:

pnpm install @corsair-dev/posthog

Add the PostHog plugin to your Corsair instance:

corsair.ts
import { createCorsair } from "corsair";
import { posthog } from "@corsair-dev/posthog";

export const corsair = createCorsair({
    plugins: [
        posthog(),
    ],
});

Once configured, you can access the PostHog API through your Corsair instance:

await corsair.posthog.api.events.eventCreate({
    distinct_id: "user-123",
    event: "page_view",
    properties: { page: "/home" },
});

Authentication

Supported Auth Types

The PostHog plugin uses API key authentication.

  • api_key (default) - Project API key authentication

API Key Setup

Store credentials with the CLI:

pnpm corsair setup --posthog api_key=your-api-key

See Get Credentials for step-by-step instructions on obtaining an API key.

Webhook Secret

Store the webhook secret with the CLI:

pnpm corsair setup --posthog webhook_signature=your-webhook-secret

See Get Credentials for step-by-step instructions on setting up webhooks.

See Authentication for details on managing credentials.

Options

The PostHog plugin accepts the following configuration options:

OptionTypeDescription
authType'api_key'Authentication method (defaults to 'api_key')
keystringAPI key (optional, uses database if not provided)
webhookSecretstringWebhook signing secret (optional)
hooksobjectEndpoint hooks for custom logic
webhookHooksobjectWebhook hooks for event handling
errorHandlersobjectCustom error handlers

For complete documentation on getting credentials, see the Plugin Credentials Guide.