Socket
Socket
Sign inDemoInstall

@sentry/hub

Package Overview
Dependencies
3
Maintainers
11
Versions
429
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
Weekly downloads
3M
decreased by-1.75%
Maintainers
11
Created
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

Changelog

Source

7.93.0

Important Changes

Deprecations

As we're moving closer to the next major version of the SDK, more public APIs were deprecated.

To get a head start on migrating to the replacement APIs, please take a look at our migration guide.

  • feat(core): Deprecate getActiveTransaction() & scope.getTransaction() (#10098)
  • feat(core): Deprecate Hub.shouldSendDefaultPii (#10062)
  • feat(core): Deprecate new Transaction() (#10125)
  • feat(core): Deprecate scope.getSpan() & scope.setSpan() (#10114)
  • feat(core): Deprecate scope.setTransactionName() (#10113)
  • feat(core): Deprecate span.startChild() (#10091)
  • feat(core): Deprecate startTransaction() (#10073)
  • feat(core): Deprecate Transaction.getDynamicSamplingContext in favor of getDynamicSamplingContextFromSpan (#10094)
  • feat(core): Deprecate arguments for startSpan() (#10101)
  • feat(core): Deprecate hub capture APIs and add them to Scope (#10039)
  • feat(core): Deprecate session APIs on hub and add global replacements (#10054)
  • feat(core): Deprecate span name and description (#10056)
  • feat(core): Deprecate span tags, data, context & setters (#10053)
  • feat(core): Deprecate transaction metadata in favor of attributes (#10097)
  • feat(core): Deprecate span.sampled in favor of span.isRecording() (#10034)
  • ref(node-experimental): Deprecate lastEventId on scope (#10093)
Cron Monitoring Support for node-schedule library

This release adds auto instrumented check-ins for the node-schedule library.

import * as Sentry from '@sentry/node';
import * as schedule from 'node-schedule';

const scheduleWithCheckIn = Sentry.cron.instrumentNodeSchedule(schedule);

const job = scheduleWithCheckIn.scheduleJob('my-cron-job', '* * * * *', () => {
  console.log('You will see this message every minute');
});
  • feat(node): Instrumentation for node-schedule library (#10086)

Other Changes

  • feat(core): Add span.spanContext() (#10037)
  • feat(core): Add spanToJSON() method to get span properties (#10074)
  • feat(core): Allow to pass scope to startSpan APIs (#10076)
  • feat(core): Allow to pass start/end timestamp for spans flexibly (#10060)
  • feat(node): Make getModuleFromFilename compatible with ESM (#10061)
  • feat(replay): Update rrweb to 2.7.3 (#10072)
  • feat(utils): Add parameterize function (#9145)
  • fix(astro): Use correct package name for CF (#10099)
  • fix(core): Do not run setup for integration on client multiple times (#10116)
  • fix(core): Ensure we copy passed in span data/tags/attributes (#10105)
  • fix(cron): Make name required for instrumentNodeCron option (#10070)
  • fix(nextjs): Don't capture not-found and redirect errors in generation functions (#10057)
  • fix(node): LocalVariables integration should have correct name (#10084)
  • fix(node): Anr events should have an event_id (#10068)
  • fix(node): Revert to only use sync debugger for LocalVariables (#10077)
  • fix(node): Update ANR min node version to v16.17.0 (#10107)

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 10 Jan 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