Node.js SDK
0. Prerequisites
1. Installing node-SDK package
npm install @hypertestco/node-sdk-v3 nyc --save-exact 2. Initializing sdk
2.1 Create ht-init file
// process.env.APPLY_HT_OTEL_PATCH = 'yes'; // Set this env only if opentelemetry is already being used in your application.
import * as htSdk from '@hypertestco/node-sdk-v3'; // for esm/ts
// const htSdk = require('@hypertestco/node-sdk-v3'); // for commonJS
// hypertest runs only if process.env.HT_MODE is set to 'RECORD'.
// It is safe to run this code as-is in production because HT_MODE wont be set to RECORD there
htSdk.initialize({
apiKey: '<your-api-key>',
serviceId: '<your-service-identifier-from-dashboard>',
serviceName: '<organizationName:service-name>',
exporterUrl: '<hypertest-logger-url>'
});
2.3 import ht-init file at the top in entrypoint
3. Add ht-start command in package.json
4. Verifying traffic is captured
Last updated