Enrollment for the edit check a/b test

The enrollment happens in ArticleTargetLoader so that the bucket will be
set for init logging.

Bug: T342930
Depends-On: I9c7c0fb52a6ec68609df6b518c7d35ddd98a95bf
Change-Id: I03c8dc8beb2eb267c052b856a30343ecab3a7657
(cherry picked from commit e7861de221)
This commit is contained in:
David Lynch 2024-02-13 11:34:18 -06:00 committed by DLynch
parent 3e15293b39
commit 9e3bb768b2
3 changed files with 22 additions and 0 deletions

View file

@ -154,6 +154,10 @@
"value": false,
"description": "Enable experimental Edit Check feature. Can also be enabled using ?ecenable=1."
},
"VisualEditorEditCheckABTest": {
"value": false,
"description": "A/B test Edit Check for all users. A/B bucket status will override VisualEditorEditCheck."
},
"VisualEditorUseSingleEditTab": {
"value": false
}

View file

@ -1176,6 +1176,7 @@ class Hooks implements
'useChangeTagging' => $veConfig->get( 'VisualEditorUseChangeTagging' ),
'editCheckTagging' => $veConfig->get( 'VisualEditorEditCheckTagging' ),
'editCheck' => $veConfig->get( 'VisualEditorEditCheck' ),
'editCheckABTest' => $veConfig->get( 'VisualEditorEditCheckABTest' ),
'namespacesWithSubpages' => $namespacesWithSubpagesEnabled,
'specialBooksources' => urldecode( SpecialPage::getTitleFor( 'Booksources' )->getPrefixedURL() ),
'rebaserUrl' => $coreConfig->get( 'VisualEditorRebaserURL' ),

View file

@ -37,6 +37,23 @@
modules.push( 'ext.visualEditor.mwwikitext' );
}
// A/B test enrollment for edit check (T342930)
if ( conf.editCheckABTest ) {
var inABTest;
if ( mw.user.isAnon() ) {
// can't just use mw.user.sessionId() because we need this to last across sessions
var token = mw.cookie.get( 'VEECid', '', mw.user.generateRandomSessionId() );
// Store the token so our state is consistent across pages
mw.cookie.set( 'VEECid', token, { path: '/', expires: 90 * 86400, prefix: '' } );
inABTest = parseInt( token.slice( 0, 8 ), 16 ) % 2 === 1;
} else {
inABTest = mw.user.getId() % 2 === 1;
}
conf.editCheck = inABTest;
// Communicate the bucket to instrumentation:
mw.config.set( 'wgVisualEditorEditCheckABTestBucket', '2024-02-editcheck-reference-' + ( inABTest ? 'test' : 'control' ) );
}
var editCheck = conf.editCheck || !!url.searchParams.get( 'ecenable' ) || !!window.MWVE_FORCE_EDIT_CHECK_ENABLED;
if ( conf.editCheckTagging || editCheck ) {
modules.push( 'ext.visualEditor.editCheck' );