feat(billing): drop trace table, make 'analyse my spend' clickable#2331
feat(billing): drop trace table, make 'analyse my spend' clickable#2331pauldambra wants to merge 3 commits into
Conversation
Two improvements to the PostHog Code token spend banner: 1. Drop the Top traces table. Trace IDs are opaque strings (UUIDs or JSON-shaped device blobs) that aren't actionable, and the list is too long to scan. The corresponding API field is being deprecated on the backend in PR #59796 (returns empty there); removing the rendering means we don't show an empty section. 2. Replace the static GitHub link to `exploring-llm-costs` with a button that opens a new task prefilled with a markdown report of the user's spend (summary, by_product, by_tool top 10, by_model) plus a prompt asking the agent to load the skill from the PostHog skill store (`mcp__posthog__exec` -> `llma-skill-get`) and rank reduction advice by impact. The prefill saves the new task an API round-trip and gives the agent the full breakdown in its initial context, so it can answer the 'what should I do to spend less' question immediately without fetching data first. Generated-By: PostHog Code Task-Id: f9d5d152-49c6-46cf-8fde-079105ba2e67
|
…task Paul-reviewer flagged the previous "Ask an agent to analyse this and suggest reductions" copy as reading like it kicks off something inline, when it actually navigates to a new task input with a prefilled prompt. "Open a task to analyse this with an agent" makes the destination explicit. Generated-By: PostHog Code Task-Id: f9d5d152-49c6-46cf-8fde-079105ba2e67
|
Note 🤖 Automated comment by QA Swarm — not written by a human Single-reviewer pass: paul-reviewer (focused review chosen for this small frontend-only change). Verdict: 💬 APPROVE WITH NITS → 1 fix pushed, rest deferredThe diff is doing the right things — drop the unactionable trace table, swap the static GitHub link for a "send the spend data into a fresh agent task" affordance that mirrors the inbox `ReportDetailPane` pattern. No blockers. Fixed in `a457d50e`
Deferred (non-blocking)
Reviewer summary
Automated by QA Swarm — not a human review |
Greptile flagged that tool/product/model names containing `|` would split markdown-table cells mid-row, causing the receiving agent to misread the row boundaries. For example a tool name like `bash | grep` would silently extend the row by an extra column. Add a small `escapeTableCell` helper and apply it to every cell value that comes from the data (product, tool, model names). Numbers and $-prefixed formatted strings are pipe-free. Generated-By: PostHog Code Task-Id: f9d5d152-49c6-46cf-8fde-079105ba2e67
Problem
Two issues with the PostHog Code token spend banner:
{"device":"...","session":"..."}), the list is long, and there's no actionable next step from seeing it. Users get more information than they can use.Changes
TraceTablecomponent and the trace-related branch ingenerateSuggestions. Backend PR #59796 deprecates thetop_tracesAPI field (returns empty); removing the rendering here means we don't show an empty section.exploring-llm-costsGitHub link with aSparkle-iconed button: "Ask an agent to analyse this and suggest reductions". Clicking it callsnavigateToTaskInput({ initialPrompt })with a markdown report of the user's spend (summary, by_product, by_tool top 10, by_model) plus a prompt instructing the new agent to load the skill from the PostHog skill store viamcp__posthog__exec→llma-skill-getand rank reduction advice by impact.The prefill saves the new task an API round-trip and gives the agent the full breakdown in its initial context, so it can answer "what should I do to spend less" immediately without fetching data first.
How did you test this?
I'm an agent — Claude Code via PostHog Code.
pnpm exec biome check apps/code/src/renderer/features/billing/components/TokenSpendAnalysisBanner.tsx— clean.pnpm -F @posthog/code exec tsc --noEmit— only the existing unrelatedauth/service.test.tserrors, none in the modified file.Publish to changelog?
no
Created with PostHog Code