The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(orb): support new usage stats (#28208)
Kevin Grüneberg9de6ee58b15c
diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.constants.ts b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.constants.tsindex 26eb514fece..ba64d28edf3 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.constants.ts+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingBreakdown.constants.ts@@ -6,9 +6,10 @@ export interface Metric {key: stringname: stringunits: string- anchor: string+ anchor?: stringcategory: string- unitName: string+ unitName?: string+ tip?: string}export const BILLING_BREAKDOWN_METRICS: Metric[] = [@@ -58,7 +59,6 @@ export const BILLING_BREAKDOWN_METRICS: Metric[] = [units: 'absolute',anchor: 'storageImageTransformations',category: 'Storage',- unitName: 'image',},{key: PricingMetric.REALTIME_PEAK_CONNECTIONS,@@ -66,7 +66,6 @@ export const BILLING_BREAKDOWN_METRICS: Metric[] = [units: 'absolute',anchor: 'realtimePeakConnections',category: 'Realtime',- unitName: 'connection',},{key: PricingMetric.REALTIME_MESSAGE_COUNT,@@ -74,7 +73,6 @@ export const BILLING_BREAKDOWN_METRICS: Metric[] = [units: 'absolute',anchor: 'realtimeMessageCount',category: 'Realtime',- unitName: 'message',},{key: PricingMetric.FUNCTION_INVOCATIONS,@@ -82,6 +80,13 @@ export const BILLING_BREAKDOWN_METRICS: Metric[] = [units: 'absolute',anchor: 'funcInvocations',category: 'Edge Functions',- unitName: 'invocation',+ },+ {+ key: PricingMetric.DISK_SIZE_GB_HOURS,+ name: 'Disk Size',+ units: 'absolute',+ unitName: 'GB-Hrs',+ category: 'Database',+ tip: 'Each project gets provisioned with 8 GB of disk. When you get close to the disk size limit, we autoscale your disk by 1.5x. The first 8 GB of disk is free for every single project.',},]diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingMetric.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingMetric.tsxindex 5943872e241..c95e5190d34 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingMetric.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/BillingMetric.tsx@@ -36,21 +36,30 @@ const BillingMetric = ({} else if ((usageMeta.cost && usageMeta.cost > 0) ||!relativeToSubscription ||- usageMeta.unlimited+ usageMeta.unlimited ||+ usageMeta.pricing_free_units === 0) {- return metric.units === 'bytes'+ return metric.units === 'bytes' || metric.units === 'gigabytes'? `${usageMeta.usage.toLocaleString() ?? 0} GB`- : usageMeta.usage.toLocaleString()+ : usageMeta.usage.toLocaleString() + (metric.unitName ? ` ${metric.unitName}` : '')} else {- return metric.units === 'bytes'+ return metric.units === 'bytes' || metric.units === 'gigabytes'? `${usageMeta.usage.toLocaleString() ?? 0} / ${usageMeta.pricing_free_units ?? 0} GB`- : `${usageMeta.usage.toLocaleString()} / ${usageMeta.pricing_free_units?.toLocaleString()}`+ : `${usageMeta.usage.toLocaleString()} / ${usageMeta.pricing_free_units?.toLocaleString()}` ++ (metric.unitName ? ` ${metric.unitName}` : '')}}, [usageMeta, relativeToSubscription, metric])+ const sortedProjectAllocations = useMemo(() => {+ if (!usageMeta || !usageMeta.project_allocations) return []++ return usageMeta.project_allocations.sort((a, b) => b.usage - a.usage)+ }, [usageMeta])+if (!usageMeta) return null- const usageRatio = usageMeta.usage / (usageMeta.pricing_free_units ?? 0)+ const usageRatio =+ usageMeta.usage === 0 ? 0 : usageMeta.usage / (usageMeta.pricing_free_units ?? 0)const isUsageBillingEnabled = subscription?.usage_billing_enabled === true@@ -61,24 +70,32 @@ const BillingMetric = ({const unit = billingMetricUnit(usageMeta.metric as PricingMetric)const percentageLabel =- usageRatio < 0.01 ? '<1%' : `${(+(usageRatio * 100).toFixed(0)).toLocaleString()}%`+ usageMeta.usage === 0 || usageMeta.pricing_free_units === 0+ ? ''+ : usageRatio < 0.01+ ? '(<1%)'+ : `(${(+(usageRatio * 100).toFixed(0)).toLocaleString()}%)`return (<div className="flex items-center justify-between"><div>- <Link href={`/org/${slug}/usage#${metric.anchor}`}>- <div className="group flex items-center space-x-2">- <p className="text-sm text-foreground-light group-hover:text-foreground transition cursor-pointer">- {metric.name}- </p>- <IconChevronRight strokeWidth={1.5} size={16} className="transition" />- </div>- </Link>+ {metric.anchor ? (+ <Link href={`/org/${slug}/usage#${metric.anchor}`}>+ <div className="group flex items-center space-x-2">+ <p className="text-sm text-foreground-light group-hover:text-foreground transition cursor-pointer">+ {metric.name}+ </p>+ <IconChevronRight strokeWidth={1.5} size={16} className="transition" />+ </div>+ </Link>+ ) : (+ <p className="text-sm text-foreground-light">{metric.name}</p>+ )}<span className="text-sm">{usageLabel}</span> - {usageMeta.cost && usageMeta.cost > 0 ? (+ {relativeToSubscription && usageMeta.cost && usageMeta.cost > 0 ? (<span className="text-sm">({formatCurrency(usageMeta.cost)})</span>) : usageMeta.available_in_plan && !usageMeta.unlimited && relativeToSubscription ? (- <span className="text-sm">({percentageLabel})</span>+ <span className="text-sm">{percentageLabel}</span>) : null}</div>@@ -130,7 +147,25 @@ const BillingMetric = ({<div className="text-xs text-foreground space-y-2"><p className="font-medium">{usageMeta.unit_price_desc}</p>- {usageMeta.project_allocations && usageMeta.project_allocations.length > 0 && (+ {metric.tip && (+ <div className="my-2">+ <p className="text-xs">{metric.tip}</p>+ </div>+ )}++ {subscription.usage_billing_enabled === false &&+ relativeToSubscription &&+ (isApproachingLimit || isExceededLimit) && (+ <div className="mt-2">+ <p className="text-xs">+ Exceeding your plans included usage will lead to restrictions to your+ project. Upgrade to a usage-based plan or disable the spend cap to avoid+ restrictions.+ </p>+ </div>+ )}++ {sortedProjectAllocations && sortedProjectAllocations.length > 0 && (<table className="list-disc w-full"><thead><tr>@@ -139,11 +174,11 @@ const BillingMetric = ({</tr></thead><tbody>- {usageMeta.project_allocations.map((allocation) => (+ {sortedProjectAllocations.map((allocation) => (<tr key={`${usageMeta.metric}_${allocation.ref}`}><td>{allocation.name}</td><td className="text-right">- {formatUsage(usageMeta.metric as PricingMetric, allocation.usage)}+ {formatUsage(usageMeta.metric as PricingMetric, allocation)}</td></tr>))}@@ -155,27 +190,14 @@ const BillingMetric = ({Total{unit && <span> ({unit})</span>}</td><td className="py-2 border-t text-right">- {formatUsage(- usageMeta.metric as PricingMetric,- usageMeta.usage_original- )}{' '}+ {formatUsage(usageMeta.metric as PricingMetric, {+ usage: usageMeta.usage_original,+ })}{' '}</td></tr></tfoot></table>)}-- {subscription.usage_billing_enabled === false &&- relativeToSubscription &&- (isApproachingLimit || isExceededLimit) && (- <div className="mt-2">- <p className="text-xs">- Exceeding your plans included usage will lead to restrictions to your- project. Upgrade to a usage-based plan or disable the spend cap to avoid- restrictions.- </p>- </div>- )}</div></div></Tooltip.Content>diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/ComputeMetric.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/ComputeMetric.tsxindex 925015cc208..a319efb3056 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/ComputeMetric.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/ComputeMetric.tsx@@ -20,15 +20,21 @@ const ComputeMetric = ({ slug, metric, usage, relativeToSubscription }: ComputeMconst usageMeta = usage.usages.find((x) => x.metric === metric.key)const usageLabel = useMemo(() => {- if (usageMeta?.cost && usageMeta.cost > 0) {- return `${usageMeta?.usage?.toLocaleString() ?? 0} hours`- } else {+ if (usageMeta?.pricing_free_units) {return `${usageMeta?.usage?.toLocaleString() ?? 0} / ${usageMeta?.pricing_free_units ?? 0} hours`+ } else {+ return `${usageMeta?.usage?.toLocaleString() ?? 0} hours`}}, [usageMeta])+ const sortedProjectAllocations = useMemo(() => {+ if (!usageMeta || !usageMeta.project_allocations) return []++ return usageMeta.project_allocations.sort((a, b) => b.usage - a.usage)+ }, [usageMeta])+return (<div className="flex items-center justify-between"><div>@@ -57,7 +63,22 @@ const ComputeMetric = ({ slug, metric, usage, relativeToSubscription }: ComputeM<div className="text-xs text-foreground space-y-2"><p className="font-medium">{usageMeta?.unit_price_desc}</p>- {usageMeta?.project_allocations && usageMeta.project_allocations.length > 0 && (+ <div className="my-2">+ <p className="text-xs">+ Every project is a dedicated server and database. For every hour your project+ is active, it incurs compute costs based on the compute size of your project.+ Paused projects do not incur compute costs.{' '}+ <Link+ href="https://supabase.com/docs/guides/platform/org-based-billing#usage-based-billing-for-compute"+ target="_blank"+ className="transition text-brand hover:text-brand-600 underline"+ >+ Read more+ </Link>+ </p>+ </div>++ {usageMeta && sortedProjectAllocations.length > 0 && (<table className="list-disc w-full"><thead><tr>@@ -66,11 +87,11 @@ const ComputeMetric = ({ slug, metric, usage, relativeToSubscription }: ComputeM</tr></thead><tbody>- {usageMeta.project_allocations.map((allocation) => (+ {sortedProjectAllocations.map((allocation) => (<tr key={`${usageMeta.metric}_${allocation.ref}`}><td>{allocation.name}</td><td className="text-right">- {formatUsage(usageMeta.metric as PricingMetric, allocation.usage)}+ {formatUsage(usageMeta.metric as PricingMetric, allocation)}</td></tr>))}@@ -80,30 +101,14 @@ const ComputeMetric = ({ slug, metric, usage, relativeToSubscription }: ComputeM<tr><td className="py-2 border-t text-left">Total (Hours)</td><td className="py-2 border-t text-right">- {formatUsage(- usageMeta.metric as PricingMetric,- usageMeta.usage_original- )}+ {formatUsage(usageMeta.metric as PricingMetric, {+ usage: usageMeta.usage_original,+ })}</td></tr></tfoot></table>)}-- <div className="mt-2">- <p className="text-xs">- Every project is a dedicated server and database. For every hour your project- is active, it incurs compute costs based on the compute size of your project.- Paused projects do not incur compute costs.{' '}- <Link- href="https://supabase.com/docs/guides/platform/org-based-billing#usage-based-billing-for-compute"- target="_blank"- className="transition text-brand hover:text-brand-600 underline"- >- Read more- </Link>- </p>- </div></div></div></Tooltip.Content>diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/UpcomingInvoice.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/UpcomingInvoice.tsxindex 9a9a2fe5cdf..d3fe1d030e1 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/UpcomingInvoice.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingBreakdown/UpcomingInvoice.tsx@@ -193,7 +193,7 @@ const UpcomingInvoice = ({ slug }: UpcomingInvoiceProps) => {</td><td className="py-2 pr-4 text-sm text-right tabular-nums max-w-[100px]">{fee.usage_original- ? `${formatUsage(fee.usage_metric!, fee.usage_original)}`+ ? `${formatUsage(fee.usage_metric!, { usage: fee.usage_original })}`: fee.quantity? fee.quantity: null}@@ -223,7 +223,7 @@ const UpcomingInvoice = ({ slug }: UpcomingInvoiceProps) => {{breakdown.project_name}</td><td className="pb-1 text-xs tabular-nums text-right pr-4">- {formatUsage(fee.usage_metric!, breakdown.usage)}+ {formatUsage(fee.usage_metric!, breakdown)}</td><td /><td />diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/helpers.ts b/apps/studio/components/interfaces/Organization/BillingSettings/helpers.tsindex 431fe037dd0..62677c4ba83 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/helpers.ts+++ b/apps/studio/components/interfaces/Organization/BillingSettings/helpers.ts@@ -6,11 +6,32 @@ const pricingMetricBytes = [PricingMetric.STORAGE_SIZE,]-export const formatUsage = (pricingMetric: PricingMetric, usage: number) => {+export const formatUsage = (+ pricingMetric: PricingMetric,+ allocation: { usage: number; hours?: number }+) => {+ if (allocation.hours) {+ return (+ allocation.usage.toLocaleString() ++ ' (' ++ Math.round(allocation.usage / allocation.hours).toLocaleString() ++ 'x' ++ allocation.hours.toLocaleString() ++ ' hours)'+ )+ }+if (pricingMetricBytes.includes(pricingMetric)) {- return +(usage / 1e9).toFixed(2).toLocaleString()+ const formattedUsage = +(allocation.usage / 1e9).toFixed(2).toLocaleString()++ // To avoid very low usage displaying as "0", we will show "<0.01" instead+ if (allocation.usage > 0 && formattedUsage === 0) {+ return '<0.01'+ } else {+ return formattedUsage+ }} else {- return usage.toLocaleString()+ return allocation.usage.toLocaleString()}}diff --git a/apps/studio/components/interfaces/Organization/Usage/TotalUsage.tsx b/apps/studio/components/interfaces/Organization/Usage/TotalUsage.tsxindex f56de7d4206..f664536c08a 100644--- a/apps/studio/components/interfaces/Organization/Usage/TotalUsage.tsx+++ b/apps/studio/components/interfaces/Organization/Usage/TotalUsage.tsx@@ -58,9 +58,13 @@ const TotalUsage = ({)const sortedBillingMetrics = useMemo(() => {- if (!usage) return BILLING_BREAKDOWN_METRICS+ if (!usage) return []- return BILLING_BREAKDOWN_METRICS.slice().sort((a, b) => {+ const breakdownMetrics = BILLING_BREAKDOWN_METRICS.filter((metric) =>+ usage.usages.some((usage) => !usage.available_in_plan || usage.metric === metric.key)+ )++ return breakdownMetrics.slice().sort((a, b) => {const usageMetaA = usage.usages.find((x) => x.metric === a.key)const usageRatioA =typeof usageMetaA !== 'number'@@ -92,8 +96,8 @@ const TotalUsage = ({section={{name: 'Usage Summary',description: isUsageBillingEnabled- ? 'Your plan includes a limited amount of usage. If the usage on your organization exceeds these quotas, your subscription will be charged for the overages. It may take up to 24 hours for usage stats to update.'- : 'Your plan includes a limited amount of usage. If the usage on your organization exceeds these quotas, you may experience restrictions, as you are currently not billed for overages. It may take up to 24 hours for usage stats to update.',+ ? `Your plan includes a limited amount of usage. If the usage on your organization exceeds these quotas, your subscription will be charged for the overages. It may take up to ${subscription?.usage_based_billing_project_addons ? '1 hour' : '24 hours'} for usage stats to update.`+ : `Your plan includes a limited amount of usage. If the usage on your organization exceeds these quotas, you may experience restrictions, as you are currently not billed for overages. It may take up to ${subscription?.usage_based_billing_project_addons ? '1 hour' : '24 hours'} for usage stats to update.`,links: [{name: 'How billing works',@@ -184,7 +188,8 @@ const TotalUsage = ({<divclassName={clsx('col-span-12 md:col-span-6 space-y-4 py-4 border-overlay',- i % 2 === 0 ? 'md:border-r md:pr-4' : 'md:pl-4'+ (i + sortedBillingMetrics.length) % 2 === 0 ? 'md:border-r md:pr-4' : 'md:pl-4',+ 'border-b')}key={metric}>diff --git a/apps/studio/components/interfaces/Organization/Usage/Usage.constants.tsx b/apps/studio/components/interfaces/Organization/Usage/Usage.constants.tsxindex 60317e059eb..fbf88f42ebb 100644--- a/apps/studio/components/interfaces/Organization/Usage/Usage.constants.tsx+++ b/apps/studio/components/interfaces/Organization/Usage/Usage.constants.tsx@@ -47,7 +47,7 @@ export interface CategoryAttribute {key: string // Property from organization usageattributes: Attribute[] // For querying against stats-daily / infra-monitoringname: string- unit: 'bytes' | 'absolute' | 'percentage' | 'hours'+ unit: 'bytes' | 'absolute' | 'percentage' | 'hours' | 'gigabytes'links?: {name: stringurl: string@@ -56,7 +56,7 @@ export interface CategoryAttribute {chartPrefix?: 'Max' | 'Average' | 'Cumulative'chartSuffix?: stringchartDescription: string- additionalInfo?: (subscription?: OrgSubscription, usage?: OrgUsageResponse) => JSX.Element | null+ additionalInfo?: (usage?: OrgUsageResponse) => JSX.Element | null}export type CategoryMetaKey = 'bandwidth' | 'sizeCount' | 'activity' | 'compute'@@ -68,7 +68,9 @@ export interface CategoryMeta {attributes: CategoryAttribute[]}-export const USAGE_CATEGORIES: CategoryMeta[] = [+export const USAGE_CATEGORIES: (subscription?: OrgSubscription) => CategoryMeta[] = (+ subscription+) => [{key: 'bandwidth',name: 'Bandwidth',@@ -106,15 +108,25 @@ export const USAGE_CATEGORIES: CategoryMeta[] = [chartPrefix: 'Average',unit: 'bytes',description:- 'Database size refers to the monthly average storage usage, as reported by Postgres. Paid Plans use auto-scaling disks.\nBilling is based on the average daily database size used in GB throughout the billing period. Billing is independent of the provisioned disk size.',+ subscription?.usage_based_billing_project_addons === true+ ? 'Database size refers to the monthly average database space usage, as reported by Postgres. Paid Plans use auto-scaling disks and are billed based on provisioned disk size, rather than database space used.'+ : 'Database size refers to the monthly average database space usage, as reported by Postgres. Paid Plans use auto-scaling disks.\nBilling is based on the average daily database size used in GB throughout the billing period. Billing is independent of the provisioned disk size.',links: [{name: 'Documentation',url: 'https://supabase.com/docs/guides/platform/database-size',},+ ...(subscription?.usage_based_billing_project_addons === true+ ? [+ {+ name: 'Disk Management',+ url: 'https://supabase.com/docs/guides/platform/database-size#disk-management',+ },+ ]+ : []),],chartDescription: 'The data refreshes every 24 hours.',- additionalInfo: (subscription?: OrgSubscription, usage?: OrgUsageResponse) => {+ additionalInfo: (usage?: OrgUsageResponse) => {const usageMeta = usage?.usages.find((x) => x.metric === PricingMetric.DATABASE_SIZE)const usageRatio =typeof usageMeta !== 'number'diff --git a/apps/studio/components/interfaces/Organization/Usage/Usage.utils.ts b/apps/studio/components/interfaces/Organization/Usage/Usage.utils.tsindex 4e68b9e278a..62dcce33ae1 100644--- a/apps/studio/components/interfaces/Organization/Usage/Usage.utils.ts+++ b/apps/studio/components/interfaces/Organization/Usage/Usage.utils.ts@@ -38,6 +38,8 @@ export const ChartYFormatterCompactNumber = (number: number | string, unit: striconst formattedBytes = formatBytesCompact(number).replace(/\s/g, '')return formattedBytes === '0bytes' ? '0' : formattedBytes+ } else if (unit === 'gigabytes') {+ return compactNumberFormatter.format(number) + 'GB'} else {return compactNumberFormatter.format(number)}@@ -53,6 +55,8 @@ export const ChartTooltipValueFormatter = (number: number | string, unit: stringconst formattedBytes = formatBytesPrecision(number).replace(/\s/g, '')return formattedBytes === '0bytes' ? '0' : formattedBytes+ } else if (unit === 'gigabytes') {+ return compactNumberFormatter.format(number) + 'GB'} else {return compactNumberFormatter.format(number)}diff --git a/apps/studio/components/interfaces/Organization/Usage/UsageBarChart.tsx b/apps/studio/components/interfaces/Organization/Usage/UsageBarChart.tsxindex 003943ddfa5..937f36c09af 100644--- a/apps/studio/components/interfaces/Organization/Usage/UsageBarChart.tsx+++ b/apps/studio/components/interfaces/Organization/Usage/UsageBarChart.tsx@@ -21,7 +21,7 @@ export interface UsageBarChartProps {data: DataPoint[]name: string // Used within the tooltipattributes: Attribute[]- unit: 'bytes' | 'absolute' | 'percentage' | 'hours'+ unit: 'bytes' | 'absolute' | 'percentage' | 'hours' | 'gigabytes'yLimit?: numberyMin?: numberyLeftMargin?: numberdiff --git a/apps/studio/components/interfaces/Organization/Usage/UsageChartTooltips.tsx b/apps/studio/components/interfaces/Organization/Usage/UsageChartTooltips.tsxindex da6f20200c6..685c7afb46e 100644--- a/apps/studio/components/interfaces/Organization/Usage/UsageChartTooltips.tsx+++ b/apps/studio/components/interfaces/Organization/Usage/UsageChartTooltips.tsx@@ -4,7 +4,7 @@ import { Attribute, COLOR_MAP } from './Usage.constants'export interface SingleAttributeTooltipContentProps {name: string- unit: 'bytes' | 'percentage' | 'absolute' | 'hours'+ unit: 'bytes' | 'percentage' | 'absolute' | 'hours' | 'gigabytes'value: anyisAfterToday: booleantooltipFormatter?: (value: any) => any@@ -37,7 +37,7 @@ export interface MultiAttributeTooltipContentProps {values: Payload<ValueType, string | number>[]isAfterToday: booleantooltipFormatter?: (value: any) => any- unit: 'bytes' | 'percentage' | 'absolute' | 'hours'+ unit: 'bytes' | 'percentage' | 'absolute' | 'hours' | 'gigabytes'}const AttributeContent = ({@@ -51,7 +51,7 @@ const AttributeContent = ({attributeMeta?: Payload<ValueType, string | number>sumValue: numbertooltipFormatter?: (value: any) => any- unit: 'bytes' | 'percentage' | 'absolute' | 'hours'+ unit: 'bytes' | 'percentage' | 'absolute' | 'hours' | 'gigabytes'}) => {const attrValue = Number(attributeMeta?.value ?? 0)const percentageContribution = ((attrValue / sumValue) * 100).toFixed(1)diff --git a/apps/studio/components/interfaces/Organization/Usage/UsageSection/AttributeUsage.tsx b/apps/studio/components/interfaces/Organization/Usage/UsageSection/AttributeUsage.tsxindex e0a01bd76c1..bebc034cb83 100644--- a/apps/studio/components/interfaces/Organization/Usage/UsageSection/AttributeUsage.tsx+++ b/apps/studio/components/interfaces/Organization/Usage/UsageSection/AttributeUsage.tsx@@ -93,7 +93,7 @@ const AttributeUsage = ({{isSuccess && (<>- {usageMeta?.available_in_plan ? (+ {!usageMeta || usageMeta?.available_in_plan ? (<>{!projectRef && (<div className="space-y-2">@@ -150,7 +150,7 @@ const AttributeUsage = ({</div></div>- {currentBillingCycleSelected && !usageMeta.unlimited && (+ {currentBillingCycleSelected && usageMeta && !usageMeta.unlimited && (<SparkBartype="horizontal"barClass={clsx(@@ -169,8 +169,8 @@ const AttributeUsage = ({/>)}- {- <div>+ <div>+ {usageMeta && (<div className="flex items-center justify-between border-b py-1"><p className="text-xs text-foreground-light">Included in {subscription?.plan?.name.toLowerCase()} plan@@ -179,43 +179,42 @@ const AttributeUsage = ({<p className="text-xs">Unlimited</p>) : (<p className="text-xs">- {attribute.unit === 'bytes'+ {attribute.unit === 'bytes' || attribute.unit === 'gigabytes'? `${usageMeta.pricing_free_units ?? 0} GB`: (usageMeta.pricing_free_units ?? 0).toLocaleString()}</p>)}</div>- {currentBillingCycleSelected && (- <div className="flex items-center justify-between py-1">- <p className="text-xs text-foreground-light">- {attribute.chartPrefix || 'Used '} in period- </p>- <p className="text-xs">- {attribute.unit === 'bytes'- ? `${(usageMeta?.usage ?? 0).toFixed(2)} GB`- : (usageMeta?.usage ?? 0).toLocaleString()}- </p>- </div>- )}- {currentBillingCycleSelected &&- (usageMeta?.pricing_free_units ?? 0) > 0 && (- <div className="flex items-center justify-between border-t py-1">- <p className="text-xs text-foreground-light">Overage in period</p>- <p className="text-xs">- {(usageMeta?.pricing_free_units ?? 0) === -1 || usageExcess < 0- ? `0${attribute.unit === 'bytes' ? ' GB' : ''}`- : attribute.unit === 'bytes'- ? `${usageExcess.toFixed(2)} GB`- : usageExcess.toLocaleString()}- </p>- </div>- )}- </div>- }+ )}+ {currentBillingCycleSelected && usageMeta && (+ <div className="flex items-center justify-between py-1">+ <p className="text-xs text-foreground-light">+ {attribute.chartPrefix || 'Used '} in period+ </p>+ <p className="text-xs">+ {attribute.unit === 'bytes' || attribute.unit === 'gigabytes'+ ? `${(usageMeta?.usage ?? 0).toFixed(2)} GB`+ : (usageMeta?.usage ?? 0).toLocaleString()}+ </p>+ </div>+ )}+ {currentBillingCycleSelected && (usageMeta?.pricing_free_units ?? 0) > 0 && (+ <div className="flex items-center justify-between border-t py-1">+ <p className="text-xs text-foreground-light">Overage in period</p>+ <p className="text-xs">+ {(usageMeta?.pricing_free_units ?? 0) === -1 || usageExcess < 0+ ? `0${attribute.unit === 'bytes' || attribute.unit === 'gigabytes' ? ' GB' : ''}`+ : attribute.unit === 'bytes' || attribute.unit === 'gigabytes'+ ? `${usageExcess.toFixed(2)} GB`+ : usageExcess.toLocaleString()}+ </p>+ </div>+ )}+ </div></div>)}- {attribute.additionalInfo?.(subscription, usage)}+ {attribute.additionalInfo?.(usage)}<div className="space-y-1"><p className="text-sm">diff --git a/apps/studio/components/interfaces/Organization/Usage/UsageSection/UsageSection.tsx b/apps/studio/components/interfaces/Organization/Usage/UsageSection/UsageSection.tsxindex f5a4fe47b8f..21f118c093f 100644--- a/apps/studio/components/interfaces/Organization/Usage/UsageSection/UsageSection.tsx+++ b/apps/studio/components/interfaces/Organization/Usage/UsageSection/UsageSection.tsx@@ -35,7 +35,9 @@ const UsageSection = ({isSuccess: isSuccessUsage,} = useOrgUsageQuery({ orgSlug })- const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === categoryKey)+ const categoryMeta = USAGE_CATEGORIES(subscription).find(+ (category) => category.key === categoryKey+ )if (!categoryMeta) return nullreturn (diff --git a/apps/studio/data/analytics/org-daily-stats-query.ts b/apps/studio/data/analytics/org-daily-stats-query.tsindex 8b74d5e8d30..fa4e3797cc1 100644--- a/apps/studio/data/analytics/org-daily-stats-query.ts+++ b/apps/studio/data/analytics/org-daily-stats-query.ts@@ -21,6 +21,7 @@ export enum PricingMetric {EGRESS = 'EGRESS',DATABASE_SIZE = 'DATABASE_SIZE',STORAGE_SIZE = 'STORAGE_SIZE',+ DISK_SIZE_GB_HOURS = 'DISK_SIZE_GB_HOURS',MONTHLY_ACTIVE_USERS = 'MONTHLY_ACTIVE_USERS',MONTHLY_ACTIVE_SSO_USERS = 'MONTHLY_ACTIVE_SSO_USERS',FUNCTION_INVOCATIONS = 'FUNCTION_INVOCATIONS',diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.tsindex f1ad7619ef2..a56e891dd08 100644--- a/packages/api-types/types/api.d.ts+++ b/packages/api-types/types/api.d.ts@@ -3911,7 +3911,7 @@ export interface components {| 'STORAGE_IMAGES_TRANSFORMED'| 'REALTIME_MESSAGE_COUNT'| 'REALTIME_PEAK_CONNECTIONS'- | 'DISK_GB_HOURS'+ | 'DISK_SIZE_GB_HOURS'| 'COMPUTE_HOURS_BRANCH'| 'COMPUTE_HOURS_XS'| 'COMPUTE_HOURS_SM'@@ -3941,7 +3941,6 @@ export interface components {usage_original: number}OrgUsageResponse: {- slugs: string[]usage_billing_enabled: booleanusages: components['schemas']['OrgMetricUsage'][]}@@ -4308,6 +4307,7 @@ export interface components {price_type: components['schemas']['ProjectAddonVariantPricingType']}ProjectAllocation: {+ hours?: numbername: stringref: stringusage: number@@ -7803,7 +7803,7 @@ export interface operations {| 'STORAGE_IMAGES_TRANSFORMED'| 'REALTIME_MESSAGE_COUNT'| 'REALTIME_PEAK_CONNECTIONS'- | 'DISK_GB_HOURS'+ | 'DISK_SIZE_GB_HOURS'| 'COMPUTE_HOURS_BRANCH'| 'COMPUTE_HOURS_XS'| 'COMPUTE_HOURS_SM'