mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-04 11:28:19 +00:00
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
|
||
|
};
|