2024-01-12 22:30:44 +00:00
|
|
|
let isTracking = false;
|
|
|
|
|
2024-06-10 15:15:48 +00:00
|
|
|
/**
|
|
|
|
* @memberof module:ext.cite.referencePreviews
|
|
|
|
*/
|
2024-01-12 22:30:44 +00:00
|
|
|
const LOGGING_SCHEMA = 'event.ReferencePreviewsPopups';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run once the preview is initialized.
|
2024-06-10 15:15:48 +00:00
|
|
|
*
|
|
|
|
* @memberof module:ext.cite.referencePreviews
|
2024-01-12 22:30:44 +00:00
|
|
|
*/
|
|
|
|
function initReferencePreviewsInstrumentation() {
|
2024-04-30 09:51:38 +00:00
|
|
|
if ( mw.config.get( 'wgCiteReferencePreviewsActive' ) &&
|
2024-01-12 22:30:44 +00:00
|
|
|
navigator.sendBeacon &&
|
|
|
|
mw.config.get( 'wgIsArticle' ) &&
|
|
|
|
!isTracking
|
|
|
|
) {
|
|
|
|
isTracking = true;
|
|
|
|
mw.track( LOGGING_SCHEMA, { action: 'pageview' } );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-10 15:15:48 +00:00
|
|
|
/**
|
|
|
|
* @memberof module:ext.cite.referencePreviews
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
2024-01-12 22:30:44 +00:00
|
|
|
function isTrackingEnabled() {
|
|
|
|
return isTracking;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
LOGGING_SCHEMA,
|
|
|
|
initReferencePreviewsInstrumentation,
|
|
|
|
isTrackingEnabled
|
|
|
|
};
|