diff --git a/includes/WikiEditorHooks.php b/includes/WikiEditorHooks.php index d7e2f77c..0ac1588d 100644 --- a/includes/WikiEditorHooks.php +++ b/includes/WikiEditorHooks.php @@ -26,12 +26,16 @@ class WikiEditorHooks { */ public static function doEventLogging( $action, $article, $data = [] ) { global $wgVersion, $wgWMESchemaEditSamplingRate; - if ( !ExtensionRegistry::getInstance()->isLoaded( 'EventLogging' ) ) { + $extensionRegistry = ExtensionRegistry::getInstance(); + if ( !$extensionRegistry->isLoaded( 'EventLogging' ) ) { return false; } // Sample 6.25% $samplingRate = $wgWMESchemaEditSamplingRate ?? 0.0625; - if ( !EventLogging::sessionInSample( 1 / $samplingRate, $data['editingSessionId'] ) ) { + $inSample = EventLogging::sessionInSample( 1 / $samplingRate, $data['editingSessionId'] ); + $shouldOversample = $extensionRegistry->isLoaded( 'WikimediaEvents' ) && + WikimediaEventsHooks::shouldSchemaEditOversample( $article->getContext() ); + if ( !$inSample && !$shouldOversample ) { return false; } @@ -42,6 +46,7 @@ class WikiEditorHooks { $data = [ 'action' => $action, 'version' => 1, + 'isOversample' => !$inSample, 'editor' => 'wikitext', 'platform' => 'desktop', // FIXME 'integration' => 'page', @@ -58,7 +63,7 @@ class WikiEditorHooks { $data['user.class'] = 'IP'; } - return EventLogging::logEvent( 'Edit', 17541122, $data ); + return EventLogging::logEvent( 'Edit', 18476212, $data ); } /** diff --git a/modules/ext.wikiEditor.js b/modules/ext.wikiEditor.js index 25f6c5dd..25fa8616 100644 --- a/modules/ext.wikiEditor.js +++ b/modules/ext.wikiEditor.js @@ -15,18 +15,18 @@ // We have to do this on the client too because the unload handler // can cause an editingSessionId to be generated on the client // Not using mw.eventLog.inSample() because we need to be able to pass our own editingSessionId - if ( - !mw.eventLog.randomTokenMatch( - 1 / mw.config.get( 'wgWMESchemaEditSamplingRate' ), - editingSessionId - ) - ) { + var inSample = mw.eventLog.randomTokenMatch( + 1 / mw.config.get( 'wgWMESchemaEditSamplingRate' ), + editingSessionId + ); + if ( !inSample && !mw.config.get( 'wgWMESchemaEditOversample' ) ) { return; } data = $.extend( { version: 1, action: action, + isOversample: !inSample, editingSessionId: editingSessionId, editor: 'wikitext', platform: 'desktop', // FIXME diff --git a/tests/phan/config.php b/tests/phan/config.php index 543ff740..448fbd75 100644 --- a/tests/phan/config.php +++ b/tests/phan/config.php @@ -6,6 +6,7 @@ $cfg['directory_list'] = array_merge( $cfg['directory_list'], [ './../../extensions/EventLogging', + './../../extensions/WikimediaEvents', ] ); @@ -13,6 +14,7 @@ $cfg['exclude_analysis_directory_list'] = array_merge( $cfg['exclude_analysis_directory_list'], [ './../../extensions/EventLogging', + './../../extensions/WikimediaEvents', ] );