Class: NodeClient
sentry.NodeClient
The Sentry Node SDK Client.
See
- NodeClientOptions for documentation on configuration options.
- SentryClient for usage documentation.
Hierarchy
-
ServerRuntimeClient
<NodeClientOptions
>↳
NodeClient
Constructors
constructor
• new NodeClient(options
): NodeClient
Creates a new Node SDK instance.
Parameters
Name | Type | Description |
---|---|---|
options |
NodeClientOptions |
Configuration options for this SDK. |
Returns
Overrides
ServerRuntimeClient<NodeClientOptions>.constructor
Properties
_dsn
• Protected
Optional
Readonly
_dsn: DsnComponents
The client Dsn, if specified in options. Without this Dsn, the SDK will be disabled.
Inherited from
ServerRuntimeClient._dsn
_eventProcessors
• Protected
_eventProcessors: EventProcessor
[]
Inherited from
ServerRuntimeClient._eventProcessors
_integrations
• Protected
_integrations: IntegrationIndex
Array of set up integrations.
Inherited from
ServerRuntimeClient._integrations
_integrationsInitialized
• Protected
_integrationsInitialized: boolean
Indicates whether this client’s integrations have been set up.
Inherited from
ServerRuntimeClient._integrationsInitialized
_numProcessing
• Protected
_numProcessing: number
Number of calls being processed
Inherited from
ServerRuntimeClient._numProcessing
_options
• Protected
Readonly
_options: NodeClientOptions
Options passed to the SDK.
Inherited from
ServerRuntimeClient._options
_sessionFlusher
• Protected
_sessionFlusher: undefined
| SessionFlusher
Inherited from
ServerRuntimeClient._sessionFlusher
_transport
• Protected
Optional
Readonly
_transport: Transport
Inherited from
ServerRuntimeClient._transport
metricsAggregator
• Optional
metricsAggregator: MetricsAggregator
A reference to a metrics aggregator
Note this is alpha API. It may experience breaking changes in the future.
Inherited from
ServerRuntimeClient.metricsAggregator
Methods
_captureEvent
▸ _captureEvent(event
, hint?
, scope?
): PromiseLike
<undefined
| string
>
Processes the event and logs an error in case of rejection
Parameters
Name | Type |
---|---|
event |
Event |
hint? |
EventHint |
scope? |
Scope |
Returns
PromiseLike
<undefined
| string
>
Inherited from
ServerRuntimeClient._captureEvent
_captureRequestSession
▸ _captureRequestSession(): void
Method responsible for capturing/ending a request session by calling incrementSessionStatusCount
to increment
appropriate session aggregates bucket
Returns
void
Inherited from
ServerRuntimeClient._captureRequestSession
_clearOutcomes
▸ _clearOutcomes(): Outcome
[]
Clears outcomes on this client and returns them.
Returns
Outcome
[]
Inherited from
ServerRuntimeClient._clearOutcomes
_isClientDoneProcessing
▸ _isClientDoneProcessing(timeout?
): PromiseLike
<boolean
>
Determine if the client is finished processing. Returns a promise because it will wait timeout
ms before saying
“no” (resolving to false
) in order to give the client a chance to potentially finish first.
Parameters
Name | Type | Description |
---|---|---|
timeout? |
number |
The time, in ms, after which to resolve to false if the client is still busy. Passing 0 (or not passing anything) will make the promise wait as long as it takes for processing to finish before resolving to true . |
Returns
PromiseLike
<boolean
>
A promise which will resolve to true
if processing is already done or finishes before the timeout, and
false
otherwise
Inherited from
ServerRuntimeClient._isClientDoneProcessing
_isEnabled
▸ _isEnabled(): boolean
Determines whether this SDK is enabled and a transport is present.
Returns
boolean
Inherited from
ServerRuntimeClient._isEnabled
_prepareEvent
▸ _prepareEvent(event
, hint
, scope?
, isolationScope?
): PromiseLike
<null
| Event
>
Parameters
Name | Type |
---|---|
event |
Event |
hint |
EventHint |
scope? |
Scope |
isolationScope? |
Scope |
Returns
PromiseLike
<null
| Event
>
Inherit Doc
Inherited from
ServerRuntimeClient._prepareEvent
_process
▸ _process<T
>(promise
): void
Occupies the client with processing and event
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
promise |
PromiseLike <T > |
Returns
void
Inherited from
ServerRuntimeClient._process
_processEvent
▸ _processEvent(event
, hint
, scope?
): PromiseLike
<Event
>
Processes an event (either error or message) and sends it to Sentry.
This also adds breadcrumbs and context information to the event. However, platform specific meta data (such as the User’s IP address) must be added by the SDK implementor.
Parameters
Name | Type | Description |
---|---|---|
event |
Event |
The event to send to Sentry. |
hint |
EventHint |
May contain additional information about the original exception. |
scope? |
Scope |
A scope containing event metadata. |
Returns
PromiseLike
<Event
>
A SyncPromise that resolves with the event or rejects in case event was/will not be send.
Inherited from
ServerRuntimeClient._processEvent
_sendEnvelope
▸ _sendEnvelope(envelope
): void
| PromiseLike
<void
| TransportMakeRequestResponse
>
Parameters
Name | Type |
---|---|
envelope |
Envelope |
Returns
void
| PromiseLike
<void
| TransportMakeRequestResponse
>
Inherit Doc
Inherited from
ServerRuntimeClient._sendEnvelope
_setupIntegrations
▸ _setupIntegrations(): void
Setup integrations for this client.
Returns
void
Inherited from
ServerRuntimeClient._setupIntegrations
_updateSessionFromEvent
▸ _updateSessionFromEvent(session
, event
): void
Updates existing session based on the provided event
Parameters
Name | Type |
---|---|
session |
Session |
event |
Event |
Returns
void
Inherited from
ServerRuntimeClient._updateSessionFromEvent
addEventProcessor
▸ addEventProcessor(eventProcessor
): void
Parameters
Name | Type |
---|---|
eventProcessor |
EventProcessor |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.addEventProcessor
addIntegration
▸ addIntegration(integration
): void
Parameters
Name | Type |
---|---|
integration |
Integration |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.addIntegration
captureAggregateMetrics
▸ captureAggregateMetrics(metricBucketItems
): void
Parameters
Name | Type |
---|---|
metricBucketItems |
MetricBucketItem [] |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.captureAggregateMetrics
captureCheckIn
▸ captureCheckIn(checkIn
, monitorConfig?
, scope?
): string
Create a cron monitor check in and send it to Sentry.
Parameters
Name | Type | Description |
---|---|---|
checkIn |
CheckIn |
An object that describes a check in. |
monitorConfig? |
MonitorConfig |
- |
scope? |
Scope |
- |
Returns
string
Inherited from
ServerRuntimeClient.captureCheckIn
captureEvent
▸ captureEvent(event
, hint?
, scope?
): undefined
| string
Parameters
Name | Type |
---|---|
event |
Event |
hint? |
EventHint |
scope? |
Scope |
Returns
undefined
| string
Inherit Doc
Inherited from
ServerRuntimeClient.captureEvent
captureException
▸ captureException(exception
, hint?
, scope?
): undefined
| string
Parameters
Name | Type |
---|---|
exception |
any |
hint? |
EventHint |
scope? |
Scope |
Returns
undefined
| string
Inherit Doc
Inherited from
ServerRuntimeClient.captureException
captureMessage
▸ captureMessage(message
, level?
, hint?
, scope?
): undefined
| string
Parameters
Name | Type |
---|---|
message |
ParameterizedString |
level? |
SeverityLevel | Severity |
hint? |
EventHint |
scope? |
Scope |
Returns
undefined
| string
Inherit Doc
Inherited from
ServerRuntimeClient.captureMessage
captureSession
▸ captureSession(session
): void
Parameters
Name | Type |
---|---|
session |
Session |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.captureSession
close
▸ close(timeout?
): PromiseLike
<boolean
>
Parameters
Name | Type |
---|---|
timeout? |
number |
Returns
PromiseLike
<boolean
>
Inherit Doc
Inherited from
ServerRuntimeClient.close
emit
▸ emit(hook
, transaction
): void
Parameters
Name | Type |
---|---|
hook |
"startTransaction" |
transaction |
Transaction |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, transaction
): void
Parameters
Name | Type |
---|---|
hook |
"finishTransaction" |
transaction |
Transaction |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, envelope
): void
Parameters
Name | Type |
---|---|
hook |
"beforeEnvelope" |
envelope |
Envelope |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, event
, hint?
): void
Parameters
Name | Type |
---|---|
hook |
"beforeSendEvent" |
event |
Event |
hint? |
EventHint |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, event
, hint?
): void
Parameters
Name | Type |
---|---|
hook |
"preprocessEvent" |
event |
Event |
hint? |
EventHint |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, event
, sendResponse
): void
Parameters
Name | Type |
---|---|
hook |
"afterSendEvent" |
event |
Event |
sendResponse |
void | TransportMakeRequestResponse |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, breadcrumb
, hint?
): void
Parameters
Name | Type |
---|---|
hook |
"beforeAddBreadcrumb" |
breadcrumb |
Breadcrumb |
hint? |
BreadcrumbHint |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, dsc
): void
Parameters
Name | Type |
---|---|
hook |
"createDsc" |
dsc |
DynamicSamplingContext |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, otelSpan
, mutableOptions
): void
Parameters
Name | Type |
---|---|
hook |
"otelSpanEnd" |
otelSpan |
unknown |
mutableOptions |
Object |
mutableOptions.drop |
boolean |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, feedback
, options?
): void
Parameters
Name | Type |
---|---|
hook |
"beforeSendFeedback" |
feedback |
FeedbackEvent |
options? |
Object |
options.includeReplay |
boolean |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, options
): void
Parameters
Name | Type |
---|---|
hook |
"startPageLoadSpan" |
options |
StartSpanOptions |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
▸ emit(hook
, options
): void
Parameters
Name | Type |
---|---|
hook |
"startNavigationSpan" |
options |
StartSpanOptions |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.emit
eventFromException
▸ eventFromException(exception
, hint?
): PromiseLike
<Event
>
Parameters
Name | Type |
---|---|
exception |
unknown |
hint? |
EventHint |
Returns
PromiseLike
<Event
>
Inherit Doc
Inherited from
ServerRuntimeClient.eventFromException
eventFromMessage
▸ eventFromMessage(message
, level?
, hint?
): PromiseLike
<Event
>
Parameters
Name | Type |
---|---|
message |
ParameterizedString |
level? |
SeverityLevel | Severity |
hint? |
EventHint |
Returns
PromiseLike
<Event
>
Inherit Doc
Inherited from
ServerRuntimeClient.eventFromMessage
flush
▸ flush(timeout?
): PromiseLike
<boolean
>
Parameters
Name | Type |
---|---|
timeout? |
number |
Returns
PromiseLike
<boolean
>
Inherit Doc
Inherited from
ServerRuntimeClient.flush
getDsn
▸ getDsn(): undefined
| DsnComponents
Returns
undefined
| DsnComponents
Inherit Doc
Inherited from
ServerRuntimeClient.getDsn
getEventProcessors
▸ getEventProcessors(): EventProcessor
[]
Get all installed event processors.
Returns
EventProcessor
[]
Inherited from
ServerRuntimeClient.getEventProcessors
getIntegration
▸ getIntegration<T
>(integration
): null
| T
Returns the client’s instance of the given integration class, it any.
Type parameters
Name | Type |
---|---|
T |
extends Integration |
Parameters
Name | Type |
---|---|
integration |
IntegrationClass <T > |
Returns
null
| T
Deprecated
Use getIntegrationByName()
instead.
Inherited from
ServerRuntimeClient.getIntegration
getIntegrationById
▸ getIntegrationById(integrationId
): undefined
| Integration
Gets an installed integration by its id
.
Parameters
Name | Type |
---|---|
integrationId |
string |
Returns
undefined
| Integration
The installed integration or undefined
if no integration with that id
was installed.
Deprecated
Use getIntegrationByName()
instead.
Inherited from
ServerRuntimeClient.getIntegrationById
getIntegrationByName
▸ getIntegrationByName<T
>(integrationName
): undefined
| T
Gets an installed integration by its name.
Type parameters
Name | Type |
---|---|
T |
extends Integration = Integration |
Parameters
Name | Type |
---|---|
integrationName |
string |
Returns
undefined
| T
The installed integration or undefined
if no integration with that name
was installed.
Inherited from
ServerRuntimeClient.getIntegrationByName
getOptions
▸ getOptions(): NodeClientOptions
Returns
NodeClientOptions
Inherit Doc
Inherited from
ServerRuntimeClient.getOptions
getSdkMetadata
▸ getSdkMetadata(): undefined
| SdkMetadata
Returns
undefined
| SdkMetadata
The metadata of the SDK
See
SdkMetadata in @sentry/types
Inherited from
ServerRuntimeClient.getSdkMetadata
getTransport
▸ getTransport(): undefined
| Transport
Returns
undefined
| Transport
Inherit Doc
Inherited from
ServerRuntimeClient.getTransport
init
▸ init(): void
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.init
initSessionFlusher
▸ initSessionFlusher(): void
Method that initialises an instance of SessionFlusher on Client
Returns
void
Inherited from
ServerRuntimeClient.initSessionFlusher
on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"startTransaction" |
callback |
(transaction : Transaction ) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"finishTransaction" |
callback |
(transaction : Transaction ) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"beforeEnvelope" |
callback |
(envelope : Envelope ) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"beforeSendEvent" |
callback |
(event : Event , hint? : EventHint ) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"preprocessEvent" |
callback |
(event : Event , hint? : EventHint ) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"afterSendEvent" |
callback |
(event : Event , sendResponse : void | TransportMakeRequestResponse ) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"beforeAddBreadcrumb" |
callback |
(breadcrumb : Breadcrumb , hint? : BreadcrumbHint ) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"createDsc" |
callback |
(dsc : DynamicSamplingContext ) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"otelSpanEnd" |
callback |
(otelSpan : unknown , mutableOptions : { drop : boolean }) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"beforeSendFeedback" |
callback |
(feedback : FeedbackEvent , options? : { includeReplay : boolean }) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"startPageLoadSpan" |
callback |
(options : StartSpanOptions ) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
▸ on(hook
, callback
): void
Parameters
Name | Type |
---|---|
hook |
"startNavigationSpan" |
callback |
(options : StartSpanOptions ) => void |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.on
recordDroppedEvent
▸ recordDroppedEvent(reason
, category
, _event?
): void
Parameters
Name | Type |
---|---|
reason |
EventDropReason |
category |
DataCategory |
_event? |
Event |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.recordDroppedEvent
sendEvent
▸ sendEvent(event
, hint?
): void
Parameters
Name | Type |
---|---|
event |
Event |
hint? |
EventHint |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.sendEvent
sendSession
▸ sendSession(session
): void
Parameters
Name | Type |
---|---|
session |
Session | SessionAggregates |
Returns
void
Inherit Doc
Inherited from
ServerRuntimeClient.sendSession
setupIntegrations
▸ setupIntegrations(forceInitialize?
): void
This is an internal function to setup all integrations that should run on the client.
Parameters
Name | Type |
---|---|
forceInitialize? |
boolean |
Returns
void
Deprecated
Use client.init()
instead.
Inherited from
ServerRuntimeClient.setupIntegrations