Repository navigation
Record when Magic Compose asks questions, and how they were answered - #575
Merged
richshaw merged 13 commits intoOct 27, 2026
Conversation
So an operator can see whether the questions help: how often drafting
asks, how often organizers answer instead of leaving, and how often the
AI asks again anyway. Two activity events, written with
recordActivityBestEffort outside any transaction, with no signup and the
organizer's default workspace, as the other organizer telemetry is:
- magic_compose.asked { topics, options }: a first call the model
answered with questions.
- magic_compose.answered { answered, skipped, picked, added, limits,
placeholders, retried, gaveUp }: one row per follow-up the quota was
charged for, written once the request has ended, however it ended. The
route sets the write up once the quota is charged and runs it after
the handler has its response, so a draft, a refusal, asked_again, an AI
error and a thrown error each leave exactly one row, without moving the
route's existing code.
Payloads hold codes and counts only, never the description, the options
or the answers; answeredPayload is a pure function with tests that say
so. The helpers take (db, actor, workspaceId, ...) like recordFailed on
the open funnel-telemetry PR, so the two merge without reshaping.
event_type is plain text, so there is nothing to migrate. The privacy
page's activity-log line now says the log records whether AI drafting
asked questions and how they were answered, in counts only;
docs/telemetry.md lists both events and notes that picked and added are
the browser's claim.
Part of #570.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
retried now means the route made its one retry: a retry skipped for time or because the organizer left records retried: false, gaveUp: true, so counting retried counts extra calls to the AI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
This was referenced Oct 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Second review of this PR: - A first call the organizer had already left (closed the tab while the model worked) still wrote magic_compose.asked, though nobody saw the questions. Those rows read as "asked, then left the questions screen", the very drop-off this event is for. A request that's been aborted now records no asked row. - gaveUp meant "the organizer was told the AI couldn't draft from their answers", but a follow-up that asked again after the organizer had left set it too. It's now false then; running out of time for the retry still sets it. - A comment on the refusal branch said it writes no activity; a follow-up's answered row is still written there. docs/telemetry.md says both. Part of #570. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Brings in #525 and #526 (through the server branch). The two questions-round events sit after #525's in ACTIVITY_EVENTS; the privacy page's activity-log line names both sets; docs/telemetry.md points the Magic Compose section at #525's failed event. The tests of each read only their own rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Through the server branch, which resolved the route's import conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
…he 3-telemetry branch Through the server branch. The privacy page's activity-log line now names both the share panel's events (from main) and the questions round's counts (this branch). CHANGELOG keeps both new lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Through the server branch. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Through the server branch. CHANGELOG keeps this branch's line and main's updated share-panel line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Brings in the first call's retry for questions of the wrong shape, the new asked-again wording and the privacy page's date. The follow-up's retry check is now the shared worthRetrying, with this branch's outcome.gaveUp kept inside it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Through the server branch. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #570, the third of five stacked PRs. It's based on #573 (the questions reply and the follow-up request). Dormant until #577 makes the prompt ask.
The problem
Nothing records how Magic Compose's questions round goes. Without that, nobody can tell whether asking helps, or how often organizers leave at the questions screen.
The fix
Two activity events, both written by
POST /api/signups/magic-compose.magic_compose.asked{ topics, options }magic_compose.answered{ answered, skipped, picked, added, limits, placeholders, retried, gaveUp }asked_again. One row per request the quota was charged for.In
magic_compose.answered:answeredandskippedlist which ofwhatandwhenwere answered or left blank, for the ones asked. "How many" has no blank state, since an empty box means no limit.pickedandaddedcount the model's options picked and the organizer's own items. The browser reports these, and the server can't check them;docs/telemetry.mdsays so.limitsis how many items got a number of people.placeholdersistruewhen the organizer pressed Draft with placeholders with nothing answered. (From Show Magic Compose's questions, and say what a draft needs #576 on, the button sends the answers when there are any, so those requests readfalse.)retriedistruewhen the model asked again and the route made its one retry (one more call to the AI).gaveUpistruewhen the retry asked too, or there was no time for one. An organizer who had already left isn't counted as given up on.How the rows are written:
signup.draft_startedis.answeredwrite runs after the handler has its response. Every ending, including a thrown error, writes exactly one row.event_typeis plain text, so there's no migration.askedwith noansweredafter it. There's no event for leaving.magic_compose.failed(now onmain) still counts failed drafts, withasked_againadded in Let Magic Compose answer with questions, and draft from the answers #573. The two events here count the questions round.docs/telemetry.mdpoints one section at the other.Docs
docs/telemetry.mdhas a new "Magic Compose (AI drafting)" section.main's share-panel events.Tests
telemetry.test.ts: the payload for each kind of answer, and that no text gets into it.route.questions.db.test.tschecks the row written by each path:retried: false, gaveUp: true);gaveUp: false, and noaskedrow);It also checks that a first-call draft, answers rejected before the quota, and a follow-up over the hourly limit write nothing.
pnpm lint && pnpm typecheck && pnpm knip && pnpm test(1897) andpnpm test:db src/app/api/signups/magic-composepass.Tophat
This branch on its own, against a local fake OpenAI-compatible endpoint, through the API. Six requests wrote exactly these rows:
askedfor "Bake sale";answeredeach for:retriedandgaveUp);Reviews
A second review (
/code-review), fixed in f8b6857:askedrow, inflating the "left at the questions screen" count;gaveUp;Left as is:
answeredrow after the handler (it can't throw there:activityActoronly refuses non-organizers, whom the route has already turned away);signup.draft_startedand Record link copies, failed AI drafts and refused publishes #525's events);signupIdonanswered(it would put telemetry into the signup's own activity history).main(through #683) is merged in.Before merging
The separate analytics reader's allow-list needs the two event names and their payload keys:
topics,options,answered,skipped,picked,added,limits,placeholders,retriedandgaveUp.🤖 Generated with Claude Code
https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks