PostHog tracking for agents & agent playground#5036
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Context
Agent activity was either grouped into generic app events or missing when the interaction never reached the API. The API analytics middleware could identify a request from its path, but it could not inspect the committed agent configuration. Shared
@agenta/entity-uicomponents also could not call the OSS app's PostHog helpers without breaking package boundaries.This PR implements the tracking plan. API handlers now enrich middleware-owned events through an explicit
request.stateallowlist, while the OSS app injects a capture function into@agenta/entity-uifor UI-only discovery events. The package remains analytics-provider agnostic and silently no-ops when no host capture function is registered.Trackers added
The properties column lists the event-specific tags added by this PR. Existing middleware context such as project, organization, user, path, method, and status remains unchanged.
app_revision_createdis_agent,is_application,is_snippet,tool_count,mcp_server_count,skill_count,trigger_count,has_triggers,harness,connection_modeapp_archivedis_application,is_snippettool_connection_createdintegrationagent_playground_openedappId,source: "menu"agent_session_created+actionagent_tool_approval_submittedapprovedagent_tool_picker_openedtoolCountagent_trigger_menu_openedagent_mcp_server_add_startedmcpServerCountagent_skill_add_startedskillCountImplementation notes
parameters.agentdata. Missing or unexpected shapes omit a property instead of reporting an incorrect value.request.stateinto PostHog.falseand0values are retained for accurate segmentation.@agenta/entity-uiexposes a small capture registration seam. The OSS playground bridge connects it to the existing PostHog atom, so the package does not import app-layer analytics code.spans_created; this PR does not add a duplicate run event.Tests / notes
git diff --checkpasses for the resolved tracking changes.pnpm --filter @agenta/entity-ui types:checkcurrently stops at the unrelated existing type mismatch inuseModelHarness.tsx:266(string | null | undefinedtostring | null).What to QA
app_revision_createdincludes the agent role and matching feature-composition tags.app_archivedandtool_connection_createdcarry their listed tags.