<commit_before>var Api = require('./api'),
  qs = require('qs'),
  dom = require('./dom');

module.exports = Signupsio;

function Signupsio(key) {
  if(!(this instanceof Signupsio)) return new Signupsio(key);
  this.api = new Signupsio.Api(key);
}

Signupsio.Api = Api;

Signupsio.auto = function () {
  dom.ready(function () {
    dom.each("form.signupsio", function (form) {
      var href = form.getAttribute('action');
      if(href && ~href.indexOf('?')) {
        var key = qs.parse(href.slice(href.indexOf('?') + 1)).key;
        var signupsio = new Signupsio(key);
        signupsio.visit(document.title);
        signupsio.trackForm(form);
      }
    });
  });
};

Signupsio.prototype.trackForm = function(form) {
  var self = this;
  form.addEventListener('submit', this._onSubmit(form));
  dom.each(form, "input, select, textarea, button", function (el) {
    el.addEventListener('click', self._onClick(el));
  });
};

Signupsio.prototype.visit = function (page) {
  this.api.sendEvent('visit', {
    page_name: page
  });
};

Signupsio.prototype._onClick = function () {
  var self = this;
  return function (e) {
    self.api.sendEvent('click', {
      input_name: this.getAttribute('name'),<commit_msg>Add some comments for the `auto` method<commit_after>var Api = require('./api'),
  qs = require('qs'),
  dom = require('./dom');

module.exports = Signupsio;

function Signupsio(key) {
  if(!(this instanceof Signupsio)) return new Signupsio(key);
  this.api = new Signupsio.Api(key);
}

Signupsio.Api = Api;

Signupsio.auto = function () {
  dom.ready(function () {
    dom.each("form.signupsio", function (form) {

      // pull the url from the form
      var href = form.getAttribute('action');
      if(href && ~href.indexOf('?')) {

        // get the key from the query string
        var key = qs.parse(href.slice(href.indexOf('?') + 1)).key;

        // create a new instance for this form
        var signupsio = new Signupsio(key);

        // record a visit to the page
        signupsio.visit(document.title);

        // keep an eye on the form for IX
        signupsio.trackForm(form);
      }
    });
  });
};

Signupsio.prototype.trackForm = function(form) {
  var self = this;
  form.addEventListener('submit', this._onSubmit(form));
  dom.each(form, "input, select, textarea, button", function (el) {
    el.addEventListener('click', self._onClick(el));
  });
};

Signupsio.prototype.visit = function (page) {
  this.api.sendEvent('visit', {
    page_name: page
  });
};

Signupsio.prototype._onClick = function () {
  var self = this;
  return function (e) {
    self.api.sendEvent('click', {
      input_name: this.getAttribute('name'),
{'fraction_non_alphanumeric': 0.1646090534979424, 'fraction_numerical': 0.0007482229704451926, 'mean_word_length': 3.2647527910685805, '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': '6092376', 'n_tokens_mistral': 877, 'n_tokens_neox': 875, 'n_words': 191}