From 9ba1347085339d7519c8b0fcff6496ef491ea1f3 Mon Sep 17 00:00:00 2001 From: Jed Parsons <jedp@me.com> Date: Mon, 21 May 2012 12:26:21 -0700 Subject: [PATCH] blur timestamp; remove local_timestamp --- lib/wsapi/interaction_data.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/wsapi/interaction_data.js b/lib/wsapi/interaction_data.js index 629dc55cc..1b24bcb63 100644 --- a/lib/wsapi/interaction_data.js +++ b/lib/wsapi/interaction_data.js @@ -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')) { -- GitLab