Use analytics-plugin-event-validation to ensure tracking events passed to analytics conform to a specific naming convention: context:objectName_actionName. This helps maintain clean analytics data by enforcing a pattern of Context => Object => Action.
To use it, include the plugin in your Analytics configuration and define the context (the namespace of your application) and the list of allowed objects.
import Analytics from 'analytics'
import eventValidation from 'analytics-plugin-event-validation'
import customerIOPlugin from 'analytics-plugin-customerio'
const analytics = Analytics({
app: 'awesomesauce',
plugins: [
eventValidation({
// Namespace of current application
context: 'app',
// Allowed objects
objects: [
'sites', // example app:sites_cdConfigured
'user', // example app:user_signup
'widget' // example app:widget_created
]
}),
customerIOPlugin({
siteId: '123-xyz'
}),
]
})
// Event names must now conform to this format:
analytics.track('app:sites_whatever')
analytics.track('app:user_action')
analytics.track('app:widget_deleted')