mediawiki-extensions-Cite/modules/ext.cite.referencePreviews/referencePreviewsInstrumentation.js
Adam Wight f0849b2b17 Internal config variables renamed from Popups to Cite
This updates the easy variables which are set and get within a single
module, these changes should have no effect and don't need to be
coordinated across extensions.

Bug: T362332
Change-Id: Ibbe69c321e9e2b744ec88cebbdc3476d776f5956
2024-04-22 14:31:55 +02:00

28 lines
545 B
JavaScript

let isTracking = false;
const LOGGING_SCHEMA = 'event.ReferencePreviewsPopups';
/**
* Run once the preview is initialized.
*/
function initReferencePreviewsInstrumentation() {
if ( mw.config.get( 'wgCiteReferencePreviews' ) &&
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
};