jenkins-bot has submitted this change and it was merged.
Change subject: Use internal ve.track to log events
......................................................................
Use internal ve.track to log events
This patch rounds off change I29740fa7a by replacing calls to EventLogging's
eventLog.logEvent with calls to VisualEditor's ve.track. ve.track publishes
events by providing an interface, ve.trackRegisterHandler, which event handlers
use to subscribe to VisualEditor events. By making it the responsibility of the
web analytics framework to register itself as a handler, VisualEditor can
remain decoupled from (and indeed ignorant of) any particular event logging
implementation. This allows VisualEditor to be integrated with many different
web analytics platforms with nothing more than a bit of glue code for mapping
ve's event semantics to those of the target platform.
The practical difference that this makes is that it frees VisualEditor from
having to know about EventLogging or from having to load EventLogging
components, which means we can remove quite a lot of gnarly code. My current
plan is to migrate the code for registering and loading the 'Edit'
schema module to Extension:CoreEvents, which is also where I'll commit the
handler for VE events. (CoreEvents exists precisely to provide an organized
place for persistent but WMF-particular instrumentation.)
Once this patch is merged and deployed, the following two configuration
variables may be removed from mediawiki-config:
- $wgVisualEditorEnableSplitTest
- $wgVisualEditorEnableEventLogging
Change-Id: Idfdf692668d2adfbe029e8f0c4ff9e96c60ff741
---
M VisualEditor.hooks.php
M VisualEditor.php
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
D modules/ve-mw/init/ve.init.mw.splitTest.js
5 files changed, 9 insertions(+), 162 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 3fee364..a484702 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -13,8 +13,8 @@
protected static $supportedSkins = array( 'vector', 'apex', 'monobook'
);
public static function onSetup() {
- global $wgVisualEditorEnableEventLogging, $wgResourceModules,
- $wgVisualEditorResourceTemplate,
$wgVisualEditorTabMessages;
+ global $wgResourceModules, $wgVisualEditorResourceTemplate,
+ $wgVisualEditorTabMessages;
// This prevents VisualEditor from being run in environments
that don't
// have the dependent code in core; this should be updated as a
part of
@@ -32,21 +32,6 @@
}
}
- if ( $wgVisualEditorEnableEventLogging ) {
- if ( class_exists( 'ResourceLoaderSchemaModule' ) ) {
- // EventLogging schema module for logging edit
events.
- // See
<http://meta.wikimedia.org/wiki/Schema:Edit>
- $wgResourceModules['schema.Edit'] = array(
- 'class' =>
'ResourceLoaderSchemaModule',
- 'schema' => 'Edit',
- 'revision' => 5570274,
- );
- } else {
- wfWarn( 'VisualEditor is configured to use
EventLogging, but the extension is ' .
- ' not available. Disabling
wgVisualEditorEnableEventLogging.' );
- $wgVisualEditorEnableEventLogging = false;
- }
- }
// Only load jquery.ULS if ULS Extension isn't already
installed:
if ( !class_exists( 'UniversalLanguageSelectorHooks' ) ) {
$wgResourceModules['jquery.uls'] =
$wgVisualEditorResourceTemplate + array(
@@ -93,15 +78,8 @@
* @param $skin Skin
*/
public static function onBeforePageDisplay( &$output, &$skin ) {
- global $wgVisualEditorEnableEventLogging;
-
- if ( $wgVisualEditorEnableEventLogging ) {
- $output->addModules( array( 'schema.Edit' ) );
- }
-
$output->addModules( array(
'ext.visualEditor.viewPageTarget.init' ) );
$output->addModuleStyles( array(
'ext.visualEditor.viewPageTarget.noscript' ) );
-
return true;
}
@@ -282,7 +260,6 @@
public static function onResourceLoaderGetConfigVars( array &$vars ) {
global $wgDefaultUserOptions,
$wgVisualEditorDisableForAnons,
- $wgVisualEditorEnableEventLogging,
$wgVisualEditorEnableExperimentalCode,
$wgVisualEditorNamespaces,
$wgVisualEditorPluginModules,
@@ -292,7 +269,6 @@
$vars['wgVisualEditorConfig'] = array(
'disableForAnons' => $wgVisualEditorDisableForAnons,
- 'enableEventLogging' =>
$wgVisualEditorEnableEventLogging,
'enableExperimentalCode' =>
$wgVisualEditorEnableExperimentalCode,
'namespaces' => $wgVisualEditorNamespaces,
'pluginModules' => $wgVisualEditorPluginModules,
@@ -391,26 +367,6 @@
'localBasePath' => dirname( __FILE__ ) . '/modules',
'remoteExtPath' => 'VisualEditor/modules',
);
-
- return true;
- }
-
-
- /**
- * Sets user preference to enable the VisualEditor account if their new
- * account's userID is even, if $wgVisualEditorEnableSplitTest is true.
- *
- * Added per bug 49604; to be removed once no longer needed.
- */
- public static function onAddNewAccount( $user, $byEmail ) {
- global $wgVisualEditorEnableSplitTest;
-
- if ( $wgVisualEditorEnableSplitTest &&
- $user->isLoggedin() &&
- ( ( $user->getId() % 2 ) === 0 ) ) {
- $user->setOption( 'visualeditor-enable', 1 );
- $user->saveSettings();
- }
return true;
}
diff --git a/VisualEditor.php b/VisualEditor.php
index a6f8df2..aac37b5 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -55,9 +55,6 @@
$wgHooks['SkinTemplateNavigation'][] =
'VisualEditorHooks::onSkinTemplateNavigation';
$wgExtensionFunctions[] = 'VisualEditorHooks::onSetup';
-// Bug 49604: Running split test in production if
$wgVisualEditorEnableSplitTest is true.
-$wgHooks['AddNewAccount'][] = 'VisualEditorHooks::onAddNewAccount';
-
// Set default values for new preferences
$wgDefaultUserOptions['visualeditor-enable'] = 0;
$wgDefaultUserOptions['visualeditor-betatempdisable'] = 0;
@@ -99,13 +96,6 @@
'unicodejs/unicodejs.wordbreakproperties.js',
'unicodejs/unicodejs.wordbreak.js',
),
- ),
-
- // Added for 18-Jun-2013 split test; safe to remove after
- 'ext.visualEditor.splitTest' => $wgVisualEditorResourceTemplate + array(
- 'scripts' => array(
- 've-mw/init/ve.init.mw.splitTest.js',
- )
),
// Alias for backwards compat, safe to remove after
@@ -786,9 +776,6 @@
// Whether to use change tagging for VisualEditor edits
$wgVisualEditorUseChangeTagging = true;
-
-// Whether to log analytic events using EventLogging
-$wgVisualEditorEnableEventLogging = false;
// Whether to disable for logged-in users
// This allows you to enable the 'visualeditor-enable' preference by default
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
index f353395..3177668 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js
@@ -317,7 +317,7 @@
e.preventDefault();
getTarget().done( function ( target ) {
- target.logEvent( 'Edit', { action:
'edit-link-click' } );
+ ve.track( 'Edit', { action: 'edit-link-click' }
);
target.activate();
} );
},
@@ -330,7 +330,7 @@
e.preventDefault();
getTarget().done( function ( target ) {
- target.logEvent( 'Edit', { action:
'section-edit-link-click' } );
+ ve.track( 'Edit', { action:
'section-edit-link-click' } );
target.saveEditSection( $( e.target ).closest(
'h1, h2, h3, h4, h5, h6' ).get( 0 ) );
target.activate();
} );
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
index 16b7d41..5634c2c 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
@@ -95,12 +95,6 @@
$.client.test(
ve.init.mw.ViewPageTarget.compatibility.whitelist, null, true )
);
- if ( mw.config.get( 'wgVisualEditorConfig' ).enableEventLogging ) {
- this.setUpEventLogging();
- } else {
- this.logEvent = $.noop;
- }
-
// Events
this.connect( this, {
'load': 'onLoad',
@@ -307,7 +301,7 @@
*/
ve.init.mw.ViewPageTarget.prototype.onLoad = function ( doc ) {
if ( this.activating ) {
- this.logEvent( 'Edit', { action: 'page-edit-impression' } );
+ ve.track( 'Edit', { action: 'page-edit-impression' } );
this.edited = false;
this.doc = doc;
this.setUpSurface( doc, ve.bind( function() {
@@ -376,9 +370,9 @@
* @param {number} [newid] New revision id, undefined if unchanged
*/
ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, newid ) {
- this.logEvent( 'Edit', {
+ ve.track( 'Edit', {
action: 'page-save-success',
- latency: this.saveStart ? new Date() - this.saveStart : 0
+ latency: this.saveStart ? ve.now() - this.saveStart : 0
} );
delete this.saveStart;
@@ -742,7 +736,7 @@
* @param {jQuery.Event} e Mouse click event
*/
ve.init.mw.ViewPageTarget.prototype.onToolbarSaveButtonClick = function () {
- this.logEvent( 'Edit', { action: 'page-save-attempt' } );
+ ve.track( 'Edit', { action: 'page-save-attempt' } );
if ( this.edited || this.restoring ) {
this.showSaveDialog();
}
@@ -899,7 +893,7 @@
// Once we've retrieved the save options,
// reset save start and any old captcha data
- this.saveStart = +new Date();
+ this.saveStart = ve.now();
if ( this.captcha ) {
this.clearMessage( 'captcha' );
delete this.captcha;
@@ -1209,40 +1203,6 @@
} else if ( update.css ) {
this.$toolbarTracker.css( update.css );
}
-};
-
-/**
- * Set up the logging of analytic edit events using EventLogging.
- *
- * @method
- */
-ve.init.mw.ViewPageTarget.prototype.setUpEventLogging = function () {
- mw.loader.using( 'schema.Edit', function () {
- mw.eventLog.setDefaults( 'Edit', {
- version: 0,
- editor: 'visualeditor',
- pageId: mw.config.get( 'wgArticleId' ),
- pageNs: mw.config.get( 'wgNamespaceNumber' ),
- pageName: mw.config.get( 'wgPageName' ),
- pageViewSessionId: mw.user.generateRandomSessionId(),
- revId: function () {
- return mw.config.get( 'wgCurRevisionId' );
- },
- userId: +mw.config.get( 'wgUserId' )
- } );
- } );
-};
-
-/**
- * Thin wrapper around EventLogging's 'logEvent' method which ensures the
- * relevant schema module has been loaded.
- *
- * @method
- */
-ve.init.mw.ViewPageTarget.prototype.logEvent = function ( schemaName, event ) {
- mw.loader.using( 'schema.' + schemaName, function () {
- mw.eventLog.logEvent( schemaName, event );
- } );
};
/**
diff --git a/modules/ve-mw/init/ve.init.mw.splitTest.js
b/modules/ve-mw/init/ve.init.mw.splitTest.js
deleted file mode 100644
index 6ff9779..0000000
--- a/modules/ve-mw/init/ve.init.mw.splitTest.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/*global mediaWiki */
-( function ( mw, $ ) {
- 'use strict';
-
- 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;
- }
-
- if ( !mw.config.get( 'wgVisualEditorConfig', {} ).enableEventLogging ) {
- return;
- }
-
- 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 el = this,
- action = /section=/.test( el.href ) ?
'section-edit-link-click' : 'edit-link-click';
-
- log( action ).always( function () {
- window.location = el.href;
- } );
- e.preventDefault();
- } );
-
- // Log edit submit
- $( '#wpSave' ).one( 'click', function ( e ) {
- var el = this;
- log( 'page-save-attempt' ).always( function () {
- $( el ).trigger( 'click' );
- } );
- e.preventDefault();
- } );
-
-} ( mediaWiki, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/77483
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idfdf692668d2adfbe029e8f0c4ff9e96c60ff741
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits