Node.js SDK with CJS
How to add nodejs sdk into your application
1. Installing node-SDK package
npm install @hypertestco/node-sdk --save-exact 2. Initializing sdk
2.1 Adding SDK in code and Initialize
// process.env.APPLY_HT_OTEL_PATCH = 'yes'; // Set this env only if opentelemetry is already being used in your application.
process.env.HT_MODE = process.env.HT_MODE || 'RECORD'; // TODO: REMOVE THIS LINE BEFORE DEPLOYING TO PRODUCTION
import * as htSdk from '@hypertestco/node-sdk'; // for esm/ts
// const htSdk = require('@hypertestco/node-sdk'); // for commonJS
htSdk.initialize({
apiKey: '<your-api-key>',
serviceId: '<your-service-identifier-from-dashboard>',
serviceName: '<organizationName:service-name>',
exporterUrl: '<hypertest-logger-url>',
// ignoredHostsForHttpReqs: ['abc.xyz.com', /^\d+\.abcd\.co(m|)$/],
// disableInstrumentations: [] // htSdk.HtInstrumentations enum
});
// No imports or require calls should be made before htSdk.initialize is called. Fight your instincts and your linters for this :)2.2 Mark app as ready
2.4 Set env if opentelemetry is already being used.
3. Verifying traffic is captured

Last updated