Skip to content

Repository files navigation

@pontx/posthog

Pontx Hub SDK guide

An independently authored, type-safe SDK and confirmation-first CLI for the documented PostHog public project-token runtime API:

  • POST /i/v0/e/ — capture one event
  • POST /batch/ — capture events in a batch
  • POST /flags?v=2 — evaluate runtime feature flags

It deliberately excludes PostHog's personal-API-key management API, local evaluation bootstrap, SSE/workflow APIs, and deprecated routes. This is not an official PostHog SDK.

Install

pnpm add @pontx/posthog

SDK

import { createPostHogClient } from "@pontx/posthog";

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

const preview = client.capture.previewCaptureEvent({
  event: "checkout_completed",
  distinct_id: "user_123",
  properties: { plan: "pro" },
});
console.log(preview); // token is redacted

await client.capture.captureEvent({
  event: "checkout_completed",
  distinct_id: "user_123",
}, { confirm: true });

All three remote calls require { confirm: true }. Capture can create or update event, person, and group data; flag evaluation can consume quota.

CLI

pnpm add --global @pontx/posthog
export POSTHOG_PROJECT_TOKEN='set-only-in-your-local-shell'

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

preview never sends a provider request. execute fails unless --confirm is present and never prints the project token.

About

Independent type-safe SDK and confirmation-first CLI for PostHog runtime capture and flag evaluation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages