diff --git a/static/app/views/organizationStats/mapSeriesToChart.ts b/static/app/views/organizationStats/mapSeriesToChart.ts index b3c6118c4917..ce5e9420b6e1 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,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 { 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; } });