choo-analytics
v1.0.0
Published
Analytics adapter for Choo.
Downloads
4
Maintainers
Readme
choo-analytics
Analytics plugin for Choo. Contains multiple adapters for different analytics backends. Contributions for more backends would be much appreciated!
Usage
var analytics = require('choo-analytics')
var choo = require('choo')
var adapter = require('choo-analytics/fair-analytics')
var analyticsOpts = {
url: '<address-of-fair-analytics-instance>'
}
var app = choo()
app.use(analytics(adapter, analyticsOpts))
Writing your own adapters
Adapters for choo-analytics are a function that returns a function. Use the
choo-analytics/console
adapter to get a feeling for which data is passed.
Because multiple instances of choo-analytics can run side by side, this can be
especially useful.
module.exports = customAdapter
function customAdapter (opts, state, emitter) {
return function (name, ...data) {
console.log(`Event ${name} was emitted with data`, data)
}
}
Adapters
console
Adapter for the browser console. Useful for debugging.
var adapter = require('choo-analytics/console')
app.use(analytics(adapter))
Installation
$ npm install choo-analytics