Skip to content

feat(analytics): add planning cockpit - #309

Merged
imshashank merged 45 commits into
mainfrom
codex/analytics-planning-insights
Aug 14, 2026
Merged

imshashank merged 45 commits into
mainfrom
codex/analytics-planning-insights

Conversation

@imshashank

@imshashank imshashank commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Replaces the basic Analytics page with a zero-configuration planning cockpit modeled on Linear: Overview, Sprints, Projects, and People lenses; shared date/project/person filters; issue and points measures; previous-period comparison; exact hover and keyboard chart evidence; accessible drilldowns; saved defaults; semantic CSV export; and realtime refresh.

It also adds durable sprint membership, close outcomes, daily and final snapshots, workspace sprint support, previous and personal burn, and the same Sprint Insights surface on /sprints.

Why

The existing page could not answer planning questions by date, project, sprint, milestone, or person. Its burndown reconstructed mutable current rows, did not refresh after live issue changes, and could stay flat after completed or moved work. Historical sprint and employee reporting needed durable facts, explicit coverage, and formulas users can audit.

How you know it works

  • Full Core: 916 passed, 0 failed, 2,528 assertions.
  • Full Web: 2,031 passed, 0 failed, 5,096 assertions.
  • Four dedicated Playwright scenarios cover zero-config defaults and reloads, shared Sprint truth plus mouse and keyboard tooltips, real completion moving burn by completed +1 and remaining -1, and complete saved-query restoration.
  • Production build compiled, typechecked, generated 103 pages, and produced the standalone bundle.
  • Drift check passed against a disposable current-schema database.
  • Lint, comment policy, source-byte policy, Bun-import policy, dependency checks, and every package typecheck passed.
  • The root parallel test process hit the existing packages/db catchup cleanup-hook timeout at 30 seconds. That exact file passed alone immediately afterward: 10 passed, 0 failed in 321 ms.

Screenshots

Before

The previous page was a basic issue distribution and flat burndown surface without planning filters, exact chart evidence, project planning, or individual employee burn. The original screenshots are attached to the implementation task.

After, dark

Analytics overview dark

Sprint burn hover dark

People analytics dark

After, light

Analytics overview light

Advanced filters light

Sprint Insights light

Checklist

  • bun run verify is green, all four checks
  • Tests added or updated, and they fail without the change
  • No comments added to code, and no em-dash characters anywhere
  • No any, no non-null assertions
  • External input is parsed with a Zod schema from @orbit/shared
  • Authorization is enforced on the server through packages/shared/src/policy, not only in the UI
  • Docs updated if behaviour, configuration or setup changed
  • Schema changes are pushed to the target database before this ships

Anything reviewers should know

  • Run migrations 0005 through 0008 before deploying the web application. Existing installations must also run packages/db/catchup/workspace-sprints-catchup.sql for workspace sprint consolidation.
  • Configure CRON_SECRET. The analytics snapshot job runs every six hours and requires a Vercel plan that supports more-than-daily cron schedules.
  • Lead time is current issue-row creation to durable completion. Cycle time is the current mutable start column to completion. Completed sprint coverage states when history is frozen, reconstructed, observed, or unavailable rather than presenting reconstructed data as exact history.
  • The PR is intentionally draft until CI confirms the full branch and the database rollout is scheduled.

Greptile Summary

The PR replaces the basic analytics page with a shared planning cockpit and introduces durable sprint history, snapshots, semantic drilldowns and exports, saved views, and realtime refresh.

  • Adds Overview, Sprints, Projects, and People analytics lenses with shared query state and accessible chart evidence.
  • Adds sprint membership, close outcomes, snapshots, workspace sprint migrations, and lifecycle integration.
  • Adds analytics routes, CSV export, snapshot cron processing, saved defaults, and realtime invalidation.

Confidence Score: 4/5

The timezone mismatch in cycle burndown must be fixed before merging because non-UTC sprints can display missing or shifted actual values.

The shared sprint service emits dates in the sprint timezone, but cycleBurndown compares them with UTC-derived keys and consequently misclassifies valid local-day points as future.

Files Needing Attention: packages/core/src/analytics/burndown.ts

Important Files Changed

