mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-14 10:34:53 +00:00
c12150082c
Collect EventLogging metrics for footnote and reference link interactions, so that we can compare behavior with and without Reference Previews enabled. This tracking will be reverted once analysis is complete. A mostly arbitrary sample rate of 1/1000 is hardcoded here. This is loosely based on the latest tuning of Popups sampling at 1/100, divided by a conservative factor of 10 to ensure headroom. The sample is skewed by skipping clients without sendBeacon support, but we're avoiding the mw.track synchronous fallback, which injects an image tag and introduces lag any time the user clicks external links in the references. Bug: T231529 Change-Id: Iad32b64114f88675eecbb01712418c968e3cf661
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
/**
|
|
* @file Temporary tracking to establish a baseline for ReferencePreviews metrics.
|
|
* @see https://phabricator.wikimedia.org/T231529
|
|
* @see https://meta.wikimedia.org/wiki/Schema:ReferencePreviewsBaseline
|
|
*/
|
|
( 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 );
|
|
}
|
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
$( '#mw-content-text' ).on(
|
|
'click',
|
|
// Footnote links, references block in VisualEditor, and reference content links.
|
|
'.reference a[ href*="#" ], .mw-reference-text a, .reference-text a',
|
|
function () {
|
|
var isInReferenceBlock = $( this ).parents( '.references' ).length > 0;
|
|
logEvent( {
|
|
action: ( isInReferenceBlock ?
|
|
'clickedReferenceContentLink' :
|
|
'clickedFootnote' )
|
|
} );
|
|
}
|
|
);
|
|
|
|
logEvent( { action: 'pageview' } );
|
|
} );
|
|
}
|
|
}() );
|