[{"data":1,"prerenderedAt":1409},["ShallowReactive",2],{"navigation_docs":3,"-build-on-top-plugins":454,"-build-on-top-plugins-surround":1404},[4,35,159,201,289,352,438],{"title":5,"path":6,"stem":7,"children":8,"page":34},"Getting Started","\u002Fgetting-started","1.getting-started",[9,14,19,24,29],{"title":10,"path":11,"stem":12,"icon":13},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction","i-lucide-info",{"title":15,"path":16,"stem":17,"icon":18},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation","i-lucide-download",{"title":20,"path":21,"stem":22,"icon":23},"Quick Start","\u002Fgetting-started\u002Fquick-start","1.getting-started\u002F3.quick-start","i-lucide-zap",{"title":25,"path":26,"stem":27,"icon":28},"Agent Skills","\u002Fgetting-started\u002Fagent-skills","1.getting-started\u002F4.agent-skills","i-lucide-sparkles",{"title":30,"path":31,"stem":32,"icon":33},"vs Other Loggers","\u002Fgetting-started\u002Fvs-other-loggers","1.getting-started\u002F5.vs-other-loggers","i-lucide-scale",false,{"title":36,"path":37,"stem":38,"children":39,"page":34},"Logging","\u002Flogging","2.logging",[40,45,50,55,60,65,70,99,127],{"title":41,"path":42,"stem":43,"icon":44},"Overview","\u002Flogging\u002Foverview","2.logging\u002F0.overview","i-lucide-list",{"title":46,"path":47,"stem":48,"icon":49},"Simple Logging","\u002Flogging\u002Fsimple-logging","2.logging\u002F1.simple-logging","i-lucide-terminal",{"title":51,"path":52,"stem":53,"icon":54},"Wide Events","\u002Flogging\u002Fwide-events","2.logging\u002F2.wide-events","i-lucide-layers",{"title":56,"path":57,"stem":58,"icon":59},"Structured Errors","\u002Flogging\u002Fstructured-errors","2.logging\u002F3.structured-errors","i-lucide-shield-alert",{"title":61,"path":62,"stem":63,"icon":64},"Catalogs","\u002Flogging\u002Fcatalogs","2.logging\u002F4.catalogs","i-lucide-book-open",{"title":66,"path":67,"stem":68,"icon":69},"Client Logging","\u002Flogging\u002Fclient-logging","2.logging\u002F5.client-logging","i-lucide-monitor",{"title":71,"icon":72,"path":73,"stem":74,"children":75,"page":34},"AI SDK","i-simple-icons-vercel","\u002Flogging\u002Fai-sdk","2.logging\u002F6.ai-sdk",[76,79,84,89,94],{"title":41,"path":77,"stem":78,"icon":44},"\u002Flogging\u002Fai-sdk\u002Foverview","2.logging\u002F6.ai-sdk\u002F01.overview",{"title":80,"path":81,"stem":82,"icon":83},"Usage","\u002Flogging\u002Fai-sdk\u002Fusage","2.logging\u002F6.ai-sdk\u002F02.usage","i-lucide-code",{"title":85,"path":86,"stem":87,"icon":88},"Options","\u002Flogging\u002Fai-sdk\u002Foptions","2.logging\u002F6.ai-sdk\u002F03.options","i-lucide-sliders",{"title":90,"path":91,"stem":92,"icon":93},"Metadata","\u002Flogging\u002Fai-sdk\u002Fmetadata","2.logging\u002F6.ai-sdk\u002F04.metadata","i-lucide-database",{"title":95,"path":96,"stem":97,"icon":98},"Telemetry","\u002Flogging\u002Fai-sdk\u002Ftelemetry","2.logging\u002F6.ai-sdk\u002F05.telemetry","i-lucide-activity",{"title":100,"icon":101,"path":102,"stem":103,"children":104,"page":34},"Better Auth","i-simple-icons-betterauth","\u002Flogging\u002Fbetter-auth","2.logging\u002F7.better-auth",[105,108,113,118,122],{"title":41,"path":106,"stem":107,"icon":44},"\u002Flogging\u002Fbetter-auth\u002Foverview","2.logging\u002F7.better-auth\u002F01.overview",{"title":109,"path":110,"stem":111,"icon":112},"Identify User","\u002Flogging\u002Fbetter-auth\u002Fidentify-user","2.logging\u002F7.better-auth\u002F02.identify-user","i-lucide-user-check",{"title":114,"path":115,"stem":116,"icon":117},"Middleware","\u002Flogging\u002Fbetter-auth\u002Fmiddleware","2.logging\u002F7.better-auth\u002F03.middleware","i-lucide-shield",{"title":119,"path":120,"stem":121,"icon":69},"Client Sync","\u002Flogging\u002Fbetter-auth\u002Fclient-sync","2.logging\u002F7.better-auth\u002F04.client-sync",{"title":123,"path":124,"stem":125,"icon":126},"Performance","\u002Flogging\u002Fbetter-auth\u002Fperformance","2.logging\u002F7.better-auth\u002F05.performance","i-lucide-gauge",{"title":128,"icon":129,"path":130,"stem":131,"children":132,"page":34},"Audit Logs","i-lucide-shield-check","\u002Flogging\u002Faudit","2.logging\u002F8.audit",[133,136,141,146,151,155],{"title":41,"path":134,"stem":135,"icon":44},"\u002Flogging\u002Faudit\u002Foverview","2.logging\u002F8.audit\u002F01.overview",{"title":137,"path":138,"stem":139,"icon":140},"Schema","\u002Flogging\u002Faudit\u002Fschema","2.logging\u002F8.audit\u002F02.schema","i-lucide-file-text",{"title":142,"path":143,"stem":144,"icon":145},"Recording","\u002Flogging\u002Faudit\u002Frecording","2.logging\u002F8.audit\u002F03.recording","i-lucide-pen-line",{"title":147,"path":148,"stem":149,"icon":150},"Drains","\u002Flogging\u002Faudit\u002Fpipeline","2.logging\u002F8.audit\u002F04.pipeline","i-lucide-link",{"title":152,"path":153,"stem":154,"icon":129},"Compliance","\u002Flogging\u002Faudit\u002Fcompliance","2.logging\u002F8.audit\u002F05.compliance",{"title":156,"path":157,"stem":158,"icon":64},"Recipes","\u002Flogging\u002Faudit\u002Frecipes","2.logging\u002F8.audit\u002F06.recipes",{"title":160,"path":161,"stem":162,"children":163,"page":34},"Core Concepts","\u002Fcore-concepts","3.core-concepts",[164,169,174,179,184,188,191,196],{"title":165,"path":166,"stem":167,"icon":168},"Lifecycle","\u002Fcore-concepts\u002Flifecycle","3.core-concepts\u002F0.lifecycle","i-lucide-arrow-right-left",{"title":170,"path":171,"stem":172,"icon":173},"Configuration","\u002Fcore-concepts\u002Fconfiguration","3.core-concepts\u002F1.configuration","i-lucide-settings",{"title":175,"path":176,"stem":177,"icon":178},"Sampling","\u002Fcore-concepts\u002Fsampling","3.core-concepts\u002F2.sampling","i-lucide-filter",{"title":180,"path":181,"stem":182,"icon":183},"Typed Fields","\u002Fcore-concepts\u002Ftyped-fields","3.core-concepts\u002F3.typed-fields","i-simple-icons-typescript",{"title":185,"path":186,"stem":187,"icon":129},"Best Practices","\u002Fcore-concepts\u002Fbest-practices","3.core-concepts\u002F4.best-practices",{"title":123,"path":189,"stem":190,"icon":126},"\u002Fcore-concepts\u002Fperformance","3.core-concepts\u002F5.performance",{"title":192,"path":193,"stem":194,"icon":195},"Vite Plugin","\u002Fcore-concepts\u002Fvite-plugin","3.core-concepts\u002F6.vite-plugin","i-custom-vite",{"title":197,"path":198,"stem":199,"icon":200},"Auto-Redaction","\u002Fcore-concepts\u002Fredaction","3.core-concepts\u002F7.redaction","i-lucide-eye-off",{"title":202,"path":203,"stem":204,"children":205,"page":34},"Frameworks","\u002Fframeworks","4.frameworks",[206,210,215,220,225,230,235,240,245,250,255,260,265,270,274,279,284],{"title":41,"path":207,"stem":208,"icon":209},"\u002Fframeworks\u002Foverview","4.frameworks\u002F00.overview","i-lucide-layout-grid",{"title":211,"path":212,"stem":213,"icon":214},"Nuxt","\u002Fframeworks\u002Fnuxt","4.frameworks\u002F01.nuxt","i-simple-icons-nuxtdotjs",{"title":216,"path":217,"stem":218,"icon":219},"Next.js","\u002Fframeworks\u002Fnextjs","4.frameworks\u002F02.nextjs","i-simple-icons-nextdotjs",{"title":221,"path":222,"stem":223,"icon":224},"SvelteKit","\u002Fframeworks\u002Fsveltekit","4.frameworks\u002F03.sveltekit","i-simple-icons-svelte",{"title":226,"path":227,"stem":228,"icon":229},"Nitro","\u002Fframeworks\u002Fnitro","4.frameworks\u002F04.nitro","i-custom-nitro",{"title":231,"path":232,"stem":233,"icon":234},"TanStack Start","\u002Fframeworks\u002Ftanstack-start","4.frameworks\u002F05.tanstack-start","i-custom-tanstack",{"title":236,"path":237,"stem":238,"icon":239},"NestJS","\u002Fframeworks\u002Fnestjs","4.frameworks\u002F06.nestjs","i-simple-icons-nestjs",{"title":241,"path":242,"stem":243,"icon":244},"Express","\u002Fframeworks\u002Fexpress","4.frameworks\u002F07.express","i-simple-icons-express",{"title":246,"path":247,"stem":248,"icon":249},"Hono","\u002Fframeworks\u002Fhono","4.frameworks\u002F08.hono","i-simple-icons-hono",{"title":251,"path":252,"stem":253,"icon":254},"Fastify","\u002Fframeworks\u002Ffastify","4.frameworks\u002F09.fastify","i-simple-icons-fastify",{"title":256,"path":257,"stem":258,"icon":259},"Elysia","\u002Fframeworks\u002Felysia","4.frameworks\u002F10.elysia","i-custom-elysia",{"title":261,"path":262,"stem":263,"icon":264},"React Router","\u002Fframeworks\u002Freact-router","4.frameworks\u002F11.react-router","i-custom-reactrouter",{"title":266,"path":267,"stem":268,"icon":269},"Cloudflare Workers","\u002Fframeworks\u002Fcloudflare-workers","4.frameworks\u002F12.cloudflare-workers","i-simple-icons-cloudflare",{"title":271,"path":272,"stem":273,"icon":183},"Standalone","\u002Fframeworks\u002Fstandalone","4.frameworks\u002F13.standalone",{"title":275,"path":276,"stem":277,"icon":278},"Astro","\u002Fframeworks\u002Fastro","4.frameworks\u002F14.astro","i-simple-icons-astro",{"title":280,"path":281,"stem":282,"icon":283},"AWS Lambda","\u002Fframeworks\u002Faws-lambda","4.frameworks\u002F16.aws-lambda","i-custom-lambda",{"title":285,"path":286,"stem":287,"icon":288},"Custom Integration","\u002Fframeworks\u002Fcustom-integration","4.frameworks\u002F17.custom-integration","i-lucide-puzzle",{"title":290,"path":291,"stem":292,"children":293,"page":34},"Build on top","\u002Fbuild-on-top","5.build-on-top",[294,297,302,307,312,316,321,326,330,334,338,342,347],{"title":41,"path":295,"stem":296,"icon":54},"\u002Fbuild-on-top\u002Foverview","5.build-on-top\u002F0.overview",{"title":298,"path":299,"stem":300,"icon":301},"In-process stream","\u002Fbuild-on-top\u002Fin-process-stream","5.build-on-top\u002F1.in-process-stream","i-lucide-radio-tower",{"title":303,"path":304,"stem":305,"icon":306},"Fanout","\u002Fbuild-on-top\u002Ffanout-and-multi-drain","5.build-on-top\u002F10.fanout-and-multi-drain","i-lucide-share-2",{"title":308,"path":309,"stem":310,"icon":311},"Identity headers","\u002Fbuild-on-top\u002Fidentity-headers","5.build-on-top\u002F11.identity-headers","i-lucide-fingerprint",{"title":313,"path":314,"stem":315,"icon":288},"Custom framework","\u002Fbuild-on-top\u002Fcustom-framework","5.build-on-top\u002F12.custom-framework",{"title":317,"path":318,"stem":319,"icon":320},"Stream server","\u002Fbuild-on-top\u002Fstream-server","5.build-on-top\u002F2.stream-server","i-lucide-radio",{"title":322,"path":323,"stem":324,"icon":325},"FS reader","\u002Fbuild-on-top\u002Ffs-reader","5.build-on-top\u002F3.fs-reader","i-lucide-folder-search",{"title":156,"path":327,"stem":328,"icon":329},"\u002Fbuild-on-top\u002Fconsumer-recipes","5.build-on-top\u002F4.consumer-recipes","i-lucide-chef-hat",{"title":331,"path":332,"stem":333,"icon":288},"Plugins","\u002Fbuild-on-top\u002Fplugins","5.build-on-top\u002F5.plugins",{"title":335,"path":336,"stem":337,"icon":28},"Custom enrichers","\u002Fbuild-on-top\u002Fcustom-enrichers","5.build-on-top\u002F6.custom-enrichers",{"title":339,"path":340,"stem":341,"icon":178},"Tail sampling","\u002Fbuild-on-top\u002Ftail-sampling","5.build-on-top\u002F7.tail-sampling",{"title":343,"path":344,"stem":345,"icon":346},"Custom drains","\u002Fbuild-on-top\u002Fcustom-drains","5.build-on-top\u002F8.custom-drains","i-lucide-code-2",{"title":348,"path":349,"stem":350,"icon":351},"Drain pipeline","\u002Fbuild-on-top\u002Fdrain-pipeline","5.build-on-top\u002F9.drain-pipeline","i-lucide-workflow",{"title":353,"path":354,"stem":355,"children":356,"page":34},"Adapters","\u002Fadapters","6.adapters",[357,360,400,415],{"title":41,"path":358,"stem":359,"icon":44},"\u002Fadapters\u002Foverview","6.adapters\u002F01.overview",{"title":361,"path":362,"stem":363,"children":364,"page":34},"Cloud destinations","\u002Fadapters\u002Fcloud","6.adapters\u002F02.cloud",[365,370,375,380,385,390,395],{"title":366,"path":367,"stem":368,"icon":369},"Axiom","\u002Fadapters\u002Fcloud\u002Faxiom","6.adapters\u002F02.cloud\u002F01.axiom","i-custom-axiom",{"title":371,"path":372,"stem":373,"icon":374},"OTLP","\u002Fadapters\u002Fcloud\u002Fotlp","6.adapters\u002F02.cloud\u002F02.otlp","i-simple-icons-opentelemetry",{"title":376,"path":377,"stem":378,"icon":379},"PostHog","\u002Fadapters\u002Fcloud\u002Fposthog","6.adapters\u002F02.cloud\u002F03.posthog","i-simple-icons-posthog",{"title":381,"path":382,"stem":383,"icon":384},"Sentry","\u002Fadapters\u002Fcloud\u002Fsentry","6.adapters\u002F02.cloud\u002F04.sentry","i-simple-icons-sentry",{"title":386,"path":387,"stem":388,"icon":389},"Better Stack","\u002Fadapters\u002Fcloud\u002Fbetter-stack","6.adapters\u002F02.cloud\u002F05.better-stack","i-simple-icons-betterstack",{"title":391,"path":392,"stem":393,"icon":394},"Datadog","\u002Fadapters\u002Fcloud\u002Fdatadog","6.adapters\u002F02.cloud\u002F06.datadog","i-simple-icons-datadog",{"title":396,"path":397,"stem":398,"icon":399},"HyperDX","\u002Fadapters\u002Fcloud\u002Fhyperdx","6.adapters\u002F02.cloud\u002F07.hyperdx","i-custom-hyperdx",{"title":401,"path":402,"stem":403,"children":404,"page":34},"Self-hosted","\u002Fadapters\u002Fself-hosted","6.adapters\u002F03.self-hosted",[405,410],{"title":406,"path":407,"stem":408,"icon":409},"File System","\u002Fadapters\u002Fself-hosted\u002Ffs","6.adapters\u002F03.self-hosted\u002F01.fs","i-lucide-hard-drive",{"title":411,"path":412,"stem":413,"icon":414},"NuxtHub","\u002Fadapters\u002Fself-hosted\u002Fnuxthub","6.adapters\u002F03.self-hosted\u002F02.nuxthub","i-simple-icons-nuxt",{"title":416,"path":417,"stem":418,"children":419,"page":34},"Building blocks","\u002Fadapters\u002Fbuilding-blocks","6.adapters\u002F04.building-blocks",[420,424,429,433],{"title":421,"path":422,"stem":423,"icon":351},"Pipeline","\u002Fadapters\u002Fbuilding-blocks\u002Fpipeline","6.adapters\u002F04.building-blocks\u002F01.pipeline",{"title":425,"path":426,"stem":427,"icon":428},"HTTP","\u002Fadapters\u002Fbuilding-blocks\u002Fhttp","6.adapters\u002F04.building-blocks\u002F02.http","i-lucide-globe",{"title":430,"path":431,"stem":432,"icon":83},"Custom Adapters","\u002Fadapters\u002Fbuilding-blocks\u002Fcustom","6.adapters\u002F04.building-blocks\u002F03.custom",{"title":434,"path":435,"stem":436,"icon":437},"Toolkit","\u002Fadapters\u002Fbuilding-blocks\u002Ftoolkit","6.adapters\u002F04.building-blocks\u002F04.toolkit","i-lucide-blocks",{"title":439,"path":440,"stem":441,"children":442,"page":34},"Enrichers","\u002Fenrichers","7.enrichers",[443,446,450],{"title":41,"path":444,"stem":445,"icon":28},"\u002Fenrichers\u002Foverview","7.enrichers\u002F1.overview",{"title":447,"path":448,"stem":449,"icon":288},"Built-in","\u002Fenrichers\u002Fbuilt-in","7.enrichers\u002F2.built-in",{"title":451,"path":452,"stem":453,"icon":83},"Custom","\u002Fenrichers\u002Fcustom","7.enrichers\u002F3.custom",{"id":455,"title":331,"body":456,"description":1397,"extension":1398,"links":1399,"meta":1400,"navigation":1401,"path":332,"seo":1402,"stem":333,"__hash__":1403},"docs\u002F5.build-on-top\u002F5.plugins.md",{"type":457,"value":458,"toc":1390},"minimark",[459,472,475,554,559,566,587,595,599,891,895,1041,1048,1304,1308,1365,1369,1386],[460,461,462,466,467,471],"p",{},[463,464,465],"code",{},"definePlugin()"," is the ",[468,469,470],"strong",{},"canonical extension point"," for evlog. Drains and enrichers are special cases of plugins, but a single plugin can opt into multiple hooks at once — the right shape for any non-trivial extension that mixes several concerns.",[473,474],"lifecycle-flow",{},[476,477,480,483,545],"prompt",{":actions":478,"description":479,"icon":288},"[\"copy\",\"cursor\",\"windsurf\"]","Build a multi-hook evlog plugin",[460,481,482],{},"Build an evlog plugin that hooks into more than one lifecycle stage.",[484,485,486,518,521,524,531],"ul",{},[487,488,489,490,493,494,497,498,501,502,501,505,501,508,501,511,501,514,517],"li",{},"Import ",[463,491,492],{},"definePlugin"," from ",[463,495,496],{},"evlog\u002Ftoolkit"," and pick the hooks I need (",[463,499,500],{},"onRequestStart",", ",[463,503,504],{},"enrich",[463,506,507],{},"drain",[463,509,510],{},"extendLogger",[463,512,513],{},"tailSampling",[463,515,516],{},"onClientLog",")",[487,519,520],{},"Keep enrich pure (no I\u002FO, no throwing — use try\u002Fcatch internally)",[487,522,523],{},"For drains, batch and ship to the destination; respect backpressure if the sink is slow",[487,525,526,527,530],{},"Register via ",[463,528,529],{},"getGlobalPluginRunner().register(plugin)"," at app boot, or via the framework's evlog config when available",[487,532,533,534,537,538,541,542,544],{},"Prefer single-purpose ",[463,535,536],{},"enricherPlugin()"," \u002F ",[463,539,540],{},"drainPlugin()"," wrappers for simple extensions; use ",[463,543,492],{}," only when several hooks are needed",[460,546,547,548],{},"Docs: ",[549,550,551],"a",{"href":551,"rel":552},"https:\u002F\u002Fwww.evlog.dev\u002Fbuild-on-top\u002Fplugins",[553],"nofollow",[555,556,558],"h2",{"id":557},"what-is-this-and-when-do-i-want-it","What is this and when do I want it?",[460,560,561,562,565],{},"Use a plugin when your feature touches ",[468,563,564],{},"more than one"," point in the pipeline:",[484,567,568,575,578],{},[487,569,570,571,574],{},"\"On every request, copy ",[463,572,573],{},"x-tenant-id"," from headers into a context field, AND tag the event with the tenant's plan, AND alert when an error event has plan=enterprise\" → one plugin",[487,576,577],{},"\"Add Sentry breadcrumbs every time we drain a wide event with level=error\" → one plugin",[487,579,580,581,584,585],{},"\"Decorate the request logger with a custom ",[463,582,583],{},"audit.refund(...)"," method\" → one plugin's ",[463,586,510],{},[460,588,589,590,537,592,594],{},"Single-purpose extensions (just an enricher, just a drain) can use the dedicated wrappers ",[463,591,536],{},[463,593,540],{}," instead.",[555,596,598],{"id":597},"minimal-example","Minimal example",[600,601,606],"pre",{"className":602,"code":603,"language":604,"meta":605,"style":605},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { definePlugin, getGlobalPluginRunner } from 'evlog\u002Ftoolkit'\n\nexport const tenantPlugin = definePlugin({\n  name: 'tenant',\n  onRequestStart({ logger, headers }) {\n    const tenantId = headers?.['x-tenant-id']\n    if (tenantId) logger.set({ tenant: { id: tenantId } })\n  },\n  enrich({ event }) {\n    event.region = process.env.REGION\n  },\n})\n\n\u002F\u002F Register on the global runner (typically once at startup):\ngetGlobalPluginRunner().add(tenantPlugin)\n","ts","",[463,607,608,646,653,678,699,723,752,802,808,823,849,854,862,867,874],{"__ignoreMap":605},[609,610,613,617,621,625,628,631,634,637,640,643],"span",{"class":611,"line":612},"line",1,[609,614,616],{"class":615},"s7zQu","import",[609,618,620],{"class":619},"sMK4o"," {",[609,622,624],{"class":623},"sTEyZ"," definePlugin",[609,626,627],{"class":619},",",[609,629,630],{"class":623}," getGlobalPluginRunner",[609,632,633],{"class":619}," }",[609,635,636],{"class":615}," from",[609,638,639],{"class":619}," '",[609,641,496],{"class":642},"sfazB",[609,644,645],{"class":619},"'\n",[609,647,649],{"class":611,"line":648},2,[609,650,652],{"emptyLinePlaceholder":651},true,"\n",[609,654,656,659,663,666,669,672,675],{"class":611,"line":655},3,[609,657,658],{"class":615},"export",[609,660,662],{"class":661},"spNyl"," const",[609,664,665],{"class":623}," tenantPlugin ",[609,667,668],{"class":619},"=",[609,670,624],{"class":671},"s2Zo4",[609,673,674],{"class":623},"(",[609,676,677],{"class":619},"{\n",[609,679,681,685,688,690,693,696],{"class":611,"line":680},4,[609,682,684],{"class":683},"swJcz","  name",[609,686,687],{"class":619},":",[609,689,639],{"class":619},[609,691,692],{"class":642},"tenant",[609,694,695],{"class":619},"'",[609,697,698],{"class":619},",\n",[609,700,702,705,708,712,714,717,720],{"class":611,"line":701},5,[609,703,704],{"class":683},"  onRequestStart",[609,706,707],{"class":619},"({",[609,709,711],{"class":710},"sHdIc"," logger",[609,713,627],{"class":619},[609,715,716],{"class":710}," headers",[609,718,719],{"class":619}," })",[609,721,722],{"class":619}," {\n",[609,724,726,729,732,735,737,740,743,745,747,749],{"class":611,"line":725},6,[609,727,728],{"class":661},"    const",[609,730,731],{"class":623}," tenantId",[609,733,734],{"class":619}," =",[609,736,716],{"class":623},[609,738,739],{"class":619},"?.",[609,741,742],{"class":683},"[",[609,744,695],{"class":619},[609,746,573],{"class":642},[609,748,695],{"class":619},[609,750,751],{"class":683},"]\n",[609,753,755,758,761,764,767,770,773,776,778,781,784,786,788,791,793,795,797,799],{"class":611,"line":754},7,[609,756,757],{"class":615},"    if",[609,759,760],{"class":683}," (",[609,762,763],{"class":623},"tenantId",[609,765,766],{"class":683},") ",[609,768,769],{"class":623},"logger",[609,771,772],{"class":619},".",[609,774,775],{"class":671},"set",[609,777,674],{"class":683},[609,779,780],{"class":619},"{",[609,782,783],{"class":683}," tenant",[609,785,687],{"class":619},[609,787,620],{"class":619},[609,789,790],{"class":683}," id",[609,792,687],{"class":619},[609,794,731],{"class":623},[609,796,633],{"class":619},[609,798,633],{"class":619},[609,800,801],{"class":683},")\n",[609,803,805],{"class":611,"line":804},8,[609,806,807],{"class":619},"  },\n",[609,809,811,814,816,819,821],{"class":611,"line":810},9,[609,812,813],{"class":683},"  enrich",[609,815,707],{"class":619},[609,817,818],{"class":710}," event",[609,820,719],{"class":619},[609,822,722],{"class":619},[609,824,826,829,831,834,836,839,841,844,846],{"class":611,"line":825},10,[609,827,828],{"class":623},"    event",[609,830,772],{"class":619},[609,832,833],{"class":623},"region",[609,835,734],{"class":619},[609,837,838],{"class":623}," process",[609,840,772],{"class":619},[609,842,843],{"class":623},"env",[609,845,772],{"class":619},[609,847,848],{"class":623},"REGION\n",[609,850,852],{"class":611,"line":851},11,[609,853,807],{"class":619},[609,855,857,860],{"class":611,"line":856},12,[609,858,859],{"class":619},"}",[609,861,801],{"class":623},[609,863,865],{"class":611,"line":864},13,[609,866,652],{"emptyLinePlaceholder":651},[609,868,870],{"class":611,"line":869},14,[609,871,873],{"class":872},"sHwdD","\u002F\u002F Register on the global runner (typically once at startup):\n",[609,875,877,880,883,885,888],{"class":611,"line":876},15,[609,878,879],{"class":671},"getGlobalPluginRunner",[609,881,882],{"class":623},"()",[609,884,772],{"class":619},[609,886,887],{"class":671},"add",[609,889,890],{"class":623},"(tenantPlugin)\n",[555,892,894],{"id":893},"full-api","Full API",[896,897,898,914],"table",{},[899,900,901],"thead",{},[902,903,904,908,911],"tr",{},[905,906,907],"th",{},"Hook",[905,909,910],{},"When",[905,912,913],{},"Use it for",[915,916,917,934,949,962,982,995,1012,1025],"tbody",{},[902,918,919,925,928],{},[920,921,922],"td",{},[463,923,924],{},"setup(ctx)",[920,926,927],{},"Once when registered",[920,929,930,931,933],{},"Read ",[463,932,843],{},", set up shared state",[902,935,936,941,944],{},[920,937,938],{},[463,939,940],{},"onRequestStart(ctx)",[920,942,943],{},"Each request, before any handler runs",[920,945,946,947],{},"Pull values from headers into ",[463,948,769],{},[902,950,951,956,959],{},[920,952,953],{},[463,954,955],{},"enrich(ctx)",[920,957,958],{},"Every event, before drain",[920,960,961],{},"Add derived fields (geo, deploy id…)",[902,963,964,969,972],{},[920,965,966],{},[463,967,968],{},"keep(ctx)",[920,970,971],{},"Tail sampling decision",[920,973,974,975,501,978,981],{},"Force-keep based on outcome (",[463,976,977],{},"status >= 400",[463,979,980],{},"duration > 500",", …)",[902,983,984,989,992],{},[920,985,986],{},[463,987,988],{},"drain(ctx)",[920,990,991],{},"Every emitted event",[920,993,994],{},"Side-effect: alert, mirror to a queue, etc.",[902,996,997,1002,1009],{},[920,998,999],{},[463,1000,1001],{},"onRequestFinish(ctx)",[920,1003,1004,1005,1008],{},"After response, includes the emitted event (or ",[463,1006,1007],{},"null"," if sampled out)",[920,1010,1011],{},"Per-request post-processing",[902,1013,1014,1019,1022],{},[920,1015,1016],{},[463,1017,1018],{},"onClientLog(ctx)",[920,1020,1021],{},"Browser-submitted event hits the ingest endpoint",[920,1023,1024],{},"Observe \u002F reject client traffic",[902,1026,1027,1032,1035],{},[920,1028,1029],{},[463,1030,1031],{},"extendLogger(logger)",[920,1033,1034],{},"Each request",[920,1036,1037,1038,517],{},"Add custom methods (e.g. ",[463,1039,1040],{},"logger.audit.refund()",[460,1042,1043,1044,1047],{},"Every hook is ",[468,1045,1046],{},"optional",". A plugin can implement any subset.",[600,1049,1051],{"className":602,"code":1050,"language":604,"meta":605,"style":605},"export interface EvlogPlugin {\n  name: string\n  setup?: (ctx: PluginSetupContext) => void | Promise\u003Cvoid>\n  enrich?: (ctx: EnrichContext) => void | Promise\u003Cvoid>\n  drain?: (ctx: DrainContext) => void | Promise\u003Cvoid>\n  keep?: (ctx: TailSamplingContext) => void | Promise\u003Cvoid>\n  onRequestStart?: (ctx: RequestLifecycleContext) => void\n  onRequestFinish?: (ctx: RequestFinishContext) => void\n  onClientLog?: (ctx: ClientLogContext) => void\n  extendLogger?: (logger: RequestLogger) => void\n}\n",[463,1052,1053,1066,1075,1116,1147,1179,1211,1233,1255,1277,1299],{"__ignoreMap":605},[609,1054,1055,1057,1060,1064],{"class":611,"line":612},[609,1056,658],{"class":615},[609,1058,1059],{"class":661}," interface",[609,1061,1063],{"class":1062},"sBMFI"," EvlogPlugin",[609,1065,722],{"class":619},[609,1067,1068,1070,1072],{"class":611,"line":648},[609,1069,684],{"class":683},[609,1071,687],{"class":619},[609,1073,1074],{"class":1062}," string\n",[609,1076,1077,1080,1083,1085,1088,1090,1093,1095,1098,1101,1104,1107,1110,1113],{"class":611,"line":655},[609,1078,1079],{"class":683},"  setup",[609,1081,1082],{"class":619},"?:",[609,1084,760],{"class":619},[609,1086,1087],{"class":710},"ctx",[609,1089,687],{"class":619},[609,1091,1092],{"class":1062}," PluginSetupContext",[609,1094,517],{"class":619},[609,1096,1097],{"class":661}," =>",[609,1099,1100],{"class":1062}," void",[609,1102,1103],{"class":619}," |",[609,1105,1106],{"class":1062}," Promise",[609,1108,1109],{"class":619},"\u003C",[609,1111,1112],{"class":1062},"void",[609,1114,1115],{"class":619},">\n",[609,1117,1118,1120,1122,1124,1126,1128,1131,1133,1135,1137,1139,1141,1143,1145],{"class":611,"line":680},[609,1119,813],{"class":683},[609,1121,1082],{"class":619},[609,1123,760],{"class":619},[609,1125,1087],{"class":710},[609,1127,687],{"class":619},[609,1129,1130],{"class":1062}," EnrichContext",[609,1132,517],{"class":619},[609,1134,1097],{"class":661},[609,1136,1100],{"class":1062},[609,1138,1103],{"class":619},[609,1140,1106],{"class":1062},[609,1142,1109],{"class":619},[609,1144,1112],{"class":1062},[609,1146,1115],{"class":619},[609,1148,1149,1152,1154,1156,1158,1160,1163,1165,1167,1169,1171,1173,1175,1177],{"class":611,"line":701},[609,1150,1151],{"class":683},"  drain",[609,1153,1082],{"class":619},[609,1155,760],{"class":619},[609,1157,1087],{"class":710},[609,1159,687],{"class":619},[609,1161,1162],{"class":1062}," DrainContext",[609,1164,517],{"class":619},[609,1166,1097],{"class":661},[609,1168,1100],{"class":1062},[609,1170,1103],{"class":619},[609,1172,1106],{"class":1062},[609,1174,1109],{"class":619},[609,1176,1112],{"class":1062},[609,1178,1115],{"class":619},[609,1180,1181,1184,1186,1188,1190,1192,1195,1197,1199,1201,1203,1205,1207,1209],{"class":611,"line":725},[609,1182,1183],{"class":683},"  keep",[609,1185,1082],{"class":619},[609,1187,760],{"class":619},[609,1189,1087],{"class":710},[609,1191,687],{"class":619},[609,1193,1194],{"class":1062}," TailSamplingContext",[609,1196,517],{"class":619},[609,1198,1097],{"class":661},[609,1200,1100],{"class":1062},[609,1202,1103],{"class":619},[609,1204,1106],{"class":1062},[609,1206,1109],{"class":619},[609,1208,1112],{"class":1062},[609,1210,1115],{"class":619},[609,1212,1213,1215,1217,1219,1221,1223,1226,1228,1230],{"class":611,"line":754},[609,1214,704],{"class":683},[609,1216,1082],{"class":619},[609,1218,760],{"class":619},[609,1220,1087],{"class":710},[609,1222,687],{"class":619},[609,1224,1225],{"class":1062}," RequestLifecycleContext",[609,1227,517],{"class":619},[609,1229,1097],{"class":661},[609,1231,1232],{"class":1062}," void\n",[609,1234,1235,1238,1240,1242,1244,1246,1249,1251,1253],{"class":611,"line":804},[609,1236,1237],{"class":683},"  onRequestFinish",[609,1239,1082],{"class":619},[609,1241,760],{"class":619},[609,1243,1087],{"class":710},[609,1245,687],{"class":619},[609,1247,1248],{"class":1062}," RequestFinishContext",[609,1250,517],{"class":619},[609,1252,1097],{"class":661},[609,1254,1232],{"class":1062},[609,1256,1257,1260,1262,1264,1266,1268,1271,1273,1275],{"class":611,"line":810},[609,1258,1259],{"class":683},"  onClientLog",[609,1261,1082],{"class":619},[609,1263,760],{"class":619},[609,1265,1087],{"class":710},[609,1267,687],{"class":619},[609,1269,1270],{"class":1062}," ClientLogContext",[609,1272,517],{"class":619},[609,1274,1097],{"class":661},[609,1276,1232],{"class":1062},[609,1278,1279,1282,1284,1286,1288,1290,1293,1295,1297],{"class":611,"line":825},[609,1280,1281],{"class":683},"  extendLogger",[609,1283,1082],{"class":619},[609,1285,760],{"class":619},[609,1287,769],{"class":710},[609,1289,687],{"class":619},[609,1291,1292],{"class":1062}," RequestLogger",[609,1294,517],{"class":619},[609,1296,1097],{"class":661},[609,1298,1232],{"class":1062},[609,1300,1301],{"class":611,"line":851},[609,1302,1303],{"class":619},"}\n",[555,1305,1307],{"id":1306},"common-pitfalls","Common pitfalls",[484,1309,1310,1319,1330,1353],{},[487,1311,1312,1315,1316,1318],{},[468,1313,1314],{},"Don't throw from a hook",". The plugin runner catches and logs errors with the plugin name, but a thrown error from ",[463,1317,504],{}," won't propagate the event downstream. Keep hooks defensive.",[487,1320,1321,1326,1327,594],{},[468,1322,1323,1325],{},[463,1324,507],{}," runs for every event"," — not just per-request. If you only care about per-request lifecycle, use ",[463,1328,1329],{},"onRequestFinish",[487,1331,1332,1337,1338,1341,1342,1345,1346,1349,1350,772],{},[468,1333,1334,1336],{},[463,1335,510],{}," mutates the logger object"," — augment ",[463,1339,1340],{},"RequestLogger"," in a ",[463,1343,1344],{},".d.ts"," so ",[463,1347,1348],{},"useLogger(event)"," exposes the new methods to TypeScript. See ",[549,1351,1352],{"href":181},"typed fields",[487,1354,1355,1361,1362,1364],{},[468,1356,1357,1358],{},"Plugins are de-duplicated by ",[463,1359,1360],{},"name",". Re-registering with the same ",[463,1363,1360],{}," replaces the previous version (last registration wins).",[555,1366,1368],{"id":1367},"going-further","Going further",[484,1370,1371,1376,1381],{},[487,1372,1373,1374],{},"Single-purpose enricher → ",[549,1375,335],{"href":336},[487,1377,1378,1379],{},"Tail-only logic → ",[549,1380,339],{"href":340},[487,1382,1383,1384],{},"Drain-only side effect → ",[549,1385,343],{"href":344},[1387,1388,1389],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}",{"title":605,"searchDepth":648,"depth":648,"links":1391},[1392,1393,1394,1395,1396],{"id":557,"depth":648,"text":558},{"id":597,"depth":648,"text":598},{"id":893,"depth":648,"text":894},{"id":1306,"depth":648,"text":1307},{"id":1367,"depth":648,"text":1368},"definePlugin is the canonical extension contract for evlog. One plugin can opt into any subset of lifecycle hooks — enrich, drain, tail sampling, request lifecycle, client log observation.","md",null,{},{"title":331,"icon":288},{"title":331,"description":1397},"6IbgRUbRGXf4n1xWlDbUC3pWdWovIODFSZtY1sD7fw0",[1405,1407],{"title":156,"path":327,"stem":328,"description":1406,"icon":329,"children":-1},"Concrete copy-paste recipes — build your own minimal devtool, pipe to curl + jq, replay history then go live, and aggregate on the consumer side.",{"title":335,"path":336,"stem":337,"description":1408,"icon":28,"children":-1},"defineEnricher derives context from request headers, env, or anything else, and adds it to every wide event before drain — without touching call sites.",1778340943242]