AppSignal for JavaScript configuration

When initialising AppSignal in your application, you must pass an object with configuration options to the Appsignal constructor:

JavaScript
const appsignal = new Appsignal({ key: "YOUR FRONT-END API KEY", // ... other configuration options ... });

The following configuration options are available:

key

  • Type: string

This configuration option is required to send data to AppSignal. If this configuration option is not set, AppSignal for JavaScript will run in development mode, and no data will be sent to AppSignal.

The front-end error monitoring API key for your application. You can find this API key under "Front-end error monitoring" in the "Push & Deploy" section of your application's settings.

This is not the same as the organization-level or application-level API key, which is used for monitoring in our back-end integrations.

namespace

  • Type: string
  • Default value: "frontend"

The default namespace to use to report errors to AppSignal. Read more in our namespaces guide.

revision

  • Type: string

Set the app revision for the currently running version of your app. This is used to create deploy markers and tag all incoming data as belonging to a specific deploy. Read more in our deploy markers guide.

ignoreErrors

  • Type: RegExp[]

An array of regular expressions to check against the message property of any error reported to AppSignal. If any of the regular expressions matches, the error is ignored. Read more in our ignoring errors guide.

matchBacktracePaths

This feature requires AppSignal for JavaScript version 1.5.0 or higher.
  • Type: RegExp[]

This configuration option is useful when developing applications for desktop and mobile environments, or when deploying the same application environment to multiple domains. Most applications will not need to use this configuration option.

Using this configuration option will break public sourcemap detection. To use this configuration option with a sourcemapped codebase, you must upload private sourcemaps for your application.

This configuration option is experimental and may change in future versions.

An array of regular expressions with one or more match groups. These regular expressions will be checked against the backtrace line paths of errors reported to AppSignal. If any of the regular expressions matches with one or more non-empty match groups, the path in the backtrace line is replaced with the result of concatenating the match groups.

This is useful when the path at which your application is deployed is not known ahead of time. For example, the path to an Electron application may be different on each user's machine. You can match for the part of that path that is known to represent your application.

For example, if your application's source code is located at a path like the following, where ${USERNAME} changes for each user:

Shell
/Users/${USERNAME}/Applications/MyApp.app/Contents/Resources/bundle/app.js`

Then you can use this configuration option as follows:

JavaScript
const appsignal = new Appsignal({ // ... other configuration options ... matchBacktracePaths: [new RegExp("MyApp.app/Contents/Resources/(.*)")], });

When an error is reported, the backtrace line paths will be replaced with the result of the match group, which in this example will be bundle/app.js.

This ensures that errors reported to AppSignal are grouped correctly when using backtrace line grouping, and allows for private sourcemaps to be uploaded for the cleaned path.