Visitor map deployment

The homepage uses ECharts and a Cloudflare Worker with D1. This is anonymous approximate page-view counting, not unique-visitor analytics. No cookies, raw IP addresses, precise coordinates or device identifiers are stored in D1 or GitHub. Points represent 2-degree cells and are published only after at least three views. Country totals are public. Bots and opt-out requests are filtered on a best-effort basis; the public collection endpoint is not authentication, so counts can be inflated. The map uses pinned CDN packages.

One-time Cloudflare setup (free plan)

  1. Sign in to https://dash.cloudflare.com/. In D1, create a database named visitor-map.
  2. Open its SQL console and run the contents of schema.sql.
  3. In Workers & Pages, create a Worker named visitor-map and deploy the contents of index.js as an ES module. Under Bindings, add the D1 database with variable name VISITORS, selecting visitor-map. Keep request logging/observability disabled if not needed.
  4. Open the deployed https://visitor-map.<your-subdomain>.workers.dev/stats. It should return {"version":1,"total":0,"countries":[],"points":[]} on a new database.
  5. Set worker_url in visitor-config.json to the public Worker base URL (no path). Do not put any API key, token or password in GitHub.
  6. Visit the homepage normally (with GPC/DNT off only if you choose). Reload the stats URL to verify a page view was collected.
  7. In GitHub Actions, run Archive visitor statistics manually to verify the daily snapshot. The job only commits when data changes. The homepage reads the raw GitHub snapshot as a fallback, so it does not depend on Pages rebuilding when a bot commits.

The database is cumulative. Do not recreate/reset it without preserving and restoring its contents. Public snapshots omit low-frequency geographic cells and cannot restore every original database row. The old ClustrMaps counts are not available for migration. See Cloudflare’s D1 setup guide and Worker geolocation example.

Upgrade: public guestbook

For an existing visitor-map deployment, do not delete or recreate the D1 database.

  1. If you have not already run the guestbook migration, run guestbook.sql in the existing D1 SQL console. The migration is safe to repeat and leaves visits unchanged. If previously installed, no schema change is necessary.
  2. Replace the existing visitor-map Worker’s entire code with index.js and deploy. Keep the VISITORS binding.
  3. Verify https://visitor-map.lzhzlw.workers.dev/guestbook returns {“mode”:”direct”,”comments”:[]} for an empty guestbook, and /stats still returns visitor data.
  4. Refresh the homepage and post a signed comment. It should appear immediately.

Administer comments

New comments require a self-declared display name and 1–1000 characters of plain text. No registration, identity verification, or advance approval. The public API displays the latest 100 published comments. Old pending comments (if any) remain private until explicitly published or deleted. The previous reaction table, if created, is left intact but unused; reaction API and UI are disabled.

Spam protections are best-effort: a global limit of five submissions per minute, a hidden honeypot field, body limits, and text-only display. No raw IPs are stored by the application. Comments can contain voluntarily entered personal information; do not post sensitive details. Data stays in D1, not the public GitHub visitor archive. Unauthenticated posting may still attract spam.

Sign in to the Cloudflare dashboard, open the visitor-map D1 database, and select Console. Only authorized administrators can manage messages. List all messages (including hidden and older pending entries):

SELECT id, name, message, created_at, approved
FROM guestbook_comments
ORDER BY id DESC;

Delete a comment (replace 123 with the actual ID):

DELETE FROM guestbook_comments WHERE id = 123;

Alternatively, hide a published comment while retaining the row:

UPDATE guestbook_comments SET approved = 0 WHERE id = 123;

Restore a hidden message:

UPDATE guestbook_comments SET approved = 1 WHERE id = 123;

Check the message ID before running any command and replace 123 with the actual ID. Deleting a message cannot be directly undone; hiding it is reversible. Refresh the homepage to see the changes. Do not delete the visits table or the D1 database.

No public deletion route is exposed. Old Giscus discussions are not deleted or imported.