{"id":22575,"library":"vite-plugin-agent-tail","title":"vite-plugin-agent-tail","description":"A Vite plugin that captures browser console.log, console.warn, console.error, unhandled errors, and unhandled promise rejections during development and writes them to timestamped log files on disk. Current stable version is 0.4.0. Published as part of the agent-tail ecosystem, it injects a script via HTML transformation that intercepts console methods, batches output, and sends it to the dev server via sendBeacon. Key differentiators: provides tail -f friendly logs, latest symlink, and integrates with the agent-tail CLI for combined browser+server log viewing. Requires Vite >=5.0.0 and ships TypeScript types.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/gillkyle/agent-tail","tags":["javascript","vite","vite-plugin","browser-logs","console","logging","typescript"],"install":[{"cmd":"npm install vite-plugin-agent-tail","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-agent-tail","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-agent-tail","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, version >=5.0.0 required for plugin compatibility","package":"vite","optional":false}],"imports":[{"note":"Named export from 'agent-tail/vite' subpath. Default import will fail.","wrong":"import agentTail from 'agent-tail/vite'","symbol":"agentTail","correct":"import { agentTail } from 'agent-tail/vite'"},{"note":"agentTail is a factory function, must be called. Omitting parentheses is a common mistake.","wrong":"export default defineConfig({ plugins: [agentTail] })","symbol":"agentTail()","correct":"export default defineConfig({ plugins: [agentTail()] })"},{"note":"The main 'agent-tail' package does not export the Vite plugin directly; use 'agent-tail/vite' subpath.","wrong":"import { agentTail } from 'agent-tail'","symbol":"agent-tail (CLI)","correct":"import { agentTail } from 'agent-tail/vite'; import { defineConfig } from 'vite'"}],"quickstart":{"code":"// install: npm install -D agent-tail\n// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { agentTail } from 'agent-tail/vite';\n\nexport default defineConfig({\n  plugins: [agentTail()],\n});\n\n// Terminal 2: view logs\n// tail -f tmp/logs/latest/browser.log\n// or use CLI: agent-tail tail browser -f","lang":"typescript","description":"Install agent-tail, add the Vite plugin to vite.config.ts, and tail the browser log file."},"warnings":[{"fix":"Update import from 'vite-plugin-agent-tail' to 'agent-tail/vite'.","message":"As of v0.4.0, the import path changed from 'vite-plugin-agent-tail' to 'agent-tail/vite'. Old path no longer works.","severity":"breaking","affected_versions":"<0.4.0"},{"fix":"Use a production logging solution like Sentry or LogRocket for production builds.","message":"The plugin only captures logs during development (vite dev server). It does not work in production builds.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure your HTML entry point (index.html) is present and not served externally.","message":"The plugin injects a script into HTML via transformIndexHtml. If your Vite config uses custom HTML or SSR, injection may not work correctly.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Add 'tmp/logs/' to .gitignore to avoid committing logs, or use a custom log directory.","message":"Logs are written to a 'tmp/logs/' directory relative to the project root. Ensure this directory is writable and not excluded by .gitignore if you want to track logs.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Update Vite to >=5.0.0: npm install vite@^5.0.0","cause":"Vite version in project is below 5.0.0.","error":"ERR_PNPM_NO_MATCHING_VERSION_INSIDE_WORKSPACE  For agent-tail@0.4.0, the dependency vite@>=5.0.0 not satisfied in workspace"},{"fix":"Use plugins: [agentTail()] instead of plugins: [agentTail].","cause":"Calling agentTail as a plain plugin without invoking the factory function.","error":"Error: agentTail is not a function"},{"fix":"Install agent-tail: npm install -D agent-tail","cause":"Importing from 'agent-tail/vite' but package is not installed or not using the umbrella package.","error":"Cannot find module 'agent-tail/vite' or its corresponding type declarations."},{"fix":"Ensure the dev server runs on HTTPS or same-origin. agent-tail attempts to send to the current origin.","cause":"The injected script uses sendBeacon; if the browser or environment blocks it (e.g., HTTP vs HTTPS mismatch), logs may fail silently.","error":"TypeError: Failed to execute 'sendBeacon' on 'Navigator': The body of the beacon is not a valid type."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}