SportsFlow uses one shared analytics package to sync stats across web, mobile, and offline
Developer building SportsFlow, a sports analytics platform, encountered a reliability problem where the same player's stats showed different numbers across the web app, native app, and live tracking view. To fix this, they created a single shared package called @sportsflow/analytics that contains pure functions with no database or DOM dependencies, making it portable across all three environments. The package accepts raw match events through an adapter, resolves necessary metadata inline, and outputs stats like KPIs and heatmaps without ever querying the database. During live games, the same functions run against an in-memory event queue, meaning real-time stats are computed identically to post-game season stats once data syncs. A single helper function also handles division-by-zero edge cases uniformly, ensuring no inconsistent or undefined values appear across any surface.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in