Tracks: Studio Code chat & instructions events (STU-2120) - #4506
Conversation
📊 Performance Test ResultsComparing 7b2f127 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
bcotrim
left a comment
There was a problem hiding this comment.
LGTM and works as described 👍
Found one issue that I think we should fix before merging, unless I misunderstood the purpose of the is_resumed flag
| ability_name: resolveSkillFromPrompt( prompt ), | ||
| has_images: images.length > 0, | ||
| has_files: files.length > 0, | ||
| is_resumed: Boolean( options.resumeSession || options.resumeSessionId ), |
There was a problem hiding this comment.
It seems this is always true in the ui since we always create the session.
Should we look into existing messages instead of just session id?
Example:
Would have recorded Tracks event: studio_code_session_created {
platform: 'darwin',
arch: 'arm64',
app_version: '1.18.0-beta1',
is_a11n: true,
channel: 'studio-ui',
ui_version: 'v2',
ai_session_id: 'a989d09b-8ef5-4059-aceb-0f835203c16f',
agent_name: 'pi',
client: 'studio-code',
has_site: true
}
Would have bumped stat: studio-code-ui-send=darwin
Would have recorded Tracks event: studio_code_message_sent {
platform: 'darwin',
arch: 'arm64',
app_version: '1.18.0-beta1',
is_a11n: true,
channel: 'studio-ui',
ui_version: 'v2',
ai_session_id: 'a989d09b-8ef5-4059-aceb-0f835203c16f',
agent_name: 'pi',
client: 'studio-code',
provider: 'wpcom',
model: 'claude-sonnet-5',
model_family: 'anthropic',
has_images: false,
has_files: false,
is_resumed: true
}There was a problem hiding this comment.
Good point, this prop would be meaningful only in CLI.
I decided to remove it in 7b2f127, as we can use studio_code_session_created and studio_code_message_sent to identify the first turn in a conversation, calculate the number of messages per session, and distinguish one-shot conversations from continued ones.
Related issues
How AI was used in this PR
Claude Code explored the chat architecture, drafted the plan, and wrote the implementation and tests. The event set was decided interactively rather than taken from the issue as written — see the scope note below. I reviewed the emission points, the privacy boundaries, and the edit-session logic, and iterated to fix multiple issues.
Proposed Changes
Studio Code has had no Tracks coverage, so we could not fully answer how much the assistant is used, with which model, or whether turns actually succeed. Although we have server-side tracking on the AI proxy endpoint, having Tracks in place will allow us to see the entire process.
This adds four events:
studio_code_message_sentstudio_code_turn_completedstudio_code_session_createdstudio_setting_instructions_changeTwo props from the mandated AI vocabulary are not sent:
is_test(dev/E2E/CI runs are suppressed at the source, so it could only ever befalse) andagent_version(pi is pinned per Studio release, soapp_versionalready determines it).No prompts, replies, raw error text, site names, paths, or instructions content are ever sent.
ability_nameis resolved against the skill catalog, so arbitrary slash text a user typed cannot reach an event prop.Testing Instructions
Events log instead of sending in dev (the shared core no-ops the network call), so:
npm startlogsWould have recorded… studio_code_message_sentwith props, thenstudio_code_turn_completedwhen it finishes. (The agent fork normally discards the CLI child's stdout, since its events travel over IPC; a dev run now inherits it so this logging is visible at all.)channel: studio-uiandui_versionare present — this is the fork-env fix. Then runstudio codestandalone and confirmchannel: studio-cli./rank-me-up) and confirmability_name: rank-me-up. Try it in both UIs — desktop expands the slash command before forking, the browser UI does not, and both shapes must resolve.studio_code_session_created. Click "new chat" again without sending anything: the empty draft is reused, so no second event.studio_setting_instructions_change. Type, pause past the autosave, then leave → still exactly one. Open the tab and leave without editing → none.Pre-merge Checklist