Documentation navigation

Installing AppSignal for JavaScript

Installation

First, add the @appsignal/javascript package to your package.json. Then, run yarn install/npm install. You'll also need a Push API 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:

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

You can then import and use the package in your bundle:

1
2
3
4
5
6
import Appsignal from "@appsignal/javascript" // For ES Module
const Appsignal = require("@appsignal/javascript").default // For CommonJS module

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. One way that you can do this is by exporting an instance of the library from a .js/.ts file somewhere in your project.

1
2
3
4
5
import Appsignal from "@appsignal/javascript"

export default new Appsignal({
  key: "YOUR FRONTEND API KEY"
})

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.

Supported browsers

This package can be used in any ECMAScript 5 compatible browser. We aim for compatibility down to Internet Explorer 9 (roughly 0.22% of all browsers used today). All browsers older than this can only supported on a “best effort” basis, and full functionality cannot be guaranteed.

When developing, don’t forget to check browser support on Can I Use? and the ES6 Compatibility Table, and provide the appropriate polyfills or fallbacks. In a small percentage of browsers, a Promise polyfill may be required to use this library.

@appsignal/javascript also works in React Native/Expo apps!

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

We'd like to set cookies, read why.