mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-28 10:00:18 +00:00
Merge "Add sampling to unsampled event logging"
This commit is contained in:
commit
d19fcf60d2
|
@ -25,6 +25,17 @@ if ( !isset( $wgNetworkPerformanceSamplingFactor ) ) {
|
|||
$wgNetworkPerformanceSamplingFactor = false;
|
||||
}
|
||||
|
||||
if ( !isset( $wgMediaViewerSamplingFactor ) ) {
|
||||
/**
|
||||
* If set, records user activity and loading times. A value of 1000 means there will be an
|
||||
* 1:1000 chance to enable logging on page load; for that page, either all or none of the
|
||||
* events will be logged.
|
||||
* False if unset.
|
||||
* @var int|bool
|
||||
*/
|
||||
$wgMediaViewerSamplingFactor = false;
|
||||
}
|
||||
|
||||
if ( !isset( $wgMediaViewerIsInBeta ) ) {
|
||||
/** @var bool: If set, Media Viewer will try to use BetaFeatures. False if unset. **/
|
||||
$wgMediaViewerIsInBeta = false;
|
||||
|
|
|
@ -144,8 +144,8 @@ class MultimediaViewerHooks {
|
|||
* @return bool
|
||||
*/
|
||||
public static function resourceLoaderGetConfigVars( &$vars ) {
|
||||
global $wgAPIPropModules, $wgNetworkPerformanceSamplingFactor, $wgMediaViewerIsInBeta,
|
||||
$wgMediaViewerUseThumbnailGuessing, $wgMediaViewerShowSurvey;
|
||||
global $wgAPIPropModules, $wgNetworkPerformanceSamplingFactor, $wgMediaViewerSamplingFactor,
|
||||
$wgMediaViewerIsInBeta, $wgMediaViewerUseThumbnailGuessing, $wgMediaViewerShowSurvey;
|
||||
$vars['wgMultimediaViewer'] = array(
|
||||
'infoLink' => self::$infoLink,
|
||||
'discussionLink' => self::$discussionLink,
|
||||
|
@ -153,6 +153,7 @@ class MultimediaViewerHooks {
|
|||
'globalUsageAvailable' => isset( $wgAPIPropModules['globalusage'] ),
|
||||
'useThumbnailGuessing' => (bool)$wgMediaViewerUseThumbnailGuessing,
|
||||
'showSurvey' => (bool)$wgMediaViewerShowSurvey,
|
||||
'samplingFactor' => $wgMediaViewerSamplingFactor,
|
||||
);
|
||||
$vars['wgNetworkPerformanceSamplingFactor'] = $wgNetworkPerformanceSamplingFactor;
|
||||
$vars['wgMediaViewer'] = true;
|
||||
|
|
|
@ -98,7 +98,10 @@
|
|||
e.country = self.Geo.country;
|
||||
}
|
||||
|
||||
self.eventLog.logEvent( self.schema, e );
|
||||
if ( self.isInSample() ) {
|
||||
self.eventLog.logEvent( self.schema, e );
|
||||
}
|
||||
|
||||
mw.log( message );
|
||||
} );
|
||||
}
|
||||
|
@ -138,5 +141,14 @@
|
|||
return waitForEventLog;
|
||||
};
|
||||
|
||||
L.isInSample = function () {
|
||||
var factor = mw.config.get( 'wgMultimediaViewer' ).samplingFactor;
|
||||
|
||||
if ( !$.isNumeric( factor ) || factor < 1 ) {
|
||||
return false;
|
||||
}
|
||||
return Math.floor( Math.random() * factor ) === 0;
|
||||
};
|
||||
|
||||
mw.mmv.durationLogger = new DurationLogger();
|
||||
}( mediaWiki, jQuery ) );
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
mw.log( translatedAction );
|
||||
|
||||
if ( mw.eventLog && !skipEventLog ) {
|
||||
if ( mw.eventLog && !skipEventLog && this.isInSample() ) {
|
||||
return mw.eventLog.logEvent( 'MediaViewer', {
|
||||
version: '1.1',
|
||||
action: action
|
||||
|
@ -85,5 +85,14 @@
|
|||
return $.Deferred().resolve();
|
||||
};
|
||||
|
||||
L.isInSample = function () {
|
||||
var factor = mw.config.get( 'wgMultimediaViewer' ).samplingFactor;
|
||||
|
||||
if ( !$.isNumeric( factor ) || factor < 1 ) {
|
||||
return false;
|
||||
}
|
||||
return Math.floor( Math.random() * factor ) === 0;
|
||||
};
|
||||
|
||||
mw.mmv.logger = new Logger();
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
QUnit.module( 'mmv.DurationLogger', QUnit.newMwEnvironment({
|
||||
setup: function () {
|
||||
this.clock = this.sandbox.useFakeTimers();
|
||||
mw.config.get( 'wgMultimediaViewer' ).samplingFactor = 1;
|
||||
}
|
||||
} ) );
|
||||
|
||||
|
|
Loading…
Reference in a new issue