A tiny utility for working with analytics events
on the server and in the browser.
Install with npm:
npm install --save analytics-eventOr with yarn:
yarn add analytics-eventimport AEvent from 'analytics-event'
// Generate event from options
AEvent({
name: 'User Signed Up',
properties: {
referral_type: 'friend'
}
})
// Use your favorite analytics library to send events
analytics.track(AEvent({
name: 'User Signed Up',
properties: {
referral_type: 'friend'
}
}))import AEvent from 'analytics-event'
// Generate an event that follows https://schema.org/AnalyticsEvent
AEvent({
name: 'User Signed Up',
properties: {
referral_type: 'friend'
}
})import AEvent from 'analytics-event'
// You can also just import the format function with:
// import { format, loadFormat } 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'
}))
}All contributions are super welcome! analytics-event is MIT-licensed.
