Interface: NodeOptions

sentry.NodeOptions

Configuration options for the Sentry Node SDK

See

@sentry/types Options for more information.

Hierarchy

  • Options<NodeTransportOptions>

  • BaseNodeOptions

    NodeOptions

Properties

_experiments

Optional _experiments: Object

Options which are in beta, or otherwise not guaranteed to be stable.

Index signature

▪ [key: string]: any

Inherited from

Options._experiments


_metadata

Optional _metadata: SdkMetadata

Set of metadata about the SDK that can be internally used to enhance envelopes and events, and provide additional data about every request.

Inherited from

Options._metadata


allowUrls

Optional allowUrls: (string | RegExp)[]

A pattern for error URLs which should exclusively be sent to Sentry. This is the opposite of Options.denyUrls. By default, all errors will be sent.

Requires the use of the InboundFilters integration.

Inherited from

Options.allowUrls


attachStacktrace

Optional attachStacktrace: boolean

Attaches stacktraces to pure capture message / log integrations

Inherited from

Options.attachStacktrace


autoSessionTracking

Optional autoSessionTracking: boolean

A flag enabling Sessions Tracking feature. By default, Sessions Tracking is enabled.

Inherited from

Options.autoSessionTracking


beforeBreadcrumb

Optional beforeBreadcrumb: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => null | Breadcrumb

A callback invoked when adding a breadcrumb, allowing to optionally modify it before adding it to future events.

Note that you must return a valid breadcrumb from this callback. If you do not wish to modify the breadcrumb, simply return it at the end. Returning null will cause the breadcrumb to be dropped.

Type declaration

▸ (breadcrumb, hint?): null | Breadcrumb

Parameters
Name Type Description
breadcrumb Breadcrumb The breadcrumb as created by the SDK.
hint? BreadcrumbHint -
Returns

null | Breadcrumb

Inherited from

Options.beforeBreadcrumb


beforeSend

Optional beforeSend: (event: ErrorEvent, hint: EventHint) => null | Event | PromiseLike<null | Event>

An event-processing callback for error and message events, guaranteed to be invoked after all other event processors, which allows an event to be modified or dropped.

Note that you must return a valid event from this callback. If you do not wish to modify the event, simply return it at the end. Returning null will cause the event to be dropped.

Type declaration

▸ (event, hint): null | Event | PromiseLike<null | Event>

Parameters
Name Type Description
event ErrorEvent The error or message event generated by the SDK.
hint EventHint Event metadata useful for processing.
Returns

null | Event | PromiseLike<null | Event>

Inherited from

Options.beforeSend


beforeSendTransaction

Optional beforeSendTransaction: (event: TransactionEvent, hint: EventHint) => null | Event | PromiseLike<null | Event>

An event-processing callback for transaction events, guaranteed to be invoked after all other event processors. This allows an event to be modified or dropped before it’s sent.

Note that you must return a valid event from this callback. If you do not wish to modify the event, simply return it at the end. Returning null will cause the event to be dropped.

Type declaration

▸ (event, hint): null | Event | PromiseLike<null | Event>

Parameters
Name Type Description
event TransactionEvent The error or message event generated by the SDK.
hint EventHint Event metadata useful for processing.
Returns

null | Event | PromiseLike<null | Event>

Inherited from

Options.beforeSendTransaction


debug

Optional debug: boolean

Enable debug functionality in the SDK itself

Inherited from

Options.debug


defaultIntegrations

Optional defaultIntegrations: false | Integration[]

If this is set to false, default integrations will not be added, otherwise this will internally be set to the recommended default integrations.

Inherited from

Options.defaultIntegrations


denyUrls

Optional denyUrls: (string | RegExp)[]

A pattern for error URLs which should not be sent to Sentry. To allow certain errors instead, use Options.allowUrls. By default, all errors will be sent.

Requires the use of the InboundFilters integration.

Inherited from

Options.denyUrls


dist

Optional dist: string

Sets the distribution for all events

Inherited from

Options.dist


dsn

Optional dsn: string

The Dsn used to connect to Sentry and identify the project. If omitted, the SDK will not send any data to Sentry.

Inherited from

Options.dsn


enableTracing

Optional enableTracing: boolean

If this is enabled, transactions and trace data will be generated and captured. This will set the tracesSampleRate to the recommended default of 1.0 if tracesSampleRate is undefined. Note that tracesSampleRate and tracesSampler take precedence over this option.

