From 5c82e6880d6a060f6acd46595b0ccd7aa351af06 Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 13 Oct 2026 03:29:22 +0800 Subject: [PATCH] site: every sponsor link goes through usemagpie.ai/go, so its clicks are counted per place MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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//home and https://usemagpie.ai/go//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). --- README.md | 2 +- README.zh-CN.md | 2 +- site/public/index.html | 4 ++-- site/sponsors.js | 16 ++++++++++++++ site/worker.js | 20 ++++++++++++++--- site/worker.test.mjs | 50 +++++++++++++++++++++++++++++++++++++++++- 6 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 site/sponsors.js diff --git a/README.md b/README.md index cde4c1bba..9b1e04a41 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ and when a quota runs out, it quietly moves on to the next account. ![macOS](https://img.shields.io/badge/macOS-000000?logo=apple&logoColor=white) ![Windows](https://img.shields.io/badge/Windows-0078D4?logo=windows&logoColor=white) ![Linux](https://img.shields.io/badge/Linux-FCC624?logo=linux&logoColor=black) ![Docker](https://img.shields.io/badge/Docker-2496ED?logo=docker&logoColor=white) ![Termux](https://img.shields.io/badge/Termux-000000?logo=android&logoColor=white) Sponsors
-APINEBULA +APINEBULA **[Download](https://usemagpie.ai)**  ·  **[Docs](https://usemagpie.ai/docs/start)**  ·  **[Reference](docs/reference.md)**  ·  **[Plugins](https://github.com/magpie-community/plugins)**  ·  **[Discord](https://discord.gg/vGSnD3ZKQF)**  ·  **English** · [简体中文](README.zh-CN.md) diff --git a/README.zh-CN.md b/README.zh-CN.md index c4bf1e82f..4a4f0fedf 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -14,7 +14,7 @@ ![macOS](https://img.shields.io/badge/macOS-000000?logo=apple&logoColor=white) ![Windows](https://img.shields.io/badge/Windows-0078D4?logo=windows&logoColor=white) ![Linux](https://img.shields.io/badge/Linux-FCC624?logo=linux&logoColor=black) ![Docker](https://img.shields.io/badge/Docker-2496ED?logo=docker&logoColor=white) ![Termux](https://img.shields.io/badge/Termux-000000?logo=android&logoColor=white) 赞助商
-APINEBULA +APINEBULA **[下载](https://usemagpie.ai/zh/)**  ·  **[文档](https://usemagpie.ai/docs/zh/start)**  ·  **[完整参考(英文)](docs/reference.md)**  ·  **[插件](https://github.com/magpie-community/plugins)**  ·  **[Discord](https://discord.gg/vGSnD3ZKQF)**  ·  [English](README.md) · **简体中文** diff --git a/site/public/index.html b/site/public/index.html index 80a76b6db..df0fe7208 100644 --- a/site/public/index.html +++ b/site/public/index.html @@ -441,13 +441,13 @@ footer a:hover { color: var(--ink); }