A tiny utility for working with analytics events
on the server and in the browser.
Getting Started
Installation
Install with npm:
npm install --save analytics-event
Or with yarn:
yarn add analytics-event
Examples
import AEvent from 'analytics-event'
AEvent({
name: 'User Signed Up',
properties: {
referral_type: 'friend'
}
})
analytics.track(AEvent({
name: 'User Signed Up',
properties: {
referral_type: 'friend'
}
}))
Usage
Generating an event
import AEvent from 'analytics-event'
AEvent({
name: 'User Signed Up',
properties: {
referral_type: 'friend'
}
})
Formatting an event
import AEvent from 'analytics-event'
import internalDataFormat from './internal-data-format'
AEvent.loadFormat('internal-data', internalDataFormat)
function receiveIncomingEvents(batch) {
return batch.map(msg => AEvent.format(msg, {
preset: 'internal-data'
}))
}
Contributing
All contributions are super welcome! analytics-event
is MIT-licensed.