mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-04 19:38:16 +00:00
f0849b2b17
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
28 lines
545 B
JavaScript
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
|
|
};
|