jenkins-bot has submitted this change and it was merged.

Change subject: Use $wgVisualEditorPluginModules to register VE listener
......................................................................


Use $wgVisualEditorPluginModules to register VE listener

Plugin modules always run when VE is loaded, whereas
the activation hook only fires when VE has successfully initialized,
which means we miss events fired from code paths that don't lead to
successful activation.

Using the plugin system also means that we don't have to check whether
VE is present (either in the JS or when loading the module), because
the plugin system handles that for us.

However, this does mean that WikimediaEvents must be loaded after VE.

Change-Id: I7e059e759b722a1723b77f5d9b14afbf116d04c1
---
M WikimediaEvents.php
M modules/ext.wikimediaEvents.ve.js
2 files changed, 25 insertions(+), 26 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  Catrope: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/WikimediaEvents.php b/WikimediaEvents.php
index cd0d40b..9662857 100644
--- a/WikimediaEvents.php
+++ b/WikimediaEvents.php
@@ -49,6 +49,7 @@
        ),
        'ext.wikimediaEvents.ve' => array(
                'scripts'       => 'ext.wikimediaEvents.ve.js',
+               'dependencies'  => 'ext.visualEditor.viewPageTarget.init',
                'localBasePath' => __DIR__ . '/modules',
                'remoteExtPath' => 'WikimediaEvents/modules',
        ),
@@ -60,12 +61,12 @@
        ),
 );
 
+$wgVisualEditorPluginModules[] = 'ext.wikimediaEvents.ve';
+
 // Hooks
 
 $wgHooks[ 'BeforePageDisplay' ][] = function ( &$out, &$skin ) {
        global $wgResourceLoaderStorageEnabled;
-
-       $out->addModules( 'ext.wikimediaEvents.ve' );
 
        if ( !$wgResourceLoaderStorageEnabled ) {
                $out->addModules( 'ext.wikimediaEvents.moduleStorage' );
diff --git a/modules/ext.wikimediaEvents.ve.js 
b/modules/ext.wikimediaEvents.ve.js
index 743322d..f62c4f3 100644
--- a/modules/ext.wikimediaEvents.ve.js
+++ b/modules/ext.wikimediaEvents.ve.js
@@ -33,36 +33,34 @@
        }
 
 
-       mw.hook( 've.activationComplete' ).add( function () {
-               if ( !ve.trackSubscribe ) {
+       if ( !ve.trackSubscribe ) {
+               return;
+       }
+
+       ve.trackSubscribe( 'performance', function ( topic, data ) {
+               var event, schema = schemas[topic];
+
+               if ( !schema ) {
                        return;
                }
 
-               ve.trackSubscribe( 'performance', function ( topic, data ) {
-                       var event, schema = schemas[topic];
+               event = {
+                       bytes: data.bytes,
+                       duration: data.duration,
+                       pageId: mw.config.get( 'wgArticleId' ),
+                       revId: mw.config.get( 'wgCurRevisionId' )
+               };
 
-                       if ( !schema ) {
-                               return;
-                       }
+               if ( data.hasOwnProperty( 'cacheHit' ) ) {
+                       event.cacheHit = data.cacheHit;
+               }
 
-                       event = {
-                               bytes: data.bytes,
-                               duration: data.duration,
-                               pageId: mw.config.get( 'wgArticleId' ),
-                               revId: mw.config.get( 'wgCurRevisionId' )
-                       };
+               if ( data.parsoid ) {
+                       $.extend( event, parseXpp( data.parsoid ) );
+               }
 
-                       if ( data.hasOwnProperty( 'cacheHit' ) ) {
-                               event.cacheHit = data.cacheHit;
-                       }
-
-                       if ( data.parsoid ) {
-                               $.extend( event, parseXpp( data.parsoid ) );
-                       }
-
-                       mw.loader.using( 'schema.' + schema, function () {
-                               mw.eventLog.logEvent( schema, event );
-                       } );
+               mw.loader.using( 'schema.' + schema, function () {
+                       mw.eventLog.logEvent( schema, event );
                } );
        } );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/96208
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7e059e759b722a1723b77f5d9b14afbf116d04c1
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/WikimediaEvents
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to