Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

feat(action-center): show what happened to a competitor's pages on its signals (#1775)

Cihane96c8f6f5d0e
diff --git a/server/src/lib/action-center/task-writer/evidence.js b/server/src/lib/action-center/task-writer/evidence.js
index 7df186d04..a9ecd9c23 100644
--- a/server/src/lib/action-center/task-writer/evidence.js
+++ b/server/src/lib/action-center/task-writer/evidence.js
@@ -7,9 +7,9 @@
*
* Read from the signals' payloads as the evidence steps write them
* (signals/record.js): a lost citation's lost and cited-now pages, a
- * competitor's positions and winning sources, uncited mentions, AI-traffic
- * referrals, and a library finding's targets. The web's Affected tab reads the
- * same fields (web/src/lib/action-center/affected.ts).
+ * competitor's positions, winning sources and page events, uncited mentions,
+ * AI-traffic referrals, and a library finding's targets. The web's Affected
+ * tab reads the same fields (web/src/lib/action-center/affected.ts).
*
* Every entity gets a short ref ("page:1", "prompt:3") the model cites.
*/
@@ -147,7 +147,13 @@ export function buildEvidence(signals, { domains: brandDomains = [] } = {}) {
if (!key) return null;
let entry = competitors.get(key.toLowerCase());
if (!entry) {
- entry = { name: key, prompts: new Set(), sources: new Set(), evidence: 0 };
+ entry = {
+ name: key,
+ prompts: new Set(),
+ sources: new Set(),
+ pageEvents: new Map(),
+ evidence: 0,
+ };
competitors.set(key.toLowerCase(), entry);
}
entry.evidence += 1;
@@ -222,6 +228,19 @@ export function buildEvidence(signals, { domains: brandDomains = [] } = {}) {
entry.answers += num(source.answers) ?? 0;
rival?.sources.add(entry);
}
+ // What happened to its pages lately (learning C3), once per event.
+ for (const event of list(p.pageEvents)) {
+ const url = str(event?.url);
+ const day = str(event?.at).slice(0, 10);
+ if (!rival || !url || !day) continue;
+ if (event.kind !== 'first_cited' && event.kind !== 'changed') continue;
+ rival.pageEvents.set(`${event.kind}|${url}|${day}`, {
+ kind: event.kind,
+ url,
+ day,
+ detail: event.detail ?? {},
+ });
+ }
// Answers that name the brand without citing it.
for (const mention of list(p.mentions)) {
@@ -316,6 +335,36 @@ export function hasTargets(evidence) {
const refsOf = (set) => [...set].map((entry) => entry.ref).filter(Boolean);
+/** Page events shown per competitor, newest first. */
+const PAGE_EVENTS_SHOWN = 5;
+
+/** Check names from a page event's gained or lost list. */
+const checkLabels = (checks) =>
+ list(checks)
+ .map((check) => str(check?.label) || str(check?.key))
+ .filter(Boolean);
+
+/** A competitor's page events as the model reads them: what, when, on which page. */
+function pageEventsForPrompt(events) {
+ return [...events.values()]
+ .sort((a, b) => b.day.localeCompare(a.day))
+ .slice(0, PAGE_EVENTS_SHOWN)
+ .map((event) => {
+ const base = { date: event.day, page: bareUrl(event.url) };
+ if (event.kind === 'first_cited') {
+ return { ...base, event: 'first cited in your tracked answers' };
+ }
+ const gained = checkLabels(event.detail.gained);
+ const lost = checkLabels(event.detail.lost);
+ return {
+ ...base,
+ event: 'page changed',
+ ...(gained.length ? { nowHas: gained } : {}),
+ ...(lost.length ? { noLongerHas: lost } : {}),
+ };
+ });
+}
+
/**
* The evidence as the model reads it: plain objects, refs instead of
* cross-links, platform names instead of slugs.
@@ -364,6 +413,7 @@ export function evidenceForPrompt(evidence) {
name: entry.name,
...(entry.prompts.size ? { aheadOnPrompts: refsOf(entry.prompts) } : {}),
...(entry.sources.size ? { winsWith: refsOf(entry.sources) } : {}),
+ ...(entry.pageEvents.size ? { pageEvents: pageEventsForPrompt(entry.pageEvents) } : {}),
})),
topics: evidence.topics.map((entry) => ({ ref: entry.ref, name: entry.name })),
};
diff --git a/server/src/lib/action-center/task-writer/evidence.test.js b/server/src/lib/action-center/task-writer/evidence.test.js
index ec094b34b..62ba69f92 100644
--- a/server/src/lib/action-center/task-writer/evidence.test.js
+++ b/server/src/lib/action-center/task-writer/evidence.test.js
@@ -57,6 +57,57 @@ describe('buildEvidence', () => {
expect(evidence.domains[0].domain).toBe('g2.com');
});
+ it("gives a competitor's page events once each, newest first, with the checks' names", () => {
+ const changed = {
+ kind: 'changed',
+ at: '2026-10-12T03:00:00Z',
+ url: 'https://www.trade.example/pricing',
+ domain: 'trade.example',
+ detail: {
+ gained: [{ key: 'faq', label: 'FAQ section' }],
+ lost: [{ key: 'dated', label: '' }],
+ },
+ };
+ const firstCited = {
+ kind: 'first_cited',
+ at: '2026-10-03T00:00:00Z',
+ url: 'https://trade.example/guide',
+ domain: 'trade.example',
+ detail: { answers: 2 },
+ };
+ const signal = (id, kind, pageEvents) => ({
+ id,
+ kind,
+ payload: { competitorName: 'Trade Coffee', pageEvents },
+ });
+ const shown = evidenceForPrompt(
+ buildEvidence([
+ signal('s1', 'competitor_momentum', [changed, firstCited]),
+ signal('s2', 'competitor_leads', [changed, { kind: 'renamed', at: 'x', url: 'y' }]),
+ ]),
+ );
+ expect(shown.competitors).toEqual([
+ {
+ ref: 'competitor:1',
+ name: 'Trade Coffee',
+ pageEvents: [
+ {
+ date: '2026-10-12',
+ page: 'trade.example/pricing',
+ event: 'page changed',
+ nowHas: ['FAQ section'],
+ noLongerHas: ['dated'],
+ },
+ {
+ date: '2026-10-03',
+ page: 'trade.example/guide',
+ event: 'first cited in your tracked answers',
+ },
+ ],
+ },
+ ]);
+ });
+
it("reads AI-traffic pages and an audit finding's checks", () => {
const evidence = buildEvidence([
{
diff --git a/server/src/lib/signals/competitor-evidence.js b/server/src/lib/signals/competitor-evidence.js
index f320ec744..28e6741b8 100644
--- a/server/src/lib/signals/competitor-evidence.js
+++ b/server/src/lib/signals/competitor-evidence.js
@@ -7,7 +7,10 @@
* "cited far more often") was recorded with the competitor's name and one
* number. The positions come from the daily rollups through
* ae_competitor_positions (00142); the sources from the newest answers on the
- * prompts where the competitor leads, read back for those prompts only.
+ * prompts where the competitor leads, read back for those prompts only; and
+ * what happened to its pages lately (learning C3, competitor_page_events,
+ * 00376): the days one was first cited in the brand's answers, and the days
+ * one changed, with the Site Audit checks it gained and lost.
*/
import supabaseAdmin from '../../config/supabase.js';
@@ -23,6 +26,14 @@ const POSITIONS_PER_COMPETITOR = 5;
const MAX_SOURCES = 3;
const ANSWERS_READ = 60;
+/**
+ * A competitor's page events read, newest first, and how far back: a page
+ * change shows in AI answers over weeks, so four of them, not only the
+ * window the signal measured.
+ */
+const PAGE_EVENTS_PER_COMPETITOR = 5;
+const PAGE_EVENT_DAYS = 28;
+
function isoDay(now, daysAgo) {
return new Date(now.getTime() - daysAgo * DAY_MS).toISOString().slice(0, 10);
}
@@ -54,6 +65,26 @@ export function winningSources(answers, competitorId, isOwn) {
.map(([domain, count]) => ({ domain, answers: count, answersRead: won.length }));
}
+/**
+ * Page events as a signal keeps them: the table's rows without their ids,
+ * the detail cut to what the drawer and the task writer read.
+ */
+export function pageEventsOf(rows) {
+ return (rows ?? []).map((row) => {
+ const detail = row.detail ?? {};
+ return {
+ kind: row.kind,
+ at: row.at,
+ url: row.url,
+ domain: row.domain,
+ detail:
+ row.kind === 'changed'
+ ? { gained: detail.gained ?? [], lost: detail.lost ?? [] }
+ : { answers: detail.answers ?? null },
+ };
+ });
+}
+
/** One position row, named for the panel. */
export function toPosition(row, texts) {
return {
@@ -67,9 +98,10 @@ export function toPosition(row, texts) {
/**
* The evidence for each competitor, by competitor id: its positions against
- * the brand's on the prompts where it leads most, and the sources behind its
- * wins there. Four reads: the positions, the prompts' texts, the brand's
- * domains, and the newest answers per competitor.
+ * the brand's on the prompts where it leads most, the sources behind its
+ * wins there, and its pages' newest events. Five reads: the positions, the
+ * prompts' texts, the brand's domains, and per competitor the newest
+ * answers and page events.
*/
export async function competitorEvidence(brandId, competitorIds, { now, windowDays }) {
const evidence = new Map();
@@ -101,25 +133,43 @@ export async function competitorEvidence(brandId, competitorIds, { now, windowDa
if (domainsRes.error) throw new Error(domainsRes.error.message);
const isOwn = ownDomainMatcher((domainsRes.data ?? []).map((r) => r.domain));
const since = new Date(now.getTime() - windowDays * DAY_MS).toISOString();
+ const eventsSince = new Date(now.getTime() - PAGE_EVENT_DAYS * DAY_MS).toISOString();
// Only answers that leave the brand out can be the competitor's wins, so
// only those are read, the newest first, for every competitor at once.
await Promise.all(
[...byCompetitor].map(async ([competitorId, list]) => {
- const { data: answers, error: answersErr } = await supabaseAdmin
- .from('prompt_results')
- .select('mention_count, competitor_mentions, citations')
- .eq('brand_id', brandId)
- .neq('platform', 'chatgpt-shopping')
- .eq('mention_count', 0)
- .in('prompt_id', [...new Set(list.map((row) => row.prompt_id))])
- .gte('created_at', since)
- .order('created_at', { ascending: false })
- .limit(ANSWERS_READ);
- if (answersErr) throw new Error(`competitor answers read failed: ${answersErr.message}`);
+ const [answersRes, eventsRes] = await Promise.all([
+ supabaseAdmin
+ .from('prompt_results')
+ .select('mention_count, competitor_mentions, citations')
+ .eq('brand_id', brandId)
+ .neq('platform', 'chatgpt-shopping')
+ .eq('mention_count', 0)
+ .in('prompt_id', [...new Set(list.map((row) => row.prompt_id))])
+ .gte('created_at', since)
+ .order('created_at', { ascending: false })
+ .limit(ANSWERS_READ),
+ supabaseAdmin
+ .from('competitor_page_events')
+ .select('kind, at, url, domain, detail')
+ .eq('brand_id', brandId)
+ .eq('competitor_id', competitorId)
+ .gte('at', eventsSince)
+ .order('at', { ascending: false })
+ .limit(PAGE_EVENTS_PER_COMPETITOR),
+ ]);
+ if (answersRes.error) {
+ throw new Error(`competitor answers read failed: ${answersRes.error.message}`);
+ }
+ if (eventsRes.error) {
+ throw new Error(`competitor page events read failed: ${eventsRes.error.message}`);
+ }
evidence.set(competitorId, {
positions: list.map((row) => toPosition(row, texts)),
- winningSources: winningSources(answers ?? [], competitorId, isOwn),
+ winningSources: winningSources(answersRes.data ?? [], competitorId, isOwn),
+ pageEvents: pageEventsOf(eventsRes.data),
+ pageEventDays: PAGE_EVENT_DAYS,
});
}),
);
diff --git a/server/src/lib/signals/competitor-evidence.test.js b/server/src/lib/signals/competitor-evidence.test.js
index 4c6cec497..9913b21f5 100644
--- a/server/src/lib/signals/competitor-evidence.test.js
+++ b/server/src/lib/signals/competitor-evidence.test.js
@@ -8,16 +8,26 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
let rpcCalls = [];
let tables = {};
+/** Each table's reads, as the calls made on them. */
+let reads = {};
function builder(table) {
+ const calls = [];
+ (reads[table] ??= []).push(calls);
+ const call =
+ (name) =>
+ (...args) => {
+ calls.push([name, ...args]);
+ return chain;
+ };
const chain = {
- select: () => chain,
- eq: () => chain,
- neq: () => chain,
- in: () => chain,
- gte: () => chain,
- order: () => chain,
- limit: () => chain,
+ select: call('select'),
+ eq: call('eq'),
+ neq: call('neq'),
+ in: call('in'),
+ gte: call('gte'),
+ order: call('order'),
+ limit: call('limit'),
then: (resolve) => resolve({ data: tables[table] ?? [], error: null }),
};
return chain;
@@ -33,7 +43,8 @@ vi.mock('../../config/supabase.js', () => ({
},
}));
-const { competitorEvidence, winningSources } = await import('./competitor-evidence.js');
+const { competitorEvidence, pageEventsOf, winningSources } =
+ await import('./competitor-evidence.js');
const { ownDomainMatcher } = await import('../response-parser.js');
const isOwn = ownDomainMatcher(['coffee.example']);
@@ -70,6 +81,7 @@ describe('winningSources', () => {
describe('competitorEvidence', () => {
beforeEach(() => {
rpcCalls = [];
+ reads = {};
tables = {
positions: [
{
@@ -85,6 +97,15 @@ describe('competitorEvidence', () => {
prompts: [{ id: 'p1', text: 'Best AI rank tracker?' }],
brand_domains: [{ domain: 'coffee.example' }],
prompt_results: [answer({ c1: 1 }, 0, ['https://g2.example/a'])],
+ competitor_page_events: [
+ {
+ kind: 'changed',
+ at: '2026-10-12T03:00:00Z',
+ url: 'https://rival.example/pricing',
+ domain: 'rival.example',
+ detail: { similarity: 0.71, gained: [{ key: 'faq', label: 'FAQ section' }], lost: [] },
+ },
+ ],
};
});
@@ -118,11 +139,71 @@ describe('competitorEvidence', () => {
},
],
winningSources: [{ domain: 'g2.example', answers: 1, answersRead: 1 }],
+ pageEvents: [
+ {
+ kind: 'changed',
+ at: '2026-10-12T03:00:00Z',
+ url: 'https://rival.example/pricing',
+ domain: 'rival.example',
+ detail: { gained: [{ key: 'faq', label: 'FAQ section' }], lost: [] },
+ },
+ ],
+ pageEventDays: 28,
});
});
+ it("reads each competitor's five newest page events of the last four weeks", async () => {
+ await competitorEvidence('b1', ['c1'], {
+ now: new Date('2026-10-15T12:00:00Z'),
+ windowDays: 7,
+ });
+ expect(reads.competitor_page_events).toEqual([
+ [
+ ['select', 'kind, at, url, domain, detail'],
+ ['eq', 'brand_id', 'b1'],
+ ['eq', 'competitor_id', 'c1'],
+ ['gte', 'at', '2026-09-17T12:00:00.000Z'],
+ ['order', 'at', { ascending: false }],
+ ['limit', 5],
+ ],
+ ]);
+ });
+
it('reads nothing when no competitor signal needs it', async () => {
expect((await competitorEvidence('b1', [], { now: new Date(), windowDays: 7 })).size).toBe(0);
expect(rpcCalls).toEqual([]);
});
});
+
+describe('pageEventsOf', () => {
+ it("keeps a first citation's answers and a change's checks, nothing else", () => {
+ expect(
+ pageEventsOf([
+ {
+ kind: 'first_cited',
+ at: '2026-10-01T00:00:00Z',
+ url: 'https://rival.example/guide',
+ domain: 'rival.example',
+ detail: { answers: 3 },
+ },
+ { kind: 'changed', at: '2026-10-08T00:00:00Z', url: 'u', domain: 'd', detail: null },
+ ]),
+ ).toEqual([
+ {
+ kind: 'first_cited',
+ at: '2026-10-01T00:00:00Z',
+ url: 'https://rival.example/guide',
+ domain: 'rival.example',
+ detail: { answers: 3 },
+ },
+ {
+ kind: 'changed',
+ at: '2026-10-08T00:00:00Z',
+ url: 'u',
+ domain: 'd',
+ detail: { gained: [], lost: [] },
+ },
+ ]);
+ expect(pageEventsOf(null)).toEqual([]);
+ });
+});
diff --git a/server/src/lib/signals/record-evidence.test.js b/server/src/lib/signals/record-evidence.test.js
index a73a1f165..e51ee9882 100644
--- a/server/src/lib/signals/record-evidence.test.js
+++ b/server/src/lib/signals/record-evidence.test.js
@@ -170,6 +170,16 @@ describe('attachCompetitorEvidence', () => {
{ promptId: 'p1', platform: 'chatgpt-web', competitor: { now: 1 }, you: { now: 3 } },
],
winningSources: [{ domain: 'g2.example', answers: 2, answersRead: 3 }],
+ pageEvents: [
+ {
+ kind: 'changed',
+ at: '2026-10-12T03:00:00Z',
+ url: 'https://rival.example/pricing',
+ domain: 'rival.example',
+ detail: { gained: [{ key: 'faq', label: 'FAQ section' }], lost: [] },
+ },
+ ],
+ pageEventDays: 28,
};
it('finds the competitor in the payload or the key, and writes its evidence', async () => {
diff --git a/server/src/lib/signals/record.js b/server/src/lib/signals/record.js
index 35983f002..f1bb48fc4 100644
--- a/server/src/lib/signals/record.js
+++ b/server/src/lib/signals/record.js
@@ -609,7 +609,8 @@ const EVIDENCE = {
},
};
-// Signals about one competitor, which get its positions and winning sources.
+// Signals about one competitor, which get its positions, winning sources and
+// page events.
const COMPETITOR_KINDS = new Set([
'competitor_leads',
'competitor_momentum',
@@ -619,7 +620,10 @@ const COMPETITOR_KINDS = new Set([
'competitor_citation_gap',
]);
for (const kind of COMPETITOR_KINDS) {
- EVIDENCE[kind] = { marker: 'positions', fields: ['positions', 'winningSources'] };
+ EVIDENCE[kind] = {
+ marker: 'positions',
+ fields: ['positions', 'winningSources', 'pageEvents', 'pageEventDays'],
+ };
}
EVIDENCE.uncited_mentions = { marker: 'mentions', fields: ['mentions'] };
@@ -773,8 +777,9 @@ function competitorOf(candidate) {
/**
* Competitor signals arrive naming the competitor and one number. Before they
* are written they get what the drawer shows (AC-001): per prompt and
- * platform, the competitor's position against the brand's, and the sources
- * behind its wins. Best effort, like the lost-citation evidence.
+ * platform, the competitor's position against the brand's, the sources
+ * behind its wins, and what happened to its pages lately (learning C3).
+ * Best effort, like the lost-citation evidence.
*/
export async function attachCompetitorEvidence(brandId, candidates, now) {
const about = candidates
diff --git a/web/messages/en.json b/web/messages/en.json
index 4a7bae9d1..eec2471e9 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -718,6 +718,10 @@
"untitled": "Untitled prompt",
"sourceAnswers": "cited in {count} of the {of, plural, one {# latest answer} other {# latest answers}} they win"
},
+ "pageEvents": {
+ "none": "No page of theirs was first cited in your answers or changed in the last {days} days.",
+ "timeline": "See their pages over time"
+ },
"cited": {
"position": "#{position}",
"lastCited": "last cited {date}",
@@ -760,6 +764,7 @@
"evidence": "Failed checks",
"competitorPositions": "Positions by prompt",
"winningSources": "Sources behind their wins",
+ "competitorPageEvents": "What happened to their pages",
"mentionDetails": "Mentions by prompt"
},
"scopes": {
diff --git a/web/src/components/action-center/signal-detail-blocks.test.tsx b/web/src/components/action-center/signal-detail-blocks.test.tsx
index b89ad9995..63b7b5a16 100644
--- a/web/src/components/action-center/signal-detail-blocks.test.tsx
+++ b/web/src/components/action-center/signal-detail-blocks.test.tsx
@@ -264,6 +264,27 @@ describe('a competitor signal with its evidence', () => {
},
],
winningSources: [{ domain: 'g2.example', answers: 2, answersRead: 3 }],
+ competitorId: 'c1',
+ pageEventDays: 28,
+ pageEvents: [
+ {
+ kind: 'changed',
+ at: '2026-10-12T03:00:00Z',
+ url: 'https://www.profound.example/pricing/',
+ domain: 'profound.example',
+ detail: {
+ gained: [{ key: 'faq', label: 'FAQ section' }],
+ lost: [{ key: 'dated', label: 'Visible date' }],
+ },
+ },
+ {
+ kind: 'first_cited',
+ at: '2026-10-03T00:00:00Z',
+ url: 'https://profound.example/guide',
+ domain: 'profound.example',
+ detail: { answers: 2 },
+ },
+ ],
},
where: NO_WHERE,
})}
@@ -272,6 +293,15 @@ describe('a competitor signal with its evidence', () => {
const rows = [...container.querySelectorAll('dt')].map(
(dt) => `${dt.textContent}: ${dt.nextElementSibling?.textContent}`,
);
+ expect(rows).toContain(
+ 'What happened to their pages: profound.example/pricing' +
+ 'Oct 12 · Changed · now has FAQ section · no longer has Visible date' +
+ 'profound.example/guideOct 3 · First cited in your tracked answers' +
+ 'See their pages over time',
+ );
+ expect(container.querySelector('a[href*="competitors?competitor=c1"]')?.textContent).toBe(
+ 'See their pages over time',
+ );
expect(rows).toContain(
'Positions by prompt: Best AI rank tracker?ChatGPT · Profound #1 ↑2 · You #3 ↓1' +
'AI rank tracker comparisonPerplexity · Profound #2 new · You — lost',
diff --git a/web/src/components/action-center/signal-detail-blocks.tsx b/web/src/components/action-center/signal-detail-blocks.tsx
index b68b202a1..a6d1ddb92 100644
--- a/web/src/components/action-center/signal-detail-blocks.tsx
+++ b/web/src/components/action-center/signal-detail-blocks.tsx
@@ -108,6 +108,8 @@ function describeEvidence(
function WhereValueView({ value }: { value: WhereValue }) {
const t = useTranslations('actionCenter.signalsPage');
+ // A competitor's page events read as the Competitors page's timeline says them.
+ const tTimeline = useTranslations('competitors.timeline');
const format = useFormatter();
switch (value.type) {
case 'text':
@@ -396,6 +398,56 @@ function WhereValueView({ value }: { value: WhereValue }) {
))}
</ul>
);
+ case 'pageEvents':
+ return (
+ <div className="space-y-1.5">
+ {value.items.length === 0 ? (
+ <p className="text-xs text-muted-foreground">
+ {t('drawer.pageEvents.none', { days: value.days })}
+ </p>
+ ) : (
+ <ul className="space-y-1">
+ {value.items.map((event) => {
+ const checks = (list: { label: string }[]) => list.map((c) => c.label).join(', ');
+ const what =
+ event.kind === 'first_cited'
+ ? [tTimeline('firstCited')]
+ : [
+ tTimeline('changed'),
+ event.gained.length > 0 &&
+ tTimeline('gained', { checks: checks(event.gained) }),
+ event.lost.length > 0 && tTimeline('lost', { checks: checks(event.lost) }),
+ event.gained.length + event.lost.length === 0 && tTimeline('changedWords'),
+ ];
+ return (
+ <li key={`${event.kind}-${event.url}-${event.at}`}>
+ <span className="break-all">
+ {event.url.replace(/^https?:\/\/(www\.)?/i, '').replace(/\/$/, '')}
+ </span>
+ <span className="block text-xs text-muted-foreground">
+ {[
+ format.dateTime(new Date(event.at), { month: 'short', day: 'numeric' }),
+ ...what,
+ ]
+ .filter(Boolean)
+ .join(' · ')}
+ </span>
+ </li>
+ );
+ })}
+ </ul>
+ )}
+ {value.competitorId && (
+ <Link
+ href={`/dashboard/competitors?competitor=${value.competitorId}`}
+ className="inline-flex items-center gap-0.5 text-xs font-medium underline-offset-2 hover:underline"
+ >
+ {t('drawer.pageEvents.timeline')}
+ <ArrowUpRight className="h-3 w-3" />
+ </Link>
+ )}
+ </div>
+ );
case 'citations':
return (
<ul className="space-y-1">
diff --git a/web/src/lib/signals/detail.test.ts b/web/src/lib/signals/detail.test.ts
index 71b953699..13d98504e 100644
--- a/web/src/lib/signals/detail.test.ts
+++ b/web/src/lib/signals/detail.test.ts
@@ -222,6 +222,7 @@ describe('signalWhereFields', () => {
'platforms (n/a)',
'competitorPositions (n/a)',
'winningSources (n/a)',
+ 'competitorPageEvents (n/a)',
]);
});
@@ -476,6 +477,86 @@ describe('a competitor signal with its evidence recorded', () => {
});
});
+ it("lists a competitor's page events newest first, and none as a finding too", () => {
+ const withEvents = {
+ ...recorded,
+ payload: {
+ ...recorded.payload,
+ competitorId: 'c1',
+ pageEventDays: 28,
+ pageEvents: [
+ {
+ kind: 'first_cited',
+ at: '2026-10-03T00:00:00Z',
+ url: 'https://profound.example/guide',
+ domain: 'profound.example',
+ detail: { answers: 2 },
+ },
+ {
+ kind: 'changed',
+ at: '2026-10-12T03:00:00Z',
+ url: 'https://profound.example/pricing',
+ domain: 'profound.example',
+ detail: { gained: [{ key: 'faq', label: 'FAQ section' }], lost: [] },
+ },
+ { kind: 'changed', at: 'not a date', url: 'https://x.example' },
+ ],
+ },
+ };
+ const events = (signal: typeof recorded) =>
+ signalWhereFields(signal).find((f) => f.key === 'competitorPageEvents')?.value;
+ expect(events(withEvents)).toEqual({
+ type: 'pageEvents',
+ competitorId: 'c1',
+ days: 28,
+ items: [
+ {
+ kind: 'changed',
+ at: '2026-10-12T03:00:00Z',
+ url: 'https://profound.example/pricing',
+ domain: 'profound.example',
+ answers: null,
+ gained: [{ key: 'faq', label: 'FAQ section' }],
+ lost: [],
+ },
+ {
+ kind: 'first_cited',
+ at: '2026-10-03T00:00:00Z',
+ url: 'https://profound.example/guide',
+ domain: 'profound.example',
+ answers: 2,
+ gained: [],
+ lost: [],
+ },
+ ],
+ });
+ expect(events({ ...recorded, payload: { ...recorded.payload, pageEvents: [] } })).toMatchObject(
+ { type: 'pageEvents', items: [], days: 28 },
+ );
+ // Recorded before page events were read: not looked at, not none.
+ expect(events(recorded)).toBeNull();
+
+ const { where } = signalDetailForApi(withEvents, []);
+ expect(where.competitor_page_events).toEqual({
+ days: 28,
+ items: [
+ {
+ kind: 'changed',
+ at: '2026-10-12T03:00:00Z',
+ url: 'https://profound.example/pricing',
+ gained: [{ key: 'faq', label: 'FAQ section' }],
+ lost: [],
+ },
+ {
+ kind: 'first_cited',
+ at: '2026-10-03T00:00:00Z',
+ url: 'https://profound.example/guide',
+ answers: 2,
+ },
+ ],
+ });
+ });
+
it('returns the same over the API', () => {
const { where } = signalDetailForApi(recorded, []);
expect(where.competitor_positions).toEqual([
diff --git a/web/src/lib/signals/detail.ts b/web/src/lib/signals/detail.ts
index af179b872..17af6284d 100644
--- a/web/src/lib/signals/detail.ts
+++ b/web/src/lib/signals/detail.ts
@@ -3,6 +3,7 @@ import { locationName, platformName } from './names';
import { getPlatformName } from '@/lib/traffic-platforms';
import { isLibrarySignalKind, type SignalCategory, type SignalKind } from './registry';
import { libraryTargetCount } from './display';
+import { parseTimelineEvents, type CompetitorPageEvent } from '@/lib/competitor-timeline';
/**
* What a signal's detail says, as data (AC-001): where it happened, what
@@ -440,6 +441,8 @@ export type WhereFieldKey =
| 'evidence'
| 'competitorPositions'
| 'winningSources'
+ /** What happened to a competitor's pages lately (learning C3). */
+ | 'competitorPageEvents'
/** Per prompt: platforms, position, sentiment and a quote, for mentions. */
| 'mentionDetails';
@@ -458,6 +461,16 @@ export type WhereValue =
| { type: 'positions'; competitor: string; items: PromptPosition[] }
/** Domains cited in the answers a competitor wins. */
| { type: 'sources'; items: WinningSource[] }
+ /**
+ * A competitor's pages first cited in the brand's answers or changed in
+ * the last `days` (learning C3), newest first; none is a finding too.
+ */
+ | {
+ type: 'pageEvents';
+ competitorId: string | null;
+ items: CompetitorPageEvent[];
+ days: number;
+ }
/** The brand's mentions on each prompt: where, how high, in what tone. */
| { type: 'mentions'; items: PromptMention[] }
/** What each failed audit check found, page by page. */
@@ -754,6 +767,7 @@ const LAYOUT: Record<SignalCategory, WhereFieldKey[]> = {
'platforms',
'competitorPositions',
'winningSources',
+ 'competitorPageEvents',
],
};
@@ -984,6 +998,16 @@ function fieldValue(signal: Signal, key: WhereFieldKey): WhereValue | null {
const sources = winningSourcesOf(p.winningSources);
return sources.length ? { type: 'sources', items: sources } : null;
}
+ case 'competitorPageEvents': {
+ // Read with the positions: none recorded means not looked at, not none.
+ if (!Array.isArray(p.pageEvents)) return null;
+ return {
+ type: 'pageEvents',
+ competitorId: str(p, 'competitorId') || null,
+ items: parseTimelineEvents(p.pageEvents as Record<string, unknown>[]),
+ days: typeof p.pageEventDays === 'number' ? p.pageEventDays : 28,
+ };
+ }
case 'aiReferrals': {
const items = pageReferrals(p.referrals);
return items.length
@@ -1246,6 +1270,18 @@ function apiValue(value: WhereValue): unknown {
answers: source.answers,
answers_read: source.answersRead,
}));
+ case 'pageEvents':
+ return {
+ days: value.days,
+ items: value.items.map((event) => ({
+ kind: event.kind,
+ at: event.at,
+ url: event.url,
+ ...(event.kind === 'first_cited'
+ ? { answers: event.answers }
+ : { gained: event.gained, lost: event.lost }),
+ })),
+ };
case 'citations':
return value.items.map((page) => ({
url: page.url,