Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

choo-analytics

1.0.0 • Public • Published

choo-analytics

npm version build status downloads js-standard-style

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

See Also

License

Apache-2.0

install

npm i choo-analytics

Downloadsweekly downloads

3

version

1.0.0

license

Apache-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar