Skip to content

Refactor statsEmitter to normalize stats without mutation.#17166

Open
Aashuti-Tech-Trek wants to merge 1 commit intojitsi:masterfrom
Aashuti-Tech-Trek:bug/refactor-stats-emitter
Open

Refactor statsEmitter to normalize stats without mutation.#17166
Aashuti-Tech-Trek wants to merge 1 commit intojitsi:masterfrom
Aashuti-Tech-Trek:bug/refactor-stats-emitter

Conversation

@Aashuti-Tech-Trek
Copy link

@Aashuti-Tech-Trek Aashuti-Tech-Trek commented Mar 20, 2026

This PR refactors the handling of connection stats in statsEmitter.ts to improve type safety and reduce technical debt, successfully resolving a longstanding FIXME.

Currently, stats received from lib-jitsi-meet (such as framerate, resolution, and codec) are provided as maps keyed by user IDs. However, frontend consumers expect these values as primitives for individual users. The existing implementation handled this mismatch by overriding the stats object inline alongside a FIXME note, while maintaining a generic and inaccurate IStats TypeScript interface.

Changes made

  • Introduced strict IRawStats and IFormattedStats TypeScript interfaces to accurately reflect the incoming library data vs. the outgoing frontend data.
  • Refactored _onStatsUpdated to explicitly normalize stats into per-user formatted objects using an Adapter Pattern.
  • Avoided implicit mutation of the original stats object.
  • Ensured consistent handling for both local and remote user stats.
  • Removed the obsolete FIXME comment.

Why this change

  • Improves readability and typescript maintainability.
  • Removes hidden data transformation logic.
  • Makes the data flow more predictable.
  • Reduces technical debt in stats handling.

Impact

  • No visible UI changes (Visual regressions verified automatically and locally).
  • Internal refactor only.
  • Safer and cleaner stats processing.

Related Issue
Fixes #17165

@jitsi-jenkins
Copy link

Hi, thanks for your contribution!
If you haven't already done so, could you please make sure you sign our CLA (https://jitsi.org/icla for individuals and https://jitsi.org/ccla for corporations)? We would unfortunately be unable to merge your patch unless we have that piece :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up statsEmitter resolution and framerate map transformation (Technical Debt)

2 participants