From 7ef0fa540f98332ccdced5117e44caa2768457c6 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2026 10:41:24 +0000 Subject: [PATCH 1/2] fix(org-stats): Prevent TypeError when group.totals or group.series is undefined --- static/app/views/organizationStats/mapSeriesToChart.ts | 10 +++++----- .../app/views/organizationStats/usageStatsProjects.tsx | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/static/app/views/organizationStats/mapSeriesToChart.ts b/static/app/views/organizationStats/mapSeriesToChart.ts index b3c6118c4917..4cf6db592681 100644 --- a/static/app/views/organizationStats/mapSeriesToChart.ts +++ b/static/app/views/organizationStats/mapSeriesToChart.ts @@ -104,13 +104,13 @@ export function mapSeriesToChart({ // to get the `accepted_stored` count if (category === 'span_indexed') { if (outcome === Outcome.ACCEPTED) { - countAcceptedStored += group.totals['sum(quantity)']!; + countAcceptedStored += group.totals?.['sum(quantity)'] ?? 0; } } else { if (outcome !== Outcome.CLIENT_DISCARD) { - count.total += group.totals['sum(quantity)']!; + count.total += group.totals?.['sum(quantity)'] ?? 0; } - (count as any)[outcome!] += group.totals['sum(quantity)']!; + (count as any)[outcome!] += group.totals?.['sum(quantity)'] ?? 0; } if (category === 'span_indexed' && outcome !== Outcome.ACCEPTED) { @@ -118,7 +118,7 @@ export function mapSeriesToChart({ return; } - group.series['sum(quantity)']!.forEach((stat, i) => { + (group.series?.['sum(quantity)'] ?? []).forEach((stat, i) => { const dataObject = {name: orgStats.intervals[i]!, value: stat}; const strigfiedReason = String(group.by.reason ?? ''); @@ -135,7 +135,7 @@ export function mapSeriesToChart({ if (existingSubLabel) { // Check if the existing sub-label's data length matches the intervals length - if (existingSubLabel.data.length === group.series['sum(quantity)']!.length) { + if (existingSubLabel.data.length === (group.series?.['sum(quantity)'] ?? []).length) { // Update the value of the current interval existingSubLabel.data[i]!.value += stat; } else { diff --git a/static/app/views/organizationStats/usageStatsProjects.tsx b/static/app/views/organizationStats/usageStatsProjects.tsx index cc5f04763639..163d5d08ba9c 100644 --- a/static/app/views/organizationStats/usageStatsProjects.tsx +++ b/static/app/views/organizationStats/usageStatsProjects.tsx @@ -286,11 +286,11 @@ export function UsageStatsProjects({ } if (outcome !== Outcome.CLIENT_DISCARD && category !== 'span_indexed') { - stats[projectId!]!.total += group.totals['sum(quantity)']!; + stats[projectId!]!.total += group.totals?.['sum(quantity)'] ?? 0; } if (category === 'span_indexed' && outcome === Outcome.ACCEPTED) { - stats[projectId!]!.accepted_stored += group.totals['sum(quantity)']!; + stats[projectId!]!.accepted_stored += group.totals?.['sum(quantity)'] ?? 0; return; } @@ -299,7 +299,7 @@ export function UsageStatsProjects({ outcome === Outcome.FILTERED || outcome === Outcome.INVALID ) { - stats[projectId!]![outcome] += group.totals['sum(quantity)']!; + stats[projectId!]![outcome] += group.totals?.['sum(quantity)'] ?? 0; } if ( @@ -307,7 +307,7 @@ export function UsageStatsProjects({ outcome === Outcome.CARDINALITY_LIMITED || outcome === Outcome.ABUSE ) { - stats[projectId!]![SortBy.RATE_LIMITED] += group.totals['sum(quantity)']!; + stats[projectId!]![SortBy.RATE_LIMITED] += group.totals?.['sum(quantity)'] ?? 0; } }); From f12a3389d3355556cb8de0bf5bedbb541436420b Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Mon, 3 Aug 2026 11:43:46 +0000 Subject: [PATCH 2/2] fix(org-stats): Prevent TypeError when group.totals or group.series is undefined --- static/app/views/organizationStats/mapSeriesToChart.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/static/app/views/organizationStats/mapSeriesToChart.ts b/static/app/views/organizationStats/mapSeriesToChart.ts index 4cf6db592681..ce5e9420b6e1 100644 --- a/static/app/views/organizationStats/mapSeriesToChart.ts +++ b/static/app/views/organizationStats/mapSeriesToChart.ts @@ -135,7 +135,8 @@ export function mapSeriesToChart({ if (existingSubLabel) { // Check if the existing sub-label's data length matches the intervals length - if (existingSubLabel.data.length === (group.series?.['sum(quantity)'] ?? []).length) { + const seriesLength = group.series?.['sum(quantity)']?.length ?? 0; + if (existingSubLabel.data.length === seriesLength) { // Update the value of the current interval existingSubLabel.data[i]!.value += stat; } else {