mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-25 00:37:23 +00:00
Merge "Use Schema:Edit sampling rate config from WikimediaEvents"
This commit is contained in:
commit
c31bffdb17
|
@ -25,12 +25,13 @@ class WikiEditorHooks {
|
||||||
* @return bool Whether the event was logged or not.
|
* @return bool Whether the event was logged or not.
|
||||||
*/
|
*/
|
||||||
public static function doEventLogging( $action, $article, $data = [] ) {
|
public static function doEventLogging( $action, $article, $data = [] ) {
|
||||||
global $wgVersion;
|
global $wgVersion, $wgWMESchemaEditSamplingRate;
|
||||||
if ( !ExtensionRegistry::getInstance()->isLoaded( 'EventLogging' ) ) {
|
if ( !ExtensionRegistry::getInstance()->isLoaded( 'EventLogging' ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Sample 6.25% (via hex digit)
|
// Sample 6.25%
|
||||||
if ( $data['editingSessionId'][0] > '0' ) {
|
$samplingRate = $wgWMESchemaEditSamplingRate ?? 0.0625;
|
||||||
|
if ( !EventLogging::sessionInSample( 1 / $samplingRate, $data['editingSessionId'] ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,17 +10,24 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sample 6.25% (via hex digit)
|
mw.loader.using( [ 'schema.Edit', 'ext.eventLogging.subscriber' ] ).done( function () {
|
||||||
// We have to do this on the client too because the unload handler
|
// Sampling
|
||||||
// can cause an editingSessionId to be generated on the client
|
// We have to do this on the client too because the unload handler
|
||||||
if ( editingSessionId.charAt( 0 ) > '0' ) {
|
// can cause an editingSessionId to be generated on the client
|
||||||
return;
|
// 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( {
|
data = $.extend( {
|
||||||
version: 1,
|
version: 1,
|
||||||
action: action,
|
action: action,
|
||||||
|
editingSessionId: editingSessionId,
|
||||||
editor: 'wikitext',
|
editor: 'wikitext',
|
||||||
platform: 'desktop', // FIXME
|
platform: 'desktop', // FIXME
|
||||||
integration: 'page',
|
integration: 'page',
|
||||||
|
@ -66,12 +73,10 @@
|
||||||
// that don't, we just ignore them, so as to not skew the
|
// that don't, we just ignore them, so as to not skew the
|
||||||
// results towards better-performance in those cases.
|
// results towards better-performance in those cases.
|
||||||
logEditEvent( 'ready', {
|
logEditEvent( 'ready', {
|
||||||
editingSessionId: editingSessionId,
|
|
||||||
timing: Date.now() - window.performance.timing.navigationStart
|
timing: Date.now() - window.performance.timing.navigationStart
|
||||||
} );
|
} );
|
||||||
$textarea.on( 'wikiEditor-toolbar-doneInitialSections', function () {
|
$textarea.on( 'wikiEditor-toolbar-doneInitialSections', function () {
|
||||||
logEditEvent( 'loaded', {
|
logEditEvent( 'loaded', {
|
||||||
editingSessionId: editingSessionId,
|
|
||||||
timing: Date.now() - window.performance.timing.navigationStart
|
timing: Date.now() - window.performance.timing.navigationStart
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
@ -105,7 +110,6 @@
|
||||||
|
|
||||||
if ( !submitting ) {
|
if ( !submitting ) {
|
||||||
logEditEvent( 'abort', {
|
logEditEvent( 'abort', {
|
||||||
editingSessionId: editingSessionId,
|
|
||||||
type: abortType
|
type: abortType
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue