function onDomActivity(callback, opts = {}) {
  const handler = throttle(callback, opts.throttle || 10000)
  let listeners = []

  function attach() {
    const tabListener = onTabChange((isHidden) => {
      if (!isHidden) handler({ type: 'tabVisible' })
    })

    listeners = [ tabListener ]
    .concat(DOCUMENT_EVENTS.map(event => addListener(document, event, handler)))
    .concat(addListener(window, 'load', handler))
    .concat(addListener(window, 'scroll', handler, { capture: true, passive: true }))

    return detach
  }

  function detach() {
    listeners.map(detach => detach())
  }

  attach() // attach listeners

  return function() {
    detach() // remove listeners
    return attach
  }
}
@param {Function} callback 
@param {Object} opts 
@returns