Hud Node.js SDK

1.8.3 · active · verified Sun Apr 19

The `hud-sdk` package provides a lightweight, low-overhead runtime sensor for Node.js applications, designed to capture real-time, function-level behavior directly from production environments. It observes performance characteristics, error behavior, and execution patterns without requiring manual instrumentation, logs, or dashboards. The SDK integrates with various developer tools, including IDEs and CI/CD pipelines, and is specifically optimized for AI-assisted development workflows (e.g., GitHub Copilot, Cursor) to ensure AI-generated code is production-safe. Current stable version is 1.8.3, with frequent updates indicated by its last publish date. It differentiates itself by offering continuous visibility directly in the developer's IDE, focusing on high-fidelity, function-level data, and adhering to strict security and privacy standards (SOC 2 Type II, ISO 27001, GDPR compliance), transmitting only anonymized metadata.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes the Hud Node.js SDK for runtime monitoring and demonstrates a basic Express application whose routes and errors will be automatically instrumented and monitored by Hud. It requires a `HUD_API_KEY` environment variable.

import { register } from 'hud-sdk';

// Ensure this is called as early as possible in your application's entry file.
// It's crucial for Hud's auto-instrumentation to wrap functions correctly.
register({
  apiKey: process.env.HUD_API_KEY ?? '',
  // Optional: Provide a service name for better identification in Hud's dashboard
  serviceName: process.env.SERVICE_NAME ?? 'my-nodejs-app',
  // Optional: Enable debug logging if needed for troubleshooting
  // debug: process.env.NODE_ENV === 'development'
});

// Example of a simple Express app to demonstrate instrumentation
import express from 'express';

const app = express();
const port = 3000;

app.get('/', (req, res) => {
  console.log('Request received for /');
  res.send('Hello from Hud-instrumented app!');
});

app.get('/error', (req, res) => {
  console.error('Simulating an error!');
  throw new Error('This is a simulated error detected by Hud!');
});

app.listen(port, () => {
  console.log(`Server running on http://localhost:${port}`);
});

view raw JSON →