function tabEventsPlugin(pluginConfig = {}) {
  const events = {
    /**
     * `tabHidden` - Fires when visitor goes to another browser tab.
     */
    tabHidden: 'tabHidden',
    /**
     * `tabVisible` - Fires when visitor comes back to window from another browser tab.
     */
    tabVisible: 'tabVisible'
  }
  return {
    name: 'tab-events',
    EVENTS: events,
    config: pluginConfig,
    bootstrap: ({ instance }) => {
      /* Dispatch event when tab visiblity changes */
      onTabChange(isHidden => {
        instance.dispatch({
          type: (isHidden) ? events.tabHidden : events.tabVisible,
        })
      })
    }
  }
}
Expose Tab visbility events to analtyics
Trigger analytics actions when tab is hidden or visible
@param  {Object} [pluginConfig={}] - config
@return {Object} Analytics plugin