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.
Import name: Sentry.inboundFiltersIntegration
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.
Import name: Sentry.functionToStringIntegration
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.
Import name: Sentry.linkedErrorsIntegration
This integration allows you to configure linked errors. They'll be recursively read up to a specified limit, and a lookup will be performed by a specific key on the captured Error object. By default, the integration records up to five errors and the key used for recursion is "cause"
.
This integration also enhances captured error events with data from an AggregateError where applicable, by recursively iterating over the errors
property on Error objects.
Available options:
{
key: string; // default: "cause"
limit: number; // default: 5
}
Import name: Sentry.consoleIntegration
This integration wraps the console
module to record all of its calls as breadcrumbs.
Import name: Sentry.httpIntegration
This integration wraps the http
and https
modules to capture all outgoing network requests as breadcrumbs and/or tracing spans.
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;
}
(New in version 7.46.0)
Import name: nativeNodeFetchIntegration
Instruments outgoing HTTP requests made with undici and Node 18's Node Fetch by adding breadcrumbs and spans.
Supports Undici v4.7.0
or higher and requires Node v16.7.0
or higher. There have been reported issues with Node.js v19
and the Undici integration so we recommend you use an LTS version of Node.js with this integration.
Available options:
{
/**
* If breadcrumbs should be created for outgoing requests.
* Defaults to true.
*/
breadcrumbs?: boolean;
/**
* 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;
}
To change what requests get the sentry-trace
and baggage
headers attached (for use in distributed tracing), use the top-level tracePropagationTargets
option.
Sentry.init({
tracePropagationTargets: ["my-site-url.com"],
});
Import name: Sentry.onUncaughtExceptionIntegration
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;
}
Import name: Sentry.onUnhandledRejectionIntegration
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"
}
Import name: Sentry.contextLinesIntegration
(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;
}
Import name: Sentry.localVariablesIntegration
(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: [
Sentry.localVariablesIntegration({
captureAllExceptions: true,
}),
],
});
try {
mainCode();
} catch (e) {
Sentry.captureException(e);
}
(New in version 7.13.0.)
Import name: Sentry.modulesIntegration
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.
(New in version 7.17.1.)
Import name: Sentry.requestDataIntegration
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',
};
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: [
Sentry.onUncaughtExceptionIntegration({
onFatalError: () => {
// your implementation
},
}),
],
});
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!) or suggesting an update ("yeah, this would be better").