Default Integrations
The below system integrations are part of the standard library or the interpreter itself and are enabled by default. To understand what they do and how to disable them if they cause issues, read on.
What's Enabled by Default
InboundFilters
Import name: Sentry.Integrations.InboundFilters
This integration allows you to ignore specific errors based on the type, message, or URLs in a given exception.
By default, it'll ignore errors that start with Script error
or Javascript error: Script error
.
To configure this integration, 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 functions and method names, even when those functions or methods are wrapped by our error or breadcrumb handlers.
TryCatch
Import name: Sentry.Integrations.TryCatch
This integration wraps native time and events APIs (setTimeout
, setInterval
, requestAnimationFrame
, addEventListener/removeEventListener
) in try/catch
blocks to handle async exceptions.
Breadcrumbs
Import name: Sentry.Integrations.Breadcrumbs
This integration wraps native APIs to capture breadcrumbs. By default, the Sentry SDK wraps all APIs.
Available options:
{
// Log calls to `console.log`, `console.debug`, etc
console: boolean;
// Log all click and keypress events
// - When an object with `serializeAttribute` key is provided,
// Breadcrumbs integration will look for given attribute(s) in DOM elements,
// while generating the breadcrumb trails.
// Matched elements will be followed by their custom attributes,
// instead of their `id`s or `class` names.
dom: boolean | { serializeAttribute: string | string[] };
// Log HTTP requests done with the Fetch API
fetch: boolean;
// Log calls to `history.pushState` and friends
history: boolean;
// Log whenever we send an event to the server
sentry: boolean;
// Log HTTP requests done with the XHR API
xhr: boolean;
}
GlobalHandlers
Import name: Sentry.Integrations.GlobalHandlers
This integration attaches global handlers to capture uncaught exceptions and unhandled rejections.
Available options:
{
onerror: boolean;
onunhandledrejection: boolean;
}
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 Sentry SDK sets the limit to five and the key used is "cause"
.
Available options:
{
key: string;
limit: number;
}
Here is a code example of how this could be implemented:
document
.querySelector("#get-reviews-btn")
.addEventListener("click", async (event) => {
const movie = event.target.dataset.title;
try {
const reviews = await fetchMovieReviews(movie);
renderMovieReviews(reviews);
} catch (e) {
const fetchError = new Error(`Failed to fetch reviews for: ${movie}`);
fetchError.cause = e;
Sentry.captureException(fetchError);
renderMovieReviewsError(fetchError);
}
});
HttpContext
(Previously: UserAgent
)
Import name: Sentry.Integrations.HttpContext
Before version 7.0.0 of the Sentry SDK, this integration was called UserAgent
.
It was renamed because the integration handles more than user-agent data.
Import name: Sentry.Integrations.UserAgent
This integration attaches HTTP request information, such as URL, user-agent, referrer, and other headers to the event. It allows us to correctly catalog and tag events with specific OS, browser, and version information.
Dedupe
Import name: Sentry.Integrations.Dedupe
This integration is enabled by default for Browser, but only deduplicates certain events. It can be helpful if you're receiving many duplicate errors. Note, that Sentry only compares stack traces and fingerprints.
import * as Sentry from "@sentry/browser";
import { Dedupe as DedupeIntegration } from "@sentry/integrations";
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [new DedupeIntegration()],
});
Modifying System Integrations
To disable system integrations, set defaultIntegrations: false
when calling init()
.
To override their settings, provide a new instance with your config to the integrations
option. For example, to turn off browser capturing console calls:
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [
new Sentry.Integrations.Breadcrumbs({
console: false,
}),
],
});
Removing an Integration
This example removes the default-enabled integration for adding breadcrumbs to the event:
Sentry.init({
// ...
integrations: function (integrations) {
// integrations will be all default integrations
return integrations.filter(function (integration) {
return integration.name !== "Breadcrumbs";
});
},
});
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/gatsby
- Version:
- 7.54.0
- Repository:
- https://github.com/getsentry/sentry-javascript