Socket
Socket
Sign inDemoInstall

@sentry/hub

Package Overview
Dependencies
3
Maintainers
11
Versions
416
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/hub

Sentry hub which handles global state managment.


Version published
Maintainers
11
Weekly downloads
3,278,262
decreased by-7.91%

Weekly downloads

Package description

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

Readme

Source

Sentry

Sentry JavaScript SDK Hub

npm version npm dm npm dt

General

This package provides the Hub and Scope for all JavaScript related SDKs.

FAQs

Last updated on 22 Mar 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc