Skip to content

BrowserApiErrors | Sentry for Next.js

Source URL: https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/integrations/browserapierrors

This integration only works inside a browser environment.

Import name: Sentry.browserApiErrorsIntegration

This integration is enabled by default. If you’d like to modify your default integrations, read this.

This integration wraps native time and event APIs (setTimeout, setInterval, requestAnimationFrame, addEventListener/removeEventListener) in try/catch blocks to handle async exceptions.

Sentry.init({
integrations: [
Sentry.browserApiErrorsIntegration({
setTimeout: true,
setInterval: true,
requestAnimationFrame: true,
XMLHttpRequest: true,
eventTarget: true,
unregisterOriginalCallbacks: true,
}),
],
});

Type: boolean

Instrument the setTimeout browser built-in method.

Type: boolean

Instrument the setInterval browser built-in method.

Type: boolean

Instrument the requestAnimationFrame browser built-in method.

Type: boolean

Instrument the XMLHttpRequest browser built-in method.

Type: boolean | string[]

Instrument the addEventListener browser built-in method for a set number of default event targets. To override the default event targets, provide an array of strings with the event target names.

List of default event targets:

  • EventTarget
  • Window
  • Node
  • ApplicationCache
  • AudioTrackList
  • BroadcastChannel
  • ChannelMergerNode
  • CryptoOperation
  • EventSource
  • FileReader
  • HTMLUnknownElement
  • IDBDatabase
  • IDBRequest
  • IDBTransaction
  • KeyOperation
  • MediaController
  • MessagePort
  • ModalWindow
  • Notification
  • SVGElementInstance
  • Screen
  • SharedWorker
  • TextTrack
  • TextTrackCue
  • TextTrackList
  • WebSocket
  • WebSocketWorker
  • Worker
  • XMLHttpRequest
  • XMLHttpRequestEventTarget
  • XMLHttpRequestUpload

Type: boolean

Unregister the original EventTarget.addEventListener callbacks. If you experience issues with this integration (or the SDK) causing double invocations of an addEventListener callback, set this option to true. This is usually a sign of the SDK being initialized too late in the lifecycle of the page. If this is the case, you might want to consider initializing the SDK as early as possible to avoid this issue.