beforeHandler = store => next => action => {
          if (action.type.match(startRegex)) {
            callback({ // eslint-disable-line
              payload: action,
              instance,
              plugins: customPlugins
            })
          }
          return next(action)
        }
Attach an event handler function for analytics lifecycle events.
@typedef {Function} On
@param  {String}   name - Name of event to listen to
@param  {Function} callback - function to fire on event
@return {DetachListeners} - Function to detach listener

@example

// Fire function when 'track' calls happen
analytics.on('track', ({ payload }) => {
  console.log('track call just happened. Do stuff')
})

// Remove listener before it is called
const removeListener = analytics.on('track', ({ payload }) => {
  console.log('This will never get called')
})

// cleanup .on listener
removeListener()