@xrayradar/browser
v0.2.0
Published
XrayRadar SDK for browser
Maintainers
Readme
@xrayradar/browser
XrayRadar SDK for the browser – capture errors and messages and send them to your XrayRadar server. Uses fetch and automatically hooks into window.onerror and unhandledrejection.
Install
npm install @xrayradar/browserQuick start
import { init, captureException, captureMessage } from "@xrayradar/browser";
init({
dsn: "https://xrayradar.com/your_project_id",
authToken: "your-token",
// Optional: enable auto-instrumentation (fetch/XHR/history/console)
// integrations: true,
});
captureException(new Error("Something broke"));
captureMessage("Something happened");Configuration
init(options) supports:
dsn:https://xrayradar.com/your_project_idauthToken: sent asX-Xrayradar-Token- If omitted, the browser transport also checks
globalThis.XRAYRADAR_AUTH_TOKEN
- If omitted, the browser transport also checks
debug: log captured payloads toconsole.warnenvironment,release,serverNamesampleRate: number in ([0, 1])maxBreadcrumbsbeforeSend(event): return modified event,nullto drop, or aPromisetransport: custom transport implementingsendEvent(event)(disables built-in global handlers)integrations: enable auto-instrumentation (see below)
Integrations (optional)
Enable all integrations with one flag:
import { init } from "@xrayradar/browser";
init({
dsn: "https://xrayradar.com/your_project_id",
authToken: "your-token",
integrations: true,
});Or configure them individually:
init({
dsn: "https://xrayradar.com/your_project_id",
authToken: "your-token",
integrations: {
fetch: { breadcrumbs: true, captureErrors: true },
xhr: { breadcrumbs: true, captureErrors: true },
history: true,
console: true,
},
});For React (ErrorBoundary, Provider, hooks), use @xrayradar/react. Full docs: XrayRadar-JS-SDK.
