Skip to content

Instantly share code, notes, and snippets.

@ar2rsawseen
Created September 14, 2015 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ar2rsawseen/8838c50bf8692d28b8ab to your computer and use it in GitHub Desktop.
Save ar2rsawseen/8838c50bf8692d28b8ab to your computer and use it in GitHub Desktop.
Generate requests for Countly
var request = require('request');
function makeRequest(cnt){
var options = {
uri: 'http://localhost/i?app_key=ccab3e6e1b5ca7b42fc2194b57358b115edb45fc&device_id='+Math.random()+'&begin_session=1&events=[{%22key%22:%22click%22,%22count%22:1,%22segmentation%22:{%22message%22:%22a%22}},{%22key%22:%22go%22,%22count%22:1,%22segmentation%22:{%22message%22:%22b%22}},{%22key%22:%22do%22,%22count%22:1,%22segmentation%22:{%22message%22:%22c%22}}]',
method: 'GET'
};
request(options, function (error, response, body) {
if(!error){
try{
var arr = JSON.parse(body);
console.log(cnt, arr);
}
catch(ex){}
}
});
}
function iterateRequest(){
makeRequest(1);
setTimeout(iterateRequest, 1000);
}
/*
for(var i = 0; i < 100000; i++){
makeRequest(i);
}
*/
iterateRequest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment