Repository navigation
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
Merged
Conversation
…nk signal, and read only the candidates for a new AI platform broken_citation_target raised a high-impact signal for any missing page an AI visitor landed on, a single visit included, and the beacon is public: a stray or made-up visit was enough. A page AI answers cite still counts from its first visit (the citations come from tracking); any other now needs brokenLinkMinVisits (3). The nightly new-platform check read the brand's whole merged AI traffic history before the week, pages and days included, only to learn which platforms had sent a visit before. It now reads the week, stops when it has no candidate (most nights), and otherwise asks ai_traffic_platforms_seen (00193) about those platforms only: an index probe each on (brand_id, source_platform, created_at). Follow-up to ansvisor#1195's review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
|
@gkhngyk This covers #1195's two remaining notes:
00193 is on the dev DB, and the PR is independent of the others. |
4 of 12 tasks
gkhngyk
previously approved these changes
Oct 20, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
The nightly candidate read and the threshold work, and 00193 is a new invoker function behind the existing RLS.
Notes for a follow-up:
- Visits, not visitors. The threshold counts visits (IP + user agent + platform within 30 minutes), so three beacon requests from one IP with three user agents still raise
broken_citation_target. Counting distinct IPs, for example as avisitorsfield on the broken-link rows, would stop deliberate fakes too. countandrowsdisagree. When every listed row passes,currentValueusesbroken.count, which includes the one-visit pages pastp_limit. Ap_min_visitsparameter would keep the two consistent.- The new index. It is built without
set lock_timeout, unlike 00186. With at most about 11k rows per brand,idx_ai_traffic_logs_brand_visitsmay already be enough, and every beacon insert pays for the extra index.
…noise # Conflicts: # supabase/schema.sql
Contributor
|
@cihan-gyk I'm merging these now: I pushed a merge with main that has |
gkhngyk
approved these changes
Oct 20, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Re-approving after the merge with main (schema.sql rebuilt). 00193 is applied on prod, and the index is valid.
cihan-gyk
added a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Oct 20, 2026
…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]>
7 of 12 tasks
gkhngyk
added a commit
that referenced
this pull request
Oct 20, 2026
…affic digest (#1229) * fix(traffic): name only known platforms and pages in the weekly AI Traffic 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 #1196's review. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(traffic): name a broken link in the digest only when it is cited 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, #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]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
These are the two notes #1195's approval left as follow-ups: the single-404 signal and the nightly full-history read.
1.
broken_citation_targeton a single 404 visitcitationscome from tracking, not the beacon.brokenLinkMinVisits(3, inconfig/action-engine.js).currentValueis the number of pages kept. Otherwise it stays the function's full count, as before.2. The nightly new-platform read
newAiPlatformCandidatesread the brand's whole merged AI traffic history before the week (ai_traffic_merged(p_from null), pages and days included), only to learn which platforms had sent a visit before.weekCandidates);ai_traffic_platforms_seen(migration 00193) about those platforms only.ai_traffic_platforms_seenreturns whether the brand had any AI visit before the week, and which of the platforms sent one.idx_ai_traffic_logs_brand_platform_time (brand_id, source_platform, created_at) where visit_of is null. Analytics rows are daily and few.Deploy: apply 00193, then deploy the server. On a large
ai_traffic_logs, build the index withcreate index concurrentlyfirst, as the migration notes.Numbering: 00188–00192 are #1210, #1223, #1225, #1226 and #1227.
schema.sqlis built without them; whichever merges later needsbuild-schema.shagain.Related issue
Follow-up to #1195 (review of 2026-10-19 17:39 UTC; the approval kept these notes for later).
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 00193 applied, for the demo brand (its first visits per platform run from Sep 20 to Oct 10):
ai_traffic_platforms_seen(…, '2026-10-14', {chatgpt.com, perplexity.ai, claude.ai, bing-ai, gemini.google.com})any_before: true(the same asai_traffic_mergedup to Oct 13)'2026-10-05'and{chatgpt.com, perplexity.ai, gemini.google.com}gemini.google.com(first Oct 3)seen: [],any_before: falseWith seq scans off (the dev table is tiny), the per-platform probe is an Index Only Scan on the new index.
Unit tests cover:
traffic-platforms.test.js:ai-traffic-alerts-family.test.js: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