Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sentry/bun

Package Overview
Dependencies
Maintainers
0
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/bun

Official Sentry SDK for bun

  • 8.44.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18K
increased by1.47%
Maintainers
0
Weekly downloads
 
Created
Source

Sentry

Official Sentry SDK for Bun (Beta)

npm version npm dm npm dt

The Sentry Bun SDK is in beta. Please help us improve the SDK by reporting any issues or giving us feedback.

Usage

To use this SDK, call init(options) as early as possible in the main entry module. This will initialize the SDK and hook into the environment. Note that you can turn off almost all side effects using the respective options.

// CJS Syntax
const Sentry = require('@sentry/bun');
// ESM Syntax
import * as Sentry from '@sentry/bun';

Sentry.init({
  dsn: '__DSN__',
  // ...
});

To set context information or send manual events, use the exported functions of @sentry/bun. Note that these functions will not perform any action before you have called init():

// Set user information, as well as tags and further extras
Sentry.setExtra('battery', 0.7);
Sentry.setTag('user_mode', 'admin');
Sentry.setUser({ id: '4711' });

// Add a breadcrumb for future events
Sentry.addBreadcrumb({
  message: 'My Breadcrumb',
  // ...
});

// Capture exceptions, messages or manual events
Sentry.captureMessage('Hello, world!');
Sentry.captureException(new Error('Good bye'));
Sentry.captureEvent({
  message: 'Manual',
  stacktrace: [
    // ...
  ],
});

It's not possible to capture unhandled exceptions, unhandled promise rejections now - Bun is working on adding support for it. Github Issue follow this issue. To report errors to Sentry, you have to manually try-catch and call Sentry.captureException in the catch block.

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

try {
  throw new Error('test');
} catch (e) {
  Sentry.captureException(e);
}

FAQs

Package last updated on 12 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc