Docs
Logs

Send frontend logs

The Nevision recorder script automatically captures uncaught browser errors and unhandled promise rejections. Use this endpoint when you want to explicitly ship a log line from frontend code — a caught exception, a validation warning, or a custom application event.

Endpoint

POST https://api.nevision.app/public/errors/ingest
Content-Type: application/json

Frontend calls authenticate by Origin / Referer allowlist, not by API key — the domain you send from must match one of your site's authorized domains. Never put the API key in browser code.

Payload

{
  "siteId": "YOUR_SITE_ID",
  "errors": [
    {
      "type": "uncaught",
      "message": "Checkout total mismatch",
      "fingerprint": "checkout:total-mismatch",
      "timestamp": 1719000000000,
      "url": "https://example.com/checkout",
      "stack": "at validateCart (cart.ts:42)",
      "filename": "cart.ts",
      "lineno": 42
    }
  ]
}

fingerprint groups similar log events together — pick a stable identifier (route + label works well). timestamp is Unix epoch milliseconds. Up to 20 events per request.

Code examples

function logToNevision(message, context = {}) {
  return fetch("https://api.nevision.app/public/errors/ingest", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      siteId: "YOUR_SITE_ID",
      errors: [{
        type: "uncaught",
        message,
        fingerprint: context.fingerprint || "frontend:" + message.slice(0, 40),
        timestamp: Date.now(),
        url: location.href,
        stack: new Error().stack || "",
      }],
    }),
    keepalive: true, // survive page navigation
  });
}

// usage
try {
  validateCart(cart);
} catch (err) {
  logToNevision("Cart validation failed: " + err.message, {
    fingerprint: "cart:validation",
  });
  throw err;
}

Response

{ "accepted": 1 }

The endpoint always returns 200. If accepted is 0, the response includes an error field (Domain not authorized, Invalid site, or limitReached: true).

Tips

  • Use keepalive: true so logs sent during page unload still ship.
  • Don't log every console message — pick events you'd actually open the dashboard for.
  • Already using the script tag? Uncaught errors and unhandled rejections are captured automatically — you only need this endpoint for explicit logs.