feat: support for new billable metrics (#28399)
This commit is contained in:
@@ -45,6 +45,14 @@ export const BILLING_BREAKDOWN_METRICS: Metric[] = [
|
||||
category: 'Authentication',
|
||||
unitName: 'MAU',
|
||||
},
|
||||
{
|
||||
key: PricingMetric.MONTHLY_ACTIVE_THIRD_PARTY_USERS,
|
||||
name: 'Monthly Active Third-Party Users',
|
||||
units: 'absolute',
|
||||
anchor: 'mauSso',
|
||||
category: 'Authentication',
|
||||
unitName: 'MAU',
|
||||
},
|
||||
{
|
||||
key: PricingMetric.STORAGE_SIZE,
|
||||
name: 'Storage Size',
|
||||
@@ -82,11 +90,46 @@ export const BILLING_BREAKDOWN_METRICS: Metric[] = [
|
||||
category: 'Edge Functions',
|
||||
},
|
||||
{
|
||||
key: PricingMetric.DISK_SIZE_GB_HOURS,
|
||||
key: PricingMetric.DISK_SIZE_GB_HOURS_GP3,
|
||||
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.',
|
||||
},
|
||||
{
|
||||
key: PricingMetric.DISK_SIZE_GB_HOURS_IO2,
|
||||
name: 'Disk Size IO2',
|
||||
units: 'absolute',
|
||||
unitName: 'GB-Hrs',
|
||||
category: 'Database',
|
||||
},
|
||||
{
|
||||
key: PricingMetric.DISK_IOPS_IO2,
|
||||
name: 'Disk IOPS IO2',
|
||||
units: 'absolute',
|
||||
unitName: 'IOPS-Hrs',
|
||||
category: 'Database',
|
||||
},
|
||||
{
|
||||
key: PricingMetric.DISK_IOPS_GP3,
|
||||
name: 'Disk IOPS GP3',
|
||||
units: 'absolute',
|
||||
unitName: 'IOPS-Hrs',
|
||||
category: 'Database',
|
||||
},
|
||||
{
|
||||
key: PricingMetric.DISK_THROUGHPUT_GP3,
|
||||
name: 'Disk Throughput',
|
||||
units: 'absolute',
|
||||
unitName: 'IOPS-Hrs',
|
||||
category: 'Database',
|
||||
},
|
||||
{
|
||||
key: PricingMetric.LOG_DRAIN_EVENTS,
|
||||
name: 'Log Drain Events',
|
||||
units: 'absolute',
|
||||
unitName: 'hours',
|
||||
category: 'Database',
|
||||
},
|
||||
]
|
||||
|
||||
@@ -48,7 +48,7 @@ const UpcomingInvoice = ({ slug }: UpcomingInvoiceProps) => {
|
||||
|
||||
const fixedFees = useMemo(() => {
|
||||
return (upcomingInvoice?.lines || [])
|
||||
.filter((item) => item !== computeCredits && !item.breakdown)
|
||||
.filter((item) => item !== computeCredits && (!item.breakdown || !item.breakdown.length))
|
||||
.sort((a, b) => {
|
||||
// Prorations should be below regular usage fees
|
||||
return Number(a.proration) - Number(b.proration)
|
||||
|
||||
@@ -8,7 +8,11 @@ import BillingMetric from '../BillingSettings/BillingBreakdown/BillingMetric'
|
||||
import { BILLING_BREAKDOWN_METRICS } from '../BillingSettings/BillingBreakdown/BillingBreakdown.constants'
|
||||
import ComputeMetric from '../BillingSettings/BillingBreakdown/ComputeMetric'
|
||||
import clsx from 'clsx'
|
||||
import { ComputeUsageMetric, computeUsageMetricLabel } from 'data/analytics/org-daily-stats-query'
|
||||
import {
|
||||
ComputeUsageMetric,
|
||||
computeUsageMetricLabel,
|
||||
PricingMetric,
|
||||
} from 'data/analytics/org-daily-stats-query'
|
||||
|
||||
export interface ComputeProps {
|
||||
orgSlug: string
|
||||
@@ -19,6 +23,14 @@ export interface ComputeProps {
|
||||
currentBillingCycleSelected: boolean
|
||||
}
|
||||
|
||||
const METRICS_TO_HIDE_WITH_NO_USAGE: PricingMetric[] = [
|
||||
PricingMetric.DISK_IOPS_IO2,
|
||||
PricingMetric.DISK_IOPS_GP3,
|
||||
PricingMetric.DISK_SIZE_GB_HOURS_GP3,
|
||||
PricingMetric.DISK_SIZE_GB_HOURS_IO2,
|
||||
PricingMetric.DISK_THROUGHPUT_GP3,
|
||||
]
|
||||
|
||||
const TotalUsage = ({
|
||||
orgSlug,
|
||||
projectRef,
|
||||
@@ -62,7 +74,13 @@ const TotalUsage = ({
|
||||
|
||||
const breakdownMetrics = BILLING_BREAKDOWN_METRICS.filter((metric) =>
|
||||
usage.usages.some((usage) => !usage.available_in_plan || usage.metric === metric.key)
|
||||
)
|
||||
).filter((metric) => {
|
||||
if (!METRICS_TO_HIDE_WITH_NO_USAGE.includes(metric.key as PricingMetric)) return true
|
||||
|
||||
const metricUsage = usage.usages.find((it) => it.metric === metric.key)
|
||||
|
||||
return metricUsage && metricUsage.usage > 0
|
||||
})
|
||||
|
||||
return breakdownMetrics.slice().sort((a, b) => {
|
||||
const usageMetaA = usage.usages.find((x) => x.metric === a.key)
|
||||
|
||||
@@ -21,9 +21,11 @@ export enum PricingMetric {
|
||||
EGRESS = 'EGRESS',
|
||||
DATABASE_SIZE = 'DATABASE_SIZE',
|
||||
STORAGE_SIZE = 'STORAGE_SIZE',
|
||||
DISK_SIZE_GB_HOURS = 'DISK_SIZE_GB_HOURS',
|
||||
DISK_SIZE_GB_HOURS_GP3 = 'DISK_SIZE_GB_HOURS_GP3',
|
||||
DISK_SIZE_GB_HOURS_IO2 = 'DISK_SIZE_GB_HOURS_IO2',
|
||||
MONTHLY_ACTIVE_USERS = 'MONTHLY_ACTIVE_USERS',
|
||||
MONTHLY_ACTIVE_SSO_USERS = 'MONTHLY_ACTIVE_SSO_USERS',
|
||||
MONTHLY_ACTIVE_THIRD_PARTY_USERS = 'MONTHLY_ACTIVE_THIRD_PARTY_USERS',
|
||||
FUNCTION_INVOCATIONS = 'FUNCTION_INVOCATIONS',
|
||||
STORAGE_IMAGES_TRANSFORMED = 'STORAGE_IMAGES_TRANSFORMED',
|
||||
REALTIME_MESSAGE_COUNT = 'REALTIME_MESSAGE_COUNT',
|
||||
@@ -33,6 +35,11 @@ export enum PricingMetric {
|
||||
PITR_7 = 'PITR_7',
|
||||
PITR_14 = 'PITR_14',
|
||||
PITR_28 = 'PITR_28',
|
||||
DISK_IOPS_GP3 = 'DISK_IOPS_GP3',
|
||||
DISK_IOPS_IO2 = 'DISK_IOPS_IO2',
|
||||
DISK_THROUGHPUT_GP3 = 'DISK_THROUGHPUT_GP3',
|
||||
LOG_DRAIN = 'LOG_DRAIN',
|
||||
LOG_DRAIN_EVENTS = 'LOG_DRAIN_EVENTS',
|
||||
}
|
||||
|
||||
export enum ComputeUsageMetric {
|
||||
|
||||
Reference in New Issue
Block a user