The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: added sign up provider chart, tweaked stacked chart colors
TzeYiing779659889767
diff --git a/studio/components/interfaces/Reports/Reports.constants.ts b/studio/components/interfaces/Reports/Reports.constants.tsindex bf67eb7c019..187bb9a7543 100644--- a/studio/components/interfaces/Reports/Reports.constants.ts+++ b/studio/components/interfaces/Reports/Reports.constants.ts@@ -162,6 +162,19 @@ export const PRESET_CONFIG: Record<Presets, PresetConfig> = {[Presets.AUTH]: {title: 'Auth',queries: {+ signUpProviders: {+ queryType: "db",+ sql: `+select+ sum(count(u.id)) over (order by date_trunc('day', u.created_at)) as count,+ date_trunc('day', u.created_at) as timestamp,+ i.provider as provider+from auth.users u+join auth.identities as i on u.id = i.user_id+group by timestamp, provider+order by timestamp desc+ `+ },failedMigrations: {queryType: "logs",sql: `diff --git a/studio/components/interfaces/Reports/renderers/AuthRenderers.tsx b/studio/components/interfaces/Reports/renderers/AuthRenderers.tsxindex 0444185508a..f69dcc88e10 100644--- a/studio/components/interfaces/Reports/renderers/AuthRenderers.tsx+++ b/studio/components/interfaces/Reports/renderers/AuthRenderers.tsx@@ -1,14 +1,34 @@import { BarChart } from 'components/to-be-cleaned/Charts/ChartRenderer'+import StackedBarChart from 'components/ui/Charts/StackedBarChart'import { DATETIME_FORMAT } from '../Reports.constants'import { ReportWidgetProps } from '../ReportWidget'import Statistic from '../Statistic'++export const renderSignUpProviders = (+ props: ReportWidgetProps<{+ timestamp: string+ provider: string+ count: number+ }>+) => {+ return (+ <StackedBarChart+ hideHeader+ variant="percentages"+ data={props.data}+ xAxisKey="timestamp"+ yAxisKey="count"+ stackKey="provider"+ />+ )+}export const renderFailedMigrations = (props: ReportWidgetProps<{timestamp: stringcount: number}>) => {- const count = props.data.length === 0 ? 0: props?.data?.[0]?.count+ const count = props.data.length === 0 ? 0 : props?.data?.[0]?.countreturn <Statistic value={count} />}export const renderCumulativeUsers = (diff --git a/studio/components/ui/Charts/Charts.constants.ts b/studio/components/ui/Charts/Charts.constants.tsindex f9cff43f861..7aa3a6de752 100644--- a/studio/components/ui/Charts/Charts.constants.ts+++ b/studio/components/ui/Charts/Charts.constants.ts@@ -11,16 +11,13 @@ export const CHART_COLORS = {// refer to packages/ui/radix-colors.js for full list of colorsexport const STACK_COLORS = [- ['brand', 8],- ['mint', 8],- ['blue', 8],- ['sky', 7],- ['bronze', 8],- ['violet', 7],- ['indigo', 8],- ['tomato', 7],- ['orange', 8],- ['olive', 8],+ ['brand', 9],+ ['mint', 9],+ ['blue', 9],+ ['sky', 9],+ ['lime', 9],+ ['yellow', 9],+ ['orange', 9],].map(([color, n]) => ({lighter: `var(--colors-${color}${(n as number) - 1})`,base: `var(--colors-${color}${n})`,diff --git a/studio/components/ui/Charts/StackedBarChart.stories.tsx b/studio/components/ui/Charts/StackedBarChart.stories.tsxindex a6703a51727..2e0289aa158 100644--- a/studio/components/ui/Charts/StackedBarChart.stories.tsx+++ b/studio/components/ui/Charts/StackedBarChart.stories.tsx@@ -50,6 +50,7 @@ export const StackedBarChart = () => ({ title: 'No title', props: { title: undefined } },{ title: 'Minimal Header', props: { minimalHeader: true } },{ title: 'Hide Legend', props: { hideLegend: true } },+ { title: 'Hide header', props: { hideHeader: true } },{ title: 'Percentage Bars', props: { variant: 'percentages' as const } },{title: 'Percentage Bars with suffix',diff --git a/studio/components/ui/Charts/StackedBarChart.tsx b/studio/components/ui/Charts/StackedBarChart.tsxindex 8f389778d0b..df9f6484ce3 100644--- a/studio/components/ui/Charts/StackedBarChart.tsx+++ b/studio/components/ui/Charts/StackedBarChart.tsx@@ -15,6 +15,7 @@ interface Props extends CommonChartProps<any> {xAxisFormatAsDate?: booleandisplayDateInUtc?: booleanhideLegend?: boolean+ hideHeader?: boolean}const StackedBarChart: React.FC<Props> = ({size,@@ -31,6 +32,7 @@ const StackedBarChart: React.FC<Props> = ({xAxisFormatAsDate = true,displayDateInUtc,hideLegend = false,+ hideHeader = false,}) => {const { Container } = useChartSize(size)const { dataKeys, stackedData, percentagesStackedData } = useStacked({@@ -43,13 +45,15 @@ const StackedBarChart: React.FC<Props> = ({const [focusDataIndex, setFocusDataIndex] = useState<number | null>(null)if (data.length === 0) return <NoDataPlaceholder />return (- <div>- <ChartHeader- title={title}- format={format}- customDateFormat={customDateFormat}- minimalHeader={minimalHeader}- />+ <div className="w-full">+ {!hideHeader && (+ <ChartHeader+ title={title}+ format={format}+ customDateFormat={customDateFormat}+ minimalHeader={minimalHeader}+ />+ )}<Container><BarChartdata={variant === 'percentages' ? percentagesStackedData : stackedData}diff --git a/studio/pages/project/[ref]/reports/auth.tsx b/studio/pages/project/[ref]/reports/auth.tsxindex 42e22d60ade..0d84ed91ebe 100644--- a/studio/pages/project/[ref]/reports/auth.tsx+++ b/studio/pages/project/[ref]/reports/auth.tsx@@ -12,6 +12,7 @@ import {renderNewUsers,renderCumulativeUsers,renderFailedMigrations,+ renderSignUpProviders,} from 'components/interfaces/Reports/renderers/AuthRenderers'export const AuthReport: NextPageWithLayout = () => {@@ -23,20 +24,20 @@ export const AuthReport: NextPageWithLayout = () => {const newUsers = hooks.newUsers()const cumulativeUsers = hooks.cumulativeUsers()const failedMigrations = hooks.failedMigrations()+ const signUpProviders = hooks.signUpProviders()- const { isLoading, Layout } = usePresetReport([dailyActiveUsers, newUsers, cumulativeUsers])+ const { isLoading, Layout } = usePresetReport([+ dailyActiveUsers,+ newUsers,+ cumulativeUsers,+ failedMigrations,+ signUpProviders,+ ])return (<Layout title={config.title}><div className="grid lg:grid-cols-6 gap-4">- <ReportWidget- isLoading={isLoading}- params={failedMigrations[0].params}- className="col-span-2 col-start-1"- title="Failed GoTrue Migrations"- tooltip="Failed migrations may cause issues with user authentication."- data={failedMigrations[0].logData!}- renderer={renderFailedMigrations}- />+ <h2>User Activity</h2>+<ReportWidgetisLoading={isLoading}params={cumulativeUsers[0].params}@@ -64,6 +65,26 @@ export const AuthReport: NextPageWithLayout = () => {data={dailyActiveUsers[0].logData!}renderer={renderDailyActiveUsers}/>++ <ReportWidget+ isLoading={isLoading}+ params={signUpProviders[0].params}+ className="col-span-6 col-start-1"+ title="Sign Up Providers"+ description="The breakdown of providers used for user creation"+ data={signUpProviders[0].data!}+ renderer={renderSignUpProviders}+ />+ <h2>Sever Health</h2>+ <ReportWidget+ isLoading={isLoading}+ params={failedMigrations[0].params}+ className="col-span-2 col-start-1"+ title="Failed Migrations"+ tooltip="Failed GoTrue migrations may cause issues with user authentication."+ data={failedMigrations[0].logData!}+ renderer={renderFailedMigrations}+ /></div></Layout>)