This example sends one event to LogZuno's ingestion API from JavaScript. It is the exact file our snippet tests send to the API before the docs are published.
Requirements
Any modern browser (fetch and top-level await in a module script), or Deno and Bun.
Send an event
// Browser or any runtime with fetch. Ingest keys can only send data, so they
// are safe in front-end code; never put a read, admin or server key here.
const endpoint = "https://api.logzuno.app/v1";
const apiKey = "YOUR_INGEST_KEY";
const response = await fetch(`${endpoint}/log`, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
channel: "signups",
event: "User signed up",
user_id: "user-123",
icon: "🎉",
notify: true,
tags: { plan: "growth", source: "website" },
}),
});
console.log(response.status, await response.json());Replace YOUR_INGEST_KEY with your project's ingest key. LogZuno answers 202 and the event appears in your project's live feed within seconds. Keep the key in an environment variable or your secrets manager, not in source control.
Notes for JavaScript
Prefer the script tag in websites. The website script already batches events, retries, and sends anything unsent when the tab closes, and exposes LogZuno.track(). Use plain fetch when you can't add a script, for example in a browser extension.
Only ingest keys in the browser. An ingest key can send data but never read it. Never put a read, admin or server key in front-end code.
Lost requests. A request started just before the page unloads can be cancelled. For a last event on navigation, pass keepalive: true to fetch.
What the request contains
The body is the same in every language: a channel and an event, and optionally user_id, group_id, description, icon, notify and tags. All fields, limits and response codes are in sending events and the ingestion API reference.