AppSignal for Node.js configuration
In this section, we'll explain how to configure AppSignal, what can be configured in the Node.js package, and what the minimal configuration needed is.
Minimal required configuration
The minimal required configuration needed by AppSignal for Node.js is the following items. If they are not present, AppSignal will not send any data to AppSignal.com.
- A valid Push API Key
- An application name
- An application environment (
development
/production
/test
by settingNODE_ENV
) - The setting
active: true
The integration supports loading its configuration via options passed to the Appsignal
constructor. We recommend creating an appsignal.cjs
file to require and initialize AppSignal.
// appsignal.cjs const { Appsignal } = require("@appsignal/nodejs"); new Appsignal({ active: true, name: "<YOUR APPLICATION NAME>", pushApiKey: "<YOUR API KEY>", });
Alternatively, you can configure the agent using system environment variables. AppSignal will automatically become active if the APPSIGNAL_PUSH_API_KEY
environment variable is set.
export APPSIGNAL_PUSH_API_KEY="<YOUR API KEY>" export APPSIGNAL_APP_NAME="<YOUR APPLICATION NAME>" export APPSIGNAL_APP_ENV="production"
Configuration options
Read about all the configuration options on the options page.
Application environments
An application can have multiple environments such as "development", "test", "staging" and "production".
To separate the errors and performance issues that occur in the "development" environment and those in "production", it's possible to set the environment in which the application is running with the NODE_ENV
environment variable.
If you activate AppSignal per environment, you can set the active
property of the options you pass into the constructor conditionally:
// appsignal.cjs const { Appsignal } = require("@appsignal/nodejs"); new Appsignal({ active: process.env.NODE_ENV !== "development", name: "<YOUR APPLICATION NAME>", pushApiKey: "<YOUR API KEY>", });
This will also disable AppSignal when running your tests.