mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 23:24:39 +00:00
7172aae082
As a precursor to moving this code to the Cite extension move it off of webpack and switch to using require rather than import Bug: T355194 Change-Id: Ib6486ad38b79a3b67a9744b716b1a2f5d3779795
28 lines
547 B
JavaScript
28 lines
547 B
JavaScript
let isTracking = false;
|
|
|
|
const LOGGING_SCHEMA = 'event.ReferencePreviewsPopups';
|
|
|
|
/**
|
|
* Run once the preview is initialized.
|
|
*/
|
|
function initReferencePreviewsInstrumentation() {
|
|
if ( mw.config.get( 'wgPopupsReferencePreviews' ) &&
|
|
navigator.sendBeacon &&
|
|
mw.config.get( 'wgIsArticle' ) &&
|
|
!isTracking
|
|
) {
|
|
isTracking = true;
|
|
mw.track( LOGGING_SCHEMA, { action: 'pageview' } );
|
|
}
|
|
}
|
|
|
|
function isTrackingEnabled() {
|
|
return isTracking;
|
|
}
|
|
|
|
module.exports = {
|
|
LOGGING_SCHEMA,
|
|
initReferencePreviewsInstrumentation,
|
|
isTrackingEnabled
|
|
};
|