Merge "Split test: instrument edit events for standard editor interface"

This commit is contained in:
jenkins-bot 2013-06-17 21:38:10 +00:00 committed by Gerrit Code Review
commit 2693891c17
3 changed files with 66 additions and 0 deletions

View file

@ -61,6 +61,10 @@ class VisualEditorHooks {
$output->addModules( array( 'schema.Edit' ) );
}
$output->addModules( array( 'ext.visualEditor.viewPageTarget' ) );
} else {
if ( $wgVisualEditorEnableEventLogging ) {
$output->addModules( array( 'schema.Edit', 'ext.visualEditor.splitTest' ) );
}
}
return true;
}

View file

@ -91,6 +91,13 @@ $wgResourceModules += array(
'unicodejs/unicodejs.wordbreak.js',
),
),
// Added for 18-Jun-2013 split test; safe to remove after
'ext.visualEditor.splitTest' => $wgVisualEditorResourceTemplate + array(
'scripts' => array(
've/init/mw/ve.init.mw.splitTest.js',
)
),
// Alias for backwards compat, safe to remove after
'ext.visualEditor.editPageInit' => $wgVisualEditorResourceTemplate + array(
'dependencies' => array(

View file

@ -0,0 +1,55 @@
/*global mediaWiki */
( function ( mw, $ ) {
'use strict';
if ( !mw.config.get( 'wgVisualEditorConfig', {} ).enableEventLogging ) {
return;
}
function log( action ) {
var dfd = $.Deferred();
setTimeout( dfd.reject, 1000 );
mw.loader.using( 'schema.Edit', function () {
mw.eventLog.logEvent( 'Edit', {
version: 0,
action: action,
editor: 'wikitext',
pageId: mw.config.get( 'wgArticleId' ),
pageNs: mw.config.get( 'wgNamespaceNumber' ),
pageName: mw.config.get( 'wgPageName' ),
pageViewSessionId: mw.user.generateRandomSessionId(),
revId: mw.config.get( 'wgCurRevisionId' ),
userId: +mw.config.get( 'wgUserId' )
} ).always( dfd.resolve );
} );
return dfd;
}
mw.hook( 'postEdit' ).add( function () {
log( 'page-save-success' );
} );
if ( mw.config.get('wgAction') === 'edit' ) {
log( 'page-edit-impression' );
}
// Log clicks on page edit and section edit links
$( '#ca-edit a, .mw-editsection a' ).on( 'click', function ( e ) {
var href = this.href,
action = /section=/.test( href ) ? 'section-edit-link-click' : 'edit-link-click';
log( action ).always( function () {
window.location = href;
} );
e.preventDefault();
} );
// Log edit submit
$( '#wpSave' ).one( 'click', function ( e ) {
var $save = $( this );
log( 'page-save-attempt' ).always( function () {
$save.trigger( 'click' );
} );
e.preventDefault();
} );
} ( mediaWiki, jQuery ) );