A simple transform stream for filtering events from good.
Lead Maintainer: Adam Bretz
good-squeeze is a transform stream useful in custom good reporter clients. It should generally be used as the first step in a custom pipeline to filter out events that the current reporter isn't subscribed to.
Creates a new GoodSqueeze object where:
events
an object where each key is a valid good event, and the value is a string or array of strings representing event tags. "*" indicates no filtering.null
andundefined
are assumed to be "*".options
an optional configuration object that gets passed to the NodeStream.Transform
constructor. NoteobjectMode
is alwaystrue
for allGoodSqueeze
objects.
A static method on GoodSqueeze
that creates a new event subscription map where:
events
an object where each key is a valid good event, and the value is a string or array of strings representing event tags. "" indicates no filtering.null
andundefined
are assumed to be "".
var GoodSqueeze = require('good-squeeze');
GoodSqueeze.subscription({ log: 'user', ops: '*', request: ['hapi', 'foo'] });
// Results in
// {
// log: [ 'user' ],
// ops: [],
// request: [ 'hapi', 'foo', 'hapi', 'foo' ]
// }
Useful for creating an event subscription to be used with GoodSqueeze.filter
if you do not plan on creating a pipeline coming from good and instead want to manage event filtering manually.
Returns true
if the supplied data.event
+ data.tags
should be reported based on subscription
where:
subscription
- a subscription map created byGoodSqueeze.subscription()
.data
- event object emitted from good/hapi which should contain the following keys:event
- a string representing the event name ofdata
tags
- an array of strings representing tags associated with this event.