Default Integrations
System integrations are enabled by default to integrate into the standard library or the interpreter itself. They're documented so you can understand what they do and disable them if they cause issues.
Enabled by Default
InboundFilters
Import name: Sentry.Integrations.InboundFilters
This integration allows you to ignore specific errors based on the error message or the URL from which the exception originated.
To configure it, use the ignoreErrors
, ignoreTransactions
, denyUrls
, and allowUrls
SDK options directly.
Keep in mind that denyUrls
and allowUrls
only work for captured exceptions, not raw message events.
FunctionToString
Import name: Sentry.Integrations.FunctionToString
This integration allows the SDK to provide original function and method names, even when those functions or methods are wrapped by our error or breadcrumb handlers.
LinkedErrors
Import name: Sentry.Integrations.LinkedErrors
This integration allows you to configure linked errors. They'll be recursively read up to a specified limit, and lookup will be performed by a specific key. By default, the limit is set to 5
and the key used is "cause"
.
Available options:
{
key: string; // default: "cause"
limit: number; // default: 5
}
Node-specific
Console
Import name: Sentry.Integrations.Console
This integration wraps the console
module to record all of its calls as breadcrumbs.
Http
Import name: Sentry.Integrations.Http
This integration wraps the http
and https
modules to capture all network requests as breadcrumbs and/or
Available options:
{
breadcrumbs: boolean; // default: true
tracing: boolean | TracingOptions; // default: false
}
Where TracingOptions
is:
{
/**
* 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 outgoing
* requests. 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.
*/
tracePropagationTargets?: TracePropagationTargets;
/**
* Function determining whether or not to create spans to track outgoing requests to the given URL.
* By default, spans will be created for all outgoing requests.
*/
shouldCreateSpanForRequest?: (url: string) => boolean;
}
OnUncaughtException
Import name: Sentry.Integrations.OnUncaughtException
This integration attaches a global uncaught exception handler. It can be modified to provide a custom shutdown function.
The onFatalError
option is meant to perform a cleanup before the process exits, not fully prevent it from exiting.
Be aware that if you overwrite this setting, you will lose the default implementation, which handles draining queued events before exiting. If you want to examine how it works in order to be able to recreate it in your code, see the implementation of the logAndExitProcess
function.
Available options:
{
onFatalError: (firstError: Error, secondError?: Error) => void;
}
OnUnhandledRejection
Import name: Sentry.Integrations.OnUnhandledRejection
This integration attaches a global unhandled rejection handler. By default, all unhandled rejections trigger a warning and log the error. You can change this behavior using the mode
option, which works with Node's CLI options: https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode.
Available options:
{
mode: "none" | "warn" | "strict"; // default: "warn"
}
ContextLines
Import name: Sentry.Integrations.ContextLines
(Available in version 6.18.0 and above)
This integration adds source file context to stack frames for captured exceptions.
Available options:
{
// The number of context lines to include with each frame
frameContextLines: number;
}
LocalVariables
Import name: Sentry.Integrations.LocalVariables
(Available in version 7.46.0 and above)
This integration adds stack local variables to stack frames for uncaught exceptions. Only works with Node 18+.
To enable this integration, set the includeLocalVariables
init
option to true
.
Available options:
{
// Capture local variables for both handled and unhandled exceptions.
// Default: false - Only captures local variables for uncaught exceptions.
captureAllExceptions?: boolean;
}
Due to an open Node.js issue, we are currently unable to capture local variables for unhandled errors when using JavaScript modules (ESM).
You can work around this issue by wrapping your code in try/catch and
enabling the captureAllExceptions
option:
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [
new Sentry.Integrations.LocalVariables({
captureAllExceptions: true,
}),
],
});
try {
mainCode();
} catch (e) {
Sentry.captureException(e);
}
Modules
(New in version 7.13.0.)
Import name: Sentry.Integrations.Modules
This integration fetches names of all currently installed Node modules and attaches the list to the event. Once fetched, Sentry will cache the list for later reuse.
RequestData
(New in version 7.17.1.)
Import name: Sentry.Integrations.RequestData
This integration adds data from incoming requests to transaction and error events that occur during request handling.
Available options:
{
// Controls what types of data are added to the event
include: {
cookies: boolean // default: true,
data: boolean // default: true,
headers: boolean // default: true,
ip: boolean // default: false,
query_string: boolean // default: true,
url: boolean // default: true,
user: boolean | {
id: boolean // default: true,
username: boolean // default: true,
email: boolean // default: true,
},
},
// Controls how the transaction will be reported. Options are 'path' (`/some/route`),
// 'methodPath' (`GET /some/route`), and 'handler' (the name of the route handler
// function, if available)
transactionNamingScheme: string // default: 'methodPath',
};
Modifying System Integrations
To disable system integrations, set defaultIntegrations: false
when calling init()
.
To override an integration's settings, provide a new instance to the integrations
option when calling init()
. For example, to change the fatal error handler:
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [
new Sentry.Integrations.OnUncaughtException({
onFatalError: () => {
// your implementation
},
}),
],
});
Removing an Integration
This example removes the default-enabled Console
integration:
Sentry.init({
// ...
integrations: function (integrations) {
// integrations will be all default integrations
return integrations.filter((integration) => integration.name !== "Console");
},
});
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
- Package:
- npm:@sentry/node
- Version:
- 7.54.0
- Repository:
- https://github.com/getsentry/sentry-javascript