lib/events.js
function MapboxEventManager(options) {
  this.origin = options.origin || 'https://api.mapbox.com';
  this.endpoint = 'events/v2';
  this.access_token = options.accessToken;
  this.version = '0.2.0'
  this.sessionID = this.generateSessionID();
  this.userAgent = this.getUserAgent();

  this.options = options;
  this.send = this.send.bind(this);


  // parse global options to be sent with each request
  this.countries = (options.countries) ? options.countries.split(",") : null;
  this.types = (options.types) ? options.types.split(",") : null;
  this.bbox = (options.bbox) ? options.bbox : null;
  this.language = (options.language) ? options.language.split(",") : null;
  this.limit = (options.limit) ? +options.limit : null;
  this.locale = navigator.language || null;
  this.enableEventLogging = this.shouldEnableLogging(options);
  this.eventQueue = new Array();
  this.flushInterval = options.flushInterval || 1000;
  this.maxQueueSize = options.maxQueueSize || 100;
  this.timer = (this.flushInterval) ? setTimeout(this.flush.bind(this), this.flushInterval) : null;
  // keep some state to deduplicate requests if necessary
  this.lastSentInput = "";
  this.lastSentIndex = 0;
}
function MapboxEventManager(options) {
  this.origin = options.origin || 'https://api.mapbox.com';
  this.endpoint = 'events/v2';
  this.access_token = options.accessToken;
  this.version = '0.2.0'
  this.sessionID = this.generateSessionID();
  this.userAgent = this.getUserAgent();

  this.options = options;
  this.send = this.send.bind(this);


  // parse global options to be sent with each request
  this.countries = (options.countries) ? options.countries.split(",") : null;
  this.types = (options.types) ? options.types.split(",") : null;
  this.bbox = (options.bbox) ? options.bbox : null;
  this.language = (options.language) ? options.language.split(",") : null;
  this.limit = (options.limit) ? +options.limit : null;
  this.locale = navigator.language || null;
  this.enableEventLogging = this.shouldEnableLogging(options);
  this.eventQueue = new Array();
  this.flushInterval = options.flushInterval || 1000;
  this.maxQueueSize = options.maxQueueSize || 100;
  this.timer = (this.flushInterval) ? setTimeout(this.flush.bind(this), this.flushInterval) : null;
  // keep some state to deduplicate requests if necessary
  this.lastSentInput = "";
  this.lastSentIndex = 0;
}
function MapboxEventManager ( options ) { this . origin = options . origin || 'https://api.mapbox.com' ; this . endpoint = 'events/v2' ; this . access_token = options . accessToken ; this . version = '0.2.0' this . sessionID = this . generateSessionID ( ) ; this . userAgent = this . getUserAgent ( ) ; this . options = options ; this . send = this . send . bind ( this ) ; // parse global options to be sent with each request this . countries = ( options . countries ) ? options . countries . split ( "," ) : null ; this . types = ( options . types ) ? options . types . split ( "," ) : null ; this . bbox = ( options . bbox ) ? options . bbox : null ; this . language = ( options . language ) ? options . language . split ( "," ) : null ; this . limit = ( options . limit ) ? + options . limit : null ; this . locale = navigator . language || null ; this . enableEventLogging = this . shouldEnableLogging ( options ) ; this . eventQueue = new Array ( ) ; this . flushInterval = options . flushInterval || 1000 ; this . maxQueueSize = options . maxQueueSize || 100 ; this . timer = ( this . flushInterval ) ? setTimeout ( this . flush . bind ( this ) , this . flushInterval ) : null ; // keep some state to deduplicate requests if necessary this . lastSentInput = "" ; this . lastSentIndex = 0 ; }
Construct a new mapbox event client to send interaction events to the mapbox event service
@param {Object} options options with which to create the service
@param {String} options.accessToken the mapbox access token to make requests
@param {Number} [options.flushInterval=1000] the number of ms after which to flush the event queue
@param {Number} [options.maxQueueSize=100] the number of events to queue before flushing
@private
Construct a new mapbox event client to send interaction events to the mapbox event service