fix(events): guard events per user/session against division by zero (Infinity/InfinityB)#7810
Open
mrmeghana wants to merge 1 commit into
Open
fix(events): guard events per user/session against division by zero (Infinity/InfinityB)#7810mrmeghana wants to merge 1 commit into
mrmeghana wants to merge 1 commit into
Conversation
Events Overview showed "Infinity" / "InfinityB" when a period had events but zero users or sessions. The existing guard only returned 0 when BOTH the numerator and denominator were 0, so events > 0 with users/sessions = 0 produced Infinity (events / 0). - Guard the denominator instead of requiring both operands to be zero, in getEventOverview (events per user, events per session, and their prev values). - Harden countlyCommon.getShortNumber to return non-finite values as-is instead of appending a magnitude suffix (which turned Infinity into "InfinityB"), as defense-in-depth for all other callers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes non-finite (“Infinity” / “InfinityB”) values shown on Events → Overview when the selected period has events but zero users/sessions, by guarding divisions at the model layer and preventing short-number formatting from appending suffixes to non-finite values.
Changes:
- Guard events-per-user/session calculations against zero (or missing) denominators in
getEventOverview. - Add a non-finite input guard to
countlyCommon.getShortNumberto avoid producing suffixed strings likeInfinityB.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| frontend/express/public/javascripts/countly/countly.common.js | Adds a non-finite guard in getShortNumber so formatting never produces InfinityB. |
| frontend/express/public/core/events/javascripts/countly.overview.models.js | Fixes division guards for per-user/per-session metrics (current and previous period) to prevent Infinity. |
kanwarujjaval
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the Events → Overview tab, when a selected period has events but zero users and zero sessions, the cards render:
InfinityInfinityBReproduced live on
release-2503(app data:totalCount: 120,totalUsersCount: 0,totalSessionCount: 0).Root cause
Two stacked issues:
Wrong division guard in
getEventOverview(countly.overview.models.js). The guard returned0only when both numerator and denominator were0:So
events > 0withusers/sessions = 0computedevents / 0→Infinity.countlyCommon.getShortNumberdoesn't handle non-finite input.Infinity >= 1e9istrue, so(Infinity/1e9).toFixed(1)→"Infinity", then+ "B"→"InfinityB". (The per-user card renders the raw value via anumberslot, hence plainInfinity; the per-session card goes throughgetShortNumber, henceInfinityB.)Fix
!ob.totalUsersCount/!ob.totalSessionCount) for the events-per-user, events-per-session, and theirprev*values.isFiniteguard togetShortNumberso no caller can ever produceInfinityB/NaNKagain.Verification
12345→"12.3K", etc.) — no regression.0instead ofInfinity; verified visually on the dashboard (cards show0/0).