Filename Overview
packages/core/src/analytics/burndown.ts Adapts shared sprint burn data but incorrectly converts its timezone-local date domain back to UTC.
packages/core/src/analytics/sprints.ts Builds sprint facts, coverage, comparisons, and timezone-local burn series from durable membership and outcome history.
packages/core/src/analytics/membership.ts Captures and repairs durable sprint membership intervals across issue lifecycle changes.
packages/core/src/analytics/snapshot.ts Adds organization-scoped daily and final sprint progress snapshots.
packages/core/src/work/cycle-service.ts Integrates snapshots, outcomes, membership repair, rollover, and deletion ordering into sprint transactions.
packages/core/src/work/issue-service.ts Records sprint membership changes during issue assignment, movement, completion, and deletion workflows.
apps/web/src/features/analytics/data.ts Provides validated server adapters and hydration for analytics lenses and sprint bundles.
apps/web/src/app/api/analytics/export/route.ts Exports bounded semantic issue evidence with metadata and formula-neutralized CSV cells.
apps/web/src/features/analytics/charts/line-plot.tsx Adds pointer and keyboard chart inspection with accessible tabular evidence.
packages/db/src/schema/work.ts Declares durable sprint membership, outcomes, snapshot fields, constraints, and supporting indexes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Q[Validated analytics query] --> L[Core lens loaders]
  I[Issue and sprint lifecycle] --> M[Membership and close outcomes]
  M --> S[Daily and final snapshots]
  S --> L
  L --> A[Analytics API and hydration]
  A --> C[Planning cockpit]
  C --> D[Semantic drilldown and CSV]
  R[Realtime changes] --> V[Analytics cache invalidation]
  V --> C
Loading

Fix all with Greploop

Fix All in Claude Code

Prompt To Fix All With AI
### Issue 1
packages/core/src/analytics/burndown.ts:82-92
**UTC keys break local burndown**

When a sprint timezone maps its boundaries or the current instant to a different calendar date than UTC, `cycleBurndown` compares UTC-derived keys with the timezone-local dates returned by `loadSprintAnalytics`, causing valid actual values to be marked as future and replaced with `null`; boundary dates can also shift or disappear.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(analytics): clarify sprint filters a..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

…ing-insights

# Conflicts:
#	packages/core/src/work/cycle-service.ts
#	packages/core/src/work/issue-service.ts
#	packages/core/tests/work/cycle-service.test.ts
#	packages/shared/src/validators/cycle.ts
@imshashank
imshashank requested a review from pulkitxm as a code owner August 14, 2026 06:15
@imshashank

Copy link
Copy Markdown
Contributor Author

@greptile-apps please review the full pull request. Focus on analytics number reconciliation, date and sprint filters, sprint history and burndown semantics, authorization, migrations, and chart accessibility.

Comment thread packages/core/src/analytics/burndown.ts Resolved
@greptile-apps

greptile-apps Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Too many files changed for review (150 files, 100 file limit).

Bypass the limit by tagging @greptile-apps to review.

@imshashank
imshashank merged commit 2fd415b into main Aug 14, 2026
12 checks passed
@imshashank
imshashank deleted the codex/analytics-planning-insights branch August 14, 2026 07:50
@imshashank

Copy link
Copy Markdown
Contributor Author

Production rollout completed safely. The additive analytics catchup was applied without db:push, so the undeclared legacy GitHub and Standup tables were preserved. Production remained at 585 issues, 12 sprints, and 4 Git links. The first baseline captured 254 sprint memberships, 254 scoped issues, 15 completed issues, 501 total points, and 41 completed points. The production deployment is ready, protected routes enforce authentication, CRON_SECRET is recognized, and the PR/main build, migration, static, unit, CodeQL, and preview checks are green. Final main Playwright is still finishing.

@imshashank

Copy link
Copy Markdown
Contributor Author

Final merged-main verification is complete: Unit and integration tests passed, and Playwright passed in 8m29s. Every main CI and CodeQL job is green.

This branch was successfully deployed

1 active deployment
Preview — 9604e210 Deployed Aug 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: database Schema, migrations, queries, seed area: policy Roles, permissions and authorization area: sprints Sprints, cycles and planning area: web The Next.js app and its UI ci Workflows, tooling and repo automation documentation Docs, the README, or anything that explains Orbit tests Test coverage and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants