Installing AppSignal for JavaScript

Please follow the installation guide first, when adding a new application to AppSignal.

Creating a Push API Key

Before you begin, you'll need to find your Push API key on the "Push and deploy" section of your App settings page. You'll be able to find your API key under the "Front-end error monitoring". Once you have your key, follow the instructions under the Installation section to use it in your application.

Installation

With npm or yarn

First, add the @appsignal/javascript package to your package.json. Then, run yarn install/npm install. You'll also need a Front-end error monitoring key from the "Push and deploy" section of your App settings page.

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

bash
yarn add @appsignal/javascript npm install @appsignal/javascript

With JSPM.dev

It is not recommended to use the JSPM.dev CDN in production. For a production-ready setup without a build step, we recommend using JSPM.io import maps.

Thanks to the JSPM CDN, it is possible to use the AppSignal for JavaScript integration without a front-end asset build step. Your application can import packages directly from the CDN:

javascript
import Appsignal from "https://jspm.dev/@appsignal/javascript";

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 to the dependencies list, 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:

sh
./bin/importmap pin @appsignal/javascript

Usage

Create an appsignal.js file to require and configure AppSignal. From this file, we export the instance of the Appsignal object that we will use from our application. For more information about the configuration, see our configuration section.

javascript
// appsignal.js // For ES Module via npm/yarn, or with import maps import Appsignal from "@appsignal/javascript"; // For CommonJS module via npm/yarn const Appsignal = require("@appsignal/javascript").default; // With the JSPM.dev CDN import Appsignal from "https://jspm.dev/@appsignal/javascript"; export const appsignal = new Appsignal({ key: "YOUR FRONTEND API KEY", });

You can then import and use the Appsignal object in your app:

javascript
// Place this at the top // Import the file created in the previous step import { appsignal } from "./appsignal"; // Place your app code below this

NOTE: If you are running a CDN in front of your assets, you'll need to make two changes for error reporting to be able to send errors to our API endpoint. Read more about the required changes.

If you use Content Security Policy, make sure to add the correct headers as described here.


Continue with our installation guide.

Uninstall

Uninstall AppSignal from your app by following the steps below. When these steps are completed your app will no longer send data to the AppSignal servers.

  1. In the package.json of your app, delete all lines referencing an appsignal package: "*appsignal/*": "*".

  2. Run npm install or yarn install to update your package.lock/yarn.lock with the removed packages state.

    • Alternatively, run npm uninstall @appsignal/<package name> or yarn remove @appsignal/<package name> to uninstall an AppSignal package.
  3. Remove any AppSignal configuration from your app.

  4. Commit, deploy and restart your app.

    • This will make sure the AppSignal servers won't continue to receive data from your app.
  5. Finally, remove the app on AppSignal.com.

Continue with our uninstall guide.