Product integration playbook

PostHog 采集与功能开关 API Skill

面向 Agent 的产品集成流程、最佳实践和风险提示。实时 Endpoint、参数与 Schema 由 Pontx Hub 查询,不在 Skill 中重复维护。

产品
PostHog
版本
v1.0.0
许可证
MIT-0
语言
English

02 / Playbook

Skill 正文

以下内容以英文发布,Agent 可按你的语言回答。

PostHog runtime API

Begin with live Pontx discovery instead of copying request fields into an application:

pontx-hub search "PostHog feature flag or event capture" --type endpoint --json
pontx-hub show <returned-resource-id>
pontx-hub sdk posthog

Use @pontx/posthog in application code and pontx-posthog for the optional local CLI. PostHog's public project-token runtime API accepts event capture and remote feature-flag evaluation. It is caller-directed: Pontx Hub never retains the project token, proxies the traffic, or stores provider responses.

Keep tokens and requests local

Supply the project token only from the caller's local environment or client options. Never paste a token into source, a request example, terminal history, logs, Hub, or chat. Capture requests can write event, person, or group data. Remote feature-flag evaluation can affect PostHog usage quota. Treat both as consequential requests even when the immediate response is successful.

Resolve the current Endpoint and Schema, then render the exact local preview:

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

Preview never sends a provider request. Review the destination, event or identity properties, and any batch scope. Execute only after the caller gives explicit confirmation; if inputs change, create and review a fresh preview.

Choose the narrowest workflow

Use single capture for one deliberate event and batch capture only when the caller has already bounded and reviewed every entry. For feature flags, resolve the current evaluation inputs before deciding whether configuration should be included. Do not infer a flag outcome, silently retry a quota-limited result, or use a project token from a different environment.

Few-shot workflows

Scenario 1: Preview a checkout event

User: "Track checkout_completed for user_123, but don't send it yet."

Approach: Resolve the current capture contract, prepare a local redacted preview, verify the event and identity values, and wait for explicit approval before any request can write analytics data.

Scenario 2: Evaluate a rollout flag

User: "Check whether the new checkout is enabled for this user."

Approach: Discover the current feature-flag contract, prepare the local preview with the caller's token kept private, explain possible quota impact, and require explicit confirmation before the remote evaluation.

Scenario 3: Submit a reviewed backfill

User: "Send this approved set of migration events as one batch."

Approach: Resolve the current batch constraints, confirm that every event belongs to the intended project and scope, preview the exact body, then ask for a fresh explicit confirmation before sending the write request.