Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: usage v2 improvements

Kevin Grüneberg00d6d0fcb717
diff --git a/studio/components/interfaces/BillingV2/Usage/Activity.tsx b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
index 8498bce240f..a5e7ef7af2a 100644
--- a/studio/components/interfaces/BillingV2/Usage/Activity.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
@@ -35,10 +35,20 @@ const Activity = ({ projectRef }: ActivityProps) => {
: undefined
let endDate =
current_period_end !== undefined ? new Date(current_period_end * 1000).toISOString() : undefined
- // If end date is in future, set end date to now
+
+ // If end date is in future, set end date to yesterday/now
if (endDate && dayjs(endDate).isAfter(dayjs())) {
+ const yesterday = dayjs(new Date()).subtract(1, 'day')
+
+ /**
+ * Currently, daily-stats data is only available a day later, so we'll use yesterday as end date, as otherwise the current day would just show up with "0" values
+ *
+ * We are actively working on removing this restriction on the data-eng/LF side and can remove this workaround once that's done
+ */
+ let newEndDate = yesterday.isAfter(dayjs(startDate)) ? yesterday : new Date()
+
// LF seems to have an issue with the milliseconds, causes infinite loading sometimes
- endDate = new Date().toISOString().slice(0, -5) + 'Z'
+ endDate = newEndDate.toISOString().slice(0, -5) + 'Z'
}
const categoryMeta = USAGE_CATEGORIES.find((category) => category.key === 'activity')
@@ -232,7 +242,7 @@ const Activity = ({ projectRef }: ActivityProps) => {
</div>
{usageMeta.limit > 0 && (
<div className="flex items-center justify-between border-t py-1">
- <p className="text-xs text-scale-1000">Extra volume used this month</p>
+ <p className="text-xs text-scale-1000">Overage this month</p>
<p className="text-xs">
{((usageMeta?.limit ?? 0) === -1 || usageExcess < 0
? 0
@@ -266,7 +276,7 @@ const Activity = ({ projectRef }: ActivityProps) => {
data={chartData}
yLimit={usageMeta?.limit ?? 0}
yLeftMargin={chartMeta[attribute.key].margin}
- yFormatter={value => ChartYFormatterCompactNumber(value, attribute.unit)}
+ yFormatter={(value) => ChartYFormatterCompactNumber(value, attribute.unit)}
quotaWarningType={isFreeTier || isProTier ? 'danger' : 'warning'}
/>
)}
diff --git a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
index 43137183134..6dcbe70cebc 100644
--- a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
@@ -159,7 +159,7 @@ const Bandwidth = ({ projectRef }: BandwidthProps) => {
</div>
{usageMeta?.limit > 0 && (
<div className="flex items-center justify-between border-t py-1">
- <p className="text-xs text-scale-1000">Extra volume used this month</p>
+ <p className="text-xs text-scale-1000">Overage this month</p>
<p className="text-xs">
{usageExcess < 0 ? formatBytes(0) : formatBytes(usageExcess)}
</p>
diff --git a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
index feb48a059c0..16ab130462e 100644
--- a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
@@ -181,7 +181,7 @@ const SizeAndCounts = ({ projectRef }: SizeAndCountsProps) => {
</div>
{usageMeta.limit > 0 && (
<div className="flex items-center justify-between border-t py-1">
- <p className="text-xs text-scale-1000">Extra volume used this month</p>
+ <p className="text-xs text-scale-1000">Overage this month</p>
<p className="text-xs">
{usageExcess < 0
? attribute.unit === 'bytes'
diff --git a/studio/components/interfaces/BillingV2/Usage/Usage.constants.ts b/studio/components/interfaces/BillingV2/Usage/Usage.constants.ts
index 3c5c9ffe351..4fad750de7a 100644
--- a/studio/components/interfaces/BillingV2/Usage/Usage.constants.ts
+++ b/studio/components/interfaces/BillingV2/Usage/Usage.constants.ts
@@ -91,9 +91,9 @@ export const USAGE_CATEGORIES: {
attribute: 'total_egress_modified',
name: 'Database egress',
unit: 'bytes',
- description: 'Contains any outgoing traffic (egress) from your database',
- chartDescription:
- 'Billing is based on the total sum of egress in GB throughout your billing period. The data shown here is refreshed over a period of 24 hours.',
+ description:
+ 'Contains any outgoing traffic (egress) from your database\nBilling is based on the total sum of egress in GB throughout your billing period.',
+ chartDescription: 'The data shown here is refreshed over a period of 24 hours.',
},
{
anchor: 'storageEgress',
@@ -102,9 +102,8 @@ export const USAGE_CATEGORIES: {
name: 'Storage egress',
unit: 'bytes',
description:
- 'All requests to download/view your storage items go through our CDN.\nWe sum up all outgoing traffic (egress) for storage related requests through our CDN.\nWe do not differentiate between cache and no cache hits.',
- chartDescription:
- 'Billing is based on the total amount of egress in GB throughout your billing period. The data shown here is refreshed over a period of 24 hours.',
+ 'All requests to download/view your storage items go through our CDN. We sum up all outgoing traffic (egress) for storage related requests through our CDN. We do not differentiate between cache and no cache hits.\nBilling is based on the total amount of egress in GB throughout your billing period.',
+ chartDescription: 'The data shown here is refreshed over a period of 24 hours.',
},
],
},
@@ -119,15 +118,15 @@ export const USAGE_CATEGORIES: {
attribute: 'total_db_size_bytes',
name: 'Database size',
unit: 'bytes',
- description: "Size of your project's database",
+ description:
+ 'Billing is based on the average daily database size in GB throughout the billing period.',
links: [
{
name: 'Documentation',
url: 'https://supabase.com/docs/guides/platform/database-size',
},
],
- chartDescription:
- 'Billing is based on the average daily database size in GB throughout the billing period. The data shown here is refreshed over a period of 24 hours.',
+ chartDescription: 'The data shown here is refreshed over a period of 24 hours.',
},
{
anchor: 'storageSize',
@@ -135,9 +134,9 @@ export const USAGE_CATEGORIES: {
attribute: 'total_storage_size_bytes',
name: 'Storage size',
unit: 'bytes',
- description: 'Sum of all objects in your storage buckets',
- chartDescription:
- 'Billing is based on the average size in GB throughout your billing period. The data shown here is refreshed over a period of 24 hours.',
+ description:
+ 'Sum of all objects in your storage buckets\nBilling is based on the average size in GB throughout your billing period',
+ chartDescription: 'The data shown here is refreshed over a period of 24 hours.',
},
{
anchor: 'funcCount',
@@ -145,9 +144,9 @@ export const USAGE_CATEGORIES: {
attribute: 'total_func_count',
name: 'Edge function count',
unit: 'absolute',
- description: 'Number of serverless functions in your project',
- chartDescription:
- 'Billing is based on the maximum amount of functions at any point in time throughout your billing period. The data shown here is refreshed over a period of 24 hours.',
+ description:
+ 'Number of serverless functions in your project\nBilling is based on the maximum amount of functions at any point in time throughout your billing period',
+ chartDescription: 'The data shown here is refreshed over a period of 24 hours.',
},
],
},
@@ -163,7 +162,7 @@ export const USAGE_CATEGORIES: {
name: 'Monthly active users',
unit: 'absolute',
description:
- 'The amount of distinct users requesting your API throughout the billing period.',
+ 'Users who log in or refresh their token\nBilling is based on the sum of distinct users requesting your API throughout the billing period. Resets every billing cycle.',
chartDescription:
'The data shown here is refreshed over a period of 24 hours and resets at the beginning of every billing period.',
},
@@ -174,7 +173,7 @@ export const USAGE_CATEGORIES: {
name: 'Monthly active single sign-on users',
unit: 'absolute',
description:
- 'The amount of distinct Single Sign-On users requesting your API throughout the billing period.',
+ 'SSO users who log in or refresh their token\nBilling is based on the sum of distinct Single Sign-On users requesting your API throughout the billing period. Resets every billing cycle.',
chartDescription:
'The data shown here is refreshed over a period of 24 hours and resets at the beginning of every billing period.',
},
@@ -185,7 +184,7 @@ export const USAGE_CATEGORIES: {
name: 'Storage image transformations',
unit: 'absolute',
description:
- 'We distinctly count all images that were transformed in the billing period, ignoring any transformations.\nIf you transform one image with different transformations, it only counts as one.\nWe only count the unique (origin) images being transformed.',
+ 'We distinctly count all images that were transformed in the billing period, ignoring any transformations. If you transform one image with different transformations, it only counts as one.\nBilling is based on the unique count of (origin) images that used transformations throughout the billing period. Resets every billing cycle.',
chartDescription: 'The data shown here is refreshed over a period of 24 hours.',
},
{
@@ -195,9 +194,8 @@ export const USAGE_CATEGORIES: {
name: 'Edge function invocations',
unit: 'absolute',
description:
- 'Every single serverless function invocation independent of response status is counted.',
- chartDescription:
- 'Billing is based on the sum of all invocations throughout your billing period. The data shown here is refreshed over a period of 24 hours.',
+ 'Every single serverless function invocation independent of response status is counted.\nBilling is based on the sum of all invocations throughout your billing period.',
+ chartDescription: 'The data shown here is refreshed over a period of 24 hours.',
},
{
anchor: 'realtimeMessageCount',
@@ -205,9 +203,9 @@ export const USAGE_CATEGORIES: {
attribute: 'total_realtime_message_count',
name: 'Realtime message count',
unit: 'absolute',
- description: 'Total number of realtime messages sent',
- chartDescription:
- 'Billing is based on the total amount of messages throughout your billing period. The data shown here is refreshed over a period of 24 hours.',
+ description:
+ "Count of messages going through Realtime. If you do a database change and 5 clients listen to that change via Realtime, that's 5 messages. If you broadcast a message and 4 clients listen to that, that's 5 messages (1 message sent, 4 received).\nBilling is based on the total amount of messages throughout your billing period.",
+ chartDescription: 'The data shown here is refreshed over a period of 24 hours.',
},
{
anchor: 'realtimePeakConnection',
@@ -215,9 +213,9 @@ export const USAGE_CATEGORIES: {
attribute: 'total_realtime_peak_connection',
name: 'Realtime peak connections',
unit: 'absolute',
- description: 'Total number of successful connections (not connection attempts)',
- chartDescription:
- 'Billing is based on the maximum amount of concurrent peak connections throughout your billing period.',
+ description:
+ 'Total number of successful connections (not connection attempts)\nBilling is based on the maximum amount of concurrent peak connections throughout your billing period.',
+ chartDescription: 'The data shown here is refreshed over a period of 24 hours.',
},
],
},
diff --git a/studio/components/interfaces/BillingV2/Usage/Usage.tsx b/studio/components/interfaces/BillingV2/Usage/Usage.tsx
index 523d2ce5b67..12196d3279c 100644
--- a/studio/components/interfaces/BillingV2/Usage/Usage.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Usage.tsx
@@ -146,11 +146,9 @@ const Usage = () => {
onClick={() => scrollTo(category.key)}
className="flex items-center opacity-50 space-x-2 py-3 hover:opacity-100 transition cursor-pointer"
>
- {status === USAGE_STATUS.NORMAL || usageBillingEnabled ? (
- <IconCheckCircle size={15} strokeWidth={2} className="text-scale-1100" />
- ) : status === USAGE_STATUS.APPROACHING ? (
+ {!usageBillingEnabled && status === USAGE_STATUS.APPROACHING ? (
<IconAlertCircle size={15} strokeWidth={2} className="text-amber-900" />
- ) : status === USAGE_STATUS.EXCEEDED ? (
+ ) : !usageBillingEnabled && status === USAGE_STATUS.EXCEEDED ? (
<IconAlertCircle size={15} strokeWidth={2} className="text-red-900" />
) : null}
<p className="text-sm">{category.name}</p>