The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Consider tier for showing upgrade prompt
Terry Sutton7b90046a0c56
diff --git a/studio/components/interfaces/Settings/Logs/Logs.utils.ts b/studio/components/interfaces/Settings/Logs/Logs.utils.tsindex 5b7c15151f3..73d1a94eca2 100644--- a/studio/components/interfaces/Settings/Logs/Logs.utils.ts+++ b/studio/components/interfaces/Settings/Logs/Logs.utils.ts@@ -1,6 +1,7 @@import { Filters, LogData, LogsEndpointParams, LogsTableName, SQL_FILTER_TEMPLATES } from '.'import dayjs, { Dayjs } from 'dayjs'import { get } from 'lodash'+import { StripeSubscription } from 'components/interfaces/Billing'/*** Convert a micro timestamp from number/string to iso timestamp@@ -169,14 +170,14 @@ export const genSingleLogQuery = (table: LogsTableName, id: string) =>/*** Determine if we should show the user an upgrade prompt while browsing logs- *- * There's only 1440 minutes in a day, but when we select "Last day" from the dropdown,- * it will set that to mean yesterday at midnight.- * So the max possible time from that midnight to the upcoming midnight is 2880*/-export const maybeShowUpgradePrompt = (from: string | null | undefined) => {+export const maybeShowUpgradePrompt = (+ from: string | null | undefined,+ tier: StripeSubscription['tier'] | undefined+) => {const day = Math.abs(dayjs().diff(dayjs(from), 'day'))- return day > 1++ return day > 1 && tier?.key === 'FREE'}export const genCountQuery = (table: string): string => `SELECT count(*) as count FROM ${table}`diff --git a/studio/components/interfaces/Settings/Logs/LogsPreviewer.tsx b/studio/components/interfaces/Settings/Logs/LogsPreviewer.tsxindex 71b2f5b6104..f85f98ade74 100644--- a/studio/components/interfaces/Settings/Logs/LogsPreviewer.tsx+++ b/studio/components/interfaces/Settings/Logs/LogsPreviewer.tsx@@ -117,7 +117,7 @@ export const LogsPreviewer: React.FC<Props> = ({},})} else if (event === 'datepicker-change') {- const shouldShowUpgradePrompt = maybeShowUpgradePrompt(from)+ const shouldShowUpgradePrompt = maybeShowUpgradePrompt(from, tier)if (shouldShowUpgradePrompt) {setShowUpgradePrompt(!showUpgradePrompt)diff --git a/studio/pages/project/[ref]/logs-explorer/index.tsx b/studio/pages/project/[ref]/logs-explorer/index.tsxindex 7ba999afeca..f448729a8fa 100644--- a/studio/pages/project/[ref]/logs-explorer/index.tsx+++ b/studio/pages/project/[ref]/logs-explorer/index.tsx@@ -5,7 +5,7 @@ import { useRouter } from 'next/router'import { observer } from 'mobx-react-lite'import { Input, Modal, Form, Button } from '@supabase/ui'-import { useStore } from 'hooks'+import { useProjectSubscription, useStore } from 'hooks'import useLogsQuery from 'hooks/analytics/useLogsQuery'import { NextPageWithLayout, UserContent } from 'types'import { uuidv4 } from 'lib/helpers'@@ -24,7 +24,6 @@ import {maybeShowUpgradePrompt,TEMPLATES,} from 'components/interfaces/Settings/Logs'-import { useUpgradePrompt } from 'hooks/misc/useUpgradePrompt'export const LogsExplorerPage: NextPageWithLayout = () => {@@ -35,6 +34,9 @@ export const LogsExplorerPage: NextPageWithLayout = () => {const [saveModalOpen, setSaveModalOpen] = useState<boolean>(false)const [warnings, setWarnings] = useState<LogsWarning[]>([])const { content } = useStore()+ const { subscription } = useProjectSubscription(ref as string)+ const tier = subscription?.tier+const [{ params, logData, error, isLoading }, { changeQuery, runQuery, setParams }] =useLogsQuery(ref as string, {iso_timestamp_start: its ? (its as string) : undefined,@@ -112,7 +114,7 @@ export const LogsExplorerPage: NextPageWithLayout = () => {}const handleDateChange = ({ to, from }: DatePickerToFrom) => {- const shouldShowUpgradePrompt = maybeShowUpgradePrompt(from)+ const shouldShowUpgradePrompt = maybeShowUpgradePrompt(from, tier)if (shouldShowUpgradePrompt) {setShowUpgradePrompt(!showUpgradePrompt)