Quick Start
Get started with the Node.js Agent.

Installing the Agent

Installing the Bearer Agent generally only takes a few minutes. You will need an account on Bearer.sh to obtain your secret key.
To enable the Bearer Agent within your application, you'll need to:
    Install the Agent and initialize it in your application.
    Set up any optional configuration settings.
Open a terminal and install the @bearer/node-agent module into your project:
npm install --save @bearer/node-agent
# OR
yarn add @bearer/node-agent

Minimum configuration

Now, open your application's main script (e.g., index.js or main.js) and initialize the Bearer agent at the top:
const Bearer = require('@bearer/node-agent')
Bearer.init({ secretKey: 'YOUR_BEARER_SECRET_KEY' })
.then(() => {
console.log('Bearer Initialized!')
The Bearer Agent is asynchronous. If initializing at the top level we suggest using the approach shown above, however you can use async/await where it is supported.
Your Bearer Secret Key, secretKey, can be found in the settings for your app on the Bearer Dashboard at Settings > Keys. Each application you have created in the Bearer Dashboard has its own unique key.
Now, you can start your application (e.g., node index.js). All API calls will be monitored and available on your Bearer Dashboard.
We strongly recommend initializing the Bearer agent as early as possible in your codebase. This ensure that all external HTTP requests performed on your application are monitored.

Start monitoring your APIs!

With the Agent set up, you can begin monitoring your APIs on the Bearer Dashboard. To learn more about the features available on the Dashboard and how to get started, explore our Get to Know the Dashboard documentation.

Communication with Bearer

The Bearer agent communicates with Bearer servers through HTTPS. The Agent requires your firewall to allow outgoing connections to agent.bearer.sh with port 443 (HTTPS).
By default, the Agent sends to the full payload of each HTTP request (including both the request and the response) to Bearer. By default and for your own security, the Authorization header is filtered and will not be shared with Bearer.
The agent offers more options to reduce the amount of sensitive information sent to Bearer. To learn more about how to sanitize specific parts of your data, see the Keep your Data Protected documentation.
What if Bearer is experiencing a downtime? The Bearer agent has been built with resiliency in mind. If, for any reason, Bearer servers are experiencing unexpected latency, this will not affect your application.
Last modified 1yr ago