{"id":46305511,"url":"https://github.com/posthog/posthog-openclaw","last_synced_at":"2026-03-05T13:01:44.553Z","repository":{"id":340991445,"uuid":"1168439092","full_name":"PostHog/posthog-openclaw","owner":"PostHog","description":"PostHog LLM Analytics plugin for OpenClaw","archived":false,"fork":false,"pushed_at":"2026-03-04T13:43:25.000Z","size":215,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-04T16:43:46.573Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PostHog.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-02-27T11:46:36.000Z","updated_at":"2026-03-04T13:43:31.000Z","dependencies_parsed_at":"2026-03-05T13:01:35.495Z","dependency_job_id":null,"html_url":"https://github.com/PostHog/posthog-openclaw","commit_stats":null,"previous_names":["posthog/posthog-openclaw"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/PostHog/posthog-openclaw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostHog%2Fposthog-openclaw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostHog%2Fposthog-openclaw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostHog%2Fposthog-openclaw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostHog%2Fposthog-openclaw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PostHog","download_url":"https://codeload.github.com/PostHog/posthog-openclaw/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostHog%2Fposthog-openclaw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30127209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T12:40:50.676Z","status":"ssl_error","status_checked_at":"2026-03-05T12:39:32.209Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-04T12:07:05.295Z","updated_at":"2026-03-05T13:01:44.541Z","avatar_url":"https://github.com/PostHog.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @posthog/openclaw\n\n[![npm version](https://img.shields.io/npm/v/@posthog/openclaw)](https://www.npmjs.com/package/@posthog/openclaw)\n[![CI](https://github.com/PostHog/posthog-openclaw/actions/workflows/ci.yml/badge.svg)](https://github.com/PostHog/posthog-openclaw/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nPostHog LLM Analytics plugin for [OpenClaw](https://github.com/openclaw/openclaw). Captures LLM generations, tool executions, and conversation traces, sending them to PostHog as structured `$ai_*` events for the [LLM Analytics dashboard](https://posthog.com/docs/llm-analytics).\n\nhttps://github.com/user-attachments/assets/bf7ce150-becb-4df9-b78d-5660d0a3e489\n\n## Install\n\n```bash\nopenclaw plugins install @posthog/openclaw\n```\n\n## Configuration\n\nAdd to your `openclaw.json` (or `openclaw.yaml`):\n\n```jsonc\n{\n    \"plugins\": {\n        \"entries\": {\n            \"posthog\": {\n                \"enabled\": true,\n                \"config\": {\n                    \"apiKey\": \"phc_your_project_key\",\n                    \"host\": \"https://us.i.posthog.com\",\n                    \"privacyMode\": false,\n                    \"traceGrouping\": \"message\",\n                    \"sessionWindowMinutes\": 60,\n                },\n            },\n        },\n    },\n    \"diagnostics\": {\n        \"enabled\": true,\n    },\n}\n```\n\n### Options\n\n| Option                 | Type                       | Default                    | Description                                                                                                           |\n| ---------------------- | -------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------- |\n| `apiKey`               | `string`                   | _(required)_               | Your PostHog project API key                                                                                          |\n| `host`                 | `string`                   | `https://us.i.posthog.com` | PostHog instance URL                                                                                                  |\n| `privacyMode`          | `boolean`                  | `false`                    | When enabled, LLM input/output content is not sent to PostHog                                                         |\n| `traceGrouping`        | `\"message\"` \\| `\"session\"` | `\"message\"`                | Trace grouping mode. `\"message\"`: one trace per runId. `\"session\"`: group all generations in a session into one trace |\n| `sessionWindowMinutes` | `number`                   | `60`                       | Minutes of inactivity before starting a new session window. Applies to both trace grouping modes                      |\n| `enabled`              | `boolean`                  | `true`                     | Enable or disable the plugin                                                                                          |\n\n\u003e **Note:** `diagnostics.enabled` must be `true` in your OpenClaw config for trace-level events (`$ai_trace`) to be captured.\n\n## What gets captured\n\n### `$ai_generation`\n\nCaptured on every LLM call (correlated `llm_input` + `llm_output` hooks).\n\n| Property                      | Description                                                      |\n| ----------------------------- | ---------------------------------------------------------------- |\n| `$ai_model`                   | Model name (e.g. `gpt-4o`, `claude-3`)                           |\n| `$ai_provider`                | Provider name (e.g. `openai`, `anthropic`)                       |\n| `$ai_latency`                 | Request duration in seconds                                      |\n| `$ai_input_tokens`            | Input token count                                                |\n| `$ai_output_tokens`           | Output token count                                               |\n| `$ai_total_cost_usd`          | Total cost in USD                                                |\n| `$ai_input_cost_usd`          | Input cost in USD                                                |\n| `$ai_output_cost_usd`         | Output cost in USD                                               |\n| `$ai_stop_reason`             | Why generation stopped (`stop`, `length`, `tool_calls`, `error`) |\n| `$ai_is_error`                | Whether the generation errored                                   |\n| `$ai_error`                   | Error message (if any)                                           |\n| `$ai_input`                   | Input messages in OpenAI format (redacted in privacy mode)       |\n| `$ai_output_choices`          | Output choices (redacted in privacy mode)                        |\n| `$ai_trace_id`                | Trace ID for hierarchical grouping                               |\n| `$ai_span_id`                 | Span ID for this generation                                      |\n| `$ai_session_id`              | Session identifier                                               |\n| `$ai_channel`                 | Message channel (e.g. `telegram`, `slack`)                       |\n| `$ai_agent_id`                | Agent identifier                                                 |\n| `cache_read_input_tokens`     | Cache read token count                                           |\n| `cache_creation_input_tokens` | Cache creation token count                                       |\n\n### `$ai_span`\n\nCaptured for each tool call (`after_tool_call` hook).\n\n| Property           | Description                                      |\n| ------------------ | ------------------------------------------------ |\n| `$ai_span_name`    | Tool name                                        |\n| `$ai_latency`      | Tool execution duration in seconds               |\n| `$ai_is_error`     | Whether the tool call errored                    |\n| `$ai_error`        | Error message (if any)                           |\n| `$ai_input_state`  | Tool input parameters (redacted in privacy mode) |\n| `$ai_output_state` | Tool output result (redacted in privacy mode)    |\n| `$ai_trace_id`     | Trace ID                                         |\n| `$ai_span_id`      | Span ID for this tool call                       |\n| `$ai_parent_id`    | Parent generation span ID                        |\n\n### `$ai_trace`\n\nCaptured when a message cycle completes (`message.processed` diagnostic event).\n\n| Property                  | Description                                                   |\n| ------------------------- | ------------------------------------------------------------- |\n| `$ai_trace_id`            | Trace ID                                                      |\n| `$ai_session_id`          | Session identifier                                            |\n| `$ai_latency`             | Total message cycle duration in seconds                       |\n| `$ai_total_input_tokens`  | Accumulated input tokens across all generations in the trace  |\n| `$ai_total_output_tokens` | Accumulated output tokens across all generations in the trace |\n| `$ai_is_error`            | Whether the message cycle errored                             |\n| `$ai_error`               | Error message (if any)                                        |\n| `$ai_channel`             | Message channel                                               |\n\n## Privacy\n\nWith `privacyMode: true`, no message content, prompts, or tool parameters are sent to PostHog. Token counts, latency, model info, and error status are always captured.\n\n## Development\n\n```bash\npnpm install\npnpm test\npnpm typecheck\npnpm lint\n```\n\n### Local testing with OpenClaw\n\nTo test the plugin locally against a running OpenClaw gateway, use `plugins.load.paths` to point OpenClaw at your local checkout:\n\n```jsonc\n// ~/.openclaw/openclaw.json\n{\n    \"plugins\": {\n        \"load\": {\n            \"paths\": [\"/path/to/posthog-openclaw\"],\n        },\n        \"entries\": {\n            \"posthog\": {\n                \"enabled\": true,\n                \"config\": {\n                    \"apiKey\": \"phc_your_project_key\",\n                    \"host\": \"https://us.i.posthog.com\",\n                    \"privacyMode\": false,\n                },\n            },\n        },\n    },\n    \"diagnostics\": { \"enabled\": true },\n}\n```\n\nThen start the gateway:\n\n```bash\ncd /path/to/openclaw\npnpm install \u0026\u0026 pnpm build\nnode openclaw.mjs gateway --force --allow-unconfigured\n```\n\nOpen WebChat at http://127.0.0.1:18789/__openclaw__/canvas/ and send a message. Events will appear in your PostHog project under [LLM Analytics](https://us.posthog.com/llm-analytics/traces).\n\n\u003e **Note:** The config entry key must be `\"posthog\"` (matching the `id` field in `openclaw.plugin.json`), not the npm package name.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthog%2Fposthog-openclaw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthog%2Fposthog-openclaw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthog%2Fposthog-openclaw/lists"}