* turn timing off, and track with GA
This commit is contained in:
parent
e9504b1fc6
commit
54a7cb40c9
|
|
@ -20,8 +20,11 @@
|
|||
var stun = null;
|
||||
var rest = context.JK.Rest();
|
||||
|
||||
$(window).on('load', sendTimingResults)
|
||||
$(window).on('pagehide', setNavigationStart)
|
||||
if(gon.global.web_performance_timing_enabled) {
|
||||
$(window).on('load', sendTimingResults)
|
||||
$(window).on('pagehide', setNavigationStart)
|
||||
}
|
||||
|
||||
|
||||
$(document).on('JAMKAZAM_CONSTRUCTED', function(e, data) {
|
||||
|
||||
|
|
@ -262,6 +265,7 @@
|
|||
|
||||
// http://githubengineering.com/browser-monitoring-for-github-com/
|
||||
function sendTimingResults() {
|
||||
|
||||
setTimeout(function() {
|
||||
var timing;
|
||||
var hasTimingApi;
|
||||
|
|
@ -294,15 +298,13 @@
|
|||
try {
|
||||
var navStart = window.sessionStorage.getItem('navigationStart')
|
||||
if(navStart) {
|
||||
timing['simulatedNavigationStart'] = parseInt(navStart, 10)
|
||||
timing['navigationStart'] = parseInt(navStart, 10)
|
||||
}
|
||||
}
|
||||
catch(e) { }
|
||||
}
|
||||
|
||||
|
||||
//GitHub.reportStats timing
|
||||
logger.debug("timing", timing)
|
||||
context.JK.GA.trackTiming(timing);
|
||||
}, 0)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,6 +284,36 @@
|
|||
logger.debug("Tracked Jam Track Play")
|
||||
}
|
||||
|
||||
function trackTiming(timing) {
|
||||
|
||||
if(!timing) {return}
|
||||
|
||||
try {
|
||||
var computed = {
|
||||
dns: timing.domainLookupEnd - timing.domainLookupStart,
|
||||
connect: timing.connectEnd - timing.connectStart,
|
||||
ttfb: timing.responseStart - timing.connectEnd,
|
||||
basePage: timing.responseEnd - timing.responseStart,
|
||||
frontEnd: timing.loadEventStart - timing.responseEnd,
|
||||
domContentLoadedEvent: timing.domContentLoadedEventEnd - timing.domContentLoadedEventStart,
|
||||
windowLoadEvent: timing.loadEventEnd - timing.loadEventStart,
|
||||
domInteractive: timing.domInteractive - timing.domLoading,
|
||||
domComplete: timing.domComplete - timing.domLoading,
|
||||
domCompleteToOnload: timing.loadEventStart - timing.domComplete
|
||||
};
|
||||
|
||||
logger.debug("page load time: " + computed.frontEnd)
|
||||
context._.each(computed, function (key, value) {
|
||||
if (value > 0 && value < 60000) {
|
||||
context.ga("send", "timing", "NavigationTiming", key, value);
|
||||
}
|
||||
})
|
||||
}
|
||||
catch(e) {
|
||||
logger.error("loading times failed in ga.js", e)
|
||||
}
|
||||
}
|
||||
|
||||
// if you want to pass in no title, either omit it from the arg list when u invoke virtualPageView, or pass in undefined, NOT null
|
||||
function virtualPageView(page, title) {
|
||||
|
||||
|
|
@ -445,6 +475,7 @@
|
|||
GA.trackBand = trackBand;
|
||||
GA.trackJKSocial = trackJKSocial;
|
||||
GA.virtualPageView = virtualPageView;
|
||||
GA.trackTiming = trackTiming;
|
||||
|
||||
context.JK.GA = GA;
|
||||
|
||||
|
|
|
|||
|
|
@ -345,5 +345,6 @@ if defined?(Bundler)
|
|||
config.error_on_fraud = false
|
||||
config.expire_fingerprint_days = 14
|
||||
config.found_conflict_count = 1
|
||||
config.web_performance_timing_enabled = true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,4 +16,5 @@ Gon.global.video_available = Rails.application.config.video_available
|
|||
Gon.global.gear_check_ignore_high_latency = Rails.application.config.gear_check_ignore_high_latency
|
||||
Gon.global.purchases_enabled = Rails.application.config.purchases_enabled
|
||||
Gon.global.estimate_taxes = Rails.application.config.estimate_taxes
|
||||
Gon.global.web_performance_timing_enabled = Rails.application.config.web_performance_timing_enabled
|
||||
Gon.global.env = Rails.env
|
||||
|
|
|
|||
Loading…
Reference in New Issue