<commit_before>
var integration = require('../integration');
var load = require('load-script');
var user = require('../user');


/**
 * Expose `Awesm` integration.
 */

var Awesm = module.exports = integration('awe.sm');


/**
 * Default options.
 */

Awesm.prototype.defaults = {
  // your awe.sm api key (required)
  apiKey: '',
  // a dictionary of event names to awe.sm events
  events: {}
};


/**
 * Initialize.
 */

Awesm.prototype.initialize = function () {
  var options = this.options;
  window.AWESM = window.AWESM || {};
  window.AWESM.api_key = options.apiKey;
  this.load(this.ready);
};


/**
 * Load the awe.sm library.
 *
 * @param {Function} callback
 */

Awesm.prototype.load = function (callback) {
  var key = this.options.apiKey;
  load('//widgets.awe.sm/v3/widgets.js?key=' + key + '&async=true', callback);
};


/**
 * Track.
 *
 * @param {String} event
 * @param {Object} properties (optional)
 * @param {Object} options (optional)
 */

Awesm.prototype.track = function (event, properties, options) {
  var goal = this.options.events[event];
  if (!goal) return;
  var value = properties.value || 0;
  if (properties.revenue) value = properties.revenue * 100; // prefer revenue
  window.AWESM.convert(goal, value, null, user.id());
};<commit_msg>awesm: convert to cleaner options api<commit_after>
var integration = require('../integration');
var load = require('load-script');
var user = require('../user');


/**
 * Expose `Awesm` integration.
 */

var Awesm = module.exports = integration('awe.sm')
  .option('apiKey', '')
  .option('events', {});


/**
 * Initialize.
 */

Awesm.prototype.initialize = function () {
  var options = this.options;
  window.AWESM = window.AWESM || {};
  window.AWESM.api_key = options.apiKey;
  this.load(this.ready);
};


/**
 * Load the awe.sm library.
 *
 * @param {Function} callback
 */

Awesm.prototype.load = function (callback) {
  var key = this.options.apiKey;
  load('//widgets.awe.sm/v3/widgets.js?key=' + key + '&async=true', callback);
};


/**
 * Track.
 *
 * @param {String} event
 * @param {Object} properties (optional)
 * @param {Object} options (optional)
 */

Awesm.prototype.track = function (event, properties, options) {
  var goal = this.options.events[event];
  if (!goal) return;
  var value = properties.value || 0;
  if (properties.revenue) value = properties.revenue * 100; // prefer revenue
  window.AWESM.convert(goal, value, null, user.id());
};
{'fraction_non_alphanumeric': 0.1800656275635767, 'fraction_numerical': 0.004101722723543888, 'mean_word_length': 3.5845864661654137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '7287830', 'n_tokens_mistral': 857, 'n_tokens_neox': 807, 'n_words': 191}