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

rollbar-api

v1.0.4

Published

A node.js wrapper for the Rollbar API

Downloads

12

Readme

Rollbar Web API for Node

Build Status Coverage Status

A node.js wrapper for the Rollbar Web API. Rollbar already provides an SDK for node.js applications, so if you're looking to track errors and crashes, you should check that out first. Although there are plans to implement the Rollbar notifier functionalities in this project, they are not currently included.

What this package does, however, is provide you with a way to access an manipulate Rollbar account information. For example, if you want a way to programmatically look up or create new Rollbar projects and grab the relevent access tokens, this module is for you.

Included functions:

Invites

  • Invite a user to a team
  • Get information about an invitation
  • List all invitations for a team
  • Cancel a pending invitation

Items (GET, PATCH)

  • Coming soon
    • ~~Get an item by its ID~~
    • ~~Get an item by its counter~~
    • ~~List all items~~
    • ~~Modify an item~~

Items (POST)

  • Coming soon
    • ~~Create an item~~

Occurrences

  • Coming soon
    • ~~Get an occurrence by its ID~~
    • ~~List occurrences~~
    • ~~List occurrences of a specific item~~
    • ~~Delete an occurrence~~

Projects

  • List projects in an account
  • Get information about a specific project
  • Delete a project
  • Create a project
  • List project access tokens
  • Update project access token rate limits

Reports

  • Coming soon
    • ~~Get top recent active items~~
    • ~~Get occurrence counts~~
    • ~~Get activated counts~~

Teams

  • Get information about a specific team
  • List teams for an account
  • Create a new team
  • Delete a team
  • Check if a project is within a specific team
  • Add a project to a team
  • Remove a project from a team
  • Check if a user is part of a team
  • List team members
  • Remove a user from a team

Users

  • Get information about a specific user

Installation

$ npm install --save

Usage

As of now, only account-level functions are included (i.e., any function requiring a project-level access token would not work under the current configuration).

Therefore, the tokens you should pass upon instantiation are the read and write tokens found in your Rollbar account settings.

var Rollbar = require('rollbar-api');
var rollbar = new Rollbar({
  read: '<account_read_token>',
  write: '<account_write_token>'
});

Then, you can use methods to interact directly with Rollbar API

// get a list of projects
rollbar.listProjects(function (err, res) {
  if (err) {
    return console.log(err.message);
  }
  console.log("Array of projects", res.body);
});

Interacting with Responses

Errors

Callbacks will receive an error object if:

  1. Either the http request itself was unsuccessful
  2. Or the response from Rollbar was an error (http status code of >200)

Examples of the latter include attempting to make API calls with the incorrect token or trying to access information that does not exist (e.g., calling getUser() on a nonexistent user ID).

Rollbar API-type error objects have the following properties:

{
  name: "RollbarAPIError",
  message: "<message from Rollbar API>",
  statusCode: "<numeric http status code from Rollbar API>",
  statusMessage: "<http status message corresponding to statusCode>"
}

where statusCode can be any of 400, 403, 404, 413, 422, or 429. See this page for more information.

Responses

If the http request was successful and the Rollbar API processes the request, a response will be returned. All responses have the following properties:

{
  statusCode: 200,
  headers: {
    // http headers
  },
  body: {
    // json-encoded reply from the API
  }
}

where headers are from an http.incomingMessage instance.

Methods

View documentation here.

Debugging

You can start your application with a debug environment variable to view the raw http requests (being sent through the awesome request package) like this:

NODE_DEBUG=request node app.js

Tests

You can run unit tests with mocha.