<commit_before>/*!
 * node-blutrumpet
 * 
 * 
 * Copyright (c) 2012 <NAME> <<EMAIL>>
 * MIT Licensed
 */

/*
  Module Dependencies
*/

var EventEmitter = require('events').EventEmitter
  , queryString = require('querystring')
  , request = require('request');

exports = module.exports = Blutrumpet;

/*
  Blutrumpet Constants
*/

/*
  Full blutrumpet tracking url
  https://tracker.blutrumpet.com/conversion?app_guid={GUID}&udid={Unique Device Identifier}
*/
Blutrumpet.TEST_API_URL = "https://testtracker.blutrumpet.com/conversion";
Blutrumpet.API_URL = "https://tracker.blutrumpet.com/conversion";

/* 
  Library version.
*/
exports.version = '0.0.1';

/*  
  Constructor
*/

function Blutrumpet(options) {
  if (!options) options = {};
  this.guid = options.guid;
}

/* 
  Inherit from EventEmitter
*/

Blutrumpet.prototype.__proto__ = EventEmitter.prototype;


/*
---------------------
  Conversion Handling
---------------------
*/

/* 
  Send iOS Conversion
*/

Blutrumpet.prototype.sendiOSConversion = function(options, cb) {
  var self = this;
  var params = {};
  var url;

  params["app_guid"] = self.guid;
  params["udid"] = options.udid  
    
  url = self.buildURL(params);

  return request.get(url, function(error, response, body) {        
    if (error) {

      console.log("error: " + error);
      cb(error, null);
      return this.emit('failure', error);

    } else if (response.statusCode !== 200) {

      console.log("Status code: " + response.statusCode + " response body: " + body);
      cb(null, response);
      return this.emit('failure', response);

    } else if (response.statusCode === 200) {
      
      console.log("Conversion submitted.");
      cb(null, response);
      return this.emit('success', response);

    }
  });
};

/*
  buildURL
  Create the parameterized url for conversion submission
*/

Blutrumpet.prototype.buildURL = function(options) {
  var queryParams = queryString.encode(options);
  return "" + Blutrumpet.API_URL + "?" + queryParams;
};

var bt = new Blutrumpet({guid: "your-guid-here"});
bt.sendiOSConversion({udid: "device-uid-here"}, function(err, response){
  if(err) {
    console.log("Error: " + err);
  } else {
    console.log("Response: " + response.statusCode);
  }
});
<commit_msg>Adding support for alt_udid for android conversions<commit_after>/*!
 * node-blutrumpet
 * 
 * 
 * Copyright (c) 2012 <NAME> <<EMAIL>>
 * MIT Licensed
 */

/*
  Module Dependencies
*/

var EventEmitter = require('events').EventEmitter
  , queryString = require('querystring')
  , request = require('request');

exports = module.exports = Blutrumpet;

/*
  Blutrumpet Constants
*/

/*
  Full blutrumpet tracking url
  https://tracker.blutrumpet.com/conversion?app_guid={GUID}&udid={Unique Device Identifier}
*/
Blutrumpet.TEST_API_URL = "https://testtracker.blutrumpet.com/conversion";
Blutrumpet.API_URL = "https://tracker.blutrumpet.com/conversion";

/* 
  Library version.
*/
exports.version = '0.0.1';

/*  
  Constructor
*/

function Blutrumpet(options) {
  if (!options) options = {};
  this.guid = options.guid;
}

/* 
  Inherit from EventEmitter
*/

Blutrumpet.prototype.__proto__ = EventEmitter.prototype;


/*
---------------------
  Conversion Handling
---------------------
*/

/* 
  Send Conversion
*/

Blutrumpet.prototype.sendConversion = function(options, cb) {
  var self = this;
  var params = {};
  var url;

  params["app_guid"] = self.guid;
  params["udid"] = options.udid;
  // alt_udid is included for android conversions
  if(options.alt_udid) {
    params["alt_udid"] = options.alt_udid;
  }
    
  url = self.buildURL(params);

  return request.get(url, function(error, response, body) {        
    if (error) {

      console.log("error: " + error);
      cb(error, null);
      return this.emit('failure', error);

    } else if (response.statusCode !== 200) {

      console.log("Status code: " + response.statusCode + " response body: " + body);
      cb(null, response);
      return this.emit('failure', response);

    } else if (response.statusCode === 200) {
      
      console.log("Conversion submitted.");
      cb(null, response);
      return this.emit('success', response);

    }
  });
};

/*
  buildURL
  Create the parameterized url for conversion submission
*/

Blutrumpet.prototype.buildURL = function(options) {
  var queryParams = queryString.encode(options);
  return "" + Blutrumpet.API_URL + "?" + queryParams;
};

{'fraction_non_alphanumeric': 0.16730725751752204, 'fraction_numerical': 0.005878363101966991, 'mean_word_length': 3.13844714686623, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4180290', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1462, 'n_words': 285}