@koderlabs/tasks-sdk-web-errors
v0.2.0
Published
Browser error capture for the InstantTasks SDK — window.onerror + unhandledrejection + console breadcrumbs.
Maintainers
Readme
@koderlabs/tasks-sdk-web-errors
Runtime: browser DOM only. For RN errors use
@koderlabs/tasks-sdk-rn(which bundles its own ErrorUtils-based capture). For Node use@koderlabs/tasks-sdk-nestjsorprocess.on('uncaughtException').
Auto-captures uncaught JS errors, unhandled promise rejections, and (optionally) console messages from the browser. Attaches breadcrumbs, user info, feature flags, contexts, and the last N network entries (when paired with @koderlabs/tasks-sdk-web-network).
Registered as an integration against the core SDK client.
Install
npm install @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-errors
# or
pnpm add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-errors
# or
yarn add @koderlabs/tasks-sdk @koderlabs/tasks-sdk-web-errorsUsage
import { init } from '@koderlabs/tasks-sdk';
import { errorsIntegration, notify, leaveBreadcrumb, setUser } from '@koderlabs/tasks-sdk-web-errors';
init({
projectId: 'FE',
accessKey: 'sk_live_…',
integrations: [
errorsIntegration({
captureGlobalErrors: true,
captureUnhandledRejections: true,
captureConsole: false,
maxBreadcrumbs: 50,
}),
],
});
setUser({ id: 'u_123', email: '[email protected]' });
leaveBreadcrumb('Opened settings modal', 'info', 'user');
try { riskyThing(); } catch (e) { notify(e); }errorsIntegration(opts)
| Option | Type | Default | Notes |
|---|---|---|---|
| captureGlobalErrors | boolean | true | Hook window.onerror. |
| captureUnhandledRejections | boolean | true | Hook window.onunhandledrejection. |
| captureConsole | boolean | false | Intercept console.error/warn as events. Also emits matching breadcrumbs. |
| maxBreadcrumbs | number | 50 | Ring-buffer size. |
| beforeSend | (event) => event \| null | — | Sync only. Return null to drop. |
Module-level helpers
These operate on the singleton state established by errorsIntegration().setup(). They are safe to import anywhere — they no-op when the integration is not active.
| Export | Purpose |
|---|---|
| notify(err, { level? }) | Manually capture an Error \| string. level: 'error' \| 'warning' \| 'info' (default error). |
| leaveBreadcrumb(message, level?, category?, data?) | Append breadcrumb. |
| setUser(user \| null) | Attach user info to subsequent events. |
| addFeatureFlag(name, variant) | Tag events with active flag/variant. |
| clearFeatureFlag(name) | Remove a flag. |
| setContext(key, value \| null) | Add/replace/remove a context block. |
| BreadcrumbRing | Class — exposed for advanced ring access. |
| parseStack(error) | Stack-frame parser used internally. |
Integration with web-network
When @koderlabs/tasks-sdk-web-network is registered alongside this package, the last N network entries are attached to every error event automatically — no extra wiring. The network package calls _registerNetworkRing on this module to expose its ring buffer.
Caveats
- Uses module-level singleton state — only one active errors integration per page. Re-init via
init()tears the prior one down cleanly. captureConsole: truewill capture errors logged by your own logger / 3rd-party libs; expect higher volume.notify()never throws. If the integration isn't set up yet the call silently no-ops.beforeSendhere is synchronous (unlike the core SDKbeforeSendwhich can be async).- Stack-frame parsing is regex-based and best-effort. Symbol resolution requires uploading source maps (see
@koderlabs/tasks-sdk-nextjsor@koderlabs/tasks-cli).
Suite overview
Full SDK suite map + platform availability matrix: docs/sdk/overview.md.
License
KoderLabs proprietary. See LICENSE for terms. Use of this package requires a separate signed written agreement with KoderLabs; access alone confers no rights.
Licensing inquiries: [email protected]
