Merge "Use Schema:Edit sampling rate config from WikimediaEvents"

This commit is contained in:
jenkins-bot 2018-10-24 21:37:24 +00:00 committed by Gerrit Code Review
commit c31bffdb17
2 changed files with 18 additions and 13 deletions

View file

@ -25,12 +25,13 @@ class WikiEditorHooks {
* @return bool Whether the event was logged or not.
*/
public static function doEventLogging( $action, $article, $data = [] ) {
global $wgVersion;
global $wgVersion, $wgWMESchemaEditSamplingRate;
if ( !ExtensionRegistry::getInstance()->isLoaded( 'EventLogging' ) ) {
return false;
}
// Sample 6.25% (via hex digit)
if ( $data['editingSessionId'][0] > '0' ) {
// Sample 6.25%
$samplingRate = $wgWMESchemaEditSamplingRate ?? 0.0625;
if ( !EventLogging::sessionInSample( 1 / $samplingRate, $data['editingSessionId'] ) ) {
return false;
}

View file

@ -10,17 +10,24 @@
return;
}
// Sample 6.25% (via hex digit)
mw.loader.using( [ 'schema.Edit', 'ext.eventLogging.subscriber' ] ).done( function () {
// Sampling
// We have to do this on the client too because the unload handler
// can cause an editingSessionId to be generated on the client
if ( editingSessionId.charAt( 0 ) > '0' ) {
// 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
)
) {
return;
}
mw.loader.using( 'schema.Edit' ).done( function () {
data = $.extend( {
version: 1,
action: action,
editingSessionId: editingSessionId,
editor: 'wikitext',
platform: 'desktop', // FIXME
integration: 'page',
@ -66,12 +73,10 @@
// that don't, we just ignore them, so as to not skew the
// results towards better-performance in those cases.
logEditEvent( 'ready', {
editingSessionId: editingSessionId,
timing: Date.now() - window.performance.timing.navigationStart
} );
$textarea.on( 'wikiEditor-toolbar-doneInitialSections', function () {
logEditEvent( 'loaded', {
editingSessionId: editingSessionId,
timing: Date.now() - window.performance.timing.navigationStart
} );
} );
@ -105,7 +110,6 @@
if ( !submitting ) {
logEditEvent( 'abort', {
editingSessionId: editingSessionId,
type: abortType
} );
}