mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-13 17:56:55 +00:00
e4e9bb3bd6
Introduce PopupsAnonsExperimentalGroupSize config variable. This defines a population size who will be subject to experimentation. If the group size is undefined or 0 (default) and PopupsBetaFeature is false (default value) Popups will be enabled for everyone. If it is any other value, half that group will see page previews. Drop the config variable PopupsSchemaSamplingRate - we will now only EventLog when an experiment is occuring. This means we can simplify the MWEventLogger class as shouldLog will always be truthy. Given server side eventlogging is only used for preference changes traffic should be low and not need sampling. Introduce getUserBucket which determines whether a user is in a bucket on, off or control based on the value of PopupsAnonsExperimentalGroupSize. Add tests showing how these buckets are calculated. Caution: A kill switch wgPopupsEventLogging is provided for safety. It defaults to false. Before merging, please check if any config changes are necessary. Bug: T171853 Change-Id: If2a0c5fceae78262c44cb522af38a925cc5919d3
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
/*
|
|
* This file is part of the MediaWiki extension Popups.
|
|
*
|
|
* Popups is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Popups is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Popups. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* @file
|
|
* @ingroup extensions
|
|
*/
|
|
namespace Popups\EventLogging;
|
|
|
|
use Config;
|
|
use ExtensionRegistry;
|
|
|
|
class MWEventLogger implements EventLogger {
|
|
|
|
/**
|
|
* @var Config
|
|
*/
|
|
private $config;
|
|
|
|
/**
|
|
* @var ExtensionRegistry
|
|
*/
|
|
private $registry;
|
|
|
|
/**
|
|
* Module constructor.
|
|
* @param Config $config MediaWiki configuration
|
|
* @param ExtensionRegistry $registry MediaWiki extension registry
|
|
*/
|
|
public function __construct( Config $config, ExtensionRegistry $registry ) {
|
|
$this->config = $config;
|
|
$this->registry = $registry;
|
|
}
|
|
|
|
/**
|
|
* Log event
|
|
*
|
|
* @param array $event An associative array containing event data
|
|
*/
|
|
public function log( array $event ) {
|
|
$eventLoggingSchemas = $this->registry->getAttribute( 'EventLoggingSchemas' );
|
|
|
|
\EventLogging::logEvent(
|
|
self::PREVIEWS_SCHEMA_NAME,
|
|
$eventLoggingSchemas[ self::PREVIEWS_SCHEMA_NAME ],
|
|
$event
|
|
);
|
|
}
|
|
}
|