Skip to content

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

Update all charts to use the right attribute

Joshen Lim65f8bf73b7a3
diff --git a/studio/components/interfaces/BillingV2/Usage/Activity.tsx b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
index 3393afd42d1..8b037c90c09 100644
--- a/studio/components/interfaces/BillingV2/Usage/Activity.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Activity.tsx
@@ -17,23 +17,42 @@ const Activity = () => {
const startDate = new Date((current_period_start ?? 0) * 1000).toISOString()
const endDate = new Date((current_period_end ?? 0) * 1000).toISOString()
- // [JOSHEN TODO] Attribute needs to change after confirming with team o11y if this is implemented
+ const MAU_KEY = 'total_auth_billing_period_mau'
const { monthly_active_users } = usage ?? {}
const mauExcess = (monthly_active_users?.usage ?? 0) - (monthly_active_users?.limit ?? 0)
const { data: mauData, isLoading: isLoadingMauData } = useDailyStatsQuery({
projectRef: ref,
- attribute: 'total_auth_billing_period_mau',
+ attribute: MAU_KEY,
interval: '1d',
startDate,
endDate,
})
+ const ASSET_TRANSFORMATIONS_KEY = 'total_storage_image_render_count'
const { storage_image_render_count } = usage ?? {}
const assetTransformationExcess =
(storage_image_render_count?.usage ?? 0) - (storage_image_render_count?.limit ?? 0)
+ const { data: assetTransformationsData, isLoading: isLoadingAssetTransformationsData } =
+ useDailyStatsQuery({
+ projectRef: ref,
+ attribute: ASSET_TRANSFORMATIONS_KEY,
+ interval: '1d',
+ startDate,
+ endDate,
+ })
+ const FUNC_INVOCATIONS_KEY = 'total_func_invocations'
const { func_invocations } = usage ?? {}
const funcInvocationsExcess = (func_invocations?.usage ?? 0) - (func_invocations?.limit ?? 0)
+ const { data: funcInvocationsData, isLoading: isLoadingFuncInvocationsData } = useDailyStatsQuery(
+ {
+ projectRef: ref,
+ attribute: FUNC_INVOCATIONS_KEY,
+ interval: '1d',
+ startDate,
+ endDate,
+ }
+ )
return (
<>
@@ -46,7 +65,7 @@ const Activity = () => {
</div>
</div>
- {/* MONTHLY ACTIVE USERS - need to fix if no value yet (API will return period_start as 0 in first data point) */}
+ {/* MONTHLY ACTIVE USERS */}
<div className="border-b">
<div className="1xl:px-28 mx-auto flex flex-col gap-10 px-5 lg:px-16 2xl:px-32 py-16">
<div className="grid grid-cols-12">
@@ -101,7 +120,7 @@ const Activity = () => {
</div>
) : (
<BarChart
- attribute="total_auth_billing_period_mau"
+ attribute={MAU_KEY}
data={mauData?.data ?? []}
unit={undefined}
yDomain={[0, 100]}
@@ -112,7 +131,7 @@ const Activity = () => {
</div>
</div>
- {/* ASSET TRANSFORMATIONS - need to show actual data */}
+ {/* ASSET TRANSFORMATIONS */}
<div className="border-b">
<div className="1xl:px-28 mx-auto flex flex-col gap-10 px-5 lg:px-16 2xl:px-32 py-16">
<div className="grid grid-cols-12">
@@ -143,9 +162,13 @@ const Activity = () => {
<p className="text-xs text-scale-1000">
Included in {subscription?.tier.name.toLowerCase()}
</p>
- <p className="text-xs">
- {(storage_image_render_count?.limit ?? 0).toLocaleString()}
- </p>
+ {storage_image_render_count?.limit === -1 ? (
+ <p className="text-xs">None</p>
+ ) : (
+ <p className="text-xs">
+ {(storage_image_render_count?.limit ?? 0).toLocaleString()}
+ </p>
+ )}
</div>
<div className="flex items-center justify-between border-b py-1">
<p className="text-xs text-scale-1000">Used</p>
@@ -156,7 +179,8 @@ const Activity = () => {
<div className="flex items-center justify-between py-1">
<p className="text-xs text-scale-1000">Extra volume used this month</p>
<p className="text-xs">
- {(assetTransformationExcess < 0
+ {((storage_image_render_count?.limit ?? 0) === -1 ||
+ assetTransformationExcess < 0
? 0
: assetTransformationExcess
).toLocaleString()}
@@ -164,38 +188,34 @@ const Activity = () => {
</div>
</div>
</div>
- <div className="space-y-1">
- <p>Asset transformations over time</p>
- <p className="text-sm text-scale-1000">Some description here</p>
- </div>
- {isLoadingMauData ? (
- <div className="space-y-2">
- <ShimmeringLoader />
- <ShimmeringLoader className="w-3/4" />
- <ShimmeringLoader className="w-1/2" />
- </div>
- ) : (
- <BarChart
- attribute="disk_io_budget"
- data={generateUsageData('disk_io_budget', 30)}
- unit={undefined}
- yDomain={[0, 100]}
- reference={{
- value: 65,
- label: 'FREE QUOTA',
- x: 60,
- y: 49,
- width: 200,
- height: 24,
- }}
- />
+ {storage_image_render_count?.available_in_plan && (
+ <>
+ <div className="space-y-1">
+ <p>Asset transformations over time</p>
+ <p className="text-sm text-scale-1000">Some description here</p>
+ </div>
+ {isLoadingAssetTransformationsData ? (
+ <div className="space-y-2">
+ <ShimmeringLoader />
+ <ShimmeringLoader className="w-3/4" />
+ <ShimmeringLoader className="w-1/2" />
+ </div>
+ ) : (
+ <BarChart
+ attribute={MAU_KEY}
+ data={assetTransformationsData?.data ?? []}
+ unit={undefined}
+ yDomain={[0, 100]}
+ />
+ )}
+ </>
)}
</div>
</div>
</div>
</div>
- {/* EDGE FUNCTIONS INVOCATIONS - need to show actual data */}
+ {/* EDGE FUNCTIONS INVOCATIONS */}
<div className="border-b">
<div className="1xl:px-28 mx-auto flex flex-col gap-10 px-5 lg:px-16 2xl:px-32 py-16">
<div className="grid grid-cols-12">
@@ -244,7 +264,7 @@ const Activity = () => {
<p>Edge function invocations over time</p>
<p className="text-sm text-scale-1000">Some description here</p>
</div>
- {isLoadingMauData ? (
+ {isLoadingFuncInvocationsData ? (
<div className="space-y-2">
<ShimmeringLoader />
<ShimmeringLoader className="w-3/4" />
@@ -252,24 +272,75 @@ const Activity = () => {
</div>
) : (
<BarChart
- attribute="disk_io_budget"
- data={generateUsageData('disk_io_budget', 30)}
+ attribute={FUNC_INVOCATIONS_KEY}
+ data={funcInvocationsData?.data ?? []}
unit={undefined}
yDomain={[0, 100]}
- reference={{
- value: 65,
- label: 'FREE QUOTA',
- x: 60,
- y: 49,
- width: 200,
- height: 24,
- }}
/>
)}
</div>
</div>
</div>
</div>
+
+ {/* Sample Chart */}
+ <div className="border-b">
+ <div className="1xl:px-28 mx-auto flex flex-col gap-10 px-5 lg:px-16 2xl:px-32 py-16">
+ <div className="grid grid-cols-12">
+ <div className="col-span-5">
+ <div className="sticky top-16">
+ <p className="text-base">Sample Chart</p>
+ <p className="text-sm text-scale-1000">Some description here</p>
+ </div>
+ </div>
+ <div className="col-span-7 space-y-6">
+ <div className="space-y-2">
+ <div className="flex items-center justify-between">
+ <p className="text-sm">Sample quota usage</p>
+ <Button type="default" size="tiny" onClick={() => {}}>
+ Upgrade project
+ </Button>
+ </div>
+ <SparkBar type="horizontal" barClass="bg-scale-1200" value={75} max={100} />
+ <div>
+ <div className="flex items-center justify-between border-b py-1">
+ <p className="text-xs text-scale-1000">
+ Included in {subscription?.tier.name.toLowerCase()}
+ </p>
+ <p className="text-xs">{(10000).toLocaleString()}</p>
+ </div>
+ <div className="flex items-center justify-between border-b py-1">
+ <p className="text-xs text-scale-1000">Used</p>
+ <p className="text-xs">0</p>
+ </div>
+ <div className="flex items-center justify-between py-1">
+ <p className="text-xs text-scale-1000">Extra volume used this month</p>
+ <p className="text-xs">0</p>
+ </div>
+ </div>
+ </div>
+ <div className="space-y-1">
+ <p>Sample usage over time</p>
+ <p className="text-sm text-scale-1000">Some description here</p>
+ </div>
+ <BarChart
+ attribute="sample_data"
+ data={generateUsageData('sample_data', 30)}
+ unit={undefined}
+ yDomain={[0, 100]}
+ reference={{
+ value: 65,
+ label: 'FREE QUOTA',
+ x: 60,
+ y: 49,
+ width: 200,
+ height: 24,
+ }}
+ />
+ </div>
+ </div>
+ </div>
+ </div>
</>
)
}
diff --git a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
index e14131babe0..472b8019653 100644
--- a/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Bandwidth.tsx
@@ -1,12 +1,12 @@
import { useParams } from 'common'
import ShimmeringLoader from 'components/ui/ShimmeringLoader'
+import SparkBar from 'components/ui/SparkBar'
import { useDailyStatsQuery } from 'data/analytics/daily-stats-query'
import { useProjectSubscriptionQuery } from 'data/subscriptions/project-subscription-query'
import { useProjectUsageQuery } from 'data/usage/project-usage-query'
-import BarChart from './BarChart'
-import { Button } from 'ui'
-import SparkBar from 'components/ui/SparkBar'
import { formatBytes } from 'lib/helpers'
+import { Button } from 'ui'
+import BarChart from './BarChart'
const Bandwidth = () => {
const { ref } = useParams()
@@ -16,21 +16,24 @@ const Bandwidth = () => {
const startDate = new Date((current_period_start ?? 0) * 1000).toISOString()
const endDate = new Date((current_period_end ?? 0) * 1000).toISOString()
+ // [JOSHEN TODO] Double check if this is the right attribute
+ const DB_EGRESS_KEY = 'total_db_egress_bytes'
const { db_egress } = usage ?? {}
const dbEgressExcess = (db_egress?.usage ?? 0) - (db_egress?.limit ?? 0)
const { data: dbEgressData, isLoading: isLoadingDbEgressData } = useDailyStatsQuery({
projectRef: ref,
- attribute: 'total_rest_egress',
+ attribute: DB_EGRESS_KEY,
interval: '1d',
startDate,
endDate,
})
+ const STORAGE_EGRESS_KEY = 'total_storage_egress'
const { storage_egress } = usage ?? {}
const storageEgressExcess = (storage_egress?.usage ?? 0) - (storage_egress?.limit ?? 0)
const { data: storageEgressData, isLoading: isLoadingStorageEgressData } = useDailyStatsQuery({
projectRef: ref,
- attribute: 'total_storage_egress',
+ attribute: STORAGE_EGRESS_KEY,
interval: '1d',
startDate,
endDate,
@@ -104,7 +107,7 @@ const Bandwidth = () => {
</div>
) : (
<BarChart
- attribute="total_rest_egress"
+ attribute={DB_EGRESS_KEY}
data={dbEgressData?.data ?? []}
unit={undefined}
yDomain={[0, 100]}
@@ -172,7 +175,7 @@ const Bandwidth = () => {
</div>
) : (
<BarChart
- attribute="total_rest_egress"
+ attribute={STORAGE_EGRESS_KEY}
data={storageEgressData?.data ?? []}
unit={undefined}
yDomain={[0, 100]}
diff --git a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
index 209553314e3..b431d586843 100644
--- a/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/Infrastructure.tsx
@@ -3,7 +3,6 @@ import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { useInfraMonitoringQuery } from 'data/analytics/infra-monitoring-query'
import { useProjectSubscriptionQuery } from 'data/subscriptions/project-subscription-query'
import BarChart from './BarChart'
-import { generateUsageData } from './Usage.utils'
const Infrastructure = () => {
const { ref } = useParams()
@@ -12,26 +11,29 @@ const Infrastructure = () => {
const startDate = new Date((current_period_start ?? 0) * 1000).toISOString()
const endDate = new Date((current_period_end ?? 0) * 1000).toISOString()
+ const CPU_USAGE_KEY = 'cpu_usage'
const { data: cpuUsageData, isLoading: isLoadingCpuUsageData } = useInfraMonitoringQuery({
projectRef: ref,
- attribute: 'cpu_usage',
+ attribute: CPU_USAGE_KEY,
interval: '1d',
startDate,
endDate,
modifier: (x: number) => x * 100,
})
+ const MEMORY_USAGE_KEY = 'ram_usage'
const { data: memoryUsageData, isLoading: isLoadingMemoryUsageData } = useInfraMonitoringQuery({
projectRef: ref,
- attribute: 'ram_usage',
+ attribute: MEMORY_USAGE_KEY,
interval: '1d',
startDate,
endDate,
})
+ const DISK_IO_BUDGET_KEY = 'disk_io_budget'
const { data: ioBudgetData, isLoading: isLoadingIoBudgetData } = useInfraMonitoringQuery({
projectRef: ref,
- attribute: 'disk_io_budget',
+ attribute: DISK_IO_BUDGET_KEY,
interval: '1d',
startDate,
endDate,
@@ -71,7 +73,7 @@ const Infrastructure = () => {
</div>
) : (
<BarChart
- attribute="cpu_usage"
+ attribute={CPU_USAGE_KEY}
data={cpuUsageData?.data ?? []}
unit={cpuUsageData?.format}
yDomain={[0, 100]}
@@ -105,7 +107,7 @@ const Infrastructure = () => {
</div>
) : (
<BarChart
- attribute="ram_usage"
+ attribute={MEMORY_USAGE_KEY}
data={memoryUsageData?.data ?? []}
unit={memoryUsageData?.format}
yDomain={[0, 100]}
@@ -139,7 +141,7 @@ const Infrastructure = () => {
</div>
) : (
<BarChart
- attribute="disk_io_budget"
+ attribute={DISK_IO_BUDGET_KEY}
data={ioBudgetData?.data ?? []}
unit={ioBudgetData?.format}
yDomain={[0, 100]}
diff --git a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
index d5759b8660b..3a822b4dc19 100644
--- a/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
+++ b/studio/components/interfaces/BillingV2/Usage/SizeAndCounts.tsx
@@ -16,23 +16,23 @@ const SizeAndCounts = () => {
const startDate = new Date((current_period_start ?? 0) * 1000).toISOString()
const endDate = new Date((current_period_end ?? 0) * 1000).toISOString()
- // [JOSHEN TODO] Attribute needs to change after confirming with team o11y if this is implemented
+ const TOTAL_DB_SIZE_KEY = 'total_db_size_bytes'
const { db_size } = usage ?? {}
const dbSizeExcess = (db_size?.usage ?? 0) - (db_size?.limit ?? 0)
const { data: dbSizeData, isLoading: isLoadingDbSizeData } = useDailyStatsQuery({
projectRef: ref,
- attribute: 'total_rest_egress',
+ attribute: TOTAL_DB_SIZE_KEY,
interval: '1d',
startDate,
endDate,
})
- // [JOSHEN TODO] Attribute needs to change after confirming with team o11y if this is implemented
+ const TOTAL_STORAGE_SIZE_KEY = 'total_storage_size_bytes'
const { storage_size } = usage ?? {}
const storageSizeExcess = (storage_size?.usage ?? 0) - (storage_size?.limit ?? 0)
const { data: storageSizeData, isLoading: isLoadingStorageSizeData } = useDailyStatsQuery({
projectRef: ref,
- attribute: 'total_storage_egress',
+ attribute: TOTAL_STORAGE_SIZE_KEY,
interval: '1d',
startDate,
endDate,
@@ -104,7 +104,7 @@ const SizeAndCounts = () => {
</div>
) : (
<BarChart
- attribute="total_rest_egress"
+ attribute={TOTAL_DB_SIZE_KEY}
data={dbSizeData?.data ?? []}
unit={undefined}
yDomain={[0, 100]}
@@ -172,7 +172,7 @@ const SizeAndCounts = () => {
</div>
) : (
<BarChart
- attribute="total_rest_egress"
+ attribute={TOTAL_STORAGE_SIZE_KEY}
data={storageSizeData?.data ?? []}
unit={undefined}
yDomain={[0, 100]}
diff --git a/studio/data/analytics/daily-stats-query.ts b/studio/data/analytics/daily-stats-query.ts
index c8032574f88..178e76319bc 100644
--- a/studio/data/analytics/daily-stats-query.ts
+++ b/studio/data/analytics/daily-stats-query.ts
@@ -9,9 +9,22 @@ import dayjs from 'dayjs'
export type DailyStatsVariables = {
projectRef?: string
attribute:
+ | 'total_db_egress_bytes'
+ | 'total_db_size_bytes'
+
+ // Realtime
+ | 'total_realtime_ingress'
| 'total_realtime_egress'
+ | 'total_realtime_message_count'
+ | 'total_realtime_peak_connection'
| 'total_realtime_requests'
- | 'total_realtime_ingress'
+ | 'total_realtime_get_requests'
+ | 'total_realtime_post_requests'
+ | 'total_realtime_patch_requests'
+ | 'total_realtime_delete_requests'
+ | 'total_realtime_options_requests'
+
+ // Rest
| 'total_rest_ingress'
| 'total_rest_egress'
| 'total_rest_requests'
@@ -20,18 +33,26 @@ export type DailyStatsVariables = {
| 'total_rest_patch_requests'
| 'total_rest_delete_requests'
| 'total_rest_options_requests'
+
+ // Auth
| 'total_auth_billing_period_mau'
| 'total_auth_billing_period_sso_mau'
| 'total_auth_ingress'
| 'total_auth_egress'
+ | 'total_auth_texts'
+ | 'total_auth_users'
+ | 'total_auth_emails'
| 'total_auth_requests'
| 'total_auth_get_requests'
| 'total_auth_post_requests'
| 'total_auth_patch_requests'
| 'total_auth_delete_requests'
| 'total_auth_options_requests'
+
+ // Storage
| 'total_storage_ingress'
| 'total_storage_egress'
+ | 'total_storage_size_bytes'
| 'total_storage_image_render_count'
| 'total_storage_requests'
| 'total_storage_get_requests'
@@ -39,6 +60,15 @@ export type DailyStatsVariables = {
| 'total_storage_patch_requests'
| 'total_storage_delete_requests'
| 'total_storage_options_requests'
+
+ // Edge functions
+ | 'total_func_count'
+ | 'total_func_invocations'
+ | 'total_func_exec_time_ms'
+ | 'total_func_ingress'
+ | 'total_func_egress'
+
+ // Combined
| 'total_ingress'
| 'total_egress'
| 'total_requests'
@@ -100,6 +130,7 @@ export const useDailyStatsQuery = <TData = DailyStatsData>(
typeof endDate !== 'undefined',
// @ts-ignore
select(data) {
+ // [JOSHEN TODO] if no data, pad with empty data
return {
...data,
data: data.data.map((x) => {