EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/236937
Change subject: A/B test for experimental suggestions api
......................................................................
A/B test for experimental suggestions api
Creates test with 1 in 10000 sampling rate per bucket measuring
the zero result rate of the current `opensearch` completion api
and an experimental `cirrus-suggest` completion api.
Test must be enabled by setting:
$wgWMEEnableCompletionExperiment = true
Required mediawiki-core patch: I1fab57ea
Bug: T111137
Change-Id: I595db33a1970651f34290bdfe1f924ad11119bc3
---
M WikimediaEvents.php
M WikimediaEventsHooks.php
A modules/ext.wikimediaEvents.searchSuggest.js
3 files changed, 92 insertions(+), 1 deletion(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents
refs/changes/37/236937/1
diff --git a/WikimediaEvents.php b/WikimediaEvents.php
index e655ce5..d76528f 100644
--- a/WikimediaEvents.php
+++ b/WikimediaEvents.php
@@ -42,6 +42,11 @@
*/
$wgWMETrackGeoFeatures = false;
+/**
+ * @var bool Whether the completion suggestion experiment is enabled.
+ */
+$wgWMEEnableCompletionExperiment = false;
+
// Messages
$wgMessagesDirs['WikimediaEvents'] = __DIR__ . '/i18n';
@@ -75,11 +80,17 @@
'schema' => 'DidYouMean',
'revision' => 13316693,
),
+ 'schema.CompletionSuggestions' => array(
+ 'class' => 'ResourceLoaderSchemaModule',
+ 'schema' => 'CompletionSuggestions',
+ 'revision' => 13424343,
+ ),
'ext.wikimediaEvents' => array(
// Loaded globally for all users (including logged-out)
// Don't remove if empty!
'scripts' => array(
'ext.wikimediaEvents.resourceloader.js',
+ 'ext.wikimediaEvents.searchSuggest.js',
),
'dependencies' => array(
'ext.wikimediaEvents.search',
diff --git a/WikimediaEventsHooks.php b/WikimediaEventsHooks.php
index 9db6d24..2160e3b 100644
--- a/WikimediaEventsHooks.php
+++ b/WikimediaEventsHooks.php
@@ -319,8 +319,9 @@
}
public static function onResourceLoaderGetConfigVars( &$vars ) {
- global $wgWMEStatsdBaseUri;
+ global $wgWMEStatsdBaseUri, $wgWMEEnableCompletionExperiment;
$vars['wgWMEStatsdBaseUri'] = $wgWMEStatsdBaseUri;
+ $vars['wgWMEEnableCompletionExperiment'] =
$wgWMEEnableCompletionExperiment;
}
/**
diff --git a/modules/ext.wikimediaEvents.searchSuggest.js
b/modules/ext.wikimediaEvents.searchSuggest.js
new file mode 100644
index 0000000..ae8b5da
--- /dev/null
+++ b/modules/ext.wikimediaEvents.searchSuggest.js
@@ -0,0 +1,79 @@
+/*!
+ * Javacsript module for testing the experimental cirrus
+ * suggestions api.
+ *
+ * @license GNU GPL v2 or later
+ * @author Erik Bernhardson <[email protected]>
+ */
+( function ( mw, $ ) {
+
+ function oneIn( populationSize ) {
+ return Math.floor( Math.random() * populationSize ) === 0;
+ }
+
+ function participateInTest( bucket, callback ) {
+ var pageId = mw.user.generateRandomSessionId(),
+ logEvent = function ( numResults ) {
+ mw.eventLog.logEvent( 'CompletionSuggestions', {
+ bucket: bucket,
+ // The number of suggestions provided
to the user
+ numResults: numResults,
+ // used to correlate actions that
happen on the same page.
+ pageId: pageId,
+ // we noticed a number of events get
sent multiple
+ // times from javascript, especially
when using sendBeacon.
+ // This logId allows for later
deduplication
+ logId:
mw.user.generateRandomSessionId(),
+ } );
+ };
+
+ mw.searchSuggest.request = function ( api, query, response,
maxRows ) {
+ return callback( api, query, function ( data ) {
+ logEvent( data.length );
+ response( data );
+ }, maxRows );
+ };
+ }
+
+ $( document ).ready( function () {
+ if ( !mw.config.get( 'wgWMEEnableCompletionExperiment' ) ) {
+ return;
+ }
+
+ var bucket, callback,
+ sampleSize = 10000; // .01% sampling rate per bucket
+
+ if ( oneIn( sampleSize ) ) {
+ bucket = 'opensearch';
+ callback = mw.searchSuggest.request;
+ } else if ( oneIn( sampleSize ) ) {
+ bucket = 'cirrus-suggest';
+ callback = function ( api, query, response, maxRows ) {
+ return api.get( {
+ action: 'cirrus-suggest',
+ text: query,
+ limit: maxRows,
+ } ).done( function ( data ) {
+ response( $.map( data.suggest, function
( suggestion ) {
+ return suggestion.title;
+ } ) );
+ } );
+ };
+ } else {
+ return;
+ }
+
+ mw.searchSuggest.request = function ( api, query, response, maxRows ) {
+ mw.loader.using( [
+ 'mediawiki.user',
+ 'ext.eventLogging',
+ 'schema.CompletionSuggestions'
+ ] ).then( function () {
+ participateInTest( bucket, callback );
+ mw.searchSuggest.request( api, query, response,
maxRows );
+ } );
+ };
+
+ } );
+
+}( mediaWiki, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/236937
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I595db33a1970651f34290bdfe1f924ad11119bc3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaEvents
Gerrit-Branch: wmf/1.26wmf22
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits