Skip to content

feat(dashboard): update delivery latency p50/p75/p95/p99#2702

Merged
riderx merged 5 commits into
mainfrom
feat/update-delivery-latency-percentiles
Jul 16, 2026
Merged

feat(dashboard): update delivery latency p50/p75/p95/p99#2702
riderx merged 5 commits into
mainfrom
feat/update-delivery-latency-percentiles

Conversation

@riderx

@riderx riderx commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary (AI generated)

  • Add POST /private/update_delivery_stats that computes delivery latency percentiles (p50, p75, p95, p99) for app, org, and platform scopes
  • Reuse Observe-style UI via shared DeliveryLatencyPanel (percentile cards + daily trend chart + period selector)
  • Wire the panel into admin Updates (platform), org dashboard Usage (org), and app Usage (app)

Motivation (AI generated)

Capgo already exposes count-based update success metrics and Native Observe launch/WebView percentiles, but operators still lack a first-class view of how long updates take to download/deliver. Platform, org, and app owners need the same latency distribution language (p50/p75/p95/p99) to spot regressions before success-rate alone moves.

Business Impact (AI generated)

Faster diagnosis of slow OTA delivery improves trust in Capgo cloud updates and helps support/admin catch CDN, bundle size, or regional latency issues earlier. This is a foundation for future alerting and SLA-style delivery reporting.

Visual changes (AI generated)

App Observe now shows update delivery latency percentiles (p50 / p75 / p95 / p99) under the overview cards, synced to the Observe period selector.

Update delivery latency on Observe

Panel detail:

Update delivery latency panel

Metric definition (AI generated)

  • Time to update deliver: device-side time from download start (download_0 / download_zip_start / download_manifest_start) to download complete (download_complete / download_zip_complete)
  • Prefers metadata.duration_ms when present; otherwise pairs start/complete events within 2 hours (app/org scopes)
  • Platform scope is admin-only and metadata-only to avoid unbounded pairing across all apps

Test Plan (AI generated)

  • Unit tests: bunx vitest run tests/update-delivery-stats.unit.test.ts
  • Admin /admin/dashboard/updates: panel renders for platform admin, empty/demo states behave correctly
  • Org /dashboard: latency panel appears under usage charts for current org
  • App /app/:id: latency panel appears for the selected app
  • Period toggles (1/3/7/30 days) refetch and update cards/chart
  • Non-admin cannot call platform scope; missing app/org access is denied

Generated with AI


Note

Medium Risk
New authenticated analytics over stats with scope-specific SQL (including lateral pairing for app/org) can be expensive under load; platform scope is gated to admins but org/app queries still scan event data.

Overview
Adds update delivery latency reporting (P50–P99) from device download stats, exposed in the dashboard at org, app, and platform levels.

A new authenticated POST /private/update_delivery_stats endpoint aggregates public.stats download events: for app/org it uses metadata.duration_ms/duration when present, otherwise pairs start/complete actions within two hours; platform scope is admin-only and metadata-only to limit query cost. Responses include overview percentiles, sample/device counts, and daily trend series for 1/3/7/30-day windows, with RBAC on app/org and platform-admin checks.

The UI reuses a shared DeliveryLatencyPanel (percentile cards, trend chart, period selector, loading/error/empty states, demo data) via useUpdateDeliveryStats, wired into org Usage, app Observe (synced period), and admin Updates. i18n strings and unit tests cover response shaping helpers.

Reviewed by Cursor Bugbot for commit 444b0b7. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 12ba2f8a-cae1-4de8-ad54-35c8ef638afb

📥 Commits

Reviewing files that changed from the base of the PR and between caa8138 and 444b0b7.

📒 Files selected for processing (15)
  • cloudflare_workers/api/index.ts
  • docs/pr-assets/update-delivery-latency-observe.webp
  • docs/pr-assets/update-delivery-latency.webp
  • messages/en.json
  • src/auto-imports.d.ts
  • src/components.d.ts
  • src/components/dashboard/DeliveryLatencyPanel.vue
  • src/components/dashboard/Usage.vue
  • src/composables/useUpdateDeliveryStats.ts
  • src/pages/admin/dashboard/updates.vue
  • src/pages/app/[app].observe.vue
  • src/types/supabase.types.ts
  • supabase/functions/_backend/private/update_delivery_stats.ts
  • supabase/functions/_backend/utils/supabase.types.ts
  • tests/update-delivery-stats.unit.test.ts

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Visual diff passed

Visual changes

Generated at 2026-07-16T00:53:20.084Z. Threshold: 0.1% pixel difference.

Route Diff % Status
login 0.000 unchanged
dashboard 5.058 changed
apps 1.730 changed
app-overview 0.786 changed
channels 0.495 changed
devices 1.050 changed
observe 1.443 changed
observe-plugins 0.000 unchanged

Commit: 444b0b7b2e5ed9d33fb4a7ca494774aee4a03c12
Download the HTML report from workflow artifacts (artifact: visual-diff-report-444b0b7b2e5ed9d33fb4a7ca494774aee4a03c12).

Open index.html from the artifact for side-by-side before/after/diff screenshots.

@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing feat/update-delivery-latency-percentiles (444b0b7) with main (6e178ee)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (caa8138) during the generation of this report, so 6e178ee was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

riderx and others added 3 commits July 16, 2026 01:45
Show p50/p75/p95/p99 time-to-deliver metrics at platform, org, and app scope using the same Observe-style cards and trend chart.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Auto-sync on main dropped the users social username columns from generated types while tests still require them.

Co-authored-by: Cursor <cursoragent@cursor.com>
@riderx riderx force-pushed the feat/update-delivery-latency-percentiles branch from 52839d9 to d63ab39 Compare July 15, 2026 23:47
@riderx riderx marked this pull request as ready for review July 16, 2026 00:16
@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_9a23542f-352c-4592-b1cf-fd55de270170)

@cursor cursor Bot requested a review from WcaleNieWolny July 16, 2026 00:16

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment

Risk: medium. Not approving: Cursor Bugbot completed with a usage-limit skip and did not produce a clean review. Human review is needed before merge.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@cursor cursor Bot requested a review from Dalanir July 16, 2026 00:17

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment

Risk: medium. Cursor Bugbot did not complete (skipped due to usage limit), so automated review is unavailable for this run. Human review is needed for the dashboard and API changes; reviewers have been assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 11 files

Confidence score: 5/5

  • Safe to merge after the addressed issues were fixed.

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread supabase/functions/_backend/private/update_delivery_stats.ts Outdated
Comment thread supabase/functions/_backend/private/update_delivery_stats.ts Outdated
Comment thread tests/update-delivery-stats.unit.test.ts
Comment thread src/components/dashboard/Usage.vue
Comment thread src/components/dashboard/DeliveryLatencyPanel.vue
Comment thread src/composables/useUpdateDeliveryStats.ts Outdated
Comment thread supabase/functions/_backend/private/update_delivery_stats.ts Outdated
Comment thread supabase/functions/_backend/private/update_delivery_stats.ts Outdated
Comment thread messages/en.json Outdated
Comment thread src/components/dashboard/DeliveryLatencyPanel.vue Outdated
Move the app-scoped delivery latency panel to Native Observe, sync it with the page period, and replace the fake PR preview with a real Observe screenshot.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_ebee0f0c-be35-4df0-93a7-6c6c7bd4f0f6)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment

Risk: medium. Not approving: Cursor Bugbot completed with status skipping and no <!-- BUGBOT_REVIEW --> comment was produced. Human review is still required; reviewers WcaleNieWolny and Dalanir are already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment

Risk: medium. Not approving: Cursor Bugbot did not complete (skipped due to usage limit), and this dashboard/API change exceeds the low-risk approval threshold. Human review is still needed; reviewers are already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 7 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/pages/app/[app].observe.vue
Comment thread src/components/dashboard/DeliveryLatencyPanel.vue Outdated
Comment thread src/components/dashboard/Usage.vue Outdated
Harden duration parsing and query shape, clear stale panel state on scope changes, and cover null/p75 edge cases called out in review.

Co-authored-by: Cursor <cursoragent@cursor.com>
@riderx

riderx commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

Review comments addressed (AI generated)

Pushed 444b0b7b2 with fixes for the Cubic review threads:

  • Safe duration_ms/duration length guard before cast
  • Single shared deliveries CTE for daily + overview (no double scan)
  • toMetric(null) stays null; distinct (app_id, device_id) counts; start lookback -2h
  • Clear/refetch + keyed panels, fetch error UI, spanGaps: false, controlled period selector
  • Title/help copy + p75/null unit coverage

@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_9de8b366-988c-41ef-b76d-a4453245804d)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Risk: medium. Not approving: Cursor Bugbot completed with status skipping and did not produce a clean automated review. Human review is still required; reviewers WcaleNieWolny and Dalanir are already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Risk: medium. Not approving: Cursor Bugbot completed with status skipping (usage limit) and did not produce a clean <!-- BUGBOT_REVIEW --> result. This dashboard/API change exceeds the low-risk approval threshold; human review is still required. Reviewers WcaleNieWolny and Dalanir are already assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

@sonarqubecloud

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 7 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/composables/useUpdateDeliveryStats.ts">

<violation number="1" location="src/composables/useUpdateDeliveryStats.ts:53">
P3: Missing app/org identifier handling now duplicates the same request invalidation and state reset block. Combining the two predicates would keep this lifecycle behavior in one place and prevent the guards from drifting.</violation>
</file>

<file name="supabase/functions/_backend/private/update_delivery_stats.ts">

<violation number="1" location="supabase/functions/_backend/private/update_delivery_stats.ts:52">
P3: Valid numeric durations longer than 15 characters are excluded, so platform latency silently loses samples such as values with leading zeros or additional fractional precision. Consider safely parsing and checking the numeric value against the 7,200,000 ms bound instead of imposing an unrelated text-length limit.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment on lines +53 to +66
if (body.scope === 'app' && !body.app_id) {
latestRequest += 1
stats.value = null
statsError.value = false
statsLoading.value = false
return
}
if (body.scope === 'org' && !body.org_id) {
latestRequest += 1
stats.value = null
statsError.value = false
statsLoading.value = false
return
}

@cubic-dev-ai cubic-dev-ai Bot Jul 16, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: Missing app/org identifier handling now duplicates the same request invalidation and state reset block. Combining the two predicates would keep this lifecycle behavior in one place and prevent the guards from drifting.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/composables/useUpdateDeliveryStats.ts, line 53:

<comment>Missing app/org identifier handling now duplicates the same request invalidation and state reset block. Combining the two predicates would keep this lifecycle behavior in one place and prevent the guards from drifting.</comment>

<file context>
@@ -45,22 +45,37 @@ export function useUpdateDeliveryStats(
   async function fetchStats() {
     const body = params()
-    if (body.scope === 'app' && !body.app_id)
+    if (body.scope === 'app' && !body.app_id) {
+      latestRequest += 1
+      stats.value = null
</file context>
Suggested change
if (body.scope === 'app' && !body.app_id) {
latestRequest += 1
stats.value = null
statsError.value = false
statsLoading.value = false
return
}
if (body.scope === 'org' && !body.org_id) {
latestRequest += 1
stats.value = null
statsError.value = false
statsLoading.value = false
return
}
if (
(body.scope === 'app' && !body.app_id)
|| (body.scope === 'org' && !body.org_id)
) {
latestRequest += 1
stats.value = null
statsError.value = false
statsLoading.value = false
return
}
Fix with cubic

const durationExpression = String.raw`CASE
WHEN s.metadata ? 'duration_ms'
AND s.metadata ->> 'duration_ms' ~ '^[0-9]+(\.[0-9]+)?$'
AND char_length(s.metadata ->> 'duration_ms') <= 15

@cubic-dev-ai cubic-dev-ai Bot Jul 16, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: Valid numeric durations longer than 15 characters are excluded, so platform latency silently loses samples such as values with leading zeros or additional fractional precision. Consider safely parsing and checking the numeric value against the 7,200,000 ms bound instead of imposing an unrelated text-length limit.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At supabase/functions/_backend/private/update_delivery_stats.ts, line 52:

<comment>Valid numeric durations longer than 15 characters are excluded, so platform latency silently loses samples such as values with leading zeros or additional fractional precision. Consider safely parsing and checking the numeric value against the 7,200,000 ms bound instead of imposing an unrelated text-length limit.</comment>

<file context>
@@ -47,8 +47,14 @@ const startActions = ['download_0', 'download_zip_start', 'download_manifest_sta
-  WHEN s.metadata ? 'duration' AND s.metadata ->> 'duration' ~ '^[0-9]+(\.[0-9]+)?$' THEN (s.metadata ->> 'duration')::double precision
+  WHEN s.metadata ? 'duration_ms'
+    AND s.metadata ->> 'duration_ms' ~ '^[0-9]+(\.[0-9]+)?$'
+    AND char_length(s.metadata ->> 'duration_ms') <= 15
+    THEN (s.metadata ->> 'duration_ms')::double precision
+  WHEN s.metadata ? 'duration'
</file context>
Fix with cubic

@riderx riderx merged commit c868dd5 into main Jul 16, 2026
41 of 60 checks passed
@riderx riderx deleted the feat/update-delivery-latency-percentiles branch July 16, 2026 01:03
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