fix(dashboards): Improve handling of null trailing buckets in Session charts#115542
Conversation
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>
null trailing buckets in Session charts
|
@cursor review |
📊 Type Coverage Diff
🔍 2 new type safety issues introducedType assertions (
This is informational only and does not block the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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), |
There was a problem hiding this comment.
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)
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>


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 a0which 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
nullvalues. 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 aroundTimeSeriesdata, this'll be less wacky.Before:

After:

Closes DAIN-1014