Skip to content
Snippets Groups Projects
Commit 3c527dc8 authored by Lloyd Hilaiel's avatar Lloyd Hilaiel
Browse files

Merge pull request #1784 from mozilla/issue_1732_kpi_timestamp_resolution

Round the timestamp to the nearest 10 minutes.
parents 0c611cea 6fbc725f
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@
// listen for events via the mediator?
BrowserID.Modules.InteractionData = (function() {
"use strict";
var bid = BrowserID,
model = bid.Models.InteractionData,
network = bid.Network,
......@@ -98,10 +100,16 @@ BrowserID.Modules.InteractionData = (function() {
return;
}
// server_time is sent in milliseconds. The promise to users and data
// safety is the timestamp would be at a 10 minute resolution. Round to the
// nearest 10 minute mark.
var TEN_MINS_IN_MS = 10 * 60 * 1000,
roundedServerTime = Math.round(result.server_time / TEN_MINS_IN_MS) * TEN_MINS_IN_MS;
var currentData = {
event_stream: self.initialEventStream,
sample_rate: sampleRate,
timestamp: result.server_time,
timestamp: roundedServerTime,
local_timestamp: self.startTime.toString(),
lang: dom.getAttr('html', 'lang') || null,
};
......
......@@ -235,4 +235,15 @@
});
});
asyncTest("timestamp rounded to 10 minute intervals", function() {
var TEN_MINS_IN_MS = 10 * 60 * 1000;
createController();
network.withContext(function() {
var timestamp = controller.getCurrent().timestamp;
ok(timestamp, "a timestamp has been passed: " + timestamp);
equal(timestamp % TEN_MINS_IN_MS, 0, "timestamp has been rounded to a 10 minute interval");
start();
});
});
}());
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