Skip to content

Report template insights session usage per app #27413

Closed

Description

@EhabY

Complete the per-app template insights API and UI on top of the already-landed session usage storage. Originally Phase 4 of the Scalable Approach for Adding New IDE Session Types RFC; the remaining work follows the Completing Scalable IDE Session Tracking RFC.

Already landed

  • feat: store session usage per app and family in template usage stats #29109: UpsertTemplateUsageStats stores per-app session minutes in template_usage_stats_session_apps and drops the fixed *_mins columns. A child table replaced the original JSONB proposal, keeping session app names separate from workspace web-app slugs and avoiding collisions.
  • Migration 000596 backfills the historical family totals under their canonical family app names. Family-level history is preserved; per-IDE detail before this migration cannot be recovered from those totals.
  • fix: deduplicate template insights family metrics #30497: Prometheus family usage counts distinct user-minutes from raw agent stats, avoiding double-counting overlapping apps in one family. This does not change the per-app HTTP/UI path.

Delivered: #29796 (merged 2026-10-19)

  • Read per-app session usage from template_usage_stats_session_apps and build report.apps_usage dynamically: one row per used built-in app, with registry display names and icons and no family; unused built-ins are omitted.
  • Report new app names without a schema change. List registered apps and the 64 busiest unregistered names; fold the remainder into overflow ("Other apps"), with unknown for usage reported without an app name.
  • Add report.usage_total_seconds (each user's active minute counts once) and apps_usage[].seconds_is_upper_bound for folded usage whose overlap cannot be recovered from the rollup.
  • Update the Insights page to use active time as the percentage denominator, explain that overlapping app shares can exceed 100%, and show placeholder icons and accounting-row tooltips, including "Up to…" for upper bounds.
  • Update SDK/generated API artifacts and regression coverage for the new response shape.
  • Use distinct UI row keys (method/slug) for session apps and workspace apps with the same slug.

Compatibility

This is a breaking change for GET /api/v2/insights/templates: the fixed five built-in family rows become per-app rows, unused apps disappear, and Web Terminal's slug changes from reconnecting-pty to reconnecting_pty. Consumers that rely on fixed slugs/display names must adapt. Workspace web-app usage is unchanged apart from method: workspace_app; GetTemplateAppInsights remains separate. The PR also removes the unused Go SDK UnionByFamily helper.

Separate follow-ups

Storage depends on the completed #27410 work.


Updated by Coder Agents on behalf of @EhabY.

Activity

  1. added theissue type on Jul 22, 2026
  2. linear-code commented on Jul 22, 2026

    @linear-code
  3. changed the title [-]Merge template_usage_stats *_mins into app_usage_mins JSONB (IDE session types phase 4)[/-] [+]Merge template_usage_stats *_mins into app_usage_mins JSONB[/+] on Jul 22, 2026
  4. EhabY commented on Aug 19, 2026

    @EhabY
    CollaboratorAuthor

    Two decisions and one measurement from implementing phase 1 (#28124 → #28127).

    Per-IDE history starts with this phase. DeleteOldWorkspaceAgentStats purges workspace_agent_stats about a day past the rollup watermark, and #28127 has the rollup store family minutes rather than per-app minutes. No backfill can recover per-IDE detail for any period before this phase ships. Family-level history stays correct throughout, so nothing the current surfaces expose is lost.

    Use a new session_mins jsonb column, not app_usage_mins. The scope note asks to confirm how the insights queries tell the two key kinds apart, and as specified they cannot: app_usage_mins is keyed by workspace_apps.slug, joined via AND tus.app_usage_mins ? apps.slug and read as (tus.app_usage_mins -> apps.slug)::smallint (insights.sql:266 and :254). An IDE key named vscode would be attributed to any template with a web app slugged vscode, double-counting it in GetTemplateAppInsights. zed already appears as an app slug in this repo's tests. A separate column removes the ambiguity and leaves GetTemplateAppInsights untouched.

    Backfill cost. On a synthetic 8M-row template_usage_stats (1301 MB, PG13), the backfill UPDATE takes about 67s holding ACCESS EXCLUSIVE, roughly 8s per million rows and scaling with retained history. Dropping the five *_mins columns is metadata-only, about 2ms. That argues for a separate migration rather than folding this into 000569, which completes in a few seconds.

    Not required for correctness. With read-side family grouping in #28127, a new IDE already counts in its family with no schema change. This phase adds per-IDE granularity, so it can be scheduled on its own merits.

  5. changed the title [-]Merge template_usage_stats *_mins into app_usage_mins JSONB[/-] [+]Report template insights session usage per app[/+] on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions