Docs · JavaScript (browser)

SDKs

JavaScript (browser)

Bugzor works with the open-source @sentry/browser SDK and the framework packages built on it (@sentry/react, @sentry/vue, @sentry/svelte, @sentry/angular). Tested with @sentry/browser 11.12 (CDN bundle) in Chromium.

Install#

Terminal
npm install @sentry/browser

Configure#

Initialize Sentry before the rest of your app loads, in your entry file:

src/main.js
import * as Sentry from "@sentry/browser";

Sentry.init({
  dsn: "https://<public-key>@www.bugzor.com/<project-id>",
  environment: "production",
  release: "my-site@1.0.0",
  // Traces land in Rich Trace Logs; sample them to stay within your plan's storage.
  tracesSampleRate: 0.1,
});

The SDK reports uncaught errors and unhandled promise rejections, with breadcrumbs for clicks, console messages, navigation and network requests.

The DSN’s public key can only send events, so it’s fine to ship it in your bundle. Use rate limits on the key to cap what a misbehaving page can send.

Without a bundler#

Load the SDK from a CDN and call Sentry.init the same way. Pin the version you tested with and use subresource integrity: Sentry publishes the hashes for each version in its release notes.

HTML
<script src="https://browser.sentry-cdn.com/11.12.0/bundle.min.js" crossorigin="anonymous"></script>
<script>
  Sentry.init({ dsn: "https://<public-key>@www.bugzor.com/<project-id>" });
</script>

Frameworks#

Use the framework package instead of @sentry/browser. The init call is the same, with the Bugzor DSN:

JavaScript
// React
import * as Sentry from "@sentry/react";
Sentry.init({ dsn: "https://<public-key>@www.bugzor.com/<project-id>" });

// Vue 3
import * as Sentry from "@sentry/vue";
Sentry.init({ app, dsn: "https://<public-key>@www.bugzor.com/<project-id>" });

For Next.js, Nuxt, SvelteKit and Remix, follow the framework SDK’s own setup and set the DSN it asks for to your Bugzor DSN.

Capture errors and messages#

JavaScript
try {
  checkout();
} catch (err) {
  Sentry.captureException(err);
}

Sentry.captureMessage("Payment form took more than 5s", "warning");

Add context#

JavaScript
Sentry.setUser({ id: "42", email: "ann@example.com" });
Sentry.setTag("plan", "raptor");
Sentry.addBreadcrumb({ category: "cart", message: "Added item", level: "info" });

Filter noise#

Browser extensions and third-party scripts throw errors you can’t fix. Drop them before they’re sent:

JavaScript
Sentry.init({
  dsn: "https://<public-key>@www.bugzor.com/<project-id>",
  ignoreErrors: ["ResizeObserver loop limit exceeded"],
  allowUrls: [/https:\/\/(www\.)?example\.com/],
});

Content Security Policy#

If your site sets a CSP, allow the Bugzor host in connect-src:

Text
Content-Security-Policy: connect-src 'self' https://www.bugzor.com

Bugzor answers CORS preflight requests, so no other setup is needed.

Minified stack traces#

Bugzor doesn’t apply source maps yet, so production stack traces show minified file names and positions. Uploading source maps is on our roadmap.

Something unclear or out of date? Tell us.