Vanilla JS · logzai-js/browser

Browser error logging without a framework

logzai-js works in any browser environment. Drop it into a module bundle or use the CDN script tag — zero framework dependencies required.

Get ingest token

npm install logzai-js

No credit card required. 5M events free/month.

What you get out of the box

window.onerror + onunhandledrejection

Captures all unhandled errors and async rejections natively in any browser.

History API route tracking

Wraps pushState and replaceState to log SPA navigations without a framework.

CDN or npm

Works via a <script> tag from CDN or bundled with Webpack, Rollup, or Vite.

Flexible context injection

Inject any global state: window variables, sessionStorage, or cookies.

Cross-origin error filtering

Built-in example to skip the useless 'Script error.' cross-origin events.

logger.js
import logzai, { browserPlugin, spaPlugin } from 'logzai-js/browser' // Or via CDN: <script src="https://cdn.logzai.com/logzai-js@latest/browser.umd.js"></script> logzai.init({ ingestToken: window.__LOGZAI_TOKEN__ || 'YOUR_INGEST_TOKEN', ingestEndpoint: 'https://ingest.logzai.com', serviceName: 'my-website', environment: window.__ENV__ || 'production', mirrorToConsole: window.__ENV__ !== 'production', }) // Capture window.onerror and window.onunhandledrejection logzai.plugin('browser', browserPlugin, { errorFilter: (error) => { // Ignore cross-origin script errors (no useful stack trace) if (error?.message === 'Script error.') return false return true }, contextInjector: () => ({ userId: window.__currentUser?.id ?? null, userEmail: window.__currentUser?.email ?? null, currentRoute: window.location.pathname, referrer: document.referrer || null, }), }) // Track History API navigation (pushState / replaceState) logzai.plugin('spa', spaPlugin, { logNavigation: true, contextInjector: () => ({ userId: window.__currentUser?.id ?? null, }), })

Every event arrives enriched

When JavaScript captures an error or navigation, LogzAI receives these fields automatically.

FieldExample valueCaptured from
serviceNamemy-websitelogzai.init
environmentproductionwindow.__ENV__
userIdusr_01j8x...window.__currentUser
userEmailjane@acme.comwindow.__currentUser
currentRoute/checkout/step-2window.location.pathname
referrerhttps://google.comdocument.referrer
messageUncaught TypeError: ...window.onerror
levelerrorbrowserPlugin

Start sending events in 2 minutes

Add npm install logzai-js to your JavaScript app and you're done.

No infrastructure to manage. 5M events free/month.

Analyze your logs with AI

Once events are flowing, ask LogzAI questions in plain English. Find root causes in seconds.

Try LogzAI Free