import { Track } from '../report'; export class AdsActionDetection { adBreakIsShowing = false; private reportPageJumpOut = () => { this.track('AdBreakJumpOut', { context: 'AdsActionDetection' }); }; private reportPageHide = () => { this.track('AdBreakHide', { context: 'AdsActionDetection' }); }; constructor(readonly track: Track) { window.addEventListener('visibilitychange', () => { if (document.hidden && this.adBreakIsShowing) { this.reportPageHide(); } }); window.addEventListener('beforeunload', (e) => { if (this.adBreakIsShowing) { this.reportPageJumpOut(); } }); } }