Files
magpie/site/sponsors.js
T
yetone 5c82e6880d site: every sponsor link goes through usemagpie.ai/go, so its clicks are counted per place
The home page's "Sponsored by" cards and the READMEs' Sponsors logo linked
the sponsors directly, so nothing told the owner how many clicks each seat
brought. They now link /go/<id>/home and https://usemagpie.ai/go/<id>/readme.
site/sponsors.js holds where each sends the browser (the sponsor's own ref
link, unchanged: APINEBULA has one per place). The worker counts a GET as
"magpie sponsor go" {id, where, country} in PostHog, beside the in-app
partners' "magpie partner go" (whose /go links were already counted), and a
HEAD goes on uncounted. A partner's keys/site links are tried first; a
sponsor link takes no region.

A test fails if index.html or either README links a sponsor's own URL
directly, or names a /go link sponsors.js doesn't have.

Run: node --test site/worker.test.mjs (20 pass) and site/install.test.mjs
(10 pass). Broke it by hand: README.zh-CN.md back on the direct link turns
the guard red. Deployed (version e4f40cff); curl on usemagpie.ai:
/go/apinebula/readme → 302 apinebula.ai/ref/qmXqFGpr, /go/apinebula/home →
302 apinebula.ai/ref/Gs54HwyB, /go/yylx/home → 302 yylx.io/?ref=magpie,
/go/yylx/readme and /go/apinebula/home/x → 404; / and /zh/ serve the /go
hrefs. Not checked: the events arriving in PostHog (the worker's key can't
read).
2026-10-13 03:29:22 +08:00

17 lines
876 B
JavaScript

// The sponsors' own links on usemagpie.ai's "Sponsored by" and in the
// READMEs' Sponsors row. Neither page links a sponsor directly: each goes
// to usemagpie.ai/go/<id>/<where>, which counts the click and sends the
// browser here (worker.js), so a sponsor's clicks can be told per place.
//
// id a-z, 0-9 and "-"; the same as the sponsor's partners.js id when
// it has an in-app seat too (whose /go links are keys and site)
// home where the home page's card sends the browser
// readme where the READMEs' logo sends it (README.md, README.zh-CN.md)
//
// A link stays here after its seat ends: a copy of the README or the page
// may still point at it.
export const SPONSORS = [
{ id: "yylx", home: "https://yylx.io/?ref=magpie" },
{ id: "apinebula", home: "https://apinebula.ai/ref/Gs54HwyB", readme: "https://apinebula.ai/ref/qmXqFGpr" },
];