function eventValidationPlugin(pluginConfig = {}) {
  return {
    name: 'event-validation',
    config: {
      ...defaultConfig,
      ...pluginConfig
    },
    trackStart: ({ payload, config, abort }) => {
      if (!isValidEventName(payload.event, config)) {
        const msg = `invalid event name ${payload.event}`
        if (config.throwOnInvalid) {
          throw new Error(msg)
        }
        return abort(msg)
      }
    }
  }
}
Event validation plugin
@link https://getanalytics.io/plugins/event-validation/
@param {object}  pluginConfig - Plugin settings
@param {string}  pluginConfig.context - Name of app event is in. Example 'api', 'app', 'site', 'cli'
@param {boolean} pluginConfig.objects - Objects events can effect
@param {boolean} [pluginConfig.throwOnInvalid] - Objects events can effect
@return {object} Analytics plugin
@example

eventValidation({
  context: 'app',
  objects: ['sites', 'user', 'subscription']
})