@observertc/client-monitor-js
Version:
ObserveRTC Client Integration Javascript Library
1 lines • 974 B
JavaScript
import{ClientEventTypes as t}from"../schema/ClientEventTypes";export class StatsGapDetector{clientMonitor;name="stats-gap-detector";disabled=!1;_previousCollectionStartedAt;constructor(t){this.clientMonitor=t}get config(){return this.clientMonitor.config.statsGapDetector}update(){if(this.disabled)return;const i=this.clientMonitor.lastCollectingStatsAt;if(!i)return;const e=this._previousCollectionStartedAt;if(this._previousCollectionStartedAt=i,void 0===e)return;const o=i-e,n=this.clientMonitor.config.collectingPeriodInMs;if(!n||n<1)return;n*this.config.gapRatioThreshold<o&&this.config.minGapInMs<o&&(this.clientMonitor.emit("stats-collection-gap",{clientMonitor:this.clientMonitor,expectedPeriodInMs:n,actualPeriodInMs:o,gapInMs:o-n}),!1!==this.config.createEvent&&this.clientMonitor.addEvent({type:t.STATS_COLLECTION_GAP,payload:{expectedPeriodInMs:n,actualPeriodInMs:o,gapInMs:o-n,durationOfCollectingStatsInMs:this.clientMonitor.durationOfCollectingStatsInMs}}))}}