Faidon Liambotis has uploaded a new change for review. https://gerrit.wikimedia.org/r/130344
Change subject: Revert "Generate a token and use it to bucket users" ...................................................................... Revert "Generate a token and use it to bucket users" See I978282c1a83620b8522399fea9008d0379dce6df for the rationale. This reverts commit 42f0cb7bbdd5e27b7e2bdbfdb515b72b69553a76. Change-Id: I4cd34902b607893dc5892ec08739fec5c6105f0f --- M GettingStarted.php M Hooks.php D resources/ext.gettingstarted.user.js D tests/qunit/ext.gettingstarted.user.test.js 4 files changed, 0 insertions(+), 169 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GettingStarted refs/changes/44/130344/1 diff --git a/GettingStarted.php b/GettingStarted.php index 77cf165..220e179 100644 --- a/GettingStarted.php +++ b/GettingStarted.php @@ -245,14 +245,6 @@ 'position' => 'top', ) + $gettingStartedModuleInfo; -$wgResourceModules[ 'ext.gettingstarted.user' ] = array( - 'scripts' => 'ext.gettingstarted.user.js', - 'dependencies' => array( - 'mediawiki.user', - 'jquery.cookie', - ), -) + $gettingStartedModuleInfo; - $wgDefaultUserOptions[ GettingStarted\Hooks::INTRO_OPTION ] = true; $wgHooks[ 'BeforePageDisplay' ][] = 'GettingStarted\Hooks::onBeforePageDisplay'; @@ -267,4 +259,3 @@ $wgHooks[ 'UserLogoutComplete'][] = 'GettingStarted\Hooks::onUserLogoutComplete'; // Extension:CentralAuth's hook $wgHooks[ 'CentralAuthPostLoginRedirect' ][] = 'GettingStarted\Hooks::onCentralAuthPostLoginRedirect'; -$wgHooks[ 'ResourceLoaderTestModules' ][] = 'GettingStarted\Hooks::onResourceLoaderTestModules'; diff --git a/Hooks.php b/Hooks.php index c172b3c..b8d4375 100644 --- a/Hooks.php +++ b/Hooks.php @@ -435,13 +435,4 @@ $returnToQuery = $returnToQuery . '&gettingStartedReturn=true'; return true; } - - public static function onResourceLoaderTestModules( array &$testModules, \ResourceLoader &$resourceLoader ) { - $testModules[ 'qunit' ][ 'ext.gettingstarted.user.tests' ] = array( - 'scripts' => array( 'tests/qunit/ext.gettingstarted.user.test.js' ), - 'dependencies' => array( 'ext.gettingstarted.user' ), - 'localBasePath' => __DIR__, - 'remoteExtPath' => 'GettingStarted', - ); - } } diff --git a/resources/ext.gettingstarted.user.js b/resources/ext.gettingstarted.user.js deleted file mode 100644 index 5caa046..0000000 --- a/resources/ext.gettingstarted.user.js +++ /dev/null @@ -1,74 +0,0 @@ -( function ( mw, $ ) { - - 'use strict'; - - var user, - tokenCookieName = mw.config.get( 'wgCookiePrefix' ) + 'gettingStartedUserToken'; - - mw.gettingStarted = mw.gettingStarted || {}; - - /** - * The GettingStarted user API. - * - * This is currently used as part of the [Signup CTA experiment][0], which is - * part of the [Anonymous editor acquisition][1] research project. - * - * [0]: https://meta.wikimedia.org/wiki/Research:Anonymous_editor_acquisition/Signup_CTA_experiment - * [1]: https://meta.wikimedia.org/wiki/Research:Anonymous_editor_acquisition - * - * @class mw.gettingStarted.user - * @singleton - */ - mw.gettingStarted.user = user = { - - /** - * Gets the user's token from the "gettingStartedUserToken" - * cookie. If the cookie isn't set, then a token is generated, - * stored in the cookie for 90 days, and then returned. - * - * See `mw.user.generateRandomSessionId`. - * - * @return {string} - */ - getToken: function () { - var storedToken = $.cookie( tokenCookieName ), - generatedToken; - - if ( storedToken ) { - return storedToken; - } - - generatedToken = mw.user.generateRandomSessionId(); - - $.cookie( tokenCookieName, generatedToken, { - expires: 90, // (days) - path: '/' - } ); - - return generatedToken; - }, - - /** - * Gets the bucket that the user is in based on their token. - * - * Currently, the bucket corresponds to the variant of the - * Signup CTA experiement that the user will be shown: pre-edit, - * post-edit, or control. - * - * @return {string} - */ - getBucket: function () { - var token = user.getToken(), - lastCharacter = token.slice( -1 ); - - if ( lastCharacter <= 'J' ) { - return 'pre-edit'; - } else if ( lastCharacter > 'J' && lastCharacter <= 'd' ) { - return 'post-edit'; - } else { - return 'control'; - } - } - }; - -} ( mediaWiki, jQuery ) ); diff --git a/tests/qunit/ext.gettingstarted.user.test.js b/tests/qunit/ext.gettingstarted.user.test.js deleted file mode 100644 index 08f83d7..0000000 --- a/tests/qunit/ext.gettingstarted.user.test.js +++ /dev/null @@ -1,77 +0,0 @@ -( function ( QUnit, mw, $ ) { - - 'use strict'; - - var expectedTokenCookieName = mw.config.get( 'wgCookiePrefix' ) + 'gettingStartedUserToken'; - - QUnit.module( 'ext.gettingstarted.user.getToken', { - setup: function () { - this.stub( mw.user, 'generateRandomSessionId' ); - mw.user.generateRandomSessionId.returns( '1234' ); - - this.stub( $, 'cookie' ); - $.cookie.returns( null ); - } - } ); - - QUnit.test( 'should try to get the "token" cookie', 1, function ( assert ) { - mw.gettingStarted.user.getToken(); - - assert.strictEqual( $.cookie.lastCall.args[ 0 ], expectedTokenCookieName ); - } ); - - QUnit.test( 'should use the token from the "token" cookie when it is set', 1, function ( assert ) { - $.cookie.returns( '5678' ); - - assert.strictEqual( mw.gettingStarted.user.getToken(), '5678' ); - } ); - - QUnit.test( 'should generate the token when the "token" cookie isn\'t set', 1, function ( assert ) { - assert.strictEqual( mw.gettingStarted.user.getToken(), '1234' ); - } ); - - QUnit.test( 'should store the generated token when the cookie isn\'t set', 1, function ( assert ) { - mw.gettingStarted.user.getToken(); - - assert.deepEqual( $.cookie.lastCall.args, [ - expectedTokenCookieName, - '1234', - { - expires: 90, - path: '/' - } - ] ); - } ); - - QUnit.module( 'ext.gettingstarted.user.getBucket', { - setup: function () { - this.stub( mw.gettingStarted.user, 'getToken' ); - } - } ); - - $.each( [ - { - characters: '0123456789ABCDEFGHIJ', - expectedBucket: 'pre-edit' - }, - { - characters: 'KLMNOPQRSTUVWXYZabcd', - expectedBucket: 'post-edit' - }, - { - characters: 'efghijklmnopqrstuvwxyz', - expectedBucket: 'control' - } - ], function ( i, data ) { - QUnit.test( data.characters, data.characters.length, function ( assert ) { - var j; - - for ( j = 0; j < data.characters.length; ++j ) { - mw.gettingStarted.user.getToken.returns( data.characters[ j ] ); - - assert.strictEqual( mw.gettingStarted.user.getBucket(), data.expectedBucket); - } - } ); - } ); - -} ( QUnit, mediaWiki, jQuery ) ); -- To view, visit https://gerrit.wikimedia.org/r/130344 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4cd34902b607893dc5892ec08739fec5c6105f0f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GettingStarted Gerrit-Branch: wmf/1.24wmf2 Gerrit-Owner: Faidon Liambotis <fai...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits