<commit_before>var sieve = require('sievejs')
  , qs = require('querystring');

var options = {
  hooks : { onFinish: one }
};

var data = JSON.stringify({
    "url": "https://heapanalytics.com/login",
    "selector": { "csrf" : "$(input[name='_csrf']).val()" },
    "engine": "jquery",
    "debug": true,
    "useHeaders" : true,
    "verbose" : true,
    "then": {
        "url": "https://heapanalytics.com/login",
        "method": "POST",
        "useHeaders" : true,
        "redirect" : false,
        "form": {
            "email" : "<EMAIL>",
            "password" : "<PASSWORD>",
            "_csrf" : "{{csrf}}"
        },
        "headers" : {
            "Content-Type" : "application/x-www-form-urlencoded"
        }
    }
});

new sieve(data, options);

function one(results){

  var cookie = results[0].cookie[0];

  console.log(cookie);

  // The heap token requires some URLencoded stuff to be jammed into it:
  var decoded = qs.decode(cookie)
    , sid = decoded['heap.sid'];

  // Find the curly brackets
  var begin = sid.indexOf('{')
    , end = sid.indexOf('}') - 3
    , json = sid.substr(begin, end)
    , obj = JSON.parse(json);

  // Add params
  obj.email = '<EMAIL>';
  obj.app_id = '1822452561';
  obj.env_id = '1822452561';
  obj.proj_id = '1822452561';
  obj.write_perm = true; 

  var result = sid.replace(json, JSON.stringify(obj));

  // URLEncode everything up to token
  var arr = result.split(';')
    , encoded = qs.escape(arr.shift()) + ';';

  cookie = 'heap.sid=' + encoded;
  
  console.log('Generated cookie.  Getting reports JSON...');

  console.log(cookie);
  
  var data = JSON.stringify({
    "url" : "https://heapanalytics.com/api/report",
    "redirect": false,
    "headers" : {
        "Cookie" : cookie
    }
  })

  options = {
    hooks : { onFinish: two },
    verbose : true
  }

  new sieve(data, options);
}

function two(results){
  console.log(results);
}


<commit_msg>get list<commit_after>var sieve = require('sievejs')
  , qs = require('querystring');

var options = {
  hooks : { onFinish: one }
};

var data = JSON.stringify({
    "url": "https://heapanalytics.com/login",
    "selector": { "csrf" : "$(input[name='_csrf']).val()" },
    "engine": "jquery",
    "debug": true,
    "useHeaders" : true,
    "verbose" : true,
    "then": {
        "url": "https://heapanalytics.com/login",
        "method": "POST",
        "useHeaders" : true,
        "redirect" : false,
		"debug" : true,
        "form": {
            "email" : "<EMAIL>",
            "password" : "<PASSWORD>",
            "_csrf" : "{{csrf}}"
        },
        "headers" : {
            "Content-Type" : "application/x-www-form-urlencoded"
        }
    }
});

new sieve(data, options);

function one(results){

  var cookie = results[0].result[0].cookie;

  var data = JSON.stringify({
    "url" : "https://heapanalytics.com/api/report",
    "redirect": false,
    "headers" : {
        "Cookie" : cookie
    }
  })

  options = {
    hooks : { onFinish: two },
    verbose : true
  }

  new sieve(data, options);
}

function two(json){
	var obj = JSON.parse(json);
	console.log(obj);
}

function getCSV(id, cb){
	
}



{'fraction_non_alphanumeric': 0.1865104496516783, 'fraction_numerical': 0.011082963901203294, 'mean_word_length': 2.4486899563318776, 'pattern_counts': {'":': 18, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, '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': '6446653', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1094, 'n_words': 227}