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.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
fix(pulse): show the visibility-slipping warning in the email and name a weekly pulse Weekly (#1215)
Gökhan Geyikf74d91f038d7
diff --git a/docs/guides/daily-pulse.mdx b/docs/guides/daily-pulse.mdxindex ca29961cc..05156939f 100644--- a/docs/guides/daily-pulse.mdx+++ b/docs/guides/daily-pulse.mdx@@ -69,7 +69,7 @@ If a scheduled run finished but its pulse was lost (for example, the server restFor **Daily** and **Only when notable**, the period is the latest completed tracking run (at most 24 hours), compared with the run before it. For **Weekly**, it is the last 7 days compared with the 7 days before.-The email subject carries the score and the weekly trend, for example: `Acme Daily Pulse — visibility 42.5 (+1.2 pts this week)`.+The email subject carries the score and the weekly trend, for example: `Acme Daily Pulse — visibility 42.5 (+1.2 pts this week)`. On **Weekly**, the subject and heading say **Weekly Pulse**.### Highlightsdiff --git a/server/src/lib/pulse/email.js b/server/src/lib/pulse/email.jsindex 8e6b2a661..37adbb89b 100644--- a/server/src/lib/pulse/email.js+++ b/server/src/lib/pulse/email.js@@ -85,6 +85,10 @@ function warningLine(w) {return listItem(`Visibility score dropped sharply: <strong>${escapeHtml(String(w.from))} → ${escapeHtml(String(w.to))}</strong> week-over-week`,);+ case 'visibility_slipping':+ return listItem(+ `Visibility is slipping: <strong>${escapeHtml(String(w.from))} → ${escapeHtml(String(w.to))}</strong> week-over-week`,+ );case 'competitor_surge':return listItem(`<strong>${escapeHtml(w.competitorName)}</strong> surged from ${escapeHtml(String(w.from))} to ${escapeHtml(String(w.to))} week-over-week`,@@ -108,9 +112,11 @@ function warningLine(w) {export function renderPulseEmail({ brandName, metrics, insightsUrl, settingsUrl }) {const { kpis, highlights, warnings, degradedPlatforms, windowDays } = metrics;const windowLabel = windowDays === 7 ? 'last 7 days' : 'last 24 hours';+ // The weekly frequency reads a 7-day window; daily and notable read a day.+ const title = windowDays === 7 ? 'Weekly Pulse' : 'Daily Pulse';const trend = kpis.weekTrend;- const subject = `${brandName} Daily Pulse — visibility ${kpis.visibilityRate} (${signed(trend)} pts this week)`;+ const subject = `${brandName} ${title} — visibility ${kpis.visibilityRate} (${signed(trend)} pts this week)`;const highlightItems = highlights.map(highlightLine).filter(Boolean).join('');const warningItems = warnings.map(warningLine).filter(Boolean).join('');@@ -122,7 +128,7 @@ export function renderPulseEmail({ brandName, metrics, insightsUrl, settingsUrl: '';const html = `<div style="font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;max-width:600px;margin:0 auto;padding:24px;">- <h1 style="font-size:18px;color:#111827;margin:0 0 4px 0;">Daily Pulse — ${escapeHtml(brandName)}</h1>+ <h1 style="font-size:18px;color:#111827;margin:0 0 4px 0;">${title} — ${escapeHtml(brandName)}</h1><p style="font-size:13px;color:#6b7280;margin:0 0 20px 0;">How your brand showed up in AI answers over the ${windowLabel}.</p><table role="presentation" cellspacing="8" style="border-collapse:separate;width:100%;margin-bottom:8px;">diff --git a/server/src/lib/pulse/email.test.js b/server/src/lib/pulse/email.test.jsindex eada2d1a8..f672e715e 100644--- a/server/src/lib/pulse/email.test.js+++ b/server/src/lib/pulse/email.test.js@@ -70,6 +70,41 @@ describe('renderPulseEmail', () => {expect(degraded.html).toContain('Data collection was degraded on ChatGPT, Perplexity today');});+ it('renders a visibility slip under Needs attention', () => {+ const { html } = renderPulseEmail({+ brandName: 'Acme',+ metrics: {+ ...metrics,+ warnings: [+ { type: 'visibility_slipping', key: 'visibility_slipping', from: 42, to: 35, drop: 7 },+ ],+ },+ insightsUrl: 'https://example.com/insights',+ settingsUrl: 'https://example.com/settings',+ });++ expect(html).toContain('⚠ Needs attention');+ expect(html).toContain('Visibility is slipping: <strong>42 → 35</strong> week-over-week');+ });++ it('names the pulse after its window in the subject and heading', () => {+ const render = (windowDays) =>+ renderPulseEmail({+ brandName: 'Acme',+ metrics: { ...metrics, windowDays },+ insightsUrl: 'https://example.com/insights',+ settingsUrl: 'https://example.com/settings',+ });++ const weekly = render(7);+ expect(weekly.subject).toBe('Acme Weekly Pulse — visibility 42 (+1.2 pts this week)');+ expect(weekly.html).toContain('Weekly Pulse — Acme</h1>');++ const daily = render(1);+ expect(daily.subject).toBe('Acme Daily Pulse — visibility 42 (+1.2 pts this week)');+ expect(daily.html).toContain('Daily Pulse — Acme</h1>');+ });+it('uses the rounded change when selecting the KPI trend arrow', () => {const { html } = renderPulseEmail({brandName: 'Acme',