Installation & Setup for NestJS

  1. Install Atatus Node.js package.

    copy
    icon/buttons/copy
    npm install --save atatus-nodejs
    
  2. Create atatus.js file in your project root with the following code:

    copy
    icon/buttons/copy
    // atatus.js - Atatus Agent Initialization
    
    import * as atatus from 'atatus-nodejs';
    
    atatus.start({
        licenseKey: "YOUR_LICENSE_KEY",
        appName: "YOUR_APP_NAME",
        analytics: true,
        analyticsCaptureOutgoing: true,
        logBody: 'all'
    });
    
    export default atatus;
    
  3. Start your NestJS application using one of these methods:

    Option 1: Using -r flag (recommended)

    copy
    icon/buttons/copy
    node -r ./atatus.js dist/main.js
    

    Option 2: Using NODE_OPTIONS environment variable

    copy
    icon/buttons/copy
    NODE_OPTIONS='-r ./atatus.js' npm run start:prod
    

    Or update your package.json scripts:

    {
      "scripts": {
        "start:prod": "NODE_OPTIONS='-r ./atatus.js' node dist/main.js"
      }
    }
    

    For more advanced options on installing your monitoring code, view customizing agent.

  4. Build and Start your NestJS server.

    Just restart your server and access it from your web app or mobile app or curl. You will visualize your application's metrics within minutes.