// OpenPanel RUM snippet -- folded into source now that we build the fork // from source rather than patching upstream's prebuilt image (see the // now-removed homelab-compose drop-stack/patch-telemetry-snippet.js for the // original: Drop is LAN-only behind the .88 Caddy, so the .198 nginx-proxy // sub_filter injection used for the public sites never sees it, and the // frontend is SSR'd per request so there's no static HTML to inject into // either -- a client plugin covers every page exactly once per full load, // and Nuxt's own router hooks stand in for OpenPanel's trackScreenViews on // SPA navigations). // // Client id is a PUBLIC write key (no secret), scoped by CORS origin on the // telemetry side -- safe to ship in the bundle, same as before. export default defineNuxtPlugin(() => { const config = useRuntimeConfig(); const clientId = config.public.telemetry?.clientId; const apiUrl = config.public.telemetry?.apiUrl; if (!clientId || !apiUrl) return; // eslint-disable-next-line @typescript-eslint/no-explicit-any const w = window as any; if (w.__opTelemetry) return; w.__opTelemetry = 1; w.op = w.op || function (...args: unknown[]) { (w.op.q = w.op.q || []).push(args); }; w.op("init", { clientId, apiUrl: `${apiUrl}/v1`, trackScreenViews: true, trackOutgoingLinks: true, trackAttributes: true, }); const script = document.createElement("script"); script.src = `${apiUrl}/assets/site.js`; script.async = true; script.defer = true; (document.head || document.documentElement).appendChild(script); });