src/basis/tracker.js
function getSelectorList(eventName){
  if (hasOwnProperty.call(eventMap, eventName))
    return eventMap[eventName];

  var selectorList = eventMap[eventName] = [];
  var inputTimeout = null;

  switch (eventName) {
    case SHOW_EVENT:
      selectorList.visible = {};
      setInterval(checkShow, VISIBLE_CHECK_INTERVAL);
      break;

    default:
      eventUtils.addGlobalHandler(eventName, function(event){
        var path = event.path.reduce(function(res, node){
          var role = node.getAttribute ? node.getAttribute('role-marker') : null;
          if (role)
            res.unshift(parseRole(role));
          return res;
        }, []);

        // if there is at least one `role-marker` attribute in the DOM [x]path for the clicked (or hovered or `event`ed) element
        // then lets search a matching selector in our loaded track map
        if (path.length)
          selectorList.forEach(function(item){
            var result = handleEventFor(path, item, event);
            if (result)
              if (result.debounce)
              {
                clearTimeout(inputTimeout);
                inputTimeout = setTimeout(function(){
                  track(result.dataToTrack);
                }, INPUT_DEBOUNCE_TIMEOUT);
              }
              else
              {
                track(result.dataToTrack);
              }
          });
      });
  }

  return selectorList;
}
function getSelectorList(eventName){
  if (hasOwnProperty.call(eventMap, eventName))
    return eventMap[eventName];

  var selectorList = eventMap[eventName] = [];
  var inputTimeout = null;

  switch (eventName) {
    case SHOW_EVENT:
      selectorList.visible = {};
      setInterval(checkShow, VISIBLE_CHECK_INTERVAL);
      break;

    default:
      eventUtils.addGlobalHandler(eventName, function(event){
        var path = event.path.reduce(function(res, node){
          var role = node.getAttribute ? node.getAttribute('role-marker') : null;
          if (role)
            res.unshift(parseRole(role));
          return res;
        }, []);

        // if there is at least one `role-marker` attribute in the DOM [x]path for the clicked (or hovered or `event`ed) element
        // then lets search a matching selector in our loaded track map
        if (path.length)
          selectorList.forEach(function(item){
            var result = handleEventFor(path, item, event);
            if (result)
              if (result.debounce)
              {
                clearTimeout(inputTimeout);
                inputTimeout = setTimeout(function(){
                  track(result.dataToTrack);
                }, INPUT_DEBOUNCE_TIMEOUT);
              }
              else
              {
                track(result.dataToTrack);
              }
          });
      });
  }

  return selectorList;
}
function getSelectorList ( eventName ) { if ( hasOwnProperty . call ( eventMap , eventName ) ) return eventMap [ eventName ] ; var selectorList = eventMap [ eventName ] = [ ] ; var inputTimeout = null ; switch ( eventName ) { case SHOW_EVENT : selectorList . visible = { } ; setInterval ( checkShow , VISIBLE_CHECK_INTERVAL ) ; break ; default : eventUtils . addGlobalHandler ( eventName , function ( event ) { var path = event . path . reduce ( function ( res , node ) { var role = node . getAttribute ? node . getAttribute ( 'role-marker' ) : null ; if ( role ) res . unshift ( parseRole ( role ) ) ; return res ; } , [ ] ) ; // if there is at least one `role-marker` attribute in the DOM [x]path for the clicked (or hovered or `event`ed) element // then lets search a matching selector in our loaded track map if ( path . length ) selectorList . forEach ( function ( item ) { var result = handleEventFor ( path , item , event ) ; if ( result ) if ( result . debounce ) { clearTimeout ( inputTimeout ) ; inputTimeout = setTimeout ( function ( ) { track ( result . dataToTrack ) ; } , INPUT_DEBOUNCE_TIMEOUT ) ; } else { track ( result . dataToTrack ) ; } } ) ; } ) ; } return selectorList ; }
Fills up the eventMap, also adds a handler for each browser event, mentioned in custom tracking maps
@param {string} eventName browser event.type or SHOW_EVENT
@private
@return {Array}
Fills up the eventMap also adds a handler for each browser event mentioned in custom tracking maps