Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to OpenSignup are documented here. Format follows [Keep a Ch
## [Unreleased]

### Added
- Activity events for Magic Compose's questions (#570), so drafts that stop there can be counted. `magic_compose.asked` (`{ topics, options }`) is written when a first draft comes back with questions instead, and one `magic_compose.answered` for each call that carried the organizer's answers, however it ended, with `{ answered, skipped, picked, added, limits, placeholders, retried, gaveUp }`: which of "what" and "when" were answered or left blank, how many of the AI's options were picked and how many things of their own were added (as the browser reports them), how many were given a number of people, whether Draft with placeholders was pressed, and whether the AI asked again and was retried or given up on. Both are written outside any transaction, with no signup. Payloads hold codes and counts only, never the description, the options or the answers. `docs/telemetry.md` lists them, and the privacy page says the log records them.
- After **Publish and share**, a panel helps the organizer send the link, in place of the "Signup published" banner (#505). It says "Published" and "Now send people the link", and offers **Copy link**; a message to send with it, built from the signup's own data, such as "Fall book fair volunteers / Thu, Nov 12 to Sat, Nov 14 · 21 spots open / Sign up here, no account needed: <link>", which the organizer can change and which stays changed while the page is open; **Copy message** and **Email it**, a `mailto:` link with the title as its subject and the message as its body, less its first line when that is the title; and a QR code to **Download** as a PNG for a flyer or a sign-up table, with the signup's title under the code in up to two lines, shown only where the browser can draw it. The message's dates come from the date field reminders use. Days in a row read as a range, "Thu, Nov 12 to Sat, Nov 14"; two or three days with a gap are named, "Sat, Nov 7 and Sat, Nov 14" or "Sat, Nov 7, Sat, Nov 14 and Sat, Nov 21"; four or more read as a range again. When every dated slot has the same value in the time field reminders pair with that date, the message gives it: "Sat, Nov 21, 11:00 AM · 19 spots open" for one day, "Thu, Nov 12 to Sat, Nov 14 · 11:00 AM · 21 spots open" for several. The days and the time come from the slots people can still take, as the spots do (open, with a spot left or no limit), so a closed or full slot adds no day and hides no time; when none has room they come from the open slots, and when none is open from every slot. It counts spots, not slots, since readers don't know the organizer's word "slot": "21 spots open" before anyone signs up, "18 spots left" after, and no count when an open slot has no limit or no spot is left. A signup with no dates and no limits gets only its title and the link. The description stays out, since a link preview shows it. On a phone that has a share menu, **Share…** comes first and opens it with the message and link, in place of Copy message and Email it. On a phone, **QR code** shows the code large in the sheet, under the Copy link row, and then looks pressed and says **Hide QR code**, since the code pushes the message below the screen; **Save image** is under the code: where the phone can share a file it opens the share menu with the PNG, so it can go to Photos, and the menu says where it went; elsewhere, or if the phone refuses, it downloads and says "Saved". The message box is labelled "A message to send with it" on a phone and a computer, and on a computer grows with the message up to 12 rows. Copy message keeps its width while it says "Copied", so Email it doesn't move. On a computer the panel opens under the header's buttons; on a phone it is a sheet. An open signup's header now has a **Share** button that opens the panel again, headed "Share the link": on a computer in the blue spot right of **Preview**, before ⋯, and on a phone in the bar at the bottom of the screen. Publish now stays on the tab it was pressed on instead of going to Build with `?published=1`, so a reload or a shared address never opens the panel again. Escape or the panel's ✕ closes it and puts focus back on Share, as does a tap outside the sheet on a phone; on a computer a click outside closes it and leaves focus where it landed. Each copy is announced, and a copy the clipboard refuses (a site served over plain HTTP, a denied permission) says "Couldn’t copy. Select the link and copy it." and selects the link. When Publish on this page has published the signup, screen readers hear "Published. Anyone with the link can sign up now."; a signup published elsewhere, such as by an AI assistant, doesn't open the panel or say so. The QR code is drawn in the browser by `lean-qr` 2.7.4 (MIT, no dependencies); it and the rest of the panel load once a draft's or an open signup's page is idle (in Safari, which can't say when, 200 ms after it's shown), so no page's first load carries them and the panel usually opens at its full size, not on a spinner that then grows; a load that fails is tried again when the panel opens, and if that fails too the panel still shows the public link with its copy button, and "Couldn’t load the other ways to share. Reload to try again." Email it opens the organizer's own email app, and Share… the phone's own menu; the QR code goes to no outside service. Copies and shares from the panel are recorded through the link-copy beacon from #525: Copy link and Copy message as `signup.link_copied` with the surfaces `share_panel` and `share_message` (the fallback's chip counts as `share_panel`), and, as a new `signup.link_shared` event (`share_menu`, `email`, `qr_code`), Share… once the menu says it sent, Email it on its click, and the QR code once each time the panel opens, the first time a phone shows it large or it's first downloaded or saved; a refused copy or a share menu closed without sending records nothing. Each row holds only the surface and the signup's status: never the message, and nothing about who the link went to. `POST /api/signups/[id]/link-events` takes `event=shared` and refuses a surface that isn't its event's, `docs/telemetry.md` lists the new event and surfaces, and the privacy page says the log records these. The help page "Create and publish your first signup" says what the panel offers.
- The AI connector can reopen a closed signup, with a new `reopen_signup` tool (#20). It calls the same `reopenSignup` as `POST /api/signups/[id]/reopen`, and its result shows `closesAt` as null when a closing time that had passed was removed. `close_signup` no longer says closing can't be undone, and the help page "Connect an AI assistant" lists reopening among what an assistant can do. The assistant isn't told to ask before reopening, as it is before closing: a reopen only follows the organizer asking for one, and closing undoes it.
- A closed signup can be reopened (#20), through `POST /api/signups/[id]/reopen`. It takes sign-ups again at the same link, and everyone already signed up keeps their spot. Only a closed signup reopens: a draft is published as before, and an archived one stays archived. A closing time that has already passed is removed, since it would go on turning everyone away; one still to come is kept. `GET /api/signups/[id]` lists it in `_links` as `reopen`. A signup that isn't closed is refused with `conflict` on `status` ("cannot reopen a signup that is open"), and one with no slots left with `conflict` on `slots` ("reopen requires at least one slot"). Each reopen writes a `signup.reopened` activity row (`{ from, to }`, plus `clearedClosesAt` with the removed time).
Expand Down
42 changes: 42 additions & 0 deletions docs/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,48 @@ outside any transaction, and a failed write never fails the request.
`reminderFromFieldRef` is present only when the change moved the date field
reminders are timed from (`null` when none is left).

### Magic Compose (AI drafting)

A draft that fails, for whatever reason, is `magic_compose.failed` under
Signup lifecycle above. These two count the questions round.

| event | actor | payload | fired from |
|---|---|---|---|
| `magic_compose.asked` | organizer | `{ topics, options }`: the topics the model asked about (`what`, `when`, `how_many`; always `what`) and how many options it offered for "what" (2 to 4), never the options themselves | `POST /api/signups/magic-compose`, on a first call the model answered with questions instead of a draft, unless the organizer had already left |
| `magic_compose.answered` | organizer | `{ answered, skipped, picked, added, limits, placeholders, retried, gaveUp }`, described below | `POST /api/signups/magic-compose`, once a follow-up (a call carrying the organizer's answers) has ended, however it ended: a draft, a refusal, an error or `asked_again`. One row per follow-up the hourly quota was charged for |

In `magic_compose.answered`:

- `answered` and `skipped` list which of `what` and `when` the organizer
answered or left blank, for the ones they were asked. "How many" has no
blank state (an empty box means no limit), so it is in neither.
- `picked` is how many of the model's options the organizer picked, and
`added` how many things of their own they added. These are the browser's
claim: it sends the two lists apart, and the server can't check which items
came from the options.
- `limits` is how many of those things were given a number of people (`0`
when "how many" wasn't asked).
- `placeholders` is `true` when the organizer pressed Draft with placeholders.
Every answer is then blank; the flag tells it apart from leaving them all
blank by hand.
- `retried` is `true` when the model answered with questions again and the
server asked it once more, more firmly, without charging the quota again:
one more call to the AI.
- `gaveUp` is `true` when that retry asked too, or there was no time left for
one (then `retried` is `false`), and the organizer was told the AI couldn't
draft from their answers. An organizer who had already left was told
nothing, so that's `false`.

Both rows have `signup_id` set to `NULL` and `workspace_id` set to the
organizer's default workspace. They describe no change, so each is written on
its own, outside any transaction, and a failed write never fails the request.
Payloads hold codes and counts only: never the description, the options or the
answers. A first call that drafts writes neither (its `signup.created` has
`templateId: 'magic-compose'`). An organizer who was asked and then left the
questions screen, or went Back to rewrite the description, shows up as a
`magic_compose.asked` with no `magic_compose.answered` after it; there is no
event for leaving.

### Participant funnel

| event | actor | payload | fired from |
Expand Down
22 changes: 11 additions & 11 deletions src/app/(legal)/privacy/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ export default function PrivacyPage() {
An append-only activity log of organizer actions (sign-ins, creating and editing
signups, sending magic links, copying a signup&rsquo;s link, or from the share panel
sending it by your phone&rsquo;s share menu, choosing Email it, or showing or saving
the QR code, a publish or an AI
draft that didn&rsquo;t go through), which of your own pages you open and whether on a phone
or a computer (never the browser&rsquo;s full identifying string), participant
commitments on your signups, and reminder dispatches. For a copy or a share it records
only which button it was and the signup&rsquo;s status: never the message, and nothing
about who the link went to. This exists so an organizer can
audit what happened in their own workspace, so the operator can investigate abuse, and
so the operator can count, in aggregate, where organizers get stuck between starting a
signup and sharing it. The same log records anonymous view telemetry
on the marketing home page and on your public signup pages (see &ldquo;Logs and
rate-limiting&rdquo; below).
the QR code, a publish or an AI draft that didn&rsquo;t go through, and whether AI
drafting asked you questions and how you answered them, in counts only, never what you
or the AI wrote), which of your own pages you open and whether on a phone or a computer
(never the browser&rsquo;s full identifying string), participant commitments on your
signups, and reminder dispatches. For a copy or a share it records only which button
it was and the signup&rsquo;s status: never the message, and nothing about who the
link went to. This exists so an organizer can audit what happened in their own
workspace, so the operator can investigate abuse, and so the operator can count, in
aggregate, where organizers get stuck between starting a signup and sharing it. The
same log records anonymous view telemetry on the marketing home page and on your
public signup pages (see &ldquo;Logs and rate-limiting&rdquo; below).
</li>
<li>
After a sign-in email is sent, the sign-in link&apos;s token (stored as a hash, next to
Expand Down
5 changes: 4 additions & 1 deletion src/app/api/signups/magic-compose/route.failed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ function compose(
);
}

/** The magic_compose.failed rows; the questions round's own rows are tested elsewhere. */
function recordedCodes() {
return vi.mocked(recordActivityBestEffort).mock.calls.map(([, row]) => ({
return vi.mocked(recordActivityBestEffort).mock.calls
.filter(([, row]) => row.eventType === 'magic_compose.failed')
.map(([, row]) => ({
eventType: row.eventType,
workspaceId: row.workspaceId,
actorId: row.actor.actorId,
Expand Down
Loading
Loading