TypeScript SDK

@pontx/posthog

The operator-published SDK for PostHog capture and feature-flag API covers every Endpoint in the current PontxSpec.

v0.1.1Node.js 18 / 20 / 22 CIESM + CommonJSTypeScript declarationsSDK Endpoint coverage 3/3

SDK quality gate

The source for v0.1.1 passed its complete unit suite and built-package E2E on Node.js 18 / 20 / 22.

SDK quality: UT 100%, E2E passed
Unit tests
4/4 · 100%
E2E
Passed
Tested commit
c82b759
Verified
2026-08-24

Install and call

The SDK is produced by Pontx and typechecked and built before publication.

Install SDK
pnpm add @pontx/posthog
TypeScript usage
import { createPostHogClient } from "@pontx/posthog";

const client = createPostHogClient({
  projectToken: process.env.POSTHOG_PROJECT_TOKEN!
});

const sdkRequestBody = {
  "api_key": "REPLACE_WITH_API_KEY",
  "event": "REPLACE_WITH_EVENT",
  "distinct_id": "REPLACE_WITH_DISTINCT_ID"
} satisfies Parameters<typeof client.capture.captureEvent>[0];

const result = await client.capture.captureEvent(
  sdkRequestBody
);
console.log(result);

Command-line access

This npm package also publishes a dedicated CLI for the API. Use dry-run to inspect parameters, then supply your own provider credentials when required.

Dedicated API CLI
pnpm add --global @pontx/posthog

pontx-posthog preview captureEvent --json '{"event":"checkout_completed","distinct_id":"user_123"}'
pontx-posthog execute captureEvent --json '{"event":"checkout_completed","distinct_id":"user_123"}' --confirm