Skip to main content

Bug reporting

Beta

This page documents the Bugsee JavaScript SDK, which is in beta (0.1.x) and can change between betas.

A bug report covers something that is wrong but did not throw. You can open the built-in report dialog in the browser, or send a report from your own code with upload, on every runtime. Crashes and handled exceptions are covered in Crash & error reporting.

All examples use the client returned by launch. Keep it in a module of your own:

bugsee.ts
import { launch } from '@bugsee/bugsee';

export const bugsee = await launch('<your_app_token>');

Capture covers only what runs after launch(), and code that runs earlier is not recorded. Top-level await delays only the modules that import this one: an unrelated app module that your entry file imports next can still run while launch() is pending. Either import this module from every app module that needs the client or capture, or have the entry file load the app after launch settles, with import './bugsee'; await import('./app');.

launch returns a promise in the browser and the client itself on Node.js and Bun. await works for both. Top-level await needs an ES module build targeting ES2022 or newer; see the Quick start for the alternative.

Show the report dialog​

showReportDialog is available in the browser only. It opens a form over the page, sends what the user fills in as a bug report, and resolves with the upload result, or null when the user cancels, a dialog is already open, or the SDK is not running. It never throws into your page.

import { bugsee } from './bugsee';

document.querySelector('#report-bug')?.addEventListener('click', async () => {
const result = await bugsee.showReportDialog({
summary: 'Checkout is broken',
labels: ['checkout'],
theme: 'auto',
});
if (result?.ok) {
console.log('Report sent', result.issueId);
}
});

The recording is frozen the moment you call showReportDialog, before the form appears. What the user types or does while filling in the form is not part of the report.

Dialog options​

Pass these per call.

OptionTypeDefaultDescription
summarystringnonePre-fill the summary.
descriptionstringnonePre-fill the description.
severity'verylow' | 'low' | 'medium' | 'high' | 'critical' | 'blocker'reportDefaultBugPriority (high)Pre-select the severity.
labelsstring[][]Pre-fill the labels.
theme'auto' | 'light' | 'dark''auto'auto follows the system color scheme.
stringsPartial<ReportDialogStrings>EnglishOverride any text in the dialog. This is how you localize it.
cssstringnoneExtra CSS appended inside the dialog's shadow root. Write rules against the bugsee-reporting-dialog-* classes.

Launch options for the form​

These launch options shape the form. They apply to the browser SDK.

OptionTypeDefaultDescription
reportSummaryRequiredbooleanfalseThe user must enter a summary.
reportDescriptionRequiredbooleanfalseThe user must enter a description.
reportEmailRequiredbooleanfalseThe user must enter an email.
reportLabelsEnabledbooleanfalseShow the labels field.
reportLabelsRequiredbooleanfalseRequire at least one label. Only with reportLabelsEnabled.
reportPrioritySelectorEnabledbooleanfalseShow the severity picker.
reportDefaultBugPriorityseverity'high'Severity a bug report starts with.
import { launch } from '@bugsee/bugsee';

export const bugsee = await launch('<your_app_token>', {
reportSummaryRequired: true,
reportLabelsEnabled: true,
reportPrioritySelectorEnabled: true,
});

The email field is the global user identifier. A changed value is saved with setUserIdentifier, and an emptied one is cleared. No format check is applied, because the identifier is often not an email address. See User & session data.

Translate the dialog​

import { bugsee } from './bugsee';

await bugsee.showReportDialog({
strings: {
title: 'Ein Problem melden',
send: 'Senden',
summaryPlaceholder: 'Kurze Zusammenfassung',
},
});

The strings you can override are title, close, summaryPlaceholder, descriptionPlaceholder, labelsPlaceholder, emailPlaceholder, severityLegend, severityLow, severityMedium, severityHigh, severityCritical, severityBlocker, send, sending, summaryRequired, descriptionRequired, emailRequired, labelsRequired, discardTitle, discardBody, discardKeep, discardConfirm and poweredBy.

The dialog fires the BeforeReportShown and AfterReportShown lifecycle events.

Upload a report without UI​

upload sends a bug report straight away. It works on every runtime, and it is neither de-duplicated nor rate limited: every call is a report you or a user asked for. It does run the report handler.

import { bugsee } from './bugsee';

const result = await bugsee.upload({
summary: 'Export produced an empty file',
description: 'The user clicked Export on a project with 3 sheets.',
severity: 'medium',
labels: ['export'],
email: 'user@example.com',
});

if (result.ok) {
console.log('Report', result.issueId);
} else {
console.warn('Upload failed', result.error?.message);
}
OptionTypeDefaultDescription
summarystringnoneShort title.
descriptionstringnoneLonger text.
severityseverityreportDefaultBugPriority (high)verylow, low, medium, high, critical or blocker.
labelsstring[]noneLabels on the issue.
emailstringthe user identifierReporter email.
attachmentsReportAttachmentInput[]noneFiles to attach, see below.

upload resolves with an UploadResult:

FieldTypeDescription
okbooleantrue when the report was accepted.
issueIdstring | undefinedThe id of the created issue.
recordingIdstring | undefinedThe id of the recording.
errorBugseeError | undefinedWhy it failed.

After stop(), or once the collector has switched the SDK off for your app, upload is a silent no-op that resolves { ok: false }. A report that cannot be sent right now is kept in the durable queue and sent on a later launch where the platform persists data; see Privacy: Cleanup.

Attachments​

A report carries up to 3 attachments of up to 3 MB each. An attachment over the limit, a malformed one, and any beyond the third are dropped and reported through the onError launch option. They are never thrown.

import { bugsee } from './bugsee';

const cart = { items: 3, total: 42.5 };

// Bytes of a real image, here fetched from your app. Use any PNG your app produces.
const screenshot = new Uint8Array(await (await fetch('/debug/cart.png')).arrayBuffer());

await bugsee.upload({
summary: 'Wrong total in cart',
attachments: [
{
name: 'Cart state',
data: JSON.stringify(cart, null, 2),
mimeType: 'application/json',
fileName: 'cart.json',
},
{ name: 'Screenshot', data: screenshot, mimeType: 'image/png' },
],
});
FieldTypeDescription
namestringLabel shown for the attachment. Required.
dataUint8Array | stringThe content. A string is encoded as UTF-8.
mimeTypestringDefaults to text/plain for a string and application/octet-stream for bytes.
fileNamestringSuggested download name. Directory parts are stripped. Derived from name when omitted.

To attach a file to every report, or only to some, use addReportAttachment in a callback of the report handler.

caution

Attachment content is not redacted. Keep secrets out of the data you attach.

Freeze the recording first with prepareUpload​

prepareUpload freezes the recording now and returns a handle you can send later. Use it when you collect information from the user first, for example in your own form: the minutes they spend typing do not push the incident out of the rolling window.

import { bugsee } from './bugsee';

async function reportFromMyForm(readForm: () => Promise<{ summary: string } | null>): Promise<void> {
const prepared = bugsee.prepareUpload();
if (prepared === null) {
return; // the SDK is stopped or switched off
}
let form: { summary: string } | null;
try {
form = await readForm();
} catch (error) {
prepared.discard(); // release the frozen recording, then keep the original error
throw error;
}
if (form === null) {
prepared.discard(); // release the frozen recording, send nothing
return;
}
const result = await prepared.send({ summary: form.summary, severity: 'high' });
console.log(result.ok);
}
  • prepareUpload() returns null after stop() or once the SDK is switched off.
  • send(options?) takes the same options as upload. It sends at most once: a second call resolves { ok: false }.
  • discard() releases the frozen recording without sending anything.

The built-in report dialog uses this mechanism.

Found an issue, typo, or wrong statement on this page? Report it now →