mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Merge "Split test: instrument edit events for standard editor interface"
This commit is contained in:
commit
2693891c17
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
55
modules/ve/init/mw/ve.init.mw.splitTest.js
Normal file
55
modules/ve/init/mw/ve.init.mw.splitTest.js
Normal 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 ) );
|
Loading…
Reference in a new issue