raygun4node is the official Raygun.com Node.js SDK, written in TypeScript. It enables Node.js applications to send crash reports and error data to the Raygun error monitoring service.
- Error reporting to Raygun API
- Express.js middleware integration
- Breadcrumbs for debugging context
- Batched error transport for high-volume apps
- Offline caching with disk or custom storage providers
- Source map support for stack traces
- Custom error grouping and tagging
- User tracking for affected customer counts
lib/ # TypeScript source files
raygun.ts # Main Client class
raygun.transport.ts # HTTP transport for sending errors
raygun.batch.ts # Batched transport mode
raygun.offline.ts # Offline caching provider
raygun.breadcrumbs.ts # Breadcrumb tracking
raygun.messageBuilder.ts # Error payload builder
types.ts # TypeScript type definitions
build/ # Compiled JavaScript output
test/ # Test files (tap test framework)
examples/ # Usage examples
npm run prepare # Compiles TypeScript to build/npm test # Runs tests using tap with ts-nodenpm run eslint # Lint JS files (test/*.js, examples/)
npm run tseslint # Lint TS files (lib/*.ts)
npm run prettier # Format all source files- Language: TypeScript (compiled to ES5 CommonJS)
- Runtime: Node.js (>= 0.10.0)
- Test Framework: tap
- Linting: ESLint + TypeScript ESLint
- Formatting: Prettier
stack-trace: Stack trace parsingdebug: Debug logging (enabled viaDEBUG=raygun)
Two example applications are provided in examples/:
Demonstrates Express.js integration with Raygun middleware and breadcrumbs.
# From project root, build the package first
npm install
# Configure API key in examples/express-sample/config/default.json
# Then run the example
cd examples/express-sample
npm install && npm startKey files:
raygun.client.js- Raygun client setupapp.js- Express middleware configurationroutes/index.js-/sendand/errorendpoints
Shows how to use Raygun with Node.js domains (legacy, prefer reportUncaughtExceptions for Node 12+).
# From project root, build the package first
npm install
# Configure API key in examples/using-domains/config/default.json
# Then run the example
cd examples/using-domains
npm install && node app- Source files are in
lib/as.tsfiles - Tests are in
test/as.jsfiles - Entry point:
build/raygun.jswith types atbuild/raygun.d.ts - Use strict TypeScript (
"strict": true)