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

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:

yarn add @appsignal/javascript
npm install --save @appsignal/javascript

Create an appsignal.js file to require and configure AppSignal. This file may also be placed in another file location, like in the src/ directory. Check with your team the best location for this file, but make sure to name it appsignal.js. For more information about the configuration, see our configuration section.

// appsignal.js
import Appsignal from "@appsignal/javascript"; // For ES Module
const Appsignal = require("@appsignal/javascript").default; // For CommonJS module
 
export const appsignal = new Appsignal({
  key: "YOUR FRONTEND API KEY",
});

(It's recommended (although not necessarily required) to use the instance of the Appsignal object like a singleton. To do this, export the client from the appsignal.js file.)

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

// index.js
// Place this at the top
import { appsignal } from "./appsignal"; // Update to the location used in the previous step
 
// Place your app code below this

Support for CDNs

Currently, we have no plans to supply a CDN-hosted version of this library.

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.

Want to help us improve this documentation page?

Create a pull request

Need more help?

Contact us and speak directly with the engineers working on AppSignal. They will help you get set up, tweak your code and make sure you get the most out of using AppSignal.

Contact us

Start a trial - 30 days free

AppSignal is a great way to monitor your Ruby, Elixir & Node.js applications. Works great with Rails, Phoenix, Express and other frameworks, with support for background jobs too. Let's improve your apps together.

Start a trial