The Hub class will be removed in version 8 of the SDK in favour of Scope and Client objects.

If you previously used the Hub class directly, replace it with Scope and Client objects. More information:

Some of our APIs are typed with the Hub class instead of the interface (e.g. getCurrentHub). Most of them are deprecated themselves and will also be removed in version 8. More information:

Implements

Implemented by

Constructors

  • Creates a new instance of the hub, will push one Layer into the internal stack on creation.

    Parameters

    • Optionalclient: Client

      bound to the hub.

    • Optionalscope: Scope

      bound to the hub.

    • OptionalisolationScope: Scope
    • Optional_version: number

    Returns Hub

    Instantiation of Hub objects is deprecated and the constructor will be removed in version 8 of the SDK.

    If you are currently using the Hub for multi-client use like so:

    // OLD
    const hub = new Hub();
    hub.bindClient(client);
    makeMain(hub)

    instead initialize the client as follows:

    // NEW
    Sentry.withIsolationScope(() => {
    Sentry.setCurrentClient(client);
    client.init();
    });

    If you are using the Hub to capture events like so:

    // OLD
    const client = new Client();
    const hub = new Hub(client);
    hub.captureException()

    instead capture isolated events as follows:

    // NEW
    const client = new Client();
    const scope = new Scope();
    scope.setClient(client);
    scope.captureException();

Methods

  • Parameters

    Returns void

    Use Sentry.addBreadcrumb() instead.

  • This binds the given client to the current scope.

    Parameters

    • Optionalclient: Client

      An SDK client (client) instance.

    Returns void

    Use initAndBind() directly, or setCurrentClient() and/or client.init() instead.

  • Parameters

    Returns string

    Use Sentry.captureEvent() instead.

  • Parameters

    Returns string

    Use Sentry.captureException() instead.

  • Parameters

    Returns string

    Use Sentry.captureMessage() instead.

  • Parameters

    • OptionalendSession: boolean

    Returns void

    Use top level captureSession instead.

  • Parameters

    • callback: (scope: Scope) => void

    Returns void

    Use getScope() directly.

  • Returns void

    Use top level endSession instead.

  • Type Parameters

    • C extends Client

    Returns undefined | C

    Use Sentry.getClient() instead.

  • Type Parameters

    • T extends Integration

    Parameters

    • integration: IntegrationClass<T>

    Returns null | T

    Use Sentry.getClient().getIntegrationByName() instead.

  • Returns Scope

    Use Sentry.getIsolationScope() instead.

  • Returns the scope of the top stack.

    Returns Scope

    Use Sentry.getCurrentScope() instead.

  • Returns the scope stack for domains or the process.

    Returns Layer[]

    This will be removed in v8.

  • Returns the topmost scope layer in the order domain > local > process.

    Returns Layer

    This will be removed in v8.

  • Checks if this hub's version is older than the given version.

    Parameters

    • version: number

      A version number to compare to.

    Returns boolean

    True if the given version is newer; otherwise false.

    This will be removed in v8.

  • Returns undefined | string

    This will be removed in v8.

  • Returns boolean

    Use withScope instead.

  • Returns Scope

    Use withScope instead.

  • Parameters

    • callback: (hub: Hub) => void

    Returns void

  • Parameters

    • name: string
    • context: null | { [key: string]: any }

    Returns void

    Use Sentry.setContext() instead.

  • Parameters

    • key: string
    • extra: unknown

    Returns void

    Use Sentry.setExtra() instead.

  • Parameters

    • extras: Extras

    Returns void

    Use Sentry.setExtras() instead.

  • Parameters

    • key: string
    • value: Primitive

    Returns void

    Use Sentry.setTag() instead.

  • Parameters

    • tags: { [key: string]: Primitive }

    Returns void

    Use Sentry.setTags() instead.

  • Parameters

    Returns void

    Use Sentry.setUser() instead.

  • Returns if default PII should be sent to Sentry and propagated in ourgoing requests when Tracing is used.

    Returns boolean

    Use top-level getClient().getOptions().sendDefaultPii instead. This function only unnecessarily increased API surface but only wrapped accessing the option.

  • Parameters

    Returns Session

    Use top level startSession instead.

  • Starts a new Transaction and returns it. This is the entry point to manual tracing instrumentation.

    A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a new child span within the transaction or any span, call the respective .startChild() method.

    Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded.

    The transaction must be finished with a call to its .end() method, at which point the transaction with all its finished child spans will be sent to Sentry.

    Parameters

    • context: TransactionContext

      Properties of the new Transaction.

    • OptionalcustomSamplingContext: CustomSamplingContext

      Information given to the transaction sampling function (along with context-dependent default values). See Options.tracesSampler.

    Returns Transaction

    The transaction which was just started

    Use startSpan(), startSpanManual() or startInactiveSpan() instead.

  • Returns { [key: string]: string }

    Use spanToTraceHeader() instead.

  • Type Parameters

    • T

    Parameters

    Returns T

    Use Sentry.withScope() instead.