# hapi-tattle

> Hapi plugin that reports transactions to a central service

Latest version **0.2.0** (published 2015-09-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install hapi-tattle
pnpm add hapi-tattle
yarn add hapi-tattle
bun add hapi-tattle
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2015-09-25 |
| First published | 2015-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| Author | Powell Kinney |
| Maintainers | pkinney |
| Keywords | hapi, transaction, http |

## Links

- npm: https://www.npmjs.com/package/hapi-tattle
- Repository: https://github.com/dialexa/hapi-tattle
- Issues: https://github.com/dialexa/hapi-tattle/issues
- npm.io page: https://npm.io/package/hapi-tattle

## Dependencies (5)

- [joi](https://npm.io/package/joi.md) ^6.0.8
- [boom](https://npm.io/package/boom.md) ^2.6.1
- [hoek](https://npm.io/package/hoek.md) ^2.11.1
- [yarp](https://npm.io/package/yarp.md) ^0.3.0
- [bluebird](https://npm.io/package/bluebird.md) ^2.10.1

## Recent versions

- 0.2.0 (latest) — 2015-09-25
- 0.1.4 — 2015-03-21
- 0.1.3 — 2015-03-14
- 0.1.2 — 2015-03-13
- 0.1.1 — 2015-03-11

## README

Tattle Plugin for Hapi
======================

[![npm version](https://badge.fury.io/js/hapi-tattle.svg)](http://badge.fury.io/js/hapi-tattle)
[![Build Status](https://travis-ci.org/dialexa/hapi-tattle.svg)](https://travis-ci.org/dialexa/hapi-tattle)
[![Coverage Status](https://coveralls.io/repos/dialexa/hapi-tattle/badge.svg)](https://coveralls.io/r/dialexa/hapi-tattle)

A Hapi plugin that reports certain requests to a central HTTP service.  Works with Hapi version 8 or later.

```bash
npm install --save hapi-tattle
```

Register the plugin and each request for which `filterFunc` returns true will result in a call to `url` containing information about the request.  The call occurs as a `onPreResponse` extension and doesn't interrupt the response.  It also registers a "tail" event that resolves after the external service responds.

```javascript
var Hapi = require('hapi');

var server = new Hapi.Server();
server.connection({
  host: 'localhost',
  port: 8000
});

server.register({
  register: require('hapi-tattle'),
  options: {
    url: 'https://my.app.com/transactions',
    filterFunc: function(req){
      return req.route.settings.app.isTransaction;
    }
  }
}, function(){
  server.start();
});

server.route({
  method: 'GET',
  url: '/tracked',
  config: {
    app: {
      isTransaction: true
    }
  },
  method: function(req, reply){
    reply('ok');
  }
})

server.route({
  method: 'GET',
  url: '/untracked',
  config: {
    app: {
      isTransaction: false
    }
  },
  method: function(req, reply){
    reply('ok');
  }
})
```

With the above, information about calls to `/tracked` will be posted to `https://my.app.com/transactions`, and those to `/untracked` will not be.

Plugin Options
--------------

The following options are available when registering the plugin:
- _'url'_ (required) - the URL to call for authentication.
- _'auth'_ - authentication object that will be included with the request to the external service.  Can be an object including `username` and `password` or `null` to not authenticate the request.  Defaults to `null`.
- _'filterFunc'_ - function that will be passed the request object and, if it returns `true`, the request will be reported.  Otherwise the report will be skipped.  Defaults to a function that always returns `true`.
- _'objectName'_ - the name of the object that will be sent to the external service.  Defaults to "transaction".
- _'otherData'_ - static object to be merged with the transaction object being sent.  Defaults to `null`.

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