SDK
The @logged/sdk package provides a typed client for sending logs, capturing errors, and intercepting browser console activity.
Installation
bash
npm install @logged/sdkInitialization
typescript
import { Logged } from "@logged/sdk";
const logger = new Logged({
apiKey: process.env.LOGGED_API_KEY!,
});Browser vs Node
The SDK works in both browsers and Node.js. Browser-only features, such as auto capture and console interception, are guarded so they do nothing in server environments.
Logging methods
Use these methods to send logs at different severity levels.
logger.log()
typescript
logger.log("Application started");logger.info()
typescript
logger.info("User logged in");logger.success()
typescript
logger.success("Payment completed");logger.warn()
typescript
logger.warn("API response is slow");logger.error()
typescript
logger.error("Database connection failed");logger.debug()
typescript
logger.debug("Request details", { method: "GET" });Metadata
Attach structured metadata to any log for richer debugging context.
typescript
logger.info("User logged in", {
userId: "123",
role: "admin",
});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.