1.0.0 • Published 10 years ago
segment-webhook v1.0.0
segment-webhook
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.
1.0.0
10 years ago