Skip to content

Commit

Permalink
Code review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
philbooth committed Mar 11, 2014
1 parent 9c27901 commit 2c1f5f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion boomerang.js
Expand Up @@ -595,7 +595,7 @@ boomr = {

// using 2000 here as a de facto maximum URL length based on:
// http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
if(url.length > 2000 && impl.beacon_type === 'AUTO') {
if(url.length > 2000 && impl.beacon_type === "AUTO") {
BOOMR.utils.postData();
}

Expand Down
38 changes: 25 additions & 13 deletions plugins/restiming.js
Expand Up @@ -10,12 +10,28 @@ see: http://www.w3.org/TR/resource-timing/
BOOMR = BOOMR || {};
BOOMR.plugins = BOOMR.plugins || {};

var impl = {
var restricted = {
redirectStart: "rt_red_st",
redirectEnd: "rt_red_end",
domainLookupStart: "rt_dns_st",
domainLookupEnd: "rt_dns_end",
connectStart: "rt_con_st",
connectEnd: "rt_con_end",
secureConnectionStart: "rt_scon_st",
requestStart: "rt_req_st",
responseStart: "rt_res_st"
},

impl = {
complete: false,
done: function() {
var p = BOOMR.window.performance, r, data, i;
if(p && typeof p.getEntriesByType === 'function') {
r = p.getEntriesByType('resource');
var p = BOOMR.window.performance, r, data, i, k;
if(impl.complete) {
return;
}
BOOMR.removeVar("restiming");
if(p && typeof p.getEntriesByType === "function") {
r = p.getEntriesByType("resource");
if(r) {
BOOMR.info("Client supports Resource Timing API", "rt");
data = {
Expand All @@ -27,18 +43,14 @@ var impl = {
rt_type: r[i].entryType,
rt_st: r[i].startTime,
rt_dur: r[i].duration,
rt_red_st: r[i].redirectStart,
rt_red_end: r[i].redirectEnd,
rt_fet_st: r[i].fetchStart,
rt_dns_st: r[i].domainLookupStart,
rt_dns_end: r[i].domainLookupEnd,
rt_con_st: r[i].connectStart,
rt_con_end: r[i].connectEnd,
rt_scon_st: r[i].secureConnectionStart,
rt_req_st: r[i].requestStart,
rt_res_st: r[i].responseStart,
rt_res_end: r[i].responseEnd
};
for(k in restricted) {
if(restricted.hasOwnProperty(k) && r[i][k] > 0) {
data.restiming[i][restricted[k]] = r[i][k];
}
}
}
BOOMR.addVar(data);
}
Expand Down

0 comments on commit 2c1f5f8

Please sign in to comment.