Skip to content

Commit 6cab88a

Browse files
committed
docs: document /subscribe endpoint, DownloadGate, wrangler config gotcha
- extension/CLAUDE.md: list /subscribe in worker routes, document Resend integration boundaries (no PII bridging), note worker secrets, and warn about wrangler upward-config-walk picking up the wrong worker - root CLAUDE.md: mention <DownloadGate /> and the desktop-vs-mobile signup behavior in the extension/website description
1 parent 5c27f0f commit 6cab88a

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ playhtml is a collaborative, interactive HTML library that allows elements to be
1010
- **packages/react**: React wrapper components for playhtml functionality
1111
- **packages/common**: Shared TypeScript types and interfaces
1212
- **extension/**: Browser extension ("we were online") for collecting and visualizing browsing traces. See `extension/CLAUDE.md` for detailed architecture.
13-
- **extension/website/**: `wewere.online` site — marketing pages (home, privacy) plus visualization experiments (`portrait/`, `rabbithole/`, `conversations/`, `keypresses/`, `sounds/`, `components-preview/`). Shared visualization code lives in `extension/website/shared/` and is reached via the `@movement` path alias.
13+
- **extension/website/**: `wewere.online` site — marketing pages (home, privacy) plus visualization experiments (`portrait/`, `rabbithole/`, `conversations/`, `keypresses/`, `sounds/`, `components-preview/`). Shared visualization code lives in `extension/website/shared/` and is reached via the `@movement` path alias. Homepage uses `<DownloadGate />` (`src/components/DownloadGate.tsx`) which shows install buttons directly on desktop and an email-signup form on mobile (mobile detected via `(hover: none) and (pointer: coarse)` media query). The form POSTs to the worker's `/subscribe` endpoint which adds the contact to Resend and sends a welcome email with install links.
1414
- **extension/worker/**: Cloudflare Worker backend for event ingestion (Supabase persistence)
1515
- **partykit/**: Real-time sync server using PartyKit and Yjs for collaborative state
1616
- **website/**: Demo site for playhtml capabilities and the library's home page (`playhtml.fun`). Test pages go here.

extension/CLAUDE.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,18 @@ Shared between extension and Cloudflare Worker:
117117

118118
### Worker Backend (`worker/`)
119119

120-
Cloudflare Worker + Supabase PostgreSQL:
120+
Cloudflare Worker + Supabase PostgreSQL + Resend:
121121

122122
- `POST /events`: Public event ingestion (rate limited)
123123
- `GET /events/recent`: Public (for artwork visualizations)
124124
- `GET /events/stats`, `POST /events/export`: Admin key required
125+
- `POST /subscribe`: Public mailing-list signup (rate limited 5/min/IP). Adds the contact to Resend and sends a one-time welcome email on first signup; idempotent on repeat. Used by both the website (`<DownloadGate />` on mobile) and the extension setup form. Body: `{ email, source: 'website' | 'extension-setup' }`.
126+
127+
**Resend integration:** the worker uses Resend Audiences/Contacts as the mailing-list store and welcome-email sender. Email addresses are NOT linked to browsing data — the `/subscribe` endpoint accepts only `email + source`, never participant or session IDs. The welcome template lives at `worker/src/emails/WelcomeEmail.tsx` (built with `react-email`).
128+
129+
**Worker secrets:** `SUPABASE_URL`, `SUPABASE_SECRET_KEY`, `ADMIN_KEY`, `RESEND_API_KEY` (required); `RESEND_SEGMENT_ID` (optional, tags new contacts).
130+
131+
**Wrangler config gotcha:** `bun run` scripts in `extension/worker/package.json` (`dev`, `deploy`, `tail`, `secret`, `secrets`) all pin `--config wrangler.toml`. Do NOT invoke bare `wrangler ...` from `extension/worker/` — wrangler walks up the filesystem and finds the partykit config in `partykit/wrangler.jsonc`, applying secrets/deploys to the wrong worker. Use the `bun run` wrappers.
125132

126133
## Configuration
127134

0 commit comments

Comments
 (0)