Remove EventLogging/A-B test code from RelatedArticles

With RelatedArticlesEnabledBucketSize now removed, installation of this
extension will turn it on for 100% users without any mechanism to turn
it off.

Additional changes:
* Bump version
* Add Readers team to contributors

Bug: T202306
Change-Id: I7dc270a06dd3afd4e894c8298165d6d6d4fda8d6
This commit is contained in:
jdlrobson 2018-09-13 11:40:42 -07:00
parent 6856ef8b5e
commit 6b49ddff1b
6 changed files with 5 additions and 200 deletions

View file

@ -1,7 +1,8 @@
{
"name": "RelatedArticles",
"version": "3.0.0",
"version": "3.1.0",
"author": [
"[https://www.mediawiki.org/wiki/Reading/Web/Team Readers Web Team]",
"Roland Unger",
"Hans Musil",
"Matthias Mullie",
@ -40,9 +41,6 @@
],
"ResourceLoaderGetConfigVars": [
"RelatedArticles\\Hooks::onResourceLoaderGetConfigVars"
],
"ResourceLoaderRegisterModules": [
"RelatedArticles\\Hooks::onResourceLoaderRegisterModules"
]
},
"MessagesDirs": {
@ -118,7 +116,6 @@
"mediawiki.Uri",
"mediawiki.viewport",
"ext.relatedArticles.readMore.gateway",
"ext.relatedArticles.readMore.eventLogging",
"jquery.throttle-debounce"
],
"targets": [
@ -128,8 +125,7 @@
},
"ext.relatedArticles.readMore": {
"dependencies": [
"mediawiki.util",
"ext.relatedArticles.readMore.eventLogging"
"mediawiki.util"
],
"scripts": [
"resources/ext.relatedArticles.readMore/index.js"
@ -154,16 +150,11 @@
]
}
},
"EventLoggingSchemas": {
"RelatedArticles": 16352530
},
"config": {
"@RelatedArticlesCardLimit": "Maximum number of articles that should be shown in RelatedArticles widget. This limit is derived from limits in TextExtracts and PageImages extensions. Number should be between 1 and 20.",
"RelatedArticlesCardLimit": 3,
"RelatedArticlesUseCirrusSearch": false,
"RelatedArticlesOnlyUseCirrusSearch": false,
"RelatedArticlesLoggingBucketSize": 0.01,
"RelatedArticlesEnabledBucketSize": 1,
"@RelatedArticlesFooterWhitelistedSkins": "List of skin names (e.g. 'minerva') where related articles will be shown in the footer.",
"RelatedArticlesFooterWhitelistedSkins": [ "minerva" ]
},

View file

@ -6,7 +6,6 @@ use Parser;
use OutputPage;
use ParserOutput;
use MediaWiki\MediaWikiServices;
use ResourceLoader;
use Skin;
use User;
use DisambiguatorHooks;
@ -133,10 +132,6 @@ class Hooks {
public static function onResourceLoaderGetConfigVars( &$vars ) {
$config = MediaWikiServices::getInstance()->getConfigFactory()
->makeConfig( 'RelatedArticles' );
$vars['wgRelatedArticlesLoggingBucketSize'] =
$config->get( 'RelatedArticlesLoggingBucketSize' );
$vars['wgRelatedArticlesEnabledBucketSize']
= $config->get( 'RelatedArticlesEnabledBucketSize' );
$limit = $config->get( 'RelatedArticlesCardLimit' );
$vars['wgRelatedArticlesCardLimit'] = $limit;
@ -148,44 +143,6 @@ class Hooks {
return true;
}
/**
* Register the "ext.relatedArticles.readMore.eventLogging" module.
* Optionally update the dependencies and scripts if EventLogging is installed.
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderRegisterModules
*
* @param ResourceLoader &$resourceLoader The ResourceLoader object
* @return bool
*/
public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
$dependencies = [];
$scripts = [];
if ( class_exists( 'EventLogging' ) ) {
$dependencies[] = "mediawiki.user";
$dependencies[] = "mediawiki.viewport";
$dependencies[] = "ext.eventLogging.subscriber";
$dependencies[] = "mediawiki.experiments";
$scripts[] = "resources/ext.relatedArticles.readMore.eventLogging/index.js";
}
$resourceLoader->register(
"ext.relatedArticles.readMore.eventLogging",
[
"dependencies" => $dependencies,
"scripts" => $scripts,
"targets" => [
"desktop",
"mobile"
],
"localBasePath" => __DIR__ . "/..",
"remoteExtPath" => "RelatedArticles"
]
);
return true;
}
/**
* Handler for the <code>ParserFirstCallInit</code> hook.
*

View file

@ -12,33 +12,7 @@
debouncedLoad = $.debounce( 100, function () {
loadRelatedArticles(); // eslint-disable-line no-use-before-define
} ),
$window = $( window ),
shouldShowReadMore;
/**
* Gets whether the feature is enabled for the user.
*
* The user's session ID is used to determine the eligibility for
* RelatedArticles functionality, based on the value of
* `$wgRelatedArticlesEnabledBucketSize`. The result of the function will be
* the same for the duration of their session.
*
* @return {boolean}
*/
function isEnabledForCurrentUser() {
var bucket,
bucketSize = mw.config.get( 'wgRelatedArticlesEnabledBucketSize', 1 );
bucket = mw.experiments.getBucket( {
name: 'ext.relatedArticles.visibility',
enabled: true,
buckets: {
control: 1 - bucketSize,
A: bucketSize
}
}, mw.user.sessionId() );
return bucket === 'A';
}
$window = $( window );
/**
* Load related articles when the user scrolls past half of the window height.
@ -71,8 +45,6 @@
}
}
shouldShowReadMore = isEnabledForCurrentUser();
function showReadMore() {
// Add container to DOM for checking distance on scroll
// If a skin has marked up a footer content area prepend it there
@ -89,8 +61,5 @@
loadRelatedArticles();
}
if ( shouldShowReadMore ) {
$( showReadMore );
}
mw.track( 'ext.relatedArticles.logEnabled', { isEnabled: shouldShowReadMore } );
$( showReadMore );
}() );

View file

@ -1,107 +0,0 @@
// See https://meta.wikimedia.org/wiki/Schema:RelatedArticles
( function () {
var $readMore,
schemaRelatedPages,
skin = mw.config.get( 'skin' ),
$window = $( window );
/**
* Gets whether the UA supports [the Beacon API][0].
*
* [0]: https://www.w3.org/TR/beacon/
*
* @return {boolean}
*/
function supportsBeacon() {
return typeof window.navigator.sendBeacon === 'function';
}
/**
* Gets whether the instrumentation is enabled for the user.
*
* We sample at the feature level, not by pageview. If the instrumentation is
* enabled for the user, then it's enabled for the duration of their session.
*
* @return {boolean}
*/
function isEnabledForCurrentUser() {
var bucketSize = mw.config.get( 'wgRelatedArticlesLoggingBucketSize', 0 );
if ( !supportsBeacon() ) {
return false;
}
return mw.experiments.getBucket( {
name: 'ext.relatedArticles.instrumentation',
enabled: true,
buckets: {
control: 1 - bucketSize,
A: bucketSize
}
}, mw.user.sessionId() ) === 'A';
}
if ( !isEnabledForCurrentUser() ) {
return;
}
// ---
// BEGIN INSTRUMENTATION
// ---
schemaRelatedPages = new mw.eventLog.Schema(
'RelatedArticles',
// The instrumentation is enabled for the user's session. DON'T SAMPLE AT
// THE EVENT LEVEL.
1,
{
pageId: mw.config.get( 'wgArticleId' ),
skin: ( skin === 'minerva' ) ? skin + '-' + mw.config.get( 'wgMFMode' ) : skin,
userSessionToken: mw.user.sessionId()
}
);
/**
* Log when ReadMore is seen by the user
*/
function logReadMoreSeen() {
if ( mw.viewport.isElementInViewport( $readMore.get( 0 ) ) ) {
$window.off( 'scroll', logReadMoreSeen );
schemaRelatedPages.log( { eventName: 'seen' } );
}
}
mw.trackSubscribe( 'ext.relatedArticles.logEnabled', function ( _, data ) {
schemaRelatedPages.log( {
eventName: data.isEnabled ? 'feature-enabled' : 'feature-disabled'
} );
} );
mw.trackSubscribe( 'ext.relatedArticles.logReady', function ( _, data ) {
$readMore = data.$readMore;
// log ready
schemaRelatedPages.log( { eventName: 'ready' } );
// log when ReadMore is seen by the user
$window.on(
'scroll',
$.debounce( 250, logReadMoreSeen )
);
logReadMoreSeen();
// track the clicked event
// TODO: This should be moved into the PageList component or, preferably, the CardList/Card views.
$readMore.on( 'click', 'a', function () {
var index = $( this ).parents( 'li' ).index();
schemaRelatedPages.log( {
eventName: 'clicked',
clickIndex: index + 1
} );
} );
} );
}() );

View file

@ -42,9 +42,6 @@
.append( cards.$el );
$( '.read-more-container' ).append( $readMore );
// the ReadMore code is ready
mw.track( 'ext.relatedArticles.logReady', { $readMore: $readMore } );
} );
} );

View file

@ -1,6 +1,4 @@
<?php
$wgRelatedArticlesLoggingBucketSize = 1;
$wgRelatedArticlesLoggingSamplingRate = 1;
$wgRelatedArticlesUseCirrusSearch = true;
$wgRelatedArticlesOnlyUseCirrusSearch = false;