Merge "Stop sampling when Reference Previews is enabled"

This commit is contained in:
jenkins-bot 2019-10-25 11:06:30 +00:00 committed by Gerrit Code Review
commit 96b4903da4
2 changed files with 24 additions and 17 deletions

View file

@ -77,7 +77,8 @@
},
"EventLogging": {
"Schemas": {
"ReferencePreviewsBaseline": 19414499
"ReferencePreviewsBaseline": 19489336,
"ReferencePreviewsCite": 19489328
}
},
"VisualEditor": {

View file

@ -1,23 +1,29 @@
/**
* @file Temporary tracking to establish a baseline for ReferencePreviews metrics.
* @file Temporary tracking to evaluate the impact of Reference Previews on users' interaction with references.
*
* The baseline metrics are for a sample of users who don't have ReferencePreviews enabled.
*
* Users with the feature enabled are not sampled, and events are logged using the ReferencePreviewsCite schema.
*
* @see https://phabricator.wikimedia.org/T214493
* @see https://phabricator.wikimedia.org/T231529
* @see https://meta.wikimedia.org/wiki/Schema:ReferencePreviewsBaseline
* @see https://meta.wikimedia.org/wiki/Schema:ReferencePreviewsCite
*/
( function () {
'use strict';
if ( navigator.sendBeacon && mw.eventLog.eventInSample( 1000 ) ) {
$( function () {
var isReferencePreviewsEnabled = mw.config.get( 'wgPopupsReferencePreviews', false );
/**
* @param {Object} event
*/
function logEvent( event ) {
event.referencePreviewsEnabled = isReferencePreviewsEnabled;
mw.track( 'event.ReferencePreviewsBaseline', event );
}
$( function () {
var isReferencePreviewsEnabled = mw.config.get( 'wgPopupsReferencePreviews', false ),
loggingTopic = isReferencePreviewsEnabled ?
'event.ReferencePreviewsCite' :
'event.ReferencePreviewsBaseline',
samplingRate = isReferencePreviewsEnabled ?
1 :
1000,
isSampling = navigator.sendBeacon && mw.eventLog.eventInSample( samplingRate );
if ( isSampling ) {
// eslint-disable-next-line no-jquery/no-global-selector
$( '#mw-content-text' ).on(
'click',
@ -25,7 +31,7 @@
'.reference a[ href*="#" ], .mw-reference-text a, .reference-text a',
function () {
var isInReferenceBlock = $( this ).parents( '.references' ).length > 0;
logEvent( {
mw.track( loggingTopic, {
action: ( isInReferenceBlock ?
'clickedReferenceContentLink' :
'clickedFootnote' )
@ -33,7 +39,7 @@
}
);
logEvent( { action: 'pageview' } );
} );
}
mw.track( loggingTopic, { action: 'pageview' } );
}
} );
}() );