SDK
The @oheoco/logged package provides a typed client for sending logs, capturing errors, and intercepting browser console activity.
Installation
npm install @oheoco/loggedInitialization
import { Logged } from "@oheoco/logged";
const logger = new Logged({
apiKey: process.env.LOGGED_API_KEY!,
});Browser vs Node
Logging methods
Use these methods to send logs at different severity levels.
logger.log()
logger.log("Application started");logger.info()
logger.info("User logged in");logger.success()
logger.success("Payment completed");logger.warn()
logger.warn("API response is slow");logger.error()
logger.error("Database connection failed");logger.debug()
logger.debug("Request details", { method: "GET" });logger.table()
logger.table("Users", [
{ name: "Alice", active: true },
{ name: "Bob", active: false },
]);Metadata and structured context
Attach structured metadata to any log for richer debugging context. The SDK accepts a plain object and forwards it as part of the event payload.
logger.info("User logged in", {
userId: "123",
role: "admin",
requestId: "req_456",
});For tables, the SDK stores the dataset in metadata.table so it can be inspected in the dashboard.
Browser globals and script tags
<script src="https://cdn.jsdelivr.net/npm/@oheoco/logged/dist/logged.global.js"></script>
<script>
const logger = new Logged({
apiKey: "YOUR_PROJECT_API_KEY",
environment: "production",
});
logger.auto();
logger.interceptConsole();
</script>The browser build also exposes window.Logged and window.logged. If a script tag includes data-api-key, the SDK can auto-create a logger instance and start auto capture or console capture unless disabled with data-auto="false" or data-console="false".
Common usage patterns
- Use
logger.capture()around async work and external API calls. - Enable
logger.auto()in browser apps to capture uncaught errors and rejected promises. - Enable
logger.interceptConsole()during debugging to forward browser logs without stripping existing console output. - Keep the API key on the server when possible; if it must live in browser code, use a public project key and avoid exposing secrets.
Capture Errors
Extract message, stack, and name from caught errors and send them as structured logs.
Browser Auto Capture
Automatically capture uncaught browser errors and unhandled promise rejections.
Console Capture
Intercept console output and send it to Logged without replacing existing console methods.
REST API
Skip the SDK and send logs directly to the Logged ingestion API.