Skip to main content
The @appsignal/stimulus package reports errors from your Stimulus controllers to AppSignal. It supports version 3 of the @hotwired/stimulus package, and version 1.1 and later 1.x versions of the stimulus package.

Installation

With npm or yarn

Add the @appsignal/stimulus and @appsignal/javascript packages to your package.json. Then, run yarn install/npm install. You can also add these packages to your package.json on the command line:

With JSPM.io import maps

Using the JSPM.io import map generator, you can generate an import map for your application’s dependencies. Add @appsignal/javascript and @appsignal/stimulus to the dependencies list in the generator, then add the generated import map and ES module shims to your application’s code.

With rails-importmap

Use the following command to add these packages to your Rails application’s import maps:

Usage

Application.handleError

installErrorHandler reports errors that Stimulus catches to AppSignal. It uses the controller’s identifier as the action name, or [unknown Stimulus controller] if there is none. It also adds framework and message tags. It then calls the previous handleError, which by default logs the error to the browser console. Pass installErrorHandler your Appsignal instance and your Stimulus application. To create the Appsignal instance, see the installation guide.

Rails 7 and later

Rails 7 and later apps import Stimulus from the @hotwired/stimulus package. A new app splits the Stimulus setup over two files in app/javascript/controllers/:
  • application.js starts the Stimulus application and exports it.
  • index.js imports that application and registers your controllers.
Install the error handler in application.js, after Application.start(). The index.js file doesn’t need any changes.

Stimulus 1.x with Webpacker

Apps that use Stimulus 1.x from the stimulus package with Webpacker install the error handler in javascript/controllers/index.js. In a new app created using rails new $APP_NAME --webpack=stimulus, for example, that file would look something like this: