Skip to content

Improvement: count where visits come from and how the sign-in prompt is answered, and tag Modwerk's own links - #1725

Merged
repeat98 merged 4 commits into
mainfrom
improvement/visit-sources
Nov 18, 2026
Merged

repeat98 merged 4 commits into
mainfrom
improvement/visit-sources

Conversation

@repeat98

Copy link
Copy Markdown
Owner

From the 18 Nov 2026 demand review (#1724 has the first fixes). Visitors fell 30% and sign-ups 65% since early October. The site can't tell where visitors come from, or where sign-ups stop at the sign-in prompt. This adds both, as identifier-free daily totals.

What changed

  • visit_source, once per page load: one fixed category for where the visit came from.
    • The browser maps utm_source, or else the referring domain, in visit-source.ts.
    • Categories: direct, Google, Bing, DuckDuckGo, Brave, Ecosia, other search engines, ChatGPT, Claude, Perplexity, Gemini, Copilot, Reddit, YouTube, Instagram, Facebook, X, Discord, GitHub, Elektronauts, gearnews, Synthtopia, CDM, MusicRadar, synthanatomy, bonedo, email, other.
    • The address never leaves the browser.
    • Nothing is counted for a reload, back/forward, or a page reached from the site itself.
  • sign_in_prompt: shown, sign in, create account, skipped or closed. It is split between the prompt before a firmware build (gate-…) and the one before a like, follow or reply (other-…).
  • Storage: both go in site_count_daily (migration 0097) through /usage/count. The server refuses any category outside the lists rather than storing it, and keeps 90 days. No visitor digest, no device storage. DNT, GPC and the objection checkbox stop both counts.
  • Admin → Statistics: a new "Where visits come from" section shows sources with their share, and the prompt answers with a sign-up rate.
  • Read budget: /admin/statistics reads the site counts in the same statement as the page totals (UNION ALL), so it stays within its 8-read budget.
  • Privacy page: names both counts, in English and German. The consent version is unchanged, because nothing joins the consented payload.
  • Mail links: news, activity, welcome and beta mail tag every link to the site with utm_source=mail-<kind> when sent, through one helper in server/site-link-tags.ts.
    • Untouched: account mail (verify, reset), API links such as unsubscribe, images, links elsewhere, and links that already carry a tag.
    • The tag names only the kind of mail, nothing about the recipient.
    • The site drops utm_… from the address after counting, so shared or bookmarked links don't credit the mail again.
    • Six mail tests now expect the tagged links.
  • Discord links: TARS's replies tag their site links utm_source=discord-bot, in both senders: the maintenance bot's act step and /modwerk-discord's replyBody.
    • This keeps them apart from people clicking links in Discord, which show as discord, or as direct from the desktop app.
    • Discord's <link> and [label](link) forms are handled.
    • A reply that tagging would push past 2,000 characters goes out as written.
    • The bot scripts import the same helper, server/site-link-tags.ts, which plain Node 24 loads as TypeScript.
  • Push, forum feed and Share links:
    • The push service worker opens notifications as ?utm_source=push#<route>; the server still sends routes only.
    • The forum Atom feed tags its entry links forum-feed. Entry ids stay untagged, so readers keep recognising them.
    • The thread Share button hands out forum-share links, through a new shareLink helper in forum-links.ts.
    • Links inside the forum are same-site and not counted, so they stay untagged.
  • Not included: a new/returning split was considered and dropped. It needs the consented daily identifier and an extra request for the few who opt in.

Testing

  • npm run pr:ready: lint, typecheck, generators, build, the module checks and the site test suite pass, and it claimed migration 0097 on the board. Locally sdk:check fails only because the m68k toolchain (m68k-elf-readelf) is not on this shell's PATH. The branch changes nothing under sdk/; CI decides.
  • New tests:
    • src/community/site-counts.test.ts: 33 classifier cases, including look-alike hosts such as reddit.com.evil.test → other. Browser sends carry no address, credentials or storage; an objection stops them; jsdom tests check the dialog's answers.
    • src/community/site-link-tags.test.ts: Discord markdown and the 2000-character limit, HTML entities, text punctuation, hash routes with their own query, foreign and API links, and every welcome-mail link counting as mail-welcome.
    • src/community/site-counts.server.test.ts: fixed lists only, no visitor digest, 90-day cleanup, administrators only.
  • Related existing suites (usage, statistics, sign-in, mail): 28 files, 393 tests pass; Discord bot, maintenance bot, forum feed and push suites pass, with their link assertions updated to the tagged links. service.test.ts now loads migration 0097 in its fixture.

What the guides lacked

docs/STATISTICS.md had no word on traffic sources. It now has a "Visit sources and the sign-in prompt" section, which includes how to tag a campaign link with utm_source so it gets credited, and lists what Modwerk tags itself: mail, TARS's Discord replies, push notifications, the forum feed and the Share button.

🤖 Generated with Claude Code

repeat98 and others added 4 commits November 18, 2026 09:53
…is answered

Identifier-free daily totals in site_count_daily (migration 0097), through
/usage/count: visit_source (one fixed category from utm_source or the
referring domain, mapped in the browser; never the address; no count for a
reload, back/forward or a page reached from the site) and sign_in_prompt
(shown, sign in, create account, skipped, closed; before a build or before a
member action). The admin statistics show both; the 7-day statistics route
stays within its read budget by reading them with the page totals. The
privacy page names both counts in English and German.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d drop the tag once read

News, activity, welcome and beta mail tag every link to the site as
utm_source=mail-<kind> when sent (server/mail-links.ts); account mail, API
links, images and links elsewhere stay untouched. The site removes utm_ tags
from the address after counting the visit, so shared or bookmarked links do
not credit the mail again. Mail tests now expect the tagged links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…=discord-bot

Both Discord senders (the maintenance bot's act step and /modwerk-discord's
replyBody) tag modwerk.app links through the shared helper, renamed to
server/site-link-tags.ts. A reply the tags would push past 2000 characters
goes out as written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…with utm_source

The push service worker opens notifications tagged push, the forum Atom feed
tags its entry links forum-feed (ids stay untagged), and the thread Share
button hands out forum-share links. Push and feed tests now expect the tagged
links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the enhancement New feature or request label Nov 18, 2026
@repeat98
repeat98 enabled auto-merge (squash) November 18, 2026 09:10
@repeat98
repeat98 merged commit 21ac80a into main Nov 18, 2026
13 checks passed
@repeat98
repeat98 deleted the improvement/visit-sources branch November 25, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant