02
Widget
The widget key is public. Reporters never need a ChangeBox account.
npm install @changebox/react
<ChangeBox appKey="cb_live_xxxxxxxxx" />
ChangeBox.setContext({
accountId: "acct_123",
plan: "pro"
})One sentence in, a real report out
The form is one box. The reporter types what happened and presses Send; the panel turns into a short conversation. ChangeBox already has the page, the URL, the browser, the viewport, the release, the last clicks and navigations, and any console errors, so it never asks for those. It asks only what it cannot see, as tappable cards: which control (the reporter points at it on the page), what they expected, whether it happens every time, the steps. It stops at the number of questions you set on the app (the intake field on the app's object, default 3) or sooner when a builder could already reproduce it. Then it writes the report, shows it back, and one tap sends it.
Two kinds of people report bugs, and the assistant reads which one it has. Someone who types a line and wants to walk away gets the quick register: one or two cards, never a request for criteria or severity, and Just send it on every card. A tester or engineer who writes steps, expected and actual gets the deep register on their own: acceptance criteria (proposed, then edited), how often it happens, whether it used to work, a workaround, their setup, with a higher ceiling of eight cards and every field editable on the final card. Anyone can switch with Go deeper, including from the finished draft. Criteria the reporter writes go into the Change Spec first, so the Verifier checks what the tester asked for.
If a recent change on the app describes the same thing, the first card asks whether it is the same problem; a yes files a +1 on that change instead of a duplicate, and the change appears in that reporter's My Changes so they can verify it too. Every model call runs through Closure as changebox-intake; when a call is held, capped or fails, the plain sentence files as typed and nothing waits on the model. Set the question count to 0 to turn the assistant off.
// Headless, with @changebox/sdk
const { sessionId, step } = await cb.intakeStart("Save does nothing on the billing page", { screenshots: 0 });
// step.kind: "ask" (render step.question) | "ready" (show step.draft) | "plain" (file now)
let next = await cb.intakeAnswer(sessionId, { questionId: step.question.id, choice: "Every time" });
next = await cb.intakeDeepen(sessionId); // the QA register: criteria, how often, regression, workaround, setup
const filed = await cb.intakeFile(sessionId, { edits: { impact: "broken", acceptanceCriteria: ["Save stores the plan"] } });
// filed.change.publicId → "CB-42"; filed.sameAs → "CB-31" when it went in as a +1Who is reporting
Your app knows who is signed in; ChangeBox does not. Sign a short-lived statement about the current user on your server with the app's identity secret (the app's Install screen → Identity signing), then hand it to the widget. ChangeBox verifies the signature, attaches the person to the report, enforces Who can report, and lets people with the approver role approve from inside your app.
// Server (Node, Bun, Workers): never ship the secret to the browser.
import { signHostIdentity } from "@changebox/shared";
const identity = await signHostIdentity({
secret: process.env.CHANGEBOX_IDENTITY_SECRET,
appKey: "cb_live_xxxxxxxxx",
id: user.id,
email: user.email,
name: user.name,
permitted: user.isTester || user.isStaff, // may report on this app
trustedForAutoBuild: user.isStaff, // agents may start without a human first
roles: user.isAdmin ? ["approver"] : [], // capped by the app's allowed host roles
ttlSeconds: 3600, // max 86400; sign again on each page load
});
// Browser: pass it through unchanged.
ChangeBox.identify(identity);
// or, without the widget: POST /api/widget/report with { ..., identity }Who can report is set per app. Anyone on the page accepts unsigned reports as anonymous. Signed-in users requires a verified identity. Users the host permits also requires permitted: true. This organization only requires the signed email to belong to a member. Anything else is refused with 401 and a plain message the widget shows. An environment can opt out with Allow reports without a signed identity here, which is how a Local environment stays usable while production is locked down.
Rotating the secret invalidates every outstanding statement at once. The legacy unsigned-expiry form (id:email:name HMAC) is still verified but carries no permitted or roles.
Headless SDK
The widget is @changebox/sdk with a face. If your app already has a place for feedback, use the client directly: same reporter token, same endpoints, no floating button. It is also served as an ES module at /sdk.js.
import { createChangeBox } from "@changebox/sdk"; // or: from "https://changebox.ai/sdk.js"
const cb = createChangeBox({ appKey: "cb_live_xxxxxxxxx", apiUrl: "https://changebox.ai" });
cb.identify(identity); // from signHostIdentity on your server
cb.setContext({ release: build.sha, screen: "editor" });
cb.autoBreadcrumbs(); // clicks, route changes, errors → context.breadcrumbs
const { change, ticketUrl } = await cb.report({
description: "Save does nothing after the second edit",
expected: "The draft saves",
impact: "broken",
screenshots: [file], // File, Blob, or data URL; up to 6
});
const mine = await cb.mine(); // this browser's changes, newest first
await cb.confirm(change.id); // once it is live
await cb.reopen(change.id, "Still broken on Safari");
cb.subscribe((event) => { /* reported · mine · verified · error */ });In React, wrap your tree in ChangeBoxProvider and build the panel from hooks. Everything made through the same client stays in sync: a report refreshes useMyChanges, a confirm updates the list.
import { ChangeBoxProvider, useMyChanges, useReport, useVerify } from "@changebox/react";
<ChangeBoxProvider options={{ appKey: "cb_live_xxxxxxxxx" }} identity={identity} context={{ release }}>
<FeedbackPanel />
</ChangeBoxProvider>
function FeedbackPanel() {
const { visible, liveCount, counts } = useMyChanges({ filter: "live" });
const { report, sending, error } = useReport();
const { confirm, reopen } = useVerify();
// ...your markup
}The stock widget exposes the same client as window.ChangeBox.client, so a host can add breadcrumbs or file a change programmatically while keeping the panel.
Approvals without leaving your app
Approvers should never have to log in to changebox.ai. Sign their identity with roles: ["approver"](or an email that belongs to an approver in your org) and the widget shows an Approvals tab with the Build and Ship gates waiting on them. Approve or send back with a note; the decision lands on the change with their name and via widget. Signed-in members can try it on your app's Try page before your backend signs identities.
// server
const identity = await signHostIdentity({ secret, appKey, id: user.id, email: user.email, name: user.name, roles: ["approver"] });
// client (headless)
const viewer = await cb.handshake(); // { name, member, canApprove, canBuild }
const pending = await cb.approvals(); // [{ id, gate: "build" | "ship", change, requestedAt }]
await cb.decide(changeId, "ship", "approve", "Checked the preview.");
// React
const { approvals } = useApprovals({ pollMs: 60_000 });
const { approve, reject } = useDecide();