SDK Configuration
The Logged SDK is intentionally small. The main configuration is the project API key, plus optional environment and debug metadata for diagnosing issues in the dashboard.
Constructor options
| Option | Required | Description |
|---|---|---|
| apiKey | Yes | Project API key used to authenticate requests to Logged. |
| environment | No | A human-friendly environment label such as development, staging, or production. |
| debug | No | Prints additional transport and capture diagnostics to the console when requests fail or browser handlers throw. |
Basic setup
typescript
import { Logged } from "@oheoco/logged";
const logger = new Logged({
apiKey: process.env.LOGGED_API_KEY!,
debug: true,
});In server-side code, prefer environment variables. In browser code, use a public runtime variable such as NEXT_PUBLIC_* or VITE_*.
Environment variable recommendations
Server
bash
LOGGED_API_KEY=your_secret_keyBrowser
bash
NEXT_PUBLIC_LOGGED_API_KEY=your_public_keyKeep secrets safe
Do not commit real API keys. If you need logs from a public browser app, use a project key that is scoped for that environment and avoid giving access to anything sensitive.
Browser vs server behavior
Browser-only features are skipped when the SDK runs in a non-browser context. The SDK does not require a full framework and can be used in Node.js, Edge functions, or vanilla JS as long as the API key is valid.
typescript
import { Logged } from "@oheoco/logged";
const logger = new Logged({
apiKey: process.env.LOGGED_API_KEY!,
});
logger.info("Server boot complete");Current SDK limitations
- The constructor does not currently expose a custom
baseUrloverride. - Auto capture and console capture only work in browser environments.
- Capture is best-effort and will swallow internal errors when debug mode is disabled.