mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-18 02:00:53 +00:00
22 lines
470 B
JavaScript
22 lines
470 B
JavaScript
|
let isTracking = false;
|
||
|
|
||
|
export const LOGGING_SCHEMA = 'event.ReferencePreviewsPopups';
|
||
|
|
||
|
/**
|
||
|
* Run once the preview is initialized.
|
||
|
*/
|
||
|
export function initReferencePreviewsInstrumentation() {
|
||
|
if ( mw.config.get( 'wgPopupsReferencePreviews' ) &&
|
||
|
navigator.sendBeacon &&
|
||
|
mw.config.get( 'wgIsArticle' ) &&
|
||
|
!isTracking
|
||
|
) {
|
||
|
isTracking = true;
|
||
|
mw.track( LOGGING_SCHEMA, { action: 'pageview' } );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export function isTrackingEnabled() {
|
||
|
return isTracking;
|
||
|
}
|