diff --git a/extension.json b/extension.json index db1ae0885a..889af1ba9f 100644 --- a/extension.json +++ b/extension.json @@ -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 } diff --git a/includes/Hooks.php b/includes/Hooks.php index afb2555c3a..0fcb7c5dea 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -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' ), diff --git a/modules/ve-mw/preinit/ve.init.mw.ArticleTargetLoader.js b/modules/ve-mw/preinit/ve.init.mw.ArticleTargetLoader.js index a260557af1..eedac96319 100644 --- a/modules/ve-mw/preinit/ve.init.mw.ArticleTargetLoader.js +++ b/modules/ve-mw/preinit/ve.init.mw.ArticleTargetLoader.js @@ -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' );