Installation

Install the Rasputin Express SDK on a long-running Node.js or Bun server. Set a release and create a client to capture production errors.

  1. 1

    Install the package

    Add the Express SDK to your app. Register requestMiddleware first, before parsers and routes. Register errorMiddleware after routes and before your final error handler.

    npm install @rasputin-ai/express

  2. 2

    Set your release

    Pass a Git commit SHA as release. On common hosts you can use the platform's existing variable instead of setting RASPUTIN_RELEASE.

    How to set the release field
  3. 3

    Create your client

    Initialize Rasputin once when your app starts.

    import express from 'express';
    import { RasputinInit } from '@rasputin-ai/express';
    
    const { client, requestMiddleware, errorMiddleware } = RasputinInit({
      dsn: process.env.RASPUTIN_DSN!,
      projectApiKey: process.env.RASPUTIN_PROJECT_API_KEY!,
      release: process.env.RASPUTIN_RELEASE!,
      environment: 'production',
    });
    
    const app = express();
    
    app.use(requestMiddleware); // Register before parsers and routes.
    app.use(express.json());
    app.get('/health', (_req, res) => {
      res.send('ok');
    });
    app.use(errorMiddleware); // Register before your final error handler.
    app.use((_error, _req, res, _next) => {
      res.status(500).json({ error: 'internal' });
    });

  4. 4

    That's it

    Uncaught errors will report on a long-running Node or Bun process.

    Set up the runtime recorder