Breadcrumbs
Each browser error carries the steps your app took before it: the 50 most recent navigations, clicks, console warnings and errors, and requests. Vigilon shows them as a trail under the error's stack trace.
What is recorded
Navigation: path changes through the History API, as the path before and after. Client-side routers go through it, the Next.js App Router, React Router, and TanStack Router included.
Click: the clicked element as a selector, such as button#save.btn.primary: its tag, its id, and up to two classes.
Console: console.warn and console.error calls, as their first argument.
Fetch and XHR: the method, the URL without its query string or fragment, the status, and the duration. The status is 0 when the request failed or was cancelled. A 4xx response is recorded as a warning, and a 5xx or failed request as an error. The SDK's own requests to Vigilon are never recorded.
Each error carries at most 50 breadcrumbs and 16 KB of them; the oldest are dropped first.
What is never recorded
Breadcrumbs follow the same privacy rules as the rest of an event, and Vigilon applies them again when it receives the error:
Clicks never include the element's text, so a button's label or a typed value stays in the page.
Every URL and path loses its query string, its fragment, and any user:password@, including URLs inside console messages.
Data keys that look like a credential, such as password, token, secret, authorization, or cookie, are dropped, and an object logged to the console loses keys like these.
Only the first argument of a console call is kept, and console.log, console.info, and console.debug are not recorded unless you turn them on.
Apart from their URLs, console messages are free text and carry whatever your code logged. If your warnings can contain personal data, scrub them in beforeBreadcrumb, or turn console breadcrumbs off.
Add your own
Record a step of your own with addBreadcrumb:
import { addBreadcrumb } from "@vigilon/browser";
addBreadcrumb({ message: "checkout started", data: { step: 1 } });
A breadcrumb you add has the category custom unless you set one. data takes up to 8 entries of strings, numbers, and booleans. With React or Next.js, import addBreadcrumb from @vigilon/react or @vigilon/nextjs.
Choose what is recorded
Turn sources off, or record more console levels, with the breadcrumbs option of init:
init({
// ...
breadcrumbs: { console: ["log", "warn", "error"], xhr: false },
});
Each source (navigation, click, console, fetch, xhr) is on unless set to false. console also takes true for every level, or a list of levels; the default is ["warn", "error"]. breadcrumbs: false turns automatic breadcrumbs off, and addBreadcrumb still works.
Edit or drop breadcrumbs
beforeBreadcrumb sees each breadcrumb as it is recorded. Return it, an edited copy, or null to drop it:
init({
// ...
beforeBreadcrumb(breadcrumb) {
if (breadcrumb.category === "console" && breadcrumb.message) {
const message = breadcrumb.message.replace(
/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,
"[email]",
);
return { ...breadcrumb, message };
}
return breadcrumb;
},
});
A breadcrumb whose hook throws is dropped. The SDK scrubs each breadcrumb again after your hook, so the hook cannot put a query string back.