Skip to content

Fix overview unselected metrics to use data-adaptive window#174

Merged
unjica merged 1 commit into
developfrom
fix/overview-unselected-metrics-window
Jul 6, 2026
Merged

Fix overview unselected metrics to use data-adaptive window#174
unjica merged 1 commit into
developfrom
fix/overview-unselected-metrics-window

Conversation

@unjica

@unjica unjica commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes confusing ~840-day metrics window when Overview time range is left unselected.

Recommendation (options evaluated):

Option Verdict
1. Fixed preset (30d) for unselected metrics Good fallback; implemented as empty-data default
2. Data-adaptive window (last N events/errors + min/max caps) Implemented — volume-aware without arbitrary calendar length
3. Align metrics with visible list page Too narrow; rejected
4. Chart buckets over data span Partially addressed — charts now share the metrics window when unselected (120-bucket cap unchanged)

Before: Unselected range set bucket: week and effectiveIngestRateDurationMs = 120 × 7 days840 days for headline metrics, compare deltas, and ingest-rate denominators — regardless of whether the project had 100k events/day or 1/day.

After: With no time filter:

  • Lists stay all-time (latest rows, any age)
  • Metrics, charts, compare use a data-adaptive window: time span covered by the most recent 10k events + 10k error occurrences, clamped to 7–90 days, 30-day fallback when empty
  • API returns metricsSince, metricsUntil, metricsDurationMs; dashboard uses the server-computed duration for ingest-rate display

Changes

  • New overview-metrics-window.ts with resolveUnselectedMetricsWindow() and unit tests
  • Overview API route uses adaptive window + aligned chart/session bucket when unselected
  • Compare logic unchanged structurally — still uses resolveCompareWindow(metricsWindow.durationMs, …) but with the resolved adaptive duration
  • Dashboard docs updated (/docs/dashboard)

Test plan

  • pnpm lint && pnpm test && pnpm build
  • Bugbot review (no findings)
  • Manual: Overview with no time filter on high-volume project — metrics/chart span ≈ recent activity, not 840d
  • Manual: Overview with no time filter on sparse project — window at least 7d, at most 90d
  • Manual: Select explicit 7d/30d preset — behavior unchanged
  • Manual: Error/event lists with no filter still show all-time paginated rows

Made with Cursor

When no time filter is set, headline metrics and charts now infer span from recent telemetry (last 10k events/errors, clamped 7–90 days) instead of a fixed ~840-day calendar window. Lists remain all-time.

Co-authored-by: Cursor <cursoragent@cursor.com>
@unjica unjica force-pushed the fix/overview-unselected-metrics-window branch from cf8ae36 to 433ec5e Compare July 6, 2026 18:02
@unjica unjica merged commit 057ba36 into develop Jul 6, 2026
3 checks passed
@unjica unjica deleted the fix/overview-unselected-metrics-window branch July 6, 2026 18:04
@unjica unjica added this to the v1.4.x — Platform releases milestone Jul 6, 2026
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.

1 participant