# icecreambar

> hapi plugin for rollbar error logging

Latest version **5.0.1** (published 2018-02-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install icecreambar
pnpm add icecreambar
yarn add icecreambar
bun add icecreambar
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2018-02-05 |
| First published | 2014-08-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | johnny domino |
| Maintainers | jamesdixon, jmonster |
| Keywords | hapi, plugin, rollbar, error, boom, log, logging |

## Links

- npm: https://www.npmjs.com/package/icecreambar
- Repository: https://github.com/yayuhh/icecreambar
- Homepage: https://github.com/yayuhh/icecreambar#readme
- Issues: https://github.com/yayuhh/icecreambar/issues
- npm.io page: https://npm.io/package/icecreambar

## Dependencies (1)

- [rollbar](https://npm.io/package/rollbar.md) ^2.3.2

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 5.0.1 (latest) — 2018-02-05
- 5.0.0 — 2018-01-23
- 4.4.0 — 2017-03-14
- 4.3.0 — 2017-01-25
- 4.2.0 — 2017-01-25
- 4.1.0 — 2017-01-18
- 4.0.0 — 2017-01-09
- 3.2.0 — 2016-06-22
- 3.1.0 — 2016-02-22
- 3.0.0 — 2016-02-09
- 2.3.0 — 2015-07-21
- 2.2.0 — 2015-07-20
- 2.1.0 — 2015-07-09
- 1.0.1 — 2014-08-24
- 1.0.0 — 2014-08-24

## README

![logo](https://raw.githubusercontent.com/yayuhh/icecreambar/master/logo.png)

# ice cream bar [![Build Status](https://travis-ci.org/yayuhh/icecreambar.svg?branch=master)](https://travis-ci.org/yayuhh/icecreambar)
[hapi](https://hapijs.com) plugin for [Rollbar](https://rollbar.com) error logging

## quick and easy
```javascript
let accessToken = process.env.ROLLBAR_SERVER_ITEM_ACCESS_TOKEN;

server.register({
  register: require('icecreambar'),
  options: { accessToken }
}, function (err) {

  if (err) { throw err; }

  var rollbar = server.plugins.icecreambar;
  rollbar.handleUncaughtExceptions(accessToken, { exitOnUncaughtException: true });
});
```

## thorough example

```javascript
// http://hapijs.com/api#server
var Hapi = require('hapi');
var server = new Hapi.Server();
server.connection({ port: 3000 });

server.route({
  method: 'get',
  path: '/foo',
  handler: function(request, reply) {

    // implicitly trigger an error to be recorded to Rollbar via `rollbar.handleError`:
    reply(new Error('ruh-roh!'));

    // access the underlying rollbar library directly
    var rollbar = server.plugins.icecreambar;

    // implicitly log [stuff] to rollbar's recordMessage
    // leveraging hapi's built in logging system
    // http://hapijs.com/api#serverlogtags-data-timestamp
    server.log(['rollbarMessage'], 'Interesting thing just happened [somewhere in the server]');
    request.log(['rollbarMessage'], 'Interesting thing just happened [in the current request]');

    // implicitly log [stuff] to rollbar's handleError
    // leveraging hapi's built in logging system
    // http://hapijs.com/api#serverlogtags-data-timestamp
    server.log(['rollbarError'], new Error('ruh-roh, bad server'));
    request.log(['rollbarError'], new Error('ruh-roh, bad request'));

    // access the underlying rollbar library directly
    var rollbar = server.plugins.icecreambar;
    // and then proceed to do what you'd like with it...

    // respond to the client
    reply('ok');
  }
});

let accessToken = process.env.ROLLBAR_SERVER_ITEM_ACCESS_TOKEN;

server.register({
  register: require('icecreambar'),
  options: { accessToken }
}, function (err) {

  if (err) { throw err; }
  server.start();
});
```

## person tracking
The personTracking option toggles passing user identifiers to Rollbar with errors and messages. To enable this feature, include `personTracking: true` in your options object. By default, this feature inspects `request.auth.credentials` for `id`, `email` and `username` parameters to send along with Rollbar requests. If your application uses different key names then you can configure them via an object as follows;

```js

let accessToken = process.env.ROLLBAR_SERVER_ITEM_ACCESS_TOKEN;

server.register({
  register: require('icecreambar'),
  options: {
    accessToken,
    personTracking: {
      // define your request.auth.credentials attribute names if they differ from the defaults, for example:
      email: 'my_email_key_name',
      id: 'my_id_key_name',
      username: 'my_user_name_key_name'
    }

    /* Defaults to {
      email: 'email_address',
      id: 'identifier',
      username: 'user_name'
    } */
    personTracking: true
  }
}, function (err) {

  if (err) { throw err; }
  server.start();
});

```


## uncaught exceptions
This feature should only be registered on the project level; i.e., do not enable it in your plugin(s), as the result could be unexpeted error reporting and/or duplicated errors. To leverage this feature, either require the [rollbar](https://rollbar.com/docs/notifier/node_rollbar/#uncaught-exceptions) module directly or access a registered instance (e.g. `server.plugins.icecreambar`). Either way, it'll look something like this:

```js
var rollbar = require('rollbar'); // this requires `rollbar` is installed to your `node_modules` folder
var rollbar = server.plugins.icecreambar; // this requires that you've registered `icecreambar` without a scope, or explicitly named the scope `default`. you can substitute `default` for any registered scope.

rollbar.handleUncaughtExceptions('POST_SERVER_ITEM_ACCESS_TOKEN', { exitOnUncaughtException: true });
```

## important
As of version 4.0.0 this module no longer supports `scopes` and can only be registered **once**. There is only one rollbar instance -- `server.plugins.icecreambar`. `icecreambar.default` continues to exist as a deprecated alias.

---
_Source: https://npm.io/package/icecreambar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
