Create a bot rendering watchdog: hydrate error captures, blocked resource alerts, and…
- User
Create a bot rendering watchdog: hydrate error captures, blocked resource alerts, and fallbacks.
Assistant
Create a bot rendering watchdog: hydrate error captures, blocked resource alerts, and fallbacks.
The user wants me to create a bot rendering watchdog system that monitors and reports:
This is a monitoring/debugging dashboard interface. Let me create a visually striking, technical-looking dashboard that feels like a proper developer tool.
Design direction:
Features to include:
Let me build this with:
A technical monitoring dashboard for capturing hydration errors, blocked resources, and fallback states with a developer-focused aesthetic.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rendering Watchdog | Bot Monitor</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0b0f;
--bg-elevated: #12141a;
--card: #181a22;
--border: #262a36;
--fg: #e4e6ed;
--muted: #6b7280;
--accent-error: #ef4444;
--accent-warn: #f59e0b;
--accent-info: #06b6d4;
--accent-success: #10b981;
--glow-error: rgba(239, 68, 68, 0.15);
--glow-warn: rgba(245, 158, 11, 0.15);
--glow-info: rgba(6, 182, 212, 0.15);
}
* {
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
}
.font-mono {
font-family: 'IBM Plex Mono', monospace;
}
.bg-grid {
background-image:
linear-gradient(rgba(38, 42, 54, 0.4) 1px, transparent 1px),
linear-gradient(90deg, rgba(38, 42, 54, 0.4) 1px, transparent 1px);
background-size: 32px 32px;
}
.glow-error { box-shadow: 0 0 0 1px var(--accent-error), 0 0 20px var(--glow-error); }
.glow-warn { box-shadow: 0 0 0 1px var(--accent-warn), 0 0 20px var(--glow-warn); }
.glow-info { box-shadow: 0 0 0 1px var(--accent-info), 0 0 20px var(--glow-info); }
.glow-success { box-shadow: 0 0 0 1px var(--accent-success), 0 0 12px rgba(16, 185, 129, 0.15); }
@keyframes slideIn {
from { opacity: 0; transform: translateY(-12px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
}
.animate-slide-in {
animation: slideIn 0.3s ease-out forwards;
}
.animate-pulse-slow {
animation: pulse 2s ease-in-out infinite;
}
.animate-blink {
animation: blink 1s step-end infinite;
}
.log-entry {
animation: slideIn 0.25s ease-out;
}
.scrollbar-thin::-webkit-scrollbar {
width: 6px;
}
.scrollbar-thin::-webkit-scrollbar-track {
background: var(--bg-elevated);
}
.scrollbar-thin::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 3px;
}
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
background: var(--muted);
}
@media (prefers-reduced-motion: reduce) {
.animate-slide-in,
.animate-pulse-slow,
.animate-blink,
.log-entry {
animation: none;
}
}
.filter-btn.active {
background: var(--card);
border-color: var(--border);
}
.filter-btn:focus-visible {
outline: 2px solid var(--accent-info);
outline-offset: 2px;
}
.expand-btn:focus-visible {
outline: 2px solid var(--accent-info);
outline-offset: 2px;
}
</style>
</head>
<body class="bg-grid">
<!-- Header -->
<header class="sticky top-0 z-50 border-b backdrop-blur-xl" style="background: rgba(10, 11, 15, 0.85); border-color: var(--border);">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-lg flex items-center justify-center" style="background: var(--card); border: 1px solid var(--border);">
<svg class="w-5 h-5" style="color: var(--accent-error);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>
</div>
<div>
<h1 class="text-lg font-semibold tracking-tight" style="color: var(--fg);">Rendering Watchdog</h1>
<p class="text-xs font-mono" style="color: var(--muted);">v2.1.0 · monitoring active</p>
</div>
</div>
<div class="flex items-center gap-4">
<div class="hidden sm:flex items-center gap-2 px-3 py-1.5 rounded-full font-mono text-xs" style="background: var(--card); border: 1px solid var(--border);">
<span class="w-2 h-2 rounded-full animate-pulse-slow" style="background: var(--accent-success);"></span>
<span style="color: var(--muted);">Connected</span>
</div>
<button id="clearBtn" class="px-4 py-2 rounded-lg text-sm font-medium transition-all hover:scale-105 focus-visible:outline-none" style="background: var(--card); border: 1px solid var(--border); color: var(--fg);" aria-label="Clear all logs">
Clear Logs
</button>
</div>
</div>
</div>
</header>
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
<!-- Stats Grid -->
<div class="grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
<!-- Hydration Errors -->
<div class="p-4 rounded-xl glow-error" style="background: var(--card);">
<div class="flex items-start justify-between">
<div>
<p class="text-xs font-mono uppercase tracking-wider" style="color: var(--muted);">Hydration Errors</p>
<p id="hydrationCount" class="text-3xl font-bold mt-1" style="color: var(--accent-error);">0</p>
</div>
<div class="w-10 h-10 rounded-lg flex items-center justify-center" style="background: rgba(239, 68, 68, 0.1);">
<svg class="w-5 h-5" style="color: var(--accent-error);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
</svg>
</div>
</div>
<p class="text-xs mt-2 font-mono" style="color: var(--muted);">SSR/CSR mismatch detected</p>
</div>
<!-- Blocked Resources -->
<div class="p-4 rounded-xl glow-warn" style="background: var(--card);">
<div class="flex items-start justify-between">
<div>
<p class="text-xs font-mono uppercase tracking-wider" style="color: var(--muted);">Blocked Resources</p>
<p id="blockedCount" class="text-3xl font-bold mt-1" style="color: var(--accent-warn);">0</p>
</div>
<div class="w-10 h-10 rounded-lg flex items-center justify-center" style="background: rgba(245, 158, 11, 0.1);">
<svg class="w-5 h-5" style="color: var(--accent-warn);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
</svg>
</div>
</div>
<p class="text-xs mt-2 font-mono" style="color: var(--muted);">CORS, CSP, or network blocks</p>
</div>
<!-- Fallbacks Triggered -->
<div class="p-4 rounded-xl glow-info" style="background: var(--card);">
<div class="flex items-start justify-between">
<div>
<p class="text-xs font-mono uppercase tracking-wider" style="color: var(--muted);">Fallbacks</p>
<p id="fallbackCount" class="text-3xl font-bold mt-1" style="color: var(--accent-info);">0</p>
</div>
<div class="w-10 h-10 rounded-lg flex items-center justify-center" style="background: rgba(6, 182, 212, 0.1);">
<svg class="w-5 h-5" style="color: var(--accent-info);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
</div>
</div>
<p class="text-xs mt-2 font-mono" style="color: var(--muted);">Graceful degradation active</p>
</div>
<!-- Uptime -->
<div class="p-4 rounded-xl glow-success" style="background: var(--card);">
<div class="flex items-start justify-between">
<div>
<p class="text-xs font-mono uppercase tracking-wider" style="color: var(--muted);">Monitor Uptime</p>
<p id="uptime" class="text-3xl font-bold mt-1" style="color: var(--accent-success);">0s</p>
</div>
<div class="w-10 h-10 rounded-lg flex items-center justify-center" style="background: rgba(16, 185, 129, 0.1);">
<svg class="w-5 h-5" style="color: var(--accent-success);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
</div>
</div>
<p class="text-xs mt-2 font-mono" style="color: var(--muted);">Session duration</p>
</div>
</div>
<!-- Filter Bar -->
<div class="flex flex-wrap items-center gap-2 mb-4">
<span class="text-xs font-mono uppercase tracking-wider mr-2" style="color: var(--muted);">Filter:</span>
<button class="filter-btn active px-3 py-1.5 rounded-lg text-xs font-mono transition-all" data-filter="all" style="border: 1px solid transparent; color: var(--fg);">
All
</button>
<button class="filter-btn px-3 py-1.5 rounded-lg text-xs font-mono transition-all" data-filter="hydration" style="border: 1px solid transparent; color: var(--accent-error);">
Hydration
</button>
<button class="filter-btn px-3 py-1.5 rounded-lg text-xs font-mono transition-all" data-filter="blocked" style="border: 1px solid transparent; color: var(--accent-warn);">
Blocked
</button>
<button class="filter-btn px-3 py-1.5 rounded-lg text-xs font-mono transition-all" data-filter="fallback" style="border: 1px solid transparent; color: var(--accent-info);">
Fallback
</button>
</div>
<!-- Log Console -->
<div class="rounded-xl overflow-hidden" style="background: var(--bg-elevated); border: 1px solid var(--border);">
<!-- Console Header -->
<div class="flex items-center justify-between px-4 py-3" style="background: var(--card); border-bottom: 1px solid var(--border);">
<div class="flex items-center gap-3">
<div class="flex gap-1.5">
<span class="w-3 h-3 rounded-full" style="background: var(--accent-error);"></span>
<span class="w-3 h-3 rounded-full" style="background: var(--accent-warn);"></span>
<span class="w-3 h-3 rounded-full" style="background: var(--accent-success);"></span>
</div>
<span class="text-xs font-mono" style="color: var(--muted);">console.watchdog</span>
</div>
<div class="flex items-center gap-2">
<span class="text-xs font-mono animate-blink" style="color: var(--accent-success);">recording</span>
</div>
</div>
<!-- Log Entries -->
<div id="logContainer" class="h-96 overflow-y-auto scrollbar-thin p-4 space-y-2" role="log" aria-live="polite" aria-label="Error log entries">
<div class="text-center py-12" style="color: var(--muted);">
<svg class="w-12 h-12 mx-auto mb-3 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
</svg>
<p class="font-mono text-sm">Waiting for events...</p>
<p class="text-xs mt-1">Errors will appear here in real-time</p>
</div>
</div>
</div>
<!-- Expandable Details Panel -->
<div id="detailsPanel" class="mt-4 rounded-xl overflow-hidden hidden" style="background: var(--card); border: 1px solid var(--border);">
<div class="px-4 py-3 flex items-center justify-between" style="background: var(--bg-elevated); border-bottom: 1px solid var(--border);">
<span class="text-sm font-medium">Error Details</span>
<button id="closeDetails" class="p-1 rounded hover:bg-white/5 transition-colors" aria-label="Close details panel">
<svg class="w-5 h-5" style="color: var(--muted);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
<div id="detailsContent" class="p-4 font-mono text-sm" style="color: var(--muted);">
</div>
</div>
<!-- Simulate Actions -->
<div class="mt-6 p-4 rounded-xl" style="background: var(--card); border: 1px solid var(--border);">
<p class="text-xs font-mono uppercase tracking-wider mb-3" style="color: var(--muted);">Simulate Events</p>
<div class="flex flex-wrap gap-2">
<button id="simHydration" class="px-4 py-2 rounded-lg text-sm font-medium transition-all hover:scale-105" style="background: rgba(239, 68, 68, 0.1); border: 1px solid var(--accent-error); color: var(--accent-error);">
+ Hydration Error
</button>
<button id="simBlocked" class="px-4 py-2 rounded-lg text-sm font-medium transition-all hover:scale-105" style="background: rgba(245, 158, 11, 0.1); border: 1px solid var(--accent-warn); color: var(--accent-warn);">
+ Blocked Resource
</button>
<button id="simFallback" class="px-4 py-2 rounded-lg text-sm font-medium transition-all hover:scale-105" style="background: rgba(6, 182, 212, 0.1); border: 1px solid var(--accent-info); color: var(--accent-info);">
+ Fallback Trigger
</button>
<button id="simRandom" class="px-4 py-2 rounded-lg text-sm font-medium transition-all hover:scale-105" style="background: rgba(16, 185, 129, 0.1); border: 1px solid var(--accent-success); color: var(--accent-success);">
+ Random Event
</button>
</div>
</div>
</main>
<script>
// Initialize state first
const state = {
logs: [],
filter: 'all',
startTime: Date.now(),
counts: {
hydration: 0,
blocked: 0,
fallback: 0
}
};
// Sample data templates
const hydrationErrors = [
{
type: 'hydration',
message: 'Text content mismatch in <div>',
component: 'UserProfile',
expected: 'Hello, John',
received: 'Hello, undefined',
stack: 'at UserProfile (components/user.tsx:23)\nat Header (components/header.tsx:45)'
},
{
type: 'hydration',
message: 'Attribute mismatch on <button>',
component: 'SubmitButton',
expected: 'disabled="false"',
received: 'disabled="true"',
stack: 'at SubmitButton (components/form.tsx:112)\nat Form (pages/contact.tsx:28)'
},
{
type: 'hydration',
message: 'Extra node in SSR output',
component: 'Navigation',
expected: '3 children',
received: '4 children',
stack: 'at Navigation (components/nav.tsx:67)\nat Layout (components/layout.tsx:12)'
}
];
const blockedResources = [
{
type: 'blocked',
message: 'CORS policy blocked script',
resource: 'https://cdn.external.com/analytics.js',
reason: 'No Access-Control-Allow-Origin header',
initiator: 'document HEAD'
},
{
type: 'blocked',
message: 'CSP blocked inline script',
resource: 'inline script at line 234',
reason: 'script-src-elem directive violation',
initiator: 'pages/dashboard.tsx'
},
{
type: 'blocked',
message: 'Network request failed',
resource: 'https://api.service.io/data',
reason: 'NET::ERR_CONNECTION_TIMED_OUT',
initiator: 'hooks/useDataFetch.ts'
},
{
type: 'blocked',
message: 'Font blocked by CORS',
resource: 'https://fonts.custom.com/woff2/font.woff2',
reason: 'Cross-origin resource sharing denied',
initiator: 'styles/global.css'
}
];
const fallbackTriggers = [
{
type: 'fallback',
message: 'Image fallback activated',
resource: '/images/hero-banner.webp',
fallback: '/images/placeholder.svg',
reason: 'Original failed to load after 3 retries'
},
{
type: 'fallback',
message: 'API fallback to cached data',
resource: '/api/user-preferences',
fallback: 'localStorage cache (2h old)',
reason: 'Primary endpoint unavailable'
},
{
type: 'fallback',
message: 'Component fallback rendered',
resource: 'DynamicChart',
fallback: 'StaticChartPlaceholder',
reason: 'Chunk load failed: chunk-chart.js'
},
{
type: 'fallback',
message: 'Font fallback applied',
resource: 'CustomDisplayFont',
fallback: 'system-ui, sans-serif',
reason: 'Font download exceeded 100ms threshold'
}
];
// DOM elements
const logContainer = document.getElementById('logContainer');
const detailsPanel = document.getElementById('detailsPanel');
const detailsContent = document.getElementById('detailsContent');
const hydrationCountEl = document.getElementById('hydrationCount');
const blockedCountEl = document.getElementById('blockedCount');
const fallbackCountEl = document.getElementById('fallbackCount');
const uptimeEl = document.getElementById('uptime');
// Utility functions
function formatTime(date) {
return date.toLocaleTimeString('en-US', {
hour12: false,
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
}
function formatUptime(ms) {
const seconds = Math.floor(ms / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
if (hours > 0) return `${hours}h ${minutes % 60}m`;
if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
return `${seconds}s`;
}
function getTypeStyles(type) {
switch(type) {
case 'hydration':
return { color: 'var(--accent-error)', label: 'HYDRATION', icon: 'zap' };
case 'blocked':
return { color: 'var(--accent-warn)', label: 'BLOCKED', icon: 'x-circle' };
case 'fallback':
return { color: 'var(--accent-info)', label: 'FALLBACK', icon: 'refresh' };
default:
return { color: 'var(--muted)', label: 'UNKNOWN', icon: 'alert' };
}
}
function getIconSVG(icon) {
switch(icon) {
case 'zap':
return '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>';
case 'x-circle':
return '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"/>';
case 'refresh':
return '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>';
default:
return '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>';
}
}
function createLogEntry(log, index) {
const styles = getTypeStyles(log.type);
const entry = document.createElement('div');
entry.className = 'log-entry rounded-lg overflow-hidden cursor-pointer transition-all hover:scale-[1.01]';
entry.style.cssText = `background: var(--card); border: 1px solid var(--border);`;
entry.dataset.index = index;
entry.dataset.type = log.type;
entry.setAttribute('role', 'listitem');
entry.setAttribute('tabindex', '0');
entry.innerHTML = `
<div class="flex items-start gap-3 p-3">
<div class="flex-shrink-0 w-8 h-8 rounded-lg flex items-center justify-center" style="background: ${styles.color}15;">
<svg class="w-4 h-4" style="color: ${styles.color};" fill="none" stroke="currentColor" viewBox="0 0 24 24">
${getIconSVG(styles.icon)}
</svg>
</div>
<div class="flex-1 min-w-0">
<div class="flex items-center gap-2 mb-1">
<span class="text-xs font-mono font-semibold px-2 py-0.5 rounded" style="background: ${styles.color}20; color: ${styles.color};">${styles.label}</span>
<span class="text-xs font-mono" style="color: var(--muted);">${formatTime(log.timestamp)}</span>
</div>
<p class="text-sm font-medium truncate" style="color: var(--fg);">${log.message}</p>
<p class="text-xs font-mono mt-1 truncate" style="color: var(--muted);">${log.resource || log.component || 'Unknown source'}</p>
</div>
<button class="expand-btn flex-shrink-0 p-2 rounded-lg transition-colors hover:bg-white/5" aria-label="Expand error details">
<svg class="w-4 h-4" style="color: var(--muted);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
</svg>
</button>
</div>
`;
return entry;
}
function renderLogs() {
const filtered = state.filter === 'all'
? state.logs
: state.logs.filter(log => log.type === state.filter);
if (filtered.length === 0) {
logContainer.innerHTML = `
<div class="text-center py-12" style="color: var(--muted);">
<svg class="w-12 h-12 mx-auto mb-3 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
</svg>
<p class="font-mono text-sm">${state.filter === 'all' ? 'Waiting for events...' : 'No events match filter'}</p>
<p class="text-xs mt-1">Errors will appear here in real-time</p>
</div>
`;
return;
}
logContainer.innerHTML = '';
filtered.forEach((log, i) => {
const entry = createLogEntry(log, state.logs.indexOf(log));
logContainer.appendChild(entry);
});
}
function updateCounts() {
hydrationCountEl.textContent = state.counts.hydration;
blockedCountEl.textContent = state.counts.blocked;
fallbackCountEl.textContent = state.counts.fallback;
}
function addLog(logData) {
const log = { ...logData, timestamp: new Date() };
state.logs.unshift(log);
state.counts[log.type]++;
updateCounts();
if (state.filter === 'all' || state.filter === log.type) {
if (state.logs.length === 1) {
renderLogs();
} else {
const entry = createLogEntry(log, 0);
entry.style.opacity = '0';
logContainer.insertBefore(entry, logContainer.firstChild);
requestAnimationFrame(() => {
entry.style.transition = 'opacity 0.3s ease-out';
entry.style.opacity = '1';
});
logContainer.scrollTop = 0;
}
}
}
function showDetails(log) {
let content = '';
if (log.type === 'hydration') {
content = `
<div class="space-y-3">
<div>
<span style="color: var(--accent-error);">Component:</span>
<span style="color: var(--fg);">${log.component}</span>
</div>
<div>
<span style="color: var(--accent-error);">Expected:</span>
<pre class="mt-1 p-2 rounded text-xs overflow-x-auto" style="background: var(--bg); color: var(--accent-success);">${log.expected}</pre>
</div>
<div>
<span style="color: var(--accent-error);">Received:</span>
<pre class="mt-1 p-2 rounded text-xs overflow-x-auto" style="background: var(--bg); color: var(--accent-error);">${log.received}</pre>
</div>
<div>
<span style="color: var(--accent-error);">Stack Trace:</span>
<pre class="mt-1 p-2 rounded text-xs overflow-x-auto" style="background: var(--bg); color: var(--muted);">${log.stack}</pre>
</div>
</div>
`;
} else if (log.type === 'blocked') {
content = `
<div class="space-y-3">
<div>
<span style="color: var(--accent-warn);">Resource:</span>
<pre class="mt-1 p-2 rounded text-xs overflow-x-auto" style="background: var(--bg); color: var(--fg);">${log.resource}</pre>
</div>
<div>
<span style="color: var(--accent-warn);">Reason:</span>
<span style="color: var(--fg);">${log.reason}</span>
</div>
<div>
<span style="color: var(--accent-warn);">Initiator:</span>
<span style="color: var(--fg);">${log.initiator}</span>
</div>
</div>
`;
} else if (log.type === 'fallback') {
content = `
<div class="space-y-3">
<div>
<span style="color: var(--accent-info);">Original Resource:</span>
<pre class="mt-1 p-2 rounded text-xs overflow-x-auto" style="background: var(--bg); color: var(--fg);">${log.resource}</pre>
</div>
<div>
<span style="color: var(--accent-info);">Fallback Used:</span>
<pre class="mt-1 p-2 rounded text-xs overflow-x-auto" style="background: var(--bg); color: var(--accent-success);">${log.fallback}</pre>
</div>
<div>
<span style="color: var(--accent-info);">Trigger Reason:</span>
<span style="color: var(--fg);">${log.reason}</span>
</div>
</div>
`;
}
detailsContent.innerHTML = content;
detailsPanel.classList.remove('hidden');
}
// Event Listeners
document.querySelectorAll('.filter-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
state.filter = btn.dataset.filter;
renderLogs();
});
});
logContainer.addEventListener('click', (e) => {
const entry = e.target.closest('.log-entry');
if (entry) {
const index = parseInt(entry.dataset.index);
showDetails(state.logs[index]);
}
});
logContainer.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
const entry = e.target.closest('.log-entry');
if (entry) {
e.preventDefault();
const index = parseInt(entry.dataset.index);
showDetails(state.logs[index]);
}
}
});
document.getElementById('closeDetails').addEventListener('click', () => {
detailsPanel.classList.add('hidden');
});
document.getElementById('clearBtn').addEventListener('click', () => {
state.logs = [];
state.counts = { hydration: 0, blocked: 0, fallback: 0 };
updateCounts();
renderLogs();
detailsPanel.classList.add('hidden');
});
// Simulation buttons
document.getElementById('simHydration').addEventListener('click', () => {
const template = hydrationErrors[Math.floor(Math.random() * hydrationErrors.length)];
addLog({ ...template });
});
document.getElementById('simBlocked').addEventListener('click', () => {
const template = blockedResources[Math.floor(Math.random() * blockedResources.length)];
addLog({ ...template });
});
document.getElementById('simFallback').addEventListener('click', () => {
const template = fallbackTriggers[Math.floor(Math.random() * fallbackTriggers.length)];
addLog({ ...template });
});
document.getElementById('simRandom').addEventListener('click', () => {
const allTemplates = [...hydrationErrors, ...blockedResources, ...fallbackTriggers];
const template = allTemplates[Math.floor(Math.random() * allTemplates.length)];
addLog({ ...template });
});
// Uptime counter
setInterval(() => {
const uptime = Date.now() - state.startTime;
uptimeEl.textContent = formatUptime(uptime);
}, 1000);
// Auto-generate some initial events for demo
setTimeout(() => addLog({ ...hydrationErrors[0] }), 800);
setTimeout(() => addLog({ ...blockedResources[0] }), 1500);
setTimeout(() => addLog({ ...fallbackTriggers[0] }), 2200);
setTimeout(() => addLog({ ...hydrationErrors[1] }), 3000);
</script>
</body>
</html>
Dashboard Metrics:
Log Console:
Error Types Captured:
Interactions:
Design: