2023-05-09 15:11:44 +00:00
|
|
|
let isTracking = false;
|
|
|
|
|
2024-02-02 18:29:27 +00:00
|
|
|
const LOGGING_SCHEMA = 'event.ReferencePreviewsPopups';
|
2023-05-09 15:11:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Run once the preview is initialized.
|
|
|
|
*/
|
2024-02-02 18:29:27 +00:00
|
|
|
function initReferencePreviewsInstrumentation() {
|
2023-05-09 15:11:44 +00:00
|
|
|
if ( mw.config.get( 'wgPopupsReferencePreviews' ) &&
|
|
|
|
navigator.sendBeacon &&
|
|
|
|
mw.config.get( 'wgIsArticle' ) &&
|
|
|
|
!isTracking
|
|
|
|
) {
|
|
|
|
isTracking = true;
|
|
|
|
mw.track( LOGGING_SCHEMA, { action: 'pageview' } );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-02 18:29:27 +00:00
|
|
|
function isTrackingEnabled() {
|
2023-05-09 15:11:44 +00:00
|
|
|
return isTracking;
|
|
|
|
}
|
2024-02-02 18:29:27 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
LOGGING_SCHEMA,
|
|
|
|
initReferencePreviewsInstrumentation,
|
|
|
|
isTrackingEnabled
|
|
|
|
};
|