fix: serve /data success rate from global_stats#2706
Conversation
/data was computing a separate Analytics Engine device-day rate (~70%) instead of the admin global_stats success rate (~84%). Use global_stats for success_rate/daily and keep AE only for failure/platform/version breakdowns. Also remove duplicate social username type fields blocking typecheck. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
|
Bugbot couldn't run - usage limit reachedBugbot 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_f2fef751-cbc7-496a-808e-ffed443202f7) |
There was a problem hiding this comment.
Risk: medium. Not approving: Cursor Bugbot completed as skipped (usage limit reached) with no clean review signal, and this public metrics data-source change exceeds the low-risk approval threshold. WcaleNieWolny is already assigned for human review.
Sent by Cursor Approval Agent: Pull Request Approver External
There was a problem hiding this comment.
2 issues found across 6 files
Confidence score: 3/5
- In
supabase/functions/_backend/private/public_stats.ts, the/live_updatespath can include partially completedglobal_statsrows while admin excludes them, so users may see a transiently incorrect success rate versus admin during shard processing — align the filter logic (including completion criteria likecompleted_at) before merging. - In
supabase/functions/_backend/utils/cloudflare.ts,getPublicLiveUpdateMetricsCFnow returns only breakdowns and dropssuccess_rate/daily, which can break caller expectations of the full metric contract — either restore those fields or rename/scope the function to match the reduced response before merging.
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="supabase/functions/_backend/utils/cloudflare.ts">
<violation number="1" location="supabase/functions/_backend/utils/cloudflare.ts:2601">
P3: Callers can reasonably expect `getPublicLiveUpdateMetricsCF` to return the complete live-update metric contract, but it now returns only breakdowns and omits `success_rate`/`daily`. Renaming it to `getPublicLiveUpdateBreakdownMetricsCF` would keep the exported API aligned with its new responsibility.</violation>
</file>
<file name="supabase/functions/_backend/private/public_stats.ts">
<violation number="1" location="supabase/functions/_backend/private/public_stats.ts:48">
P2: During daily shard processing, `/live_updates` can still show a success rate that differs from admin because this query admits partially completed `global_stats` rows that the admin query excludes. Filtering on `completed_shards` with `REQUIRED_GLOBAL_STATS_SHARDS` keeps the KPI and daily series aligned with admin.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| .select('date_id, success_rate') | ||
| .gte('date_id', startDateId) | ||
| .lte('date_id', latestCompletedDateId) | ||
| .not('success_rate', 'is', null) |
There was a problem hiding this comment.
P2: During daily shard processing, /live_updates can still show a success rate that differs from admin because this query admits partially completed global_stats rows that the admin query excludes. Filtering on completed_shards with REQUIRED_GLOBAL_STATS_SHARDS keeps the KPI and daily series aligned with admin.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At supabase/functions/_backend/private/public_stats.ts, line 48:
<comment>During daily shard processing, `/live_updates` can still show a success rate that differs from admin because this query admits partially completed `global_stats` rows that the admin query excludes. Filtering on `completed_shards` with `REQUIRED_GLOBAL_STATS_SHARDS` keeps the KPI and daily series aligned with admin.</comment>
<file context>
@@ -33,6 +34,34 @@ export function getLatestCompletedGlobalStatsDateId(referenceDate = new Date())
+ .select('date_id, success_rate')
+ .gte('date_id', startDateId)
+ .lte('date_id', latestCompletedDateId)
+ .not('success_rate', 'is', null)
+ .order('date_id', { ascending: true })
+
</file context>
| .not('success_rate', 'is', null) | |
| .contains('completed_shards', [...REQUIRED_GLOBAL_STATS_SHARDS]) |
| daily: Array<{ date: string, success_rate: number }> | ||
| } | ||
|
|
||
| export async function getPublicLiveUpdateMetricsCF(c: Context, referenceDate = new Date()): Promise<PublicLiveUpdateBreakdownMetrics> { |
There was a problem hiding this comment.
P3: Callers can reasonably expect getPublicLiveUpdateMetricsCF to return the complete live-update metric contract, but it now returns only breakdowns and omits success_rate/daily. Renaming it to getPublicLiveUpdateBreakdownMetricsCF would keep the exported API aligned with its new responsibility.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At supabase/functions/_backend/utils/cloudflare.ts, line 2601:
<comment>Callers can reasonably expect `getPublicLiveUpdateMetricsCF` to return the complete live-update metric contract, but it now returns only breakdowns and omits `success_rate`/`daily`. Renaming it to `getPublicLiveUpdateBreakdownMetricsCF` would keep the exported API aligned with its new responsibility.</comment>
<file context>
@@ -2587,15 +2587,18 @@ export async function getPluginBreakdownCF(c: Context, referenceDate?: Date): Pr
+ daily: Array<{ date: string, success_rate: number }>
+}
+
+export async function getPublicLiveUpdateMetricsCF(c: Context, referenceDate = new Date()): Promise<PublicLiveUpdateBreakdownMetrics> {
if (!c.env.APP_LOG || !c.env.DEVICE_USAGE || !c.env.DEVICE_INFO || !getEnv(c, 'CF_ANALYTICS_TOKEN') || !getEnv(c, 'CF_ACCOUNT_ANALYTICS_ID'))
throw new Error('Public live update metric bindings are unavailable')
</file context>





Summary
/private/website_stats/live_updateswas computing a separate Analytics Engine device-day success rate (~70%).success_rate+ daily series come fromglobal_stats.discord_usernametype fields that broke typecheck on main.Test plan
bunx vitest run tests/public-live-update-metrics.unit.test.ts tests/public-stats.unit.test.tsGET /private/website_stats/live_updatessuccess_ratematches admin Updates success rateMade with Cursor