Socket
Socket
Sign inDemoInstall

@sentry/hub

Package Overview
Dependencies
3
Maintainers
11
Versions
427
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
Created

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

Changelog

Source

7.100.0

Important Changes

Deprecations

This release includes some deprecations. For more details please look at our migration guide.

The deprecation most likely to affect you is the one of BrowserTracing. Instead of new BrowserTracing(), you should now use browserTracingIntegration(), which will also handle framework-specific instrumentation out of the box for you - no need to pass a custom routingInstrumentation anymore. For @sentry/react, we expose dedicated integrations for the different react-router versions:

  • reactRouterV6BrowserTracingIntegration()
  • reactRouterV5BrowserTracingIntegration()
  • reactRouterV4BrowserTracingIntegration()
  • reactRouterV3BrowserTracingIntegration()

See the migration guide for details.

  • feat(angular): Export custom browserTracingIntegration() (#10353)
  • feat(browser): Deprecate BrowserTracing integration (#10493)
  • feat(browser): Export browserProfilingIntegration (#10438)
  • feat(bun): Export bunServerIntegration() (#10439)
  • feat(nextjs): Add browserTracingIntegration (#10397)
  • feat(react): Add reactRouterV3BrowserTracingIntegration for react router v3 (#10489)
  • feat(react): Add reactRouterV4/V5BrowserTracingIntegration for react router v4 & v5 (#10488)
  • feat(react): Add reactRouterV6BrowserTracingIntegration for react router v6 & v6.4 (#10491)
  • feat(remix): Add custom browserTracingIntegration (#10442)
  • feat(node): Expose functional integrations to replace classes (#10356)
  • feat(vercel-edge): Replace WinterCGFetch with winterCGFetchIntegration (#10436)
  • feat: Deprecate non-callback based continueTrace (#10301)
  • feat(vue): Deprecate new VueIntegration() (#10440)
  • feat(vue): Implement vue browserTracingIntegration() (#10477)
  • feat(sveltekit): Add custom browserTracingIntegration() (#10450)
Profiling Node

@sentry/profiling-node has been ported into the monorepo. Future development for it will happen here!

  • pkg(profiling-node): port profiling-node repo to monorepo (#10151)

Other Changes

  • feat: Export setHttpStatus from all packages (#10475)
  • feat(bundles): Add pluggable integrations on CDN to Sentry namespace (#10452)
  • feat(core): Pass name & attributes to tracesSampler (#10426)
  • feat(feedback): Add system-ui to start of font family (#10464)
  • feat(node-experimental): Add koa integration (#10451)
  • feat(node-experimental): Update opentelemetry packages (#10456)
  • feat(node-experimental): Update tracing integrations to functional style (#10443)
  • feat(replay): Bump rrweb to 2.10.0 (#10445)
  • feat(replay): Enforce masking of credit card fields (#10472)
  • feat(utils): Add propagationContextFromHeaders (#10313)
  • fix: Make startSpan, startSpanManual and startInactiveSpan pick up the scopes at time of creation instead of termination (#10492)
  • fix(feedback): Fix logo color when colorScheme is "system" (#10465)
  • fix(nextjs): Do not report redirects and notFound calls as errors in server actions (#10474)
  • fix(nextjs): Fix navigation tracing on app router (#10502)
  • fix(nextjs): Apply server action data to correct isolation scope (#10514)
  • fix(node): Use normal require call to import Undici (#10388)
  • ref(nextjs): Remove internally used deprecated APIs (#10453)
  • ref(vue): use startInactiveSpan in tracing mixin (#10406)

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 06 Feb 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