Merge "Track DOM retrieved events"

This commit is contained in:
jenkins-bot 2013-10-07 22:15:07 +00:00 committed by Gerrit Code Review
commit bcbefc63cc
2 changed files with 14 additions and 1 deletions

View file

@ -236,6 +236,7 @@ $wgResourceModules += array(
've-mw/init/ve.init.mw.Target.js',
),
'dependencies' => array(
'jquery.byteLength',
'jquery.client',
'mediawiki.Uri',
'ext.visualEditor.base',

View file

@ -491,7 +491,7 @@ ve.init.mw.Target.prototype.getHtml = function ( newDoc ) {
* @returns {boolean} Loading has been started
*/
ve.init.mw.Target.prototype.load = function () {
var data;
var data, start;
// Prevent duplicate requests
if ( this.loading ) {
return false;
@ -519,6 +519,8 @@ ve.init.mw.Target.prototype.load = function () {
}
// Load DOM
start = ve.now();
this.loading = $.ajax( {
'url': this.apiUrl,
'data': data,
@ -530,6 +532,16 @@ ve.init.mw.Target.prototype.load = function () {
'success': ve.bind( ve.init.mw.Target.onLoad, this ),
'error': ve.bind( ve.init.mw.Target.onLoadError, this )
} );
this.loading.done( function ( data, status, jqxhr ) {
ve.track( 'DOM retrieved', {
'bytes': $.byteLength( jqxhr.responseText ),
'duration': ve.now() - start,
'cacheHit': /hit/i.test( jqxhr.getResponseHeader( 'X-Cache' ) ),
'parsoid': jqxhr.getResponseHeader( 'X-Parsoid-Performance' )
} );
} );
return true;
};