mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Merge "Stop sampling when Reference Previews is enabled"
This commit is contained in:
commit
96b4903da4
|
@ -77,7 +77,8 @@
|
|||
},
|
||||
"EventLogging": {
|
||||
"Schemas": {
|
||||
"ReferencePreviewsBaseline": 19414499
|
||||
"ReferencePreviewsBaseline": 19489336,
|
||||
"ReferencePreviewsCite": 19489328
|
||||
}
|
||||
},
|
||||
"VisualEditor": {
|
||||
|
|
|
@ -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' } );
|
||||
}
|
||||
} );
|
||||
}() );
|
||||
|
|
Loading…
Reference in a new issue