mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-24 20:42:58 +00:00
ed1501c577
Change-Id: I8237dd3aa9ad73dce59e9a9bf001d6af5de8e185
37 lines
732 B
JavaScript
37 lines
732 B
JavaScript
let isTracking = false;
|
|
|
|
/**
|
|
* @memberof module:ext.cite.referencePreviews
|
|
*/
|
|
const LOGGING_SCHEMA = 'event.ReferencePreviewsPopups';
|
|
|
|
/**
|
|
* Run once the preview is initialized.
|
|
*
|
|
* @memberof module:ext.cite.referencePreviews
|
|
*/
|
|
function initReferencePreviewsInstrumentation() {
|
|
if ( mw.config.get( 'wgCiteReferencePreviewsActive' ) &&
|
|
navigator.sendBeacon &&
|
|
mw.config.get( 'wgIsArticle' ) &&
|
|
!isTracking
|
|
) {
|
|
isTracking = true;
|
|
mw.track( LOGGING_SCHEMA, { action: 'pageview' } );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @memberof module:ext.cite.referencePreviews
|
|
* @return {boolean}
|
|
*/
|
|
function isTrackingEnabled() {
|
|
return isTracking;
|
|
}
|
|
|
|
module.exports = {
|
|
LOGGING_SCHEMA,
|
|
initReferencePreviewsInstrumentation,
|
|
isTrackingEnabled
|
|
};
|