plugin-window-events

The @appsignal/plugin-window-events plugin binds to the window.onerror and window.onunhandledrejection event handlers to catch any errors that are otherwise not caught elsewhere in your code.

Installation

Add the @appsignal/plugin-window-events and @appsignal/javascript packages to your package.json file and run yarn install/npm install.

You can also add these packages to your package.json on the command line:

Shell
yarn add @appsignal/javascript @appsignal/plugin-window-events npm install @appsignal/javascript @appsignal/plugin-window-events

Usage

JavaScript
import { plugin } from `@appsignal/plugin-window-events` appsignal.use(plugin(options));

Use with Next.js

Even with "use client", Next.js pre-renders client components on the server, where the window object is not available. Guard the plugin initialization with:

JavaScript
if (typeof window !== "undefined") { appsignal.use(plugin(options)); }

plugin options

The plugin can be initialized with the following options:

ParamTypeDescription
onerrorBoolean(optional) A boolean value representing whether the plugin should bind to the window.onerror handler. Defaults to true.
onunhandledrejectionBoolean(optional) A boolean value representing whether the plugin should bind to the window.onunhandledrejection handler. Defaults to true.