API reference

@fixback/sdk reference

The complete API of @fixback/sdk. For a narrative walkthrough, see the Web SDK guide.

Exports

ts
import { init, Fixback, LAUNCH_EVENT } from "@fixback/sdk";const fixback = await init({ key: "pk_live_…" });await fixback.signIn();   // open ConnectFixback.captureException(error);   // report an error your app caughtfixback.destroy();
  • init(options) — boots the SDK; returns a Promise resolving to an instance.
  • Fixback — a module-level object with signIn() / signOut() / identity() and captureException() / captureMessage() that delegate to the most recent init instance, so a host app can start a Connect, or report an error it caught, from anywhere.
  • LAUNCH_EVENT — the name of the fixback:launch event the SDK dispatches when the launcher is activated — see the launch event.

init(options)

Returns a promise that resolves to an instance. All options other than key are optional. Calling it again is safe — see calling init more than once.

OptionTypeDefaultDescription
keystring—The publishable key of one of your Project's environments (an identifier, not a secret). It decides which environment reports land in and whose Gate applies — there is no environment option.
apiUrlstringhttps://api.fixback.devThe Fixback API origin. Override for a self-hosted or local deployment.
hostIdentitystring—A Host identity token minted by your server with a secret key of the same environment as key, for trusted reporters that already have a login.
anonymousIdstringa persisted per-browser idA stable first-party id for an anonymous reporter.
targetHTMLElementdocument.bodyWhere to mount the launcher.
reduceMotionbooleanfalseStill the launcher's pulse and motion, and the Walkthrough recorder's (a short fade stands in). The OS reduced-motion setting does the same on its own.
draggablebooleantrueLet the visitor drag the Feedback pill to any of the four screen corners, where it snaps; the corner is remembered per key. Set false to pin it, e.g. when your page positions it itself.
position"bottom-right" · "bottom-left" · "top-right" · "top-left""bottom-right"The corner the launcher sits in, and the report panel opens from. A corner the visitor dragged to still wins — see customizing the widget.
text{ launcher?, title?, placeholder?, send?, sent?, sentDetail? }the SDK's own wordingReword the launcher's label, the panel's heading and comment placeholder, Send, and the confirmation — see customizing the widget.
autoCapturebooleantrueAutomatic error capture — file uncaught errors with no prompt, from the moment init runs. Set false to turn it off, including for visitors the Gate turns away when the environment captures errors from every visitor. captureException still files for a visitor who can report.
capture{ console?, network?, replay? }served per-projectConsole / network Trace capture and session replay. On by default and normally governed per-project; set a stream here to override (e.g. { network: false }).
propagateTostring[][] — same-origin onlyCross-origin APIs that also receive the Correlation id header, as origins — e.g. ["https://api.example.com"]. Same-origin requests always carry it.
traceparentSampledbooleantrueWhether that header claims sampled (01) or not (00). A parent-based OpenTelemetry sampler on your backend follows it — see the sampled flag.
enabledbooleantrueMaster switch. false mounts nothing and captures nothing — keep the call in place and switch it off per build, e.g. in local dev.
releasestring—The build identifier of the running app. Match it to the release you upload sourcemaps under so errors symbolicate.
scrubbooleantrueRun the built-in URL / PII scrubbers before beforeSend.
beforeSend(report) => report | null—Reshape or drop (null) any report before transport. Not called for a Walkthrough's uploads, which stream pieces, not reports.
beforeBreadcrumb(crumb) => crumb | null—Filter or edit Trace entries at the source — including every crumb a Walkthrough streams.
trace{ budgets?, maxAgeMs?, consoleLevels? }SDK defaultsTune the Trace ring buffer. maxAgeMs takes one number for every stream or a per-stream record (network 3 min, console and breadcrumbs 15). To turn a stream off, use capture.
replay{ windowMs?, … }SDK defaultsTune the buffered session-replay window. To turn replay off, use capture.replay.

Calling init more than once

init is idempotent, so React StrictMode, hot module reloading and a re-rendered root can call it again without the SDK installing a second set of listeners — which would file every error twice.

  • The same key resolves to the instance already running (or still booting). Its options are not applied again, and a development build says so once in the console. To start over with new options, call destroy() on the instance, then init again.
  • A different key tears the running instance down before the new one starts.
  • No key (an unset variable) or enabled: false leaves a running instance alone.

The Correlation id

Every fetch and XMLHttpRequest the SDK records to your own origin goes out with a freshly minted W3C traceparent header (00-<32-hex id>-<16-hex parent>-01, or -00 with traceparentSampled: false), and the request's network entry records that 32-hex id. When your backend runs @fixback/node or the .NET SDK, it adopts the same id for any error the request causes, so the browser Issue for a failed request and the server Issue behind it show the same Correlation id — in the expanded request row of one and the server request row of the other — and Fixback links the two: the browser Issue names the server error behind its request, and the server Issue lists the browser Issues it was seen from, whichever was captured first.

A cross-origin API receives the header only when you list its origin:

ts
await init({  key: "pk_live_…",  // Your API on another origin — it must allow the header in its CORS preflight.  propagateTo: ["https://api.example.com"],});
  • Why opt-in cross-origin: a custom header makes the browser send a CORS preflight, so the listed API must answer it with Access-Control-Allow-Headers: traceparent. Nothing cross-origin is touched by default, so a third-party API never sees a preflight it would refuse.
  • Entries are bare origins — scheme://host[:port]. A path, a query, or a wildcard makes an entry mean something the SDK does not do, so it is ignored with a console warning.
  • Never breaks a request. The SDK never reads a header value and never overrides one: a traceparent your app or its tracer already set (OpenTelemetry's, say) is left alone, and that request records no id. A request whose header cannot be set — a no-cors request, a Request with immutable headers — simply goes out without it. And a fetch or XMLHttpRequest call the SDK cannot read (no arguments, an object whose toString throws) goes to the browser exactly as made, to succeed or fail as it would have.
  • The sampled flag is 01 by default — see below for what that means to a parent-based sampler, and when to turn it off.
  • sendBeacon cannot carry a header, so beacons are never stamped; with network capture off (capture: { network: false }) nothing is injected at all.
  • Repeats keep their ids. A captured error that happens again is counted and sent later as a light update with no Trace; that update carries just the Correlation ids of the requests made before the repeats, so Fixback records every occurrence's requests, not only the first one's.
  • The id is random: it identifies one request, never a person or a session.

The sampled flag

A traceparent also carries a sampled flag, and a backend running OpenTelemetry with a parent-based sampler — the common default in Node and ASP.NET Core setups — obeys it for every request that arrives with one:

  • 01, sampled (the default). The backend traces every request the page sends it, whatever its own sampling rate, so each browser-originated request shows up in your APM with the page as its parent. On a busy site this can multiply the traces your APM records and bills for.
  • 00, not sampled — traceparentSampled: false. A parent-based sampler with its default settings then traces none of those requests. To have your own sampler decide for them instead, configure its "remote parent not sampled" case to use your root sampler (OpenTelemetry's ParentBasedSampler takes remoteParentNotSampled in JavaScript and .NET alike).
ts
await init({  key: "pk_live_…",  // Let your backend's sampler decide; the Correlation id is unchanged.  traceparentSampled: false,});

Turn it off when browser-originated traces should not be forced on — your APM bill is driven by page traffic, or your backend already samples to a rate it wants to keep. The Correlation id is the same either way: the Node and .NET SDKs read the id, never the flag, so browser and server Issues link exactly as before. A backend with no OpenTelemetry, or with a sampler that ignores its parent, is unaffected.

The instance & Fixback

init resolves to an instance; the module-level Fixback object exposes the same Connect and capture methods against the most recent instance. Its captureException and captureMessage reach the instance from the moment init is called, before its promise resolves.

MemberDescription
destroy()Tears the launcher and overlay down and removes the SDK's handlers. The next init then starts afresh.
signIn()Open Connect — the platform's connect page in a popup (a full redirect when it is blocked) — and bind the person's Account to this site as a Reporter session. Resolves to the resulting identity.
signOut()Revoke the Reporter session and forget the token — the person becomes anonymous again.
identity()The current identity: { status: "anonymous" } or { status: "connected", name, email, tier }.
captureException(error, options?)Report an error your app caught — see reporting errors.
captureMessage(message, options?)Report a message as an Issue — see reporting errors.

Reporting errors: captureException & captureMessage

ts
Fixback.captureException(error);                     // "Captured"Fixback.captureException(error, { handled: false }); // "Uncaught"Fixback.captureMessage("Checkout took 9s", { level: "warning" });

Both file a source: error Issue through the same path as an uncaught error: the Trace and masked replay as they stood when it was reported, the same dedup (one Issue for a caught error and an uncaught one with the same fingerprint), the same burst limiter and per-session cap, and beforeSend after the default scrub. Neither returns anything or ever throws. The narrative and framework examples are in Report errors you catch.

CallOptionDefaultDescription
captureException(error)handledtrueThe Issue reads Captured. Pass false for an error that stands in for a crash (an error boundary's fallback) and it reads Uncaught. error can be anything thrown; an Error keeps its name, message and stack. An error reported and then rethrown is filed once, and so is one the SDK already caught uncaught.
captureException(error)componentStack—The component stack React reported the error with (errorInfo.componentStack). It rides with the error's first report, at most 50 lines and 8 KB, each line's script URL scrubbed like a stack frame's, and the Issue shows it under the error. beforeSend sees it as report.componentStack. @fixback/react passes it for you.
captureMessage(message)level"info""fatal", "error", "warning", "info" or "debug": the level of the entry the message leaves in its Trace. The message is filed under the name Message and grouped by its text, every number collapsed.
bothfingerprint—A custom fingerprint, string[]: what the error groups by instead of the fingerprint the SDK computed, which "{{ default }}" stands for — ["{{ default }}", tenantId] splits the usual grouping, ["payment-provider-down"] replaces it. beforeSend sees it as report.fingerprint and may change it. See Grouping.
  • When they file. Where an uncaught error would: for a visitor who can report, and for any visitor when the environment captures errors from every visitor. One reported before Fixback has answered init's check is held until it does, and discarded if Fixback turns the visitor away or can't be reached. Before init, after destroy(), or with enabled: false they do nothing.
  • Busy or unreachable. When Fixback asks the SDK to slow down, the report waits for the time it names; when Fixback can't be reached, the SDK tries again later. The report it sends then still carries the Trace and replay from when the error happened.

Page shortcuts

The launcher listens for a few shortcuts from anywhere on the page, in the capture phase, so a menu your page has open survives them. The Reporter turns them all off with the Page shortcuts switch in the panel's settings.

ShortcutWhat it does
⌥ ⇧ FOpen the report panel.
⌥ ⇧ EOpen it and pick an element. While a Walkthrough records: Pick.
⌥ ⇧ SOpen it and capture a screenshot. While a Walkthrough records: Circle.
⌥ ⇧ WStart a Walkthrough — only for a Reporter who may start one.

While a Walkthrough records, the single keys P (Pick), C (Circle), Z (remove the last mark) and Esc (leave the tool) work too — never while focus is in a field, so your page's inputs keep every key. See Marking, and the keys.

Customizing the widget

You can move the widget, reword it, and restyle it. Placement and wording are init options. The look is plain CSS on your page.

ts
await init({  key: "pk_live_…",  position: "bottom-left", // your page's chat bubble holds bottom-right  text: {    launcher: "Report a bug",    title: "Tell us what broke",    placeholder: "What happened?",  },});

Where it sits

position picks the corner the launcher docks to, and the report panel opens from it. Move it when your page already uses bottom-right, for example for a chat bubble, a cookie banner or a sticky checkout bar. position sets the starting corner. A visitor can still drag the pill to another corner, and the corner they choose is remembered per key and wins over position. Pass draggable: false as well to keep the launcher in your corner.

What it says

Set only the strings you want to change. Each one is shown as text and is never parsed as HTML. A string that is missing or empty keeps its default, and a field the widget doesn't have is ignored with a console warning.

FieldDefaultWhere it shows
launcherFeedbackThe pill's label. It also becomes the pill's accessible name and appears in the first-visit welcome. A long label is cut off with an ellipsis.
titleSend feedbackThe panel's heading, and the panel's accessible name.
placeholderA bug, an idea, something that could be better…The comment field.
sendSendThe Send button.
sentFeedback sentThe confirmation's heading.
sentDetailThanks — the team can see it now.The line under it.

The rest of the widget's wording (hints, the settings menu, error messages, the Walkthrough) is not configurable.

How it looks: theme properties

The widget renders in a Shadow DOM, so your page's CSS cannot accidentally break it. It also means your selectors cannot reach the widget's internal class names, and those names are not a stable API. Instead, set these custom properties on :root or on the widget's host elements. Custom properties pass through the Shadow DOM, so one value reaches every part of the widget that uses it: the launcher, the panel, the open and close animation, and the Walkthrough.

PropertyDefaultWhat it sets
--fixback-accent#2f6fedThe accent: the pill, Send, and every accent glow, ring and tint.
--fixback-accent-hover#245fd0The accent, hovered.
--fixback-on-accent#ffffffText and icons on the accent. Set it to a dark colour for a light accent.
--fixback-fontIBM Plex Sans, then the system sansThe widget's font stack.
--fixback-launcher-radius999px (a full pill)The launcher pill's corner radius.
--fixback-panel-radius14pxThe report panel's corner radius.
css
:root {  --fixback-accent: #e11d48;  --fixback-accent-hover: #be123c;  --fixback-launcher-radius: 8px;  --fixback-panel-radius: 6px;}

The accent's glows, rings and light tints are mixed from --fixback-accent with color-mix(). In a browser that doesn't support it (Chrome before 111, Safari before 16.2, Firefox before 113), those details keep Fixback's blue. The accent itself still changes. The Fixback logo in the panel header keeps its own colours.

How it looks: parts

For anything the theme properties don't cover, the widget exposes these elements to ::part(). Select launcher parts through [data-fixback-root] and panel parts through [data-fixback-overlay].

HostPartElement
[data-fixback-root]launcherThe Feedback pill (its ground, radius and shadow).
launcher-buttonThe pill's main button (icon and label).
launcher-labelThe pill's label text.
launcher-dividerThe rule between the button and the tuck control.
launcher-tuckThe chevron that tucks the pill away.
launcher-nubThe edge tab that brings a tucked pill back.
launcher-welcomeThe first-visit welcome toast.
[data-fixback-overlay]panelThe report panel (its ground, border, radius and shadow).
panel-headerThe header row.
panel-titleThe panel's heading.
panel-closeThe header's ✕.
commentThe comment field.
add-buttonThe Add element and Add screenshot buttons.
send-buttonThe Send button.
confirmationThe confirmation shown once a report is sent.
css
[data-fixback-root]::part(launcher) {  box-shadow: 0 2px 6px rgb(0 0 0 / 0.2);}[data-fixback-overlay]::part(comment),[data-fixback-overlay]::part(send-button) {  border-radius: 4px;}[data-fixback-overlay]::part(send-button):hover {  filter: brightness(1.1);}

The launch event

Activating the launcher dispatches a bubbling, composed fixback:launch (LAUNCH_EVENT) from the SDK's host element, so listeners outside its Shadow DOM hear it. Its detail says how:

  • via — "click" for the pill, "shortcut" for a page shortcut.
  • action — for a shortcut, which one: "open" (⌥ ⇧ F), "pick" (⌥ ⇧ E), "capture" (⌥ ⇧ S) or "walkthrough" (⌥ ⇧ W).

Connect

A reporter is an Account. The overlay's identity chip shows "Anonymous · Sign in"; clicking it (or calling Fixback.signIn()) opens the platform's connect page, signs the person in with Google, GitHub, Apple, or an email magic link, and returns them to your page as their Account — the chip then shows their name and tier. Behind an Invited or Internal Gate nothing is shown to a signed-out visitor; entry is a Fixback-issued link's ?fixback= code or a host call to Fixback.signIn().

ts
await init({ key: "pk_live_…" }); // mounts the launcher + identity chip where the key's environment is Open// From your own UI, e.g. a "Report a bug" menu item behind an Invited or Internal Gate:await Fixback.signIn();