Skip to content

Commit

Permalink
fix: calculate difference for sample
Browse files Browse the repository at this point in the history
  • Loading branch information
eswarclynn committed Mar 12, 2024
1 parent 4a9b74b commit 3670978
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export abstract class RunningTrackAnalytics {

protected samples: (LocalBaseSample | LocalVideoSample | RemoteAudioSample | RemoteVideoSample)[] = [];
protected tempStats: TempPublishStats[] = [];
protected prevLatestStat?: TempPublishStats;

constructor({
track,
Expand Down Expand Up @@ -118,6 +119,7 @@ export abstract class RunningTrackAnalytics {
}

this.samples.push(this.collateSample());
this.prevLatestStat = this.getLatestStat();
this.tempStats.length = 0;
}

Expand Down Expand Up @@ -160,7 +162,7 @@ export abstract class RunningTrackAnalytics {
}

protected calculateDifferenceForSample(key: keyof TempPublishStats) {
const firstValue = Number(this.tempStats[0][key]) || 0;
const firstValue = Number(this.prevLatestStat?.[key]) || 0;
const latestValue = Number(this.getLatestStat()[key]) || 0;

return latestValue - firstValue;
Expand Down

0 comments on commit 3670978

Please sign in to comment.