Skip to content

fix(dashboards): Improve handling of null trailing buckets in Session charts#115542

Draft
gggritso wants to merge 2 commits into
masterfrom
georgegritsouk/dain-1014-crash-free-sessions-chart-incorrectly-treats-null-values
Draft

fix(dashboards): Improve handling of null trailing buckets in Session charts#115542
gggritso wants to merge 2 commits into
masterfrom
georgegritsouk/dain-1014-crash-free-sessions-chart-incorrectly-treats-null-values

Conversation

@gggritso
Copy link
Copy Markdown
Member

@gggritso gggritso commented May 14, 2026

Crash Free Rate charts (like on Project Details pages) have a funny problem. The Y-axis is scaled from data min to 100%, but the crash free rate tends to hover around 100%. Sometimes, when the most recent data point is null, that gets turned into a 0 which scales the Y-axis from 0 to 100%, which makes it useless because it washes out the differences.

Instead, we can rely on ECharts' default behaviour of omitting null values. This is a bit of a bandaid, but it's very effective. I updated the types and the transformation to take care of this. In the future when we're passing around TimeSeries data, this'll be less wacky.

Before:
Screenshot 2026-05-13 at 9 51 58 PM

After:
Screenshot 2026-05-13 at 9 52 07 PM

Closes DAIN-1014

The Sessions API returns null for time buckets with no data (e.g.,
first bucket in a 90d range out of retention, or last bucket in a 2h
range not yet populated). These nulls were converted to 0 at multiple
points, causing crash free rate charts to show misleading 0% data
points instead of gaps.

Fix the SeriesApi type to reflect that series data can contain nulls,
then preserve those nulls through the dashboard widget pipeline so
TimeSeriesWidgetVisualization renders gaps. For the Project Details
page, guard null before arithmetic so the existing tooltip null
handling shows a dash.

Refs DAIN-1014
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 14, 2026

DAIN-1014

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 14, 2026
@gggritso gggritso changed the title fix(dashboards): Preserve null values in Crash Free Sessions charts fix(dashboards): Improve handling of null trailing buckets in Session charts May 14, 2026
@gggritso
Copy link
Copy Markdown
Member Author

@cursor review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

📊 Type Coverage Diff

Metric Before After Delta
Coverage 93.51% 93.51% ±0%
Typed 135,556 135,557 🟢 +1
Untyped 9,406 9,404 🟢 -2
🔍 2 new type safety issues introduced

Type assertions (as) (2 new)

File Line Detail
static/app/views/dashboards/utils/transformSessionsResponseToSeries.tsx 104 as Series[]results as unknown as Series[]
static/app/views/dashboards/utils/transformSessionsResponseToSeries.tsx 104 as unknownresults as unknown

This is informational only and does not block the PR.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f300642. Configure here.

value: countsForTimestamp.reduce((acc, {count}) => acc + count, 0),
value: countsForTimestamp.some(({count}) => count === null)
? null
: countsForTimestamp.reduce((acc, {count}) => acc + count, 0),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Null check is ineffective due to mismatched type

Low Severity

The count === null check compares against a value typed as number in EventsStatsData, so from TypeScript's perspective this condition is always false and the null branch is never taken. Unlike SeriesApi.series which was updated to Array<number | null>, the EventsStatsData type still defines count: number. If the API can genuinely return null counts, the EventsStatsData type needs a matching update to count: number | null for the null check to be meaningful to TypeScript and to ensure null-safety is enforced across all consumers of this type.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f300642. Configure here.

Release/session widget data does not flow through
convertEventsStatsToTimeSeriesData, so the null count check was
unreachable and triggered a TypeScript lint complaint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant