12 Commits

Author SHA1 Message Date
kumarabhirup
45acfbb493
fix(telemetry): emit per-turn cost instead of cumulative session total
extractUsageFromMessages was summing ALL assistant messages, so each
$ai_generation event reported a growing cumulative total — PostHog's
sum() then massively over-counted costs (e.g. $634 reported vs $73 actual).
2026-03-15 13:09:54 -07:00
kumarabhirup
aa97489785
👌 IMPROVE: feat(telemetry): add DenchClaw and OpenClaw version tracking
Integrate version tracking for DenchClaw and OpenClaw into the telemetry system. The versions are now read from the package.json and environment variables, and are included in the PostHog client initialization and telemetry events. This enhancement allows for better monitoring and analytics of the versions in use.
2026-03-15 04:33:44 -07:00
kumarabhirup
eaef8df20b
fix(telemetry): prevent anonymousId from leaking via npm package
The root layout called getOrCreateAnonymousId() in a Server Component
without marking the route as dynamic. Next.js treated it as static,
pre-rendering the developer's UUID into the standalone build shipped
via npm — so every `npx denchclaw` user shared the same PostHog identity.

- Add `export const dynamic = "force-dynamic"` to root layout
- Replace `process.env.HOME || "~"` fallback with `homedir()` in web
  telemetry and posthog-analytics plugin (Node.js path.join doesn't
  expand "~", creating a relative path under cwd instead)
2026-03-06 23:30:31 -08:00
kumarabhirup
ec73141a01
chore: bump version to 2.0.16 and enhance feedback API message handling
Update package versions for denchclaw and dench to 2.0.16. Refactor feedback API to convert chat lines into PostHog-compatible messages, preserving chronological order and including tool calls and results. Improve test cases to reflect changes in message handling.
2026-03-05 21:38:55 -08:00
kumarabhirup
83f6b69f82
feat(telemetry): use session key as trace ID and improve AI event inputs
Use the session key directly as the PostHog trace ID so feedback and generation events share the same trace. Extract non-assistant messages from conversations for $ai_input.
2026-03-05 19:09:13 -08:00
kumarabhirup
a0853ec83c
feat(telemetry): unified identity for PostHog plugin with key fallback
Plugin reads the same persisted install ID from telemetry.json and falls back to a build-time baked PostHog key when no config-level key is set.
2026-03-05 19:09:05 -08:00
kumarabhirup
135fa3608a
chore: bump version to 2.0.12 and add plugin build infra
Add build:plugin-env script to bake the PostHog key into the plugin at pack time.
2026-03-05 19:08:51 -08:00
kumarabhirup
261f49de9b
feat(telemetry): add trace conversation state and improve tool extraction
Populates $ai_input_state/$ai_output_state on traces for full conversation view in PostHog, and handles toolCall content blocks.
2026-03-05 15:35:57 -08:00
kumarabhirup
6b794dac4e
feat(telemetry): add structure-preserving privacy redaction
Redacts text content and tool arguments while keeping roles, tool names, and message ordering visible in PostHog.
2026-03-05 15:35:51 -08:00
kumarabhirup
8755c509f8
feat: extract real token usage from messages and auto-restart gateway on web runtime updates
Add extractUsageFromMessages and normalizeOutputForPostHog to pull actual
token counts and cost from OpenClaw per-message usage metadata, and convert
Anthropic-style tool call blocks to OpenAI format for PostHog AI observability.

Integrate gateway daemon restart (stop → install → start) into both the
update and start web runtime commands so the gateway stays in sync with
runtime upgrades.
2026-03-05 13:46:51 -08:00
kumarabhirup
460bf6bf6e
fix: resolve PostHog trace linkage, cost display, and tool capture
Switch TraceContextManager from runId to sessionId-based indexing so
tool spans share the same trace_id as their parent generation. Extract
tool names from agent_end messages for the PostHog Tools tab. Guard
against sending $0 cost and null token counts.
2026-03-05 12:58:24 -08:00
kumarabhirup
fdd89b4e6f
feat: add PostHog AI observability, feedback UI, and telemetry privacy mode
Integrate PostHog LLM Analytics via a bundled OpenClaw plugin that captures
$ai_generation, $ai_span, and $ai_trace events with configurable privacy
mode (content redaction on by default). Add like/dislike feedback buttons
to the web chat UI backed by a /api/feedback route. Extend the CLI with
`telemetry privacy on|off` subcommands and fix command delegation so
telemetry subcommands aren't forwarded to OpenClaw. Harden the web runtime
installer to auto-flatten pnpm standalone deps and dereference dangling
symlinks, preventing "Cannot find module 'next'" crashes in dev. Move
plugin installation before onboard in bootstrap so the gateway starts
with plugins.allow already configured.
2026-03-05 12:28:08 -08:00