tensorbuzz-api
v0.0.14
Published
JavaScript client for TensorBuzz error reporting with browser, Node, and Expo/React Native support.
Readme
tensorbuzz-api
JavaScript client for TensorBuzz error reporting with browser, Node, and Expo/React Native support.
Install
npm install tensorbuzz-apiUsage
import {BugReporting, debuggerInstance} from "tensorbuzz-api"
const bugReporting = new BugReporting({
authToken: "your-token",
runtimeEnvironment: "browser"
})
bugReporting.connect()You can add deployment/user context to every report:
bugReporting.collectEnvironment(() => ({
release: "2026.05.19",
runtime: "browser"
}))
bugReporting.collectParams(() => ({
accountId: currentAccount?.id,
userId: currentUser?.id
}))Request transport
By default, BugReporting uses XMLHttpRequest when available, otherwise it falls back to fetch. If neither is available, you must provide a request class.
import {BugReporting, NodeRequest} from "tensorbuzz-api"
const bugReporting = new BugReporting({
authToken: "your-token",
hostname: "api.example.com",
postUrl: "https://server.tensorbuzz.com/errors/reports",
runtimeEnvironment: "node",
RequestClass: NodeRequest
})Browser error listeners
import {BugReporting} from "tensorbuzz-api"
const bugReporting = new BugReporting({authToken: "your-token"})
// Optional: enable source map parsing for script tags in web apps.
bugReporting.enableSourceMapsLoader()
bugReporting.connectOnError()
bugReporting.connectUnhandledRejection()Node error listeners
import {BugReporting, NodeRequest} from "tensorbuzz-api"
const bugReporting = new BugReporting({
authToken: process.env.TENSORBUZZ_BUG_REPORT_AUTH_TOKEN,
hostname: process.env.TENSORBUZZ_BUG_REPORT_HOSTNAME,
runtimeEnvironment: "node",
RequestClass: NodeRequest
})
bugReporting.connectNodeUncaughtException()
bugReporting.connectNodeUnhandledRejection()Instance control audits
import {InstanceControlAudits} from "tensorbuzz-api"
const instanceControlAudits = new InstanceControlAudits()
await instanceControlAudits.report({
emittedAt: new Date().toISOString(),
eventType: "action_cable.subscription.rejected",
instanceControlToken: "instance-control-token",
level: "error",
message: "ProjectEnvironmentTerminalSessionsChannel subscription rejected",
metadata: {attempt: 3},
postUrl: "https://server.tensorbuzz.com/errors/instance_control_audits",
projectEnvironmentInstanceId: "instance-id",
projectEnvironmentTerminalSessionId: "terminal-session-id",
projectId: "project-id"
})Expo / React Native error listeners
import {BugReporting} from "tensorbuzz-api"
const bugReporting = new BugReporting({authToken: "your-token"})
bugReporting.connectExpoErrorHandlers()Direct reporting endpoint
Non-JavaScript runtimes can post JSON directly to /errors/reports:
await fetch("https://server.tensorbuzz.com/errors/reports", {
body: JSON.stringify({
auth_token: "your-token",
hostname: "app.example.test",
runtimeEnvironment: "browser",
error: {
backtrace: ["Error: boom", "at checkout.js:10:4"],
environment: {release: "2026.05.19"},
error_class: "CheckoutError",
message: "Checkout failed",
parameters: {orderId: "ord_123"},
url: "https://app.example.test/checkout",
user_agent: navigator.userAgent
}
}),
headers: {"Content-Type": "application/json"},
method: "POST"
})CLI
npx tensorbuzz-api login
npx tensorbuzz-api build-logs --latest-build-group --failinglogin uses browser approval by default: it prints a TensorBuzz URL, you approve the request while signed in (including GitHub-authenticated users), and the CLI stores credentials automatically.
The CLI stores credentials in .tensorbuzz-api/credentials.json at the git root and uses the current branch by default.
For manual token login, pass --auth-token (or TENSORBUZZ_API_AUTH_TOKEN):
npx tensorbuzz-api login --host https://tensorbuzz.example --repo owner/name --auth-token your-project-auth-tokenFor legacy password login, pass --password (and optionally --email, or TENSORBUZZ_API_EMAIL / TENSORBUZZ_API_PASSWORD):
npx tensorbuzz-api login --host https://tensorbuzz.example --repo owner/name --email [email protected] --password your-password