Repository navigation
fix(traffic): name only known platforms and pages in the weekly AI Traffic digest - #1229
Conversation
…affic digest The digest's top changes, platform list and "sent the most" sentence named any platform key or page path in the AI traffic data, and the snippet's beacon is public: a caller could put any text in a customer's e-mail. Platforms are now named only when the page can name them (platform-names .json, old keys included). Pages are named only when a source the beacon can't write knows them: ai_traffic_known_pages (00194) checks the week's moved pages against the site's pages (site_pages), Google Analytics and AI answer citations in the last 90 days, active prompts' target URLs, and the home page. Follow-up to ansvisor#1196's review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk This is the last AI Traffic follow-up, #1196's beacon-keys note. The digest now names:
00194 is on the dev DB. One choice to check: a real page that only the snippet has seen isn't named any more. With this, every follow-up from the AI Traffic approvals has a PR: #1222–#1225, #1228 and #1229. |
gkhngyk
left a comment
There was a problem hiding this comment.
The platform and page filters are right: site_pages is never filled from the beacon, and every real platform is in platform-names.json. One change:
The broken-link row still names a beacon-only page (summary.js, topChanges). It prints brokenRows[0].page and brokenRows[0].target unconditionally, and it comes first in Top changes. engine.js reads ai_traffic_broken_links with p_limit: 1 and no visit minimum. A single beacon request for /<any text> with http_status: 404 therefore puts "1 page AI visitors landed on doesn't exist: /, redirect to …" in Monday's e-mail. The target can be beacon text too, since 00186's landed candidates come from ai_traffic_logs. That goes against 00194's own comment that it "never prints a path only the public beacon sent". After #1228 it also names a one-visit 404 that Action Center no longer signals.
Name the page only when it is cited or in knownPages (add the broken page and its target to the ai_traffic_known_pages ask). Otherwise print only the count, and drop the target unless it is known. Apply #1228's "cited or at least 3 visits" rule too, so the e-mail and the signal agree.
Nit: "X sent the most" now skips unnamed keys, but the page's line (traffic-summary-line.ts) still takes platforms[0], so the two can name different platforms.
# Conflicts: # supabase/schema.sql
# Conflicts: # supabase/schema.sql
# Conflicts: # supabase/schema.sql
…or known The weekly e-mail's broken-link line printed the first row's page and redirect unconditionally, and both can be any text the public beacon sent (00186 also picks redirects among the pages it logged). It now reads the broken links as the broken_citation_target signal does (50 rows, cited or brokenLinkMinVisits, ansvisor#1228), asks ai_traffic_known_pages about the top one's page and redirect along with the moved pages, and names the page only when AI answers cite it or it's known, the redirect only when it's known; otherwise the line gives the count. The AI Traffic page's summary line and its Top platform card now pick the platform that sent the most among those they can name, as the e-mail does, so a key only the beacon sent isn't named there either. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk thanks, fixed in 59125cd: Broken-link row
Nit: the page's summary line now picks the top platform among those Checked locally with tagged temp rows on the dev DB (deleted since), rendering the e-mail with
Server 1843 tests, web 1793 tests + build pass; |
# Conflicts: # supabase/schema.sql
schema.sql is rebuilt with build-schema.sh after 00190 and 00196 landed. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks, the broken-link line is right now:
- it counts only what #1228's signal would raise (cited, or
brokenLinkMinVisits); - it names the page only when AI answers cite it or another source knows it, and the redirect only when it is known;
ai_traffic_known_pagesis asked about both;- the summary line and the Top platform card now name the same platform as the e-mail.
I timed 00194 on production in a rolled-back transaction:
- Largest traffic brand: 20 ms for its 14 most visited keys plus a made-up one. 5 are known; the made-up key isn't.
- Largest citation brand: 144 ms.
00194 is now applied to production. I pushed a merge commit with schema.sql rebuilt.
Small, not blocking: count is now the number of qualifying rows among the 50 read. A week with more than 50 broken links worth a line therefore says "50 pages". When 50 rows come back and broken.count is higher, print "50+".
Summary
Follow-up from #1196's approval: "the top changes still name any platform key or page path the public beacon sends; only
unknownis filtered out."The snippet's beacon is public, so a source key or page path in the AI traffic data can be any text a caller sent. The digest printed it into a customer's e-mail.
Platforms
isNamedPlatform(key)accepts only keysplatform-names.jsoncan name. That is the page's own list, old keys such aschat.openai.comincluded, and neverunknown.topPlatforms);Pages
pageCandidates(data)lists the pages whose AI visits moved by 3 or more, keyed as the Pages section keys them.readDigestDataasksai_traffic_known_pages(migration 00194) which of them a source the beacon can't write knows:site_pages: up to 500 from the sitemap, Analytics and citations, written nightly);ga_page_stats,ga_ai_traffic_stats) in the last 90 days;topChangesnames only those pages. Without the answer, it names no page.Broken AI links (review of 2026-10-20)
broken_citation_targetsignal does: 50 rows, kept when AI answers cite the page or it hadbrokenLinkMinVisits(3) visits (fix(action-center): keep one stray 404 visit from raising a broken-link signal, and read only the candidates for a new AI platform #1228). One stray or made-up 404 visit doesn't make the e-mail.ai_traffic_known_pagesask, since 00186 can pick a redirect among pages the beacon logged.The page agrees: the AI Traffic page's summary line ("X sent the most") and its Top platform card pick the top platform among those
isNamedPlatformaccepts (webtraffic-platforms.ts, the same names), so they and the e-mail name the same platform.A real page no trusted source has seen is no longer named. I think that is the right trade for an e-mail that goes to customers.
Deploy: apply 00194, then deploy the server.
Numbering: 00188–00193 are #1210, #1223, #1225, #1226, #1227 and #1228.
schema.sqlis built without them; whichever merges later needsbuild-schema.shagain.Related issue
Follow-up to #1196 (approval of 2026-10-19 21:31 UTC).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
On the dev DB with 00194 applied, for the demo brand (8 site pages):
ai_traffic_known_pages(…, {/menu, /gifts, /cheap-pills, /, /shipping})returns{/, /gifts, /shipping};has_function_privilege('authenticated', …)is false).The demo brand had no AI visits last week, so
scripts/test-traffic-digest.jsrenders an e-mail without changes. Unit tests cover the logic:summary.test.js: a beacon-made platform key andunknownare left out of the platform list and the changes; an unknown page is not named;pageCandidatesasks about the moved pages.engine.test.js: the digest asksai_traffic_known_pagesabout['/cheap-pills', '/menu'], and the e-mail says "/menu got 30 AI visits, none the week before." and never mentionscheap-pills.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): web not touchedyarn typecheckpasses (run fromweb/): web not touchedyarn format:checkpasses (run fromweb/): web not touchedAlso run:
npm run format,npm run lint,npm test(1820 passed);bash supabase/build-schema.sh.🤖 Generated with Claude Code