Skip to content

collectors/segment-webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

segment-webhook

NPM version Build status Test coverage Dependency Status License Downloads Gittip

Koa middleware for Segment Webhooks Integration.

API

const JSONStream = require('JSONStream')
const app = require('koa')()

const webhooks = new Map()
webhooks.set('/webhooks/production', 'production')
webhooks.set('/webhooks/debug', 'debug')

const webhook = require('segment-webhook')(webhooks)

app.use(webhook)

webhook.pipe(JSONStream.stringify()).pipe(process.stdout)

webhook.stream.on('data', function (obj) {
  console.log(JSON.stringify(obj))
})

Returns Koa middlweare.

const fn = SegmentWebhooks(webhooks)

webhooks is a required Map of path -> project_name. The project_name will be set on each object as .project. This allows you to differentiate against different projects and environments while using the same webhook for all of them.

fn.pipe([dest])

Pipe all the objects into another stream. The destination must also be in objectMode

fn.stream.on('data', obj => )

Listen for all objects being passed.

fn.stream.on(type, obj => )

Filter by data types, ex. page, identify, track, etc.

About

Koa middleware for Segment Webhooks

Resources

License

Stars

Watchers

Forks

Packages

No packages published