Inherited from

Options.enableTracing


enabled

Optional enabled: boolean

Specifies whether this SDK should send events to Sentry. Defaults to true.

Inherited from

Options.enabled


environment

Optional environment: string

The current environment of your application (e.g. “production”).

Inherited from

Options.environment


ignoreErrors

Optional ignoreErrors: (string | RegExp)[]

A pattern for error messages which should not be sent to Sentry. By default, all errors will be sent.

Inherited from

Options.ignoreErrors


ignoreTransactions

Optional ignoreTransactions: (string | RegExp)[]

A pattern for transaction names which should not be sent to Sentry. By default, all transactions will be sent.

Inherited from

Options.ignoreTransactions


includeLocalVariables

Optional includeLocalVariables: boolean

Include local variables with stack traces.

Requires the LocalVariables integration.

Inherited from

BaseNodeOptions.includeLocalVariables


initialScope

Optional initialScope: CaptureContext

Initial data to populate scope.

Inherited from

Options.initialScope


instrumenter

Optional instrumenter: Instrumenter

The instrumenter to use. Defaults to sentry. When not set to sentry, auto-instrumentation inside of Sentry will be disabled, in favor of using external auto instrumentation.

NOTE: Any option except for sentry is highly experimental and subject to change!

Inherited from

Options.instrumenter


integrations

Optional integrations: Integration[] | (integrations: Integration[]) => Integration[]

List of integrations that should be installed after SDK was initialized. Accepts either a list of integrations or a function that receives default integrations and returns a new, updated list.

Inherited from

Options.integrations


maxBreadcrumbs

Optional maxBreadcrumbs: number

The maximum number of breadcrumbs sent with events. Defaults to 100. Sentry has a maximum payload size of 1MB and any events exceeding that payload size will be dropped.

Inherited from

Options.maxBreadcrumbs


maxValueLength

Optional maxValueLength: number

Maximum number of chars a single value can have before it will be truncated.

Inherited from

Options.maxValueLength


normalizeDepth

Optional normalizeDepth: number

Maximum number of levels that normalization algorithm will traverse in objects and arrays. Used when normalizing an event before sending, on all of the listed attributes:

  • breadcrumbs.data
  • user
  • contexts
  • extra Defaults to 3. Set to 0 to disable.

Inherited from

Options.normalizeDepth


normalizeMaxBreadth

Optional normalizeMaxBreadth: number

Maximum number of properties or elements that the normalization algorithm will output in any single array or object included in the normalized event. Used when normalizing an event before sending, on all of the listed attributes:

  • breadcrumbs.data
  • user
  • contexts
  • extra Defaults to 1000

Inherited from

Options.normalizeMaxBreadth


profilesSampleRate

Optional profilesSampleRate: number

Sets profiling sample rate when @sentry/profiling-node is installed

Inherited from

BaseNodeOptions.profilesSampleRate


profilesSampler

Optional profilesSampler: (samplingContext: SamplingContext) => number | boolean

Function to compute profiling sample rate dynamically and filter unwanted profiles.

Profiling is enabled if either this or profilesSampleRate is defined. If both are defined, profilesSampleRate is ignored.

Will automatically be passed a context object of default and optional custom data. See Transaction.samplingContext and Hub.startTransaction.

Type declaration

▸ (samplingContext): number | boolean

Parameters
Name Type
samplingContext SamplingContext
Returns

number | boolean

Inherited from

BaseNodeOptions.profilesSampler


release

Optional release: string

The release identifier used when uploading respective source maps. Specify this value to allow Sentry to resolve the correct source maps when processing events.

Inherited from

Options.release


sampleRate

Optional sampleRate: number

A global sample rate to apply to all events.

0.0 = 0% chance of a given event being sent (send no events) 1.0 = 100% chance of a given event being sent (send all events)

Inherited from

Options.sampleRate


sendClientReports

Optional sendClientReports: boolean

Send SDK Client Reports. By default, Client Reports are enabled.

Inherited from

Options.sendClientReports


sendDefaultPii

Optional sendDefaultPii: boolean

Controls if potentially sensitive data should be sent to Sentry by default. Note that this only applies to data that the SDK is sending by default but not data that was explicitly set (e.g. by calling Sentry.setUser()).

Defaults to false.

NOTE: This option currently controls only a few data points in a selected set of SDKs. The goal for this option is to eventually control all sensitive data the SDK sets by default. However, this would be a breaking change so until the next major update this option only controls data points which were added in versions above 7.9.0.

Inherited from

Options.sendDefaultPii


serverName

Optional serverName: string

Sets an optional server name (device name)

Inherited from

BaseNodeOptions.serverName


shutdownTimeout

Optional shutdownTimeout: number

Controls how many milliseconds to wait before shutting down. The default is SDK-specific but typically around 2 seconds. Setting this too low can cause problems for sending events from command line applications. Setting it too high can cause the application to block for users with network connectivity problems.

Inherited from

Options.shutdownTimeout


spotlight

Optional spotlight: string | boolean

If you use Spotlight by Sentry during development, use this option to forward captured Sentry events to Spotlight.

Either set it to true, or provide a specific Spotlight Sidecar URL.

More details: https://spotlightjs.com/

IMPORTANT: Only set this option to true while developing, not in production!

Inherited from

BaseNodeOptions.spotlight


stackParser

Optional stackParser: StackParser | StackLineParser[]

A stack parser implementation or an array of stack line parsers By default, a stack parser is supplied for all supported browsers

Inherited from

Options.stackParser


tracePropagationTargets

Optional tracePropagationTargets: TracePropagationTargets

List of strings/regex controlling to which outgoing requests the SDK will attach tracing headers.

By default the SDK will attach those headers to all requests to localhost and same origin. If this option is provided, the SDK will match the request URL of outgoing requests against the items in this array, and only attach tracing headers if a match was found.

Example

Sentry.init({
  tracePropagationTargets: ['api.site.com'],
});

Default: [’localhost’, /^//] {@see DEFAULT_TRACE_PROPAGATION_TARGETS}

Inherited from

Options.tracePropagationTargets


tracesSampleRate

Optional tracesSampleRate: number

Sample rate to determine trace sampling.

0.0 = 0% chance of a given trace being sent (send no traces) 1.0 = 100% chance of a given trace being sent (send all traces)

Tracing is enabled if either this or tracesSampler is defined. If both are defined, tracesSampleRate is ignored.

Inherited from

Options.tracesSampleRate


tracesSampler

Optional tracesSampler: (samplingContext: SamplingContext) => number | boolean

Function to compute tracing sample rate dynamically and filter unwanted traces.

Tracing is enabled if either this or tracesSampleRate is defined. If both are defined, tracesSampleRate is ignored.

Will automatically be passed a context object of default and optional custom data. See Transaction.samplingContext and Hub.startTransaction.

Type declaration

▸ (samplingContext): number | boolean

Parameters
Name Type
samplingContext SamplingContext
Returns

number | boolean

Inherited from

Options.tracesSampler


transport

Optional transport: (transportOptions: NodeTransportOptions) => Transport

A function that takes transport options and returns the Transport object which is used to send events to Sentry. The function is invoked internally during SDK initialization. By default, the SDK initializes its default transports.

Type declaration

▸ (transportOptions): Transport

Parameters
Name Type
transportOptions NodeTransportOptions
Returns

Transport

Inherited from

Options.transport


transportOptions

Optional transportOptions: Partial<NodeTransportOptions>

Options for the default transport that the SDK uses.

Inherited from

Options.transportOptions


tunnel

Optional tunnel: string

A URL to an envelope tunnel endpoint. An envelope tunnel is an HTTP endpoint that accepts Sentry envelopes for forwarding. This can be used to force data through a custom server independent of the type of data.

Inherited from

Options.tunnel

Methods

onFatalError

onFatalError(this, error): void

Callback that is executed when a fatal global error occurs.

Parameters

Name Type
this void
error Error

Returns

void

Inherited from

BaseNodeOptions.onFatalError


shouldCreateSpanForRequest

shouldCreateSpanForRequest(this, url): boolean

Parameters

Name Type
this void
url string

Returns

boolean

Deprecated

Moved to constructor options of the Http and Undici integration.

Example

Sentry.init({
  integrations: [
    new Sentry.Integrations.Http({
      tracing: {
        shouldCreateSpanForRequest: (url: string) => false,
      }
    });
  ],
});

Inherited from

BaseNodeOptions.shouldCreateSpanForRequest