Opbeat HTTP Client
The `opbeat-http-client` is a low-level HTTP client designed specifically for interacting with the Opbeat intake API, intended for developers building higher-level Opbeat integration modules rather than direct application usage. Its last published version is 1.2.2, which was released before Opbeat's acquisition by Elastic in June 2017. Following the acquisition, the standalone Opbeat service was transitioned into Elastic APM, and related Opbeat agents (like `opbeat-node`) were deprecated in favor of Elastic APM agents. Consequently, this client is no longer maintained and its target API is obsolete. It primarily differentiates itself by being a minimal, focused client for a specific (now defunct) APM service, in contrast to general-purpose HTTP clients like Axios or Node's built-in `http` module.
Common errors
-
Error: getaddrinfo ENOTFOUND intake.opbeat.com
cause The Opbeat intake API endpoint (intake.opbeat.com) is no longer active or resolvable.fixThis error confirms the Opbeat service is offline. The package is obsolete; migration to Elastic APM or another APM solution is required. -
TypeError: opbeatHttpClient is not a function
cause Attempting to directly call `opbeat-http-client` as a function without `require` or using it like an ES module `import`.fixEnsure you are using `const opbeatHttpClient = require('opbeat-http-client')({ ... })` for CJS environments, passing the configuration object directly to the `require`'d factory function.
Warnings
- breaking The Opbeat service and its associated APIs were deprecated following its acquisition by Elastic in June 2017. This client communicates with the intake.opbeat.com API, which is no longer active. Any attempts to use this client will result in network errors or failed requests, as the service has been replaced by Elastic APM.
- deprecated This package is explicitly considered abandoned and unmaintained. Its last update was prior to 2018. Using it introduces risks associated with unpatched vulnerabilities, lack of compatibility with modern Node.js versions, and reliance on a defunct service.
- gotcha The client requires all initialization options (`appId`, `organizationId`, `secretToken`, `userAgent`) to be present. Omitting any of these will lead to runtime errors during client instantiation.
Install
-
npm install opbeat-http-client -
yarn add opbeat-http-client -
pnpm add opbeat-http-client
Imports
- opbeatHttpClientFactory
import opbeatHttpClientFactory from 'opbeat-http-client';
const opbeatHttpClientFactory = require('opbeat-http-client'); - client.request
opbeatHttpClient.request('errors', body, callback);
Quickstart
const opbeatHttpClientFactory = require('opbeat-http-client');
// NOTE: The Opbeat service is deprecated. This code will likely fail
// as the intake API endpoints are no longer active.
// Replace with your actual (historical) Opbeat credentials if attempting to run.
const client = opbeatHttpClientFactory({
appId: process.env.OPBEAT_APP_ID ?? 'your-app-id',
organizationId: process.env.OPBEAT_ORG_ID ?? 'your-organization-id',
secretToken: process.env.OPBEAT_SECRET_TOKEN ?? 'your-secret-token',
userAgent: 'my-custom-module/1.0.0'
});
const errorBody = {
message: 'Simulated error from opbeat-http-client',
culprit: 'example.js',
timestamp: new Date().toISOString()
};
client.request('errors', errorBody, function (err, res, body) {
if (err) {
console.error('Failed to send error to Opbeat:', err.message);
// Expected error: 'getaddrinfo ENOTFOUND intake.opbeat.com'
} else if (res && res.statusCode !== 202) {
console.error(`Opbeat responded with status ${res.statusCode}: ${body}`);
} else {
console.log('Successfully sent error to Opbeat:', body);
}
});
console.log('Attempting to send data to deprecated Opbeat API...');