npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

atatus-node

v0.1.7

Published

The official Atatus agent for Node.js

Downloads

1,092

Readme

Atatus for Node.js

Atatus Node.js agent allows you to monitor your Node.js application performance and captures errors in real-time.

Create a free account to start monitoring your Node.js apps.

Installation & Setup

Install atatus-node using npm:

npm install --save atatus-node

Require atatus-node in your node.js app:

var atatus = require("atatus-node");

Start the atatus agent with your API key:

atatus.start({ apiKey: "YOUR_API_KEY" });

See below for additional configuration options.

Configuration

The atatus.start can accept other options along with API Key. The options can be a combination of any of the following:

appVersion

If you use an appVersion to identify releases of your app you can send it to Atatus. It is highly recommended to set App Version.


// From your app Package.json
atatus.start({ apiKey: "YOUR_API_KEY", appVersion: require('./package.json').version });


// OR

// You can also directly assign it
atatus.start({ apiKey: "YOUR_API_KEY", appVersion: "1.0.0" });

releaseStage

By default, Atatus looks at the NODE_ENV environment variable to see what releaseStage the script is running in. If that is not set, Atatus assumes you are running in production. If you want to override this behavior, you can set the releaseStage option:

atatus.start({ apiKey: "YOUR_API_KEY", releaseStage: "development" });

projectRoot

Atatus can highlight stacktrace lines that are in your project, and automatically hides stacktrace lines from external libraries. If Atatus is not hiding external stacktrace lines, it is likely that the projectRoot is being incorrectly calculated. You can set projectRoot as part of the register call:

atatus.start({ apiKey: "YOUR_API_KEY", projectRoot: "/path/to/root" });

tags

It is often very useful to send some extra info along with errors and performance metrics, so that you can filter them in the Atatus UI. To do this, you can set the tags:

atatus.start({ apiKey: "YOUR_API_KEY", tags: ['new-user', 'signup'] });

customData

To debug error effectively, you can also send some meta data along with errors. To do this, you can set the customData:

atatus.start({ apiKey: "YOUR_API_KEY", customData: { foo: 'bar', name: "John Doe" }});

proxy

You can use a proxy server by configuring a proxy url when registering with atatus.

atatus.start({ apiKey: "YOUR_API_KEY", proxy: "http://localhost:8080" });

hostname

By default we'll fetch the hostname using Node's os.hostname(), but you can override this as follows:

atatus.start({ apiKey: "YOUR_API_KEY", hostname: "web1.example.com" });

beforeErrorSend

If you want to modify error reports just before they are sent to Atatus, or prevent them from being sent, you can add before notify callbacks:

Atatus.beforeErrorSend(function (payload) {

    var errorMessage = payload.exceptions[0].message;

    // Dont send Not found message
    if (errorMessage.indexOf('Not Found') === 0) {
        return false;
    }

    return true;
});

sendCode

If you want to send code snippets for each frame of the stacktrace you can enable sendCode. This asynchronously loads any file from the stacktrace, which is within the scope of the project, and sends 3 lines either side of the erroneous line of code to Atatus.

This works almost the same as how Atatus JavaScript projects handle sourcemaps - however loading the code is done on the local machine and sent over the internet with the error data. By default, this option is enabled. If you don't want, you can disable it.

atatus.start({ apiKey: "YOUR_API_KEY", sendCode: false });

groupingKey

If you need programmatical control over how the errors are grouped within atatus, you can send a groupingKey to the notify call. This will ensure that atatus groups all errors with the same groupingKey together.

atatus.start({ apiKey: "YOUR_API_KEY", groupingKey: function(payload) {
        // You can generate grouping based on error payload details or send static grouping key for all errors
        return "auth/create";
    }
});

Notify Error

Atatus automatically captures exceptions and HTTP errors from your Node.js app. If you want to send error manually, you can do it by atatus.notifyError function. The accepts an error as either a string or an Error object as the first argument, as well as options object as its second parameter. The second parameter may contain tags, custom data and user id.

atatus.notifyError(new Error("Something went badly wrong"), { tags: ['new-user', 'signup'], customData: { name: 'John Doe', country: 'US' } });

userId

A unique identifier for a user affected by this error. This could be any distinct identifier that makes sense for your application. In Express/Connect apps, this is automatically set to the ip address of the current request.

atatus.notifyError(new Error("Something went badly wrong"), { userId: "[email protected]" });