Skip to content
Bugtail Docs
Menu

Browser JavaScript

Bugtail works with the official Sentry browser SDK. It reports errors, page loads and sessions, and Bugtail adds two things on top: source maps, and a filter that keeps errors from other people's scripts out of your issues.

Install

npm install @sentry/browser

Configure

At the top of your entry point, before the rest of your code runs:

import * as Sentry from '@sentry/browser';

Sentry.init({
    dsn: 'https://<key>@ingest.bugtail.eu/<project-id>',
    release: '[email protected]',
    environment: 'production',
    integrations: [Sentry.browserTracingIntegration()],
    tracesSampleRate: 0.2,
});

Copy the DSN from your collector under Settings > Projects and collectors. The key in it ends up in your bundle, and that is fine: it can only send data to this collector, never read anything back. To stop other sites from sending with it, list your own sites under allowed origins.

tracesSampleRate is the share of page loads and navigations that is traced. Leave out the integration and the rate to report errors only.

Send a test event

Add this line anywhere in your code and load the page:

Sentry.captureMessage('Bugtail test event');

Keep third-party errors out

A public page runs code you did not write: browser extensions, tag managers, chat widgets. Their errors land in the same handler as yours. List the hosts that serve your own scripts under Browser filtering and Bugtail keeps only the errors that pass through your code.

Readable stack traces

Minified code gives unreadable stack traces. Upload your source maps for every release and Bugtail shows the code you wrote. The release in Sentry.init() has to match the release you upload the maps for.

Frameworks

@sentry/react, @sentry/vue, @sentry/angular and the other framework packages are configured the same way, with the same DSN. Their build plugins upload source maps to Sentry itself; use the upload described in Source maps instead.

Release health

The browser SDK tracks sessions by itself and reports whether each one ended in a crash. With a release set, Bugtail turns that into a crash-free rate per release under Releases.