import { Bot } from 'lucide-react'; import { motion } from 'framer-motion'; import { GlassCard } from '../shared/GlassCard'; import { AnalyticsIconInfo } from '../shared/AnalyticsIconInfo'; import { CardIcon } from '../shared/CardIcon'; import { CardEmptyState } from '../shared/CardEmptyState'; import { StatusPill } from '../shared/StatusPill'; import { AI_BRAND_MAP } from '@/lib/brands'; interface CrawlerLog { timestamp: string; agent: string; action: string; ip: string; visits?: number; } interface CrawlerLogsCardProps { logs: CrawlerLog[]; isActive: boolean; totalCrawlerCount?: number; className?: string; delay?: number; } function formatCount(n: number): string { if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(n >= 10_000_000 ? 0 : 1)}M`; if (n >= 10_000) return `${(n / 1000).toFixed(0)}k`; if (n >= 1000) return `${(n / 1000).toFixed(1)}k`; return `${Math.round(n)}`; } const BOT_KEY_MAP: Record = { gptbot: 'gpt', 'chatgpt-user': 'gpt', claudebot: 'claude', 'claude-web': 'claude', googleother: 'google', googlebot: 'google', 'google-extended': 'google', perplexitybot: 'perplexity', bingbot: 'bing', semrushbot: 'semrush', ahrefsbot: 'ahrefs', }; function getBotBrandKey(agent: string) { return BOT_KEY_MAP[agent.toLowerCase()] ?? agent.toLowerCase(); } function getBotIcon(agent: string) { return AI_BRAND_MAP[getBotBrandKey(agent)]?.icon; } function getBotLabel(agent: string) { const key = getBotBrandKey(agent); return AI_BRAND_MAP[key]?.label ?? agent; } export function CrawlerLogsCard({ logs, isActive, totalCrawlerCount = 0, className = '', delay = 0 }: CrawlerLogsCardProps) { return (
Recent requests from known AI and SEO bots hitting your site. Use this to confirm crawlers are reaching the URLs you care about.

} >

Crawler Logs

{totalCrawlerCount > 0 ? ( {formatCount(totalCrawlerCount)} ) : null}
Bot URL Visits
{logs.length === 0 ? ( ) : ( logs.map((log, i) => { const brandKey = getBotBrandKey(log.agent); const iconSrc = getBotIcon(log.agent); return (
{iconSrc ? ( ) : null} {getBotLabel(log.agent)}
{log.action} {formatCount(log.visits ?? 1)}
); }) )}
{isActive ? (
) : null}
); }