lib/kissmetrics.js
function request_kissmetrics_client(pathname, query_params, callback) {
 
  var query_string  = ['_k=', this.key, '&'].join('')
    , uri
    , v
    ;
  
  query_params['_t'] = (query_params['_d'] ? query_params['_t'] : Date.now());
                  
  for(var k in query_params) {
    
    v = query_params[k];
    
    if (query_string !== '') {
      query_string += '&';
    }
    
    query_string += [k, v].join('=');
    
  }
  
  uri = encodeURI(['http', ':', '//', this.host, ':', this.port, pathname, '?', query_string].join(''));
  
  // should encode the = sign in the user id
  var regex = new RegExp("&_p=" + query_params["_p"] + "&");
  var uri = uri.replace(regex, "&_p=" + query_params["_p"].replace("=", "%3D") + "&");
  
  request({ uri: uri }, function (err, res) {
    
    if (err) { 
      
      console.log('xxx KISSmetrics error');
      console.log('    uri    : ' + uri);
      console.log('    error  : ' + err.message);
      
    } else if (res.statusCode !== 200) {
      err = new Error('KISSmetrics error ---> RECEIVED WRONG STATUS CODE [' + res.statusCode + ']'); 
    }
    
    callback(err, res);
  
  });

}
function request_kissmetrics_client(pathname, query_params, callback) {
 
  var query_string  = ['_k=', this.key, '&'].join('')
    , uri
    , v
    ;
  
  query_params['_t'] = (query_params['_d'] ? query_params['_t'] : Date.now());
                  
  for(var k in query_params) {
    
    v = query_params[k];
    
    if (query_string !== '') {
      query_string += '&';
    }
    
    query_string += [k, v].join('=');
    
  }
  
  uri = encodeURI(['http', ':', '//', this.host, ':', this.port, pathname, '?', query_string].join(''));
  
  // should encode the = sign in the user id
  var regex = new RegExp("&_p=" + query_params["_p"] + "&");
  var uri = uri.replace(regex, "&_p=" + query_params["_p"].replace("=", "%3D") + "&");
  
  request({ uri: uri }, function (err, res) {
    
    if (err) { 
      
      console.log('xxx KISSmetrics error');
      console.log('    uri    : ' + uri);
      console.log('    error  : ' + err.message);
      
    } else if (res.statusCode !== 200) {
      err = new Error('KISSmetrics error ---> RECEIVED WRONG STATUS CODE [' + res.statusCode + ']'); 
    }
    
    callback(err, res);
  
  });

}
****************************************************************************
Performs the given request on the KISSmetrics tracker host.

@param pathname {String} The path section of the URL, that comes after the
host and before the query, including the initial slash if present.

@param query_params {Object}

@param callback {Function} A callback of the form `function(res)`.