<commit_before>var debounce = require('debounce')
  , xhr = require('xhr')
  , track = require('../track')()

  , noop = function () {}
  , data = []

    // save all events happening within a second and send them in one POST
    //  request
  , batchPost = debounce(function () {
      var body = data.join('\n')
      data = []

      xhr({
          method: 'POST'
        , body: body
        , uri: '/track'
      })
    }, 1000)

track.ondata = function (csv) {
  data.push(csv)
  batchPost()
}

// this gets called by beforeunload - so anything in here must be synchronous
track.onend = function (csv) {
  data.push(csv)

  // this will be an end-event - meaning that the visit on the page has ended
  xhr({
      method: 'POST'
    , body: data.join('\n')
    , uri: '/track'
    , sync: true<commit_msg>bugfix in example<commit_after>var debounce = require('debounce')
  , xhr = require('xhr')
  , track = require('../track')()

  , noop = function () {}
  , data = []

    // save all events happening within a second and send them in one POST
    //  request
  , batchPost = debounce(function () {
      var body = data.join('\n')
      data = []

      xhr({
          method: 'POST'
        , body: body
        , uri: '/track'
      }, noop)
    }, 1000)

track.ondata = function (csv) {
  data.push(csv)
  batchPost()
}

// this gets called by beforeunload - so anything in here must be synchronous
track.onend = function (csv) {
  data.push(csv)

  // this will be an end-event - meaning that the visit on the page has ended
  xhr({
      method: 'POST'
    , body: data.join('\n')
    , uri: '/track'
    , sync: true
{'fraction_non_alphanumeric': 0.14504283965728273, 'fraction_numerical': 0.004895960832313341, 'mean_word_length': 2.256972111553785, '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': '6913486', 'n_tokens_mistral': 545, 'n_tokens_neox': 526, 'n_words': 166}