Class: Hub
sentry.Hub
Deprecated
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
Hub
Constructors
constructor
• new Hub(client?
, scope?
, isolationScope?
, _version?
): Hub
Creates a new instance of the hub, will push one Layer into the internal stack on creation.
Parameters
Name | Type | Description |
---|---|---|
client? |
Client <ClientOptions <BaseTransportOptions >> |
bound to the hub. |
scope? |
Scope |
bound to the hub. |
isolationScope? |
Scope |
- |
_version? |
number |
- |
Returns
Deprecated
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();
Properties
_callExtensionMethod
• Private
_callExtensionMethod: any
Calls global extension method and binding current instance to the function call
_isolationScope
• Private
_isolationScope: any
_lastEventId
• Private
Optional
_lastEventId: any
Contains the last event id of a captured event.
_sendSessionUpdate
• Private
_sendSessionUpdate: any
Sends the current Session on the scope
_stack
• Private
Readonly
_stack: any
Is a Layer[] containing the client and scope
_version
• Private
Readonly
_version: any
Methods
addBreadcrumb
▸ addBreadcrumb(breadcrumb
, hint?
): void
Parameters
Name | Type |
---|---|
breadcrumb |
Breadcrumb |
hint? |
BreadcrumbHint |
Returns
void
Inherit Doc
Deprecated
Use Sentry.addBreadcrumb()
instead.
Implementation of
HubInterface.addBreadcrumb
bindClient
▸ bindClient(client?
): void
This binds the given client to the current scope.
Parameters
Name | Type | Description |
---|---|---|
client? |
Client <ClientOptions <BaseTransportOptions >> |
An SDK client (client) instance. |
Returns
void
Deprecated
Use initAndBind()
directly, or setCurrentClient()
and/or client.init()
instead.
Implementation of
HubInterface.bindClient
captureEvent
▸ captureEvent(event
, hint?
): string
Parameters
Name | Type |
---|---|
event |
Event |
hint? |
EventHint |
Returns
string
Inherit Doc
Deprecated
Use Sentry.captureEvent()
instead.
Implementation of
HubInterface.captureEvent
captureException
▸ captureException(exception
, hint?
): string
Parameters
Name | Type |
---|---|
exception |
unknown |
hint? |
EventHint |
Returns
string
Inherit Doc
Deprecated
Use Sentry.captureException()
instead.
Implementation of
HubInterface.captureException
captureMessage
▸ captureMessage(message
, level?
, hint?
): string
Parameters
Name | Type |
---|---|
message |
string |
level? |
SeverityLevel | Severity |
hint? |
EventHint |
Returns
string
Inherit Doc
Deprecated
Use Sentry.captureMessage()
instead.
Implementation of
HubInterface.captureMessage
captureSession
▸ captureSession(endSession?
): void
Parameters
Name | Type |
---|---|
endSession? |
boolean |
Returns
void
Inherit Doc
Deprecated
Use top level captureSession
instead.
Implementation of
HubInterface.captureSession
configureScope
▸ configureScope(callback
): void
Parameters
Name | Type |
---|---|
callback |
(scope : Scope ) => void |
Returns
void
Inherit Doc
Deprecated
Use getScope()
directly.
Implementation of
HubInterface.configureScope
endSession
▸ endSession(): void
Returns
void
Inherit Doc
Deprecated
Use top level endSession
instead.
Implementation of
HubInterface.endSession
getClient
▸ getClient<C
>(): undefined
| C
Type parameters
Name | Type |
---|---|
C |
extends Client <ClientOptions <BaseTransportOptions >> |
Returns
undefined
| C
Inherit Doc
Deprecated
Use Sentry.getClient()
instead.
Implementation of
HubInterface.getClient
getIntegration
▸ getIntegration<T
>(integration
): null
| T
Type parameters
Name | Type |
---|---|
T |
extends Integration |
Parameters
Name | Type |
---|---|
integration |
IntegrationClass <T > |
Returns
null
| T
Inherit Doc
Deprecated
Use Sentry.getClient().getIntegrationByName()
instead.
Implementation of
HubInterface.getIntegration
getIsolationScope
▸ getIsolationScope(): Scope
Returns
Deprecated
Use Sentry.getIsolationScope()
instead.
Implementation of
HubInterface.getIsolationScope
getScope
▸ getScope(): Scope
Returns the scope of the top stack.
Returns
Deprecated
Use Sentry.getCurrentScope()
instead.
Implementation of
HubInterface.getScope
getStack
▸ getStack(): Layer
[]
Returns the scope stack for domains or the process.
Returns
Layer
[]
Deprecated
This will be removed in v8.
getStackTop
▸ getStackTop(): Layer
Returns the topmost scope layer in the order domain > local > process.
Returns
Layer
Deprecated
This will be removed in v8.
isOlderThan
▸ isOlderThan(version
): boolean
Checks if this hub’s version is older than the given version.
Parameters
Name | Type | Description |
---|---|---|
version |
number |
A version number to compare to. |
Returns
boolean
True if the given version is newer; otherwise false.
Deprecated
This will be removed in v8.
Implementation of
HubInterface.isOlderThan
lastEventId
▸ lastEventId(): undefined
| string
Returns
undefined
| string
Inherit Doc
Deprecated
This will be removed in v8.
Implementation of
HubInterface.lastEventId
popScope
▸ popScope(): boolean
Returns
boolean
Inherit Doc
Deprecated
Use withScope
instead.
Implementation of
HubInterface.popScope
pushScope
▸ pushScope(): Scope
Returns
Inherit Doc
Deprecated
Use withScope
instead.
Implementation of
HubInterface.pushScope
run
▸ run(callback
): void
Parameters
Name | Type |
---|---|
callback |
(hub : Hub ) => void |
Returns
void
Inherit Doc
Implementation of
HubInterface.run
setContext
▸ setContext(name
, context
): void
Parameters
Name | Type |
---|---|
name |
string |
context |
null | { [key: string] : any ; } |
Returns
void
Inherit Doc
Deprecated
Use Sentry.setContext()
instead.
Implementation of
HubInterface.setContext
setExtra
▸ setExtra(key
, extra
): void
Parameters
Name | Type |
---|---|
key |
string |
extra |
unknown |
Returns
void
Inherit Doc
Deprecated
Use Sentry.setExtra()
instead.
Implementation of
HubInterface.setExtra
setExtras
▸ setExtras(extras
): void
Parameters
Name | Type |
---|---|
extras |
Extras |
Returns
void
Inherit Doc
Deprecated
Use Sentry.setExtras()
instead.
Implementation of
HubInterface.setExtras
setTag
▸ setTag(key
, value
): void
Parameters
Name | Type |
---|---|
key |
string |
value |
Primitive |
Returns
void
Inherit Doc
Deprecated
Use Sentry.setTag()
instead.
Implementation of
HubInterface.setTag
setTags
▸ setTags(tags
): void
Parameters
Name | Type |
---|---|
tags |
Object |
Returns
void
Inherit Doc
Deprecated
Use Sentry.setTags()
instead.
Implementation of
HubInterface.setTags
setUser
▸ setUser(user
): void
Parameters
Name | Type |
---|---|
user |
null | User |
Returns
void
Inherit Doc
Deprecated
Use Sentry.setUser()
instead.
Implementation of
HubInterface.setUser
shouldSendDefaultPii
▸ shouldSendDefaultPii(): boolean
Returns if default PII should be sent to Sentry and propagated in ourgoing requests when Tracing is used.
Returns
boolean
Deprecated
Use top-level getClient().getOptions().sendDefaultPii
instead. This function
only unnecessarily increased API surface but only wrapped accessing the option.
Implementation of
HubInterface.shouldSendDefaultPii
startSession
▸ startSession(context?
): Session
Parameters
Name | Type |
---|---|
context? |
Partial <Session > |
Returns
Inherit Doc
Deprecated
Use top level startSession
instead.
Implementation of
HubInterface.startSession
startTransaction
▸ startTransaction(context
, customSamplingContext?
): Transaction
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
Name | Type | Description |
---|---|---|
context |
TransactionContext |
Properties of the new Transaction . |
customSamplingContext? |
CustomSamplingContext |
Information given to the transaction sampling function (along with context-dependent default values). See Options.tracesSampler. |
Returns
The transaction which was just started
Deprecated
Use startSpan()
, startSpanManual()
or startInactiveSpan()
instead.
Implementation of
HubInterface.startTransaction
traceHeaders
▸ traceHeaders(): Object
Returns
Object
Inherit Doc
Deprecated
Use spanToTraceHeader()
instead.
Implementation of
HubInterface.traceHeaders
withScope
▸ withScope<T
>(callback
): T
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
callback |
(scope : Scope ) => T |
Returns
T
Inherit Doc
Deprecated
Use Sentry.withScope()
instead.
Implementation of
HubInterface.withScope