| 1 |
let isTracking = false; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
const LOGGING_SCHEMA = 'event.ReferencePreviewsPopups'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
function initReferencePreviewsInstrumentation() { |
| 14 |
if ( mw.config.get( 'wgCiteReferencePreviewsActive' ) && |
| 15 |
navigator.sendBeacon && |
| 16 |
mw.config.get( 'wgIsArticle' ) && |
| 17 |
!isTracking |
| 18 |
) { |
| 19 |
isTracking = true; |
| 20 |
mw.track( LOGGING_SCHEMA, { action: 'pageview' } ); |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
function isTrackingEnabled() { |
| 29 |
return isTracking; |
| 30 |
} |
| 31 |
|
| 32 |
module.exports = { |
| 33 |
LOGGING_SCHEMA, |
| 34 |
initReferencePreviewsInstrumentation, |
| 35 |
isTrackingEnabled |
| 36 |
}; |