AI-native design editor. Open-source Figma alternative.
@open-pencil/feedback
The Cloudflare Worker behind feedback.openpencil.dev. It is operated by the OpenPencil team for official builds and is not meant to be self-hosted; forks and self-built apps never call it.
| Route | What it does | What it keeps |
|---|---|---|
POST /ping |
The daily anonymous ping. | One counter per day and build (version, OS, architecture, desktop or web, browser family), and one per day, app, platform, and network (Cloudflare's AS number and operator name). Nothing per install, no addresses. |
POST /ingest |
Opt-in usage stats, forwarded to PostHog EU. Refuses any event or property not in src/contract. |
Nothing. PostHog gets no client address, person profile, or GeoIP. |
POST /reports |
Error and problem reports a person chose to send from the app, forwarded to PostHog EU: errors as $exception events for error tracking, which symbolicates their stacks with the source maps each release uploads; problems as problem_reported. Answers with the report's ID and, when it declared files, a one-hour upload token. |
Nothing. PostHog gets no client address, person profile, or GeoIP. |
PUT /reports/:id/files/:name |
Uploads one file the report declared, at its declared size, with the report's upload token. | The file in the EU R2 bucket openpencil-reports, deleted after 90 days. |
GET /admin/reports/:id/files/:name |
Downloads a report's file, behind Cloudflare Access; the PostHog event links to it. | Nothing. |
GET /admin/ |
The team's metrics dashboard, built from the app's metrics.html (bun run build:metrics writes dist-metrics/, which Wrangler uploads as the Worker's assets), behind Cloudflare Access. |
Nothing. |
GET /admin/api/snapshot?start&end |
The metrics dashboard's data for a range of UTC days, behind Cloudflare Access. | Nothing; it reads pings, snapshots, and the waitlist from D1 (email domains only) and asks PostHog for usage. |
POST /waitlist |
OpenPencil Cloud waitlist sign-ups from the website and the web app's Settings, checked by Turnstile and confirmed by email. | The address and optional note; unconfirmed sign-ups are removed after seven days. |
Two daily cron jobs run besides the routes. Just after midnight UTC the metrics snapshot records the day that ended for the team's metrics dashboard: GitHub stars and forks, running download totals per release and kind of file (installers, macOS updates, and latest.json update checks), repository views, clones, and referrers, and Cloudflare's visits to openpencil.dev and app.openpencil.dev with the website's top pages and countries. It also mirrors the repository's issues and pull requests (author association, opening, closing, and merge times), syncing only what changed since the last run, so open counts per day go back to the repository's start. GitHub keeps traffic for 14 days and Cloudflare's Free plan keeps visits for 31, so these tables are the only lasting history; each run also fetches again the last few days Cloudflare may still have been counting, and fills any missing days it still can. At 03:17 UTC, retention deletes unconfirmed waitlist sign-ups and report files older than 90 days.
@open-pencil/feedback/contract holds the request schemas and the event list, and @open-pencil/feedback/client is a client typed by the Worker's routes (hc<FeedbackAPI>). The app sends through that client and the privacy page renders its tables from the contract, so the documented, sent, and accepted data cannot drift apart.
Development
cp packages/feedback/.dev.vars.example packages/feedback/.dev.vars
bun --filter @open-pencil/feedback dev # wrangler dev with a local D1
bun run test:feedback # typecheck and tests against a local D1
bun --filter @open-pencil/feedback types # after changing wrangler.jsonc
bun run build:metrics # the dashboard page in dist-metrics/, for deploys
The dashboard's components have Storybook stories under App/Metrics/Dashboard.
Apply migrations to the local database with bunx wrangler d1 migrations apply feedback --local from this folder.
Production setup
Done once on the Cloudflare account; .github/workflows/feedback.yml deploys every change to master afterwards.
bunx wrangler d1 create feedback --jurisdiction euand put the database ID inwrangler.jsonc(done for the production database).- Onboard
openpencil.devto Email Service so[email protected]can send. Sending to addresses outside the account needs the Workers Paid plan; send one confirmation to an outside address before announcing the waitlist. - Create a Turnstile widget for
openpencil.devandapp.openpencil.dev, the hostnames inTURNSTILE_HOSTNAMES(its public site key isTURNSTILE_SITE_KEYin the contract; the form gives it thewaitlistaction), thenbunx wrangler secret put TURNSTILE_SECRET. - Create a PostHog EU project with "Discard client IP data" on and data retention at 12 months, as the privacy page promises, then
bunx wrangler secret put POSTHOG_KEYwith its project key. - For the metrics snapshot,
bunx wrangler secret put GITHUB_TOKENwith a fine-grained token for the repository inGITHUB_REPOSITORYthat has read-only Administration access, which the traffic API requires (every token can already read the public repository's releases, issues, and pull requests), andbunx wrangler secret put CLOUDFLARE_ANALYTICS_TOKENwith an account API token that has Zone → Analytics → Read on the zone inSITE_ZONE_ID. - For the dashboard's API, create a Cloudflare Access self-hosted application for
feedback.openpencil.dev/admin/*that allows the team's addresses (add the One-time PIN login method for people without a Cloudflare account), thenbunx wrangler secret put ACCESS_TEAM_DOMAINwithhttps://<team>.cloudflareaccess.comandbunx wrangler secret put ACCESS_AUDwith the application's audience tag. Until both are set,/adminrefuses every request. - Create a PostHog personal API key scoped to the project in
POSTHOG_PROJECT_IDwith only Query: Read, thenbunx wrangler secret put POSTHOG_PERSONAL_KEY. - For reports,
bunx wrangler r2 bucket create openpencil-reports --jurisdiction eu, thenbunx wrangler secret put REPORT_UPLOAD_SECRETwith a long random string (openssl rand -hex 32), which signs upload tokens.