Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-pages into master #1

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
9fe2bde
firebase script is included
pavelk2 Oct 5, 2015
2bd0aac
firebase init on script load
pavelk2 Oct 5, 2015
cfc221b
LOGGER object keeping settings
pavelk2 Oct 5, 2015
4d4a4a6
getScript removed
pavelk2 Oct 5, 2015
0c196b8
scriptURL - > bucketURL
pavelk2 Oct 5, 2015
4e3392e
restructured everything to EDA_LOGGER
pavelk2 Oct 5, 2015
6c12a4e
no message
pavelk2 Oct 5, 2015
2a1d8ae
debug
pavelk2 Oct 5, 2015
dc60bb7
"this" added
pavelk2 Oct 5, 2015
657432f
logs tree.
pavelk2 Oct 6, 2015
8b7a0c7
no message
pavelk2 Oct 6, 2015
410cec4
no message
pavelk2 Oct 6, 2015
2beef50
periods are removed from domain name
pavelk2 Oct 6, 2015
1222c60
log function went up
pavelk2 Oct 6, 2015
a8259fe
"/./" -> "."
pavelk2 Oct 6, 2015
2d6b701
"." ->/\./g
pavelk2 Oct 6, 2015
8499a9b
listener first commit
pavelk2 Oct 6, 2015
35e0e3b
listener
pavelk2 Oct 22, 2015
37c674e
runtime unit_id updates
pavelk2 Oct 22, 2015
9bfc759
Heroku deploy
pavelk2 Nov 5, 2015
ac793ee
simplified app.son
pavelk2 Nov 5, 2015
2ea59e6
Logger is omitted in title
pavelk2 Nov 5, 2015
d7ad852
logger dt: Date.now() is added
pavelk2 Nov 23, 2015
7ae2870
Log dates changed to Firebase.ServerValue.TIMESTAMP
pavelk2 Nov 30, 2015
6d2659b
log worker_id
pavelk2 Nov 30, 2015
20862a5
Firebase logs for a given job to csv converter
pavelk2 Nov 30, 2015
67f4d15
index.html is renamed into example.html
pavelk2 Nov 30, 2015
a626ad7
Readme. Set up logs collection.
pavelk2 Nov 30, 2015
1086af6
Readme. Formatting.
pavelk2 Nov 30, 2015
8e83e63
Update README.md
pavelk2 Nov 30, 2015
37106d3
Update README.md
pavelk2 Nov 30, 2015
d70935f
search for worker_id
pavelk2 Nov 30, 2015
71faae6
fix logger
pavelk2 Nov 30, 2015
f7c8aad
worker_id or user_id
pavelk2 Nov 30, 2015
2e3371e
removed worker_id logging
pavelk2 Nov 30, 2015
e124f8d
Update README.md
pavelk2 Dec 1, 2015
5af2489
unit_id set right from logger
pavelk2 Jan 15, 2016
cc3b2cd
Merge branch 'gh-pages' of https://github.com/ReLauncher/worker-activ…
pavelk2 Jan 15, 2016
664070f
tab session to logger
pavelk2 Jan 15, 2016
438646f
automatic capture of worker_id and task_id
pavelk2 Jan 15, 2016
8ff7719
task_id
pavelk2 Jan 15, 2016
fad5902
fixed error with ":"
pavelk2 Jan 15, 2016
03b76fa
split sessions in logs
pavelk2 Jan 15, 2016
d441901
logs/sessions
pavelk2 Jan 15, 2016
348ebbe
job_id/unit_id/assignment_code/sessions/logs
pavelk2 Jan 15, 2016
89af029
no message
pavelk2 Jan 15, 2016
b73d752
logs simplification
pavelk2 Jan 15, 2016
f257c89
mouse
pavelk2 Jan 15, 2016
993969e
init activity capturing
pavelk2 Jan 15, 2016
eb25a25
no message
pavelk2 Jan 15, 2016
86bf4be
add key logging
pavelk2 Jan 26, 2016
1955d79
keys
pavelk2 Jan 26, 2016
87f5e9e
2 seconds, scroll top
pavelk2 Jan 26, 2016
23f8ce3
text selected
pavelk2 Jan 26, 2016
282b5e0
keyup -> mouse
pavelk2 Jan 26, 2016
4425785
mouse clicks
pavelk2 Jan 26, 2016
a8c49c1
Update README.md
pavelk2 Mar 4, 2016
645982d
Update README.md
pavelk2 Mar 4, 2016
479254c
generators
pavelk2 Mar 4, 2016
711da21
Merge branch 'gh-pages' of https://github.com/ReLauncher/worker-activ…
pavelk2 Mar 4, 2016
5f9a287
update firebase to 3.6.9
pavelk2 Feb 14, 2017
87f1589
updated back to 2.2.9
pavelk2 Feb 14, 2017
e8d0a02
Update logger.js
pavelk2 Feb 14, 2017
0e33cbb
Update logger.js
pavelk2 May 12, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
# worker-activity-logger
# ReLauncher | Worker Activity Logger

#### Setup worker browser logs collection for your tasks in 5 steps:

1. fork this repository,
2. create a bucket in [Firebase](https://www.firebase.com/) (it is free),
3. insert your firebase bucket name in [logger.js](https://github.com/ReLauncher/worker-activity-logger/blob/gh-pages/logger.js#L17):

```javascript
var settings = {
debug: true,
firebase: {
bucket: "YOUR_FIREBASE_BUCKET_NAME"
}
}
```
4. [create a job](https://success.crowdflower.com/hc/en-us/articles/204056975-Getting-Started-on-CrowdFlower-An-Overview-to-Building-a-Job) in CrowdFlower, upload your data. Make sure you have a column, which can be used as an identificator of a given data row (unit). If you collect tags for images, it can be *image_url*
5. add the following in [CML](https://success.crowdflower.com/hc/en-us/articles/202817989-CML-CrowdFlower-Markup-Language-Overview) of your CrowdFlower job:

```html
<script src="https://YOUR_GITHUB_USERNAME.github.io/worker-activity-logger/logger.js"></script>
<script>
EDA_LOGGER.init({
key_name:"KEY_COLUMN_NAME",
key_value:"{{KEY_COLUMN_NAME}}",
task_id: YOUR_CROWDFLOWER_JOB_ID
});
</script>
```

When you launch the job you should see logs appearing in your firebase bucket. If you do not - check all the steps carefully. If it still does not work, create an *issue* in this repository.

- [ ] run unit_references_maker.js (once)
- [ ] run queue_management.js (keep it running during execution)
- [ ] run ReLauncher server (npm start)
- [ ] launch the job
- [ ] start ReLauncher for this job

[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
17 changes: 17 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Relauncher ReferenceMaker",
"description": "Aapplication listening to a given Firebase bucket and fixing unit references.",
"repository": "https://github.com/ReLauncher/worker-activity-logger",
"logo": "https://avatars3.githubusercontent.com/u/14817691?v=3&s=200",
"keywords": ["relauncher", "crowdflower", "crowdsourcing", "microtasks"],
"env": {
"HEROKU_URL": {
"description": "The URL of this Heroku app.",
"value": "http://YOURAPPNAME.herokuapp.com"
},
"CROWDFLOWER_API_KEY":{
"description" : "your API key from https://make.crowdflower.com/account/user",
"value":""
}
}
}
13 changes: 11 additions & 2 deletions index.html → example.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<html>

<head>
<script src="https://cdn.firebase.com/js/client/2.2.9/firebase.js"></script>
<script src="logger.js"></script>
<script src="logger.js"></script>
<script>
EDA_LOGGER.init({
key_name: "image_url",
key_value: "http://kucherbaev.com/123123",
task_id:32452345
});
</script>
</head>

<body>
<div>
<div class="hero">
Expand All @@ -18,4 +26,5 @@ <h1>CrowdFlower Launcher</h1>
</div>
</div>
</body>

</html>
101 changes: 101 additions & 0 deletions firebase_to_csv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
var requestify = require('requestify');
var fs = require('fs');


var firebase_base_url = 'https://crowdworker-logger.firebaseio.com/' + "taskscrowdflowercom" + '/';
var task_id = 837900;
var firebase_target_url = firebase_base_url + task_id + ".json";
var folder = "logs/";
var filename = folder + task_id + "_logs.csv";

fs.createWriteStream(filename);
fs.truncate(filename, 0, function() {
console.log('file ' + filename + ' was cleaned up.')
});
fs.appendFile(filename, 'unit_number, unit_id, assignment_id, dt_start, dt_end, status\n', function(err) {});

var Logs = [];
var Units = {};
var MaxUnit = 0;
// -------------------------------------------------------
// Convert log object into a string
// -------------------------------------------------------
function stringify(log_array) {
for (var i = 0; i < log_array.length; i++) {
log_array[i]['string'] = "";
log_array[i]['string'] += log_array[i].unit_number + ", ";
log_array[i]['string'] += log_array[i].unit_id + ", ";
log_array[i]['string'] += log_array[i].assignment_id + ", ";
//log_array[i]['string'] += log_array[i].worker_id + ", ";
log_array[i]['string'] += log_array[i].dt_start + ", ";
log_array[i]['string'] += log_array[i].dt_end + ", ";
log_array[i]['string'] += log_array[i].status;
}
return log_array;
}
// -------------------------------------------------------
// Collect data for a given Job and make a plain Array of log objects
// -------------------------------------------------------
requestify.get(firebase_target_url, {
headers: {
"Accept": "application/json"
}
})
.then(function(response) {
var assignments = response.getBody();
for (var a_id in assignments) {
var a = assignments[a_id];
if (a_id != "editor_preview" && a.unit_id) {
var unit_number;
if (Units[a.unit_id.toString()]) {
unit_number = Units[a.unit_id.toString()];
} else {
MaxUnit++;
Units[a.unit_id.toString()] = MaxUnit;
unit_number = Units[a.unit_id.toString()];
}



//console.log(a);
for (var l_id in a.logs) {
var l = a.logs[l_id];
var log_record = {
'unit_number': unit_number,
'unit_id': a.unit_id,
'assignment_id': a_id,
//'worker_id': a.worker_id || "0",
'dt_start': l.dt,
'status': l.status
}
Logs.push(log_record);
}
} else {
console.log("PROBLEMATIC ASSIGNMENT", a_id, a);
}
}
// -------------------------------------------------------
// Add end events to log objects
// -------------------------------------------------------
for (var i = 0; i < Logs.length; i++) {
if (Logs[i].status != 'closed') {
if (i < (Logs.length - 1) && Logs[i].assignment_id == Logs[i + 1].assignment_id) {
Logs[i]['dt_end'] = Logs[i + 1]['dt_start'];
}
}
if (Logs[i]['dt_end'] == undefined) {
Logs[i]['dt_end'] = Logs[i]['dt_start'] + 1000;
}

}
// -------------------------------------------------------
// Convert each object in array into string and save it into the log file
// -------------------------------------------------------
Logs = stringify(Logs);
//console.log(Logs.length);
for (var i = 0; i < Logs.length; i++) {
console.log(Logs[i]['string']);
fs.appendFile(filename, Logs[i]['string'] + '\n', function(err) {});
}
console.log(firebase_target_url);
});
94 changes: 94 additions & 0 deletions generators/clicks_to_csv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
var requestify = require('requestify');
var fs = require('fs');


var firebase_base_url = 'https://crowdworker-logger.firebaseio.com/' + "taskscrowdflowercom" + '/';
var task_id = process.argv[2];
var firebase_target_url = firebase_base_url + task_id + ".json";
var folder = "../logs/"+task_id+"/";
var filename = folder + task_id + "_clicks.csv";

fs.createWriteStream(filename);
fs.truncate(filename, 0, function() {
console.log('file ' + filename + ' was cleaned up.')
});
fs.appendFile(filename, 'task_id, unit_id, assignment_id, session_id, dt_start, element\n', function(err) {});

var LOGS = [];

var MaxUnit = 0;
// -------------------------------------------------------
// Convert log object into a string
// -------------------------------------------------------
function stringify(log_array) {
for (var i = 0; i < log_array.length; i++) {
log_array[i]['string'] = "";
log_array[i]['string'] += log_array[i].task_id + ", ";
log_array[i]['string'] += log_array[i].unit_id + ", ";
log_array[i]['string'] += log_array[i].assignment_id + ", ";
log_array[i]['string'] += log_array[i].session_id + ", ";
log_array[i]['string'] += log_array[i].dt_start + ", ";
log_array[i]['string'] += log_array[i].element;
}
return log_array;
}

function endify(log_array) {
var Logs = log_array;
for (var i = 0; i < Logs.length; i++) {
if (Logs[i].status != 'closed') {
if (i < (Logs.length - 1) && Logs[i].assignment_id == Logs[i + 1].assignment_id && Logs[i].session_id == Logs[i + 1].session_id) {
Logs[i]['dt_end'] = Logs[i + 1]['dt_start'];
}
}
if (Logs[i]['dt_end'] == undefined) {
Logs[i]['dt_end'] = Logs[i]['dt_start'] + 1000;
}

}
return Logs;
}
// -------------------------------------------------------
// Collect data for a given Job and make a plain Array of log objects
// -------------------------------------------------------
requestify.get(firebase_target_url, {
headers: {
"Accept": "application/json"
}
})
.then(function(response) {
var job_logs = response.getBody();
var units = job_logs.units
for (var unit_id in units) {
var assignments = units[unit_id]['assignments'];
for (var assignment_id in assignments) {
var sessions = assignments[assignment_id]['sessions'];
for (var session_id in sessions) {
var logs = sessions[session_id]['clicks'];
//console.log(logs);
for (var log_id in logs) {
var log_record = {
task_id: task_id,
unit_id: unit_id,
assignment_id: assignment_id,
session_id: session_id,
dt_start: logs[log_id].dt,
element: logs[log_id].element
};
LOGS.push(log_record);
}
}
}
}
//LOGS = endify(LOGS);
LOGS = stringify(LOGS);
console.log(LOGS.length);
var all_text = "";
for (var i = 0; i < LOGS.length; i++) {
all_text+=LOGS[i]['string'] + '\n';
}
fs.appendFile(filename, all_text, function(err) {
if (err)
console.log(err);
});
});
22 changes: 22 additions & 0 deletions generators/generate_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

echo "===================================="
echo "= FIREBASE CROWDFLOWER LOGS TO CSV ="
echo "===================================="

echo "\nNow we create a folder for $@ task"
mkdir "../logs/$@"
echo "\nNow we generate logs of key presses from firebase..."
node key_presses_to_csv.js $@
echo "\nNow we generate logs of clicks from firebase..."
node clicks_to_csv.js $@
echo "\nNow we generate logs of page activity from firebase..."
node page_activity_to_csv.js $@
echo "\nNow we generate logs of tab visibility from firebase..."
node tab_visibility_to_csv.js $@

echo "\nNow we copy the folder with logs to stats-and-graphs folder to be further processed"
cp -r "../logs/$@" "../../stats-and-graphs/logs/$@"

echo "\nDONE"
echo "===================================="
94 changes: 94 additions & 0 deletions generators/key_presses_to_csv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
var requestify = require('requestify');
var fs = require('fs');


var firebase_base_url = 'https://crowdworker-logger.firebaseio.com/' + "taskscrowdflowercom" + '/';
var task_id = process.argv[2];
var firebase_target_url = firebase_base_url + task_id + ".json";
var folder = "../logs/"+task_id+"/";
var filename = folder + task_id + "_keys.csv";

fs.createWriteStream(filename);
fs.truncate(filename, 0, function() {
console.log('file ' + filename + ' was cleaned up.')
});
fs.appendFile(filename, 'task_id, unit_id, assignment_id, session_id, dt_start, key\n', function(err) {});

var LOGS = [];

var MaxUnit = 0;
// -------------------------------------------------------
// Convert log object into a string
// -------------------------------------------------------
function stringify(log_array) {
for (var i = 0; i < log_array.length; i++) {
log_array[i]['string'] = "";
log_array[i]['string'] += log_array[i].task_id + ", ";
log_array[i]['string'] += log_array[i].unit_id + ", ";
log_array[i]['string'] += log_array[i].assignment_id + ", ";
log_array[i]['string'] += log_array[i].session_id + ", ";
log_array[i]['string'] += log_array[i].dt_start + ", ";
log_array[i]['string'] += log_array[i].key;
}
return log_array;
}

function endify(log_array) {
var Logs = log_array;
for (var i = 0; i < Logs.length; i++) {
if (Logs[i].status != 'closed') {
if (i < (Logs.length - 1) && Logs[i].assignment_id == Logs[i + 1].assignment_id && Logs[i].session_id == Logs[i + 1].session_id) {
Logs[i]['dt_end'] = Logs[i + 1]['dt_start'];
}
}
if (Logs[i]['dt_end'] == undefined) {
Logs[i]['dt_end'] = Logs[i]['dt_start'] + 1000;
}

}
return Logs;
}
// -------------------------------------------------------
// Collect data for a given Job and make a plain Array of log objects
// -------------------------------------------------------
requestify.get(firebase_target_url, {
headers: {
"Accept": "application/json"
}
})
.then(function(response) {
var job_logs = response.getBody();
var units = job_logs.units
for (var unit_id in units) {
var assignments = units[unit_id]['assignments'];
for (var assignment_id in assignments) {
var sessions = assignments[assignment_id]['sessions'];
for (var session_id in sessions) {
var logs = sessions[session_id]['key_pressed'];
//console.log(logs);
for (var log_id in logs) {
var log_record = {
task_id: task_id,
unit_id: unit_id,
assignment_id: assignment_id,
session_id: session_id,
dt_start: logs[log_id].dt,
key: logs[log_id].key
};
LOGS.push(log_record);
}
}
}
}
//LOGS = endify(LOGS);
LOGS = stringify(LOGS);
console.log(LOGS.length);
var all_text = "";
for (var i = 0; i < LOGS.length; i++) {
all_text+=LOGS[i]['string'] + '\n';
}
fs.appendFile(filename, all_text, function(err) {
if (err)
console.log(err);
});
});
Loading