PluginsPostHog
PostHog
Integrate PostHog analytics and event tracking
Quick Start
Install the plugin:
pnpm install @corsair-dev/posthogAdd the PostHog plugin to your Corsair instance:
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-keySee 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-secretSee 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:
| Option | Type | Description |
|---|---|---|
authType | 'api_key' | Authentication method (defaults to 'api_key') |
key | string | API key (optional, uses database if not provided) |
webhookSecret | string | Webhook signing secret (optional) |
hooks | object | Endpoint hooks for custom logic |
webhookHooks | object | Webhook hooks for event handling |
errorHandlers | object | Custom error handlers |
For complete documentation on getting credentials, see the Plugin Credentials Guide.