Capture analytics events in the browser. Uses window.navigator.sendBeacon()
to send data down with the least priority.
Friendly reminder not to ever store people's IP addresses. Only store the minimum amount of data needed to inform decisions. Be kind, don't give analytics a bad name.
var microanalytics = require('microanalytics')
var analytics = microanalytics('https://analytics.my-app.com')
analytics.append({
type: 'navigation'
route: '/my-route'
})
analytics.append({
type: 'navigation'
route: '/my-other-route'
})
var tx = analytics.batch()
tx.append({
type: 'video',
data: {
offset: 1225,
buf: 20
}
})
tx.append({
type: 'video',
data: {
offset: 15,
buf: 26
}
})
tx.flush()
analytics = microanalytics(url, [defaultArgs])Create a new analytics instance. Takes a url and optional default options which are always sent down.
analytics.append(data)Send new data down to the analytics API.
transaction = analytics.batchCreate a new transaction. Transaction data will be sent as an array of data once it's flushed.
transaction.append(data)Append new data to the transaction.
transaction.flush()End the transaction.