Skip to content
Snippets Groups Projects
Commit 9ba13470 authored by Jed Parsons's avatar Jed Parsons
Browse files

blur timestamp; remove local_timestamp

parent 206461bd
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,8 @@ const coarse = require('../coarse_user_agent_parser'),
querystring = require('querystring'),
und = require('underscore'),
urlparse = require('urlparse'),
wsapi = require('../wsapi.js');
wsapi = require('../wsapi.js'),
TEN_MIN_IN_MS = 10 * 60 * 1000;
// Accept JSON formatted interaction data and send it to the KPI Backend
......@@ -28,11 +29,22 @@ var store = function (kpi_json, cb) {
kpi_resp = function (res) {
logger.debug('KPI Backend responded ' + res.statusCode);
};
// TODO - timestamp should be client or server side?
und.each(kpi_json, function (kpi) {
// Out of concern for the user's privacy, scrub the data of identifying
// details before storing it.
//
// - Remove the local_timestamp: This was necessary for the client to keep
// track of the start time for the event stream, but it should not be part
// of the final record.
//
// - Round the server timestamp off to the nearest 10-minute mark.
und.each(kpi_json, function (kpi) { delete kpi.local_timestamp;
delete kpi.local_timestamp;
if (! kpi.timestamp) {
kpi.timestamp = new Date().getTime();
}
kpi.timestamp = kpi.timestamp - (kpi.timestamp % TEN_MIN_IN_MS);
});
if (!! config.get('kpi_backend_db_url')) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment