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

@sentry/hub

Package Overview
Dependencies
Maintainers
11
Versions
433
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/hub

Sentry hub which handles global state managment.

  • 7.119.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3M
increased by6.6%
Maintainers
11
Weekly downloads
 
Created

What is @sentry/hub?

The @sentry/hub package is part of the Sentry SDK for JavaScript. It is responsible for managing scopes, breadcrumbs, and client instances. It allows for the isolation of data through the use of multiple hubs and scopes, which is useful in complex applications where different parts of the application might need to report different pieces of context or breadcrumbs.

What are @sentry/hub's main functionalities?

Managing Scopes

This feature allows you to manage scopes, which are used to hold contextual data such as tags, extra information, and breadcrumbs. You can push and pop scopes to control the context data that is sent with events.

{"const { Hub, Scope } = require('@sentry/hub');

const hub = new Hub();
const scope = new Scope();

scope.setExtra('user_id', '12345');
hub.pushScope(scope);
// Perform operations within this scope
hub.popScope(); // Revert to the previous scope"}

Managing Breadcrumbs

Breadcrumbs are a way to record events that happened prior to an issue. This feature allows you to add breadcrumbs to the current scope, which can then be sent along with error reports to help diagnose issues.

{"const { Hub } = require('@sentry/hub');

const hub = new Hub();
hub.addBreadcrumb({
  message: 'User clicked a button',
  category: 'user-interaction',
  level: 'info'
});
// This breadcrumb will be attached to the next captured event"}

Isolating Clients

This feature allows you to create isolated instances of Sentry clients. Each client can have its own configuration and integrations, and you can use multiple clients within the same application for different purposes.

{"const { Hub, Integrations } = require('@sentry/hub');
const Sentry = require('@sentry/node');

const client = new Sentry.NodeClient({
  dsn: 'your dsn',
  integrations: [new Integrations.Http({ tracing: true })]
});

const hub = new Hub(client);
// You can now use this hub to capture events and manage scopes with the associated client"}

Other packages similar to @sentry/hub

FAQs

Package last updated on 14 Aug 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