Skip to content

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

[COM-205] feat(studio): add logs:all flag to hide all logs (#45202)

Alaister Young5f6060197e9e
diff --git a/apps/studio/components/interfaces/Sidebar.tsx b/apps/studio/components/interfaces/Sidebar.tsx
index d8b538b29b1..d5c3c9045cf 100644
--- a/apps/studio/components/interfaces/Sidebar.tsx
+++ b/apps/studio/components/interfaces/Sidebar.tsx
@@ -239,6 +239,7 @@ const ProjectLinks = () => {
const { data: project } = useSelectedProjectQuery()
const { securityLints, errorLints } = useLints()
const showReports = useIsFeatureEnabled('reports:all')
+ const showLogs = useIsFeatureEnabled('logs:all')
const { isEnabled: isUnifiedLogsEnabled } = useUnifiedLogsPreview()
@@ -269,6 +270,7 @@ const ProjectLinks = () => {
const otherRoutes = generateOtherRoutes(ref, project, {
unifiedLogs: isUnifiedLogsEnabled,
showReports,
+ showLogs,
})
const settingsRoutes = generateSettingsRoutes(ref)
diff --git a/apps/studio/components/layouts/LogsLayout/Logs.Commands.tsx b/apps/studio/components/layouts/LogsLayout/Logs.Commands.tsx
index f1cd1dfaa1d..213cf4f0d53 100644
--- a/apps/studio/components/layouts/LogsLayout/Logs.Commands.tsx
+++ b/apps/studio/components/layouts/LogsLayout/Logs.Commands.tsx
@@ -10,58 +10,60 @@ export function useLogsGotoCommands(options?: CommandOptions) {
let { ref } = useParams()
ref ||= '_'
- const { logsCollections } = useIsFeatureEnabled(['logs:collections'])
+ const { logsAll, logsCollections } = useIsFeatureEnabled(['logs:all', 'logs:collections'])
useRegisterCommands(
COMMAND_MENU_SECTIONS.NAVIGATE,
- [
- {
- id: 'nav-logs-explorer',
- name: 'Logs Explorer',
- route: `/project/${ref}/logs/explorer`,
- defaultHidden: true,
- },
- ...(logsCollections
- ? ([
- {
- id: 'nav-logs-postgres',
- name: 'Postgres Logs',
- route: `/project/${ref}/logs/postgres-logs`,
- defaultHidden: true,
- },
- {
- id: 'nav-logs-postgrest',
- name: 'PostgREST Logs',
- route: `/project/${ref}/logs/postgrest-logs`,
- defaultHidden: true,
- },
- {
- id: 'nav-logs-pooler',
- name: 'Pooler Logs',
- route: `/project/${ref}/logs/pooler-logs`,
- defaultHidden: true,
- },
- {
- id: 'nav-logs-auth',
- name: 'Auth Logs',
- route: `/project/${ref}/logs/auth-logs`,
- defaultHidden: true,
- },
- {
- id: 'nav-logs-storage',
- name: 'Storage Logs',
- route: `/project/${ref}/logs/storage-logs`,
- defaultHidden: true,
- },
- {
- id: 'nav-logs-realtime',
- name: 'Realtime Logs',
- route: `/project/${ref}/logs/realtime-logs`,
- defaultHidden: true,
- },
- ] as IRouteCommand[])
- : []),
- ],
+ logsAll
+ ? [
+ {
+ id: 'nav-logs-explorer',
+ name: 'Logs Explorer',
+ route: `/project/${ref}/logs/explorer`,
+ defaultHidden: true,
+ },
+ ...(logsCollections
+ ? ([
+ {
+ id: 'nav-logs-postgres',
+ name: 'Postgres Logs',
+ route: `/project/${ref}/logs/postgres-logs`,
+ defaultHidden: true,
+ },
+ {
+ id: 'nav-logs-postgrest',
+ name: 'PostgREST Logs',
+ route: `/project/${ref}/logs/postgrest-logs`,
+ defaultHidden: true,
+ },
+ {
+ id: 'nav-logs-pooler',
+ name: 'Pooler Logs',
+ route: `/project/${ref}/logs/pooler-logs`,
+ defaultHidden: true,
+ },
+ {
+ id: 'nav-logs-auth',
+ name: 'Auth Logs',
+ route: `/project/${ref}/logs/auth-logs`,
+ defaultHidden: true,
+ },
+ {
+ id: 'nav-logs-storage',
+ name: 'Storage Logs',
+ route: `/project/${ref}/logs/storage-logs`,
+ defaultHidden: true,
+ },
+ {
+ id: 'nav-logs-realtime',
+ name: 'Realtime Logs',
+ route: `/project/${ref}/logs/realtime-logs`,
+ defaultHidden: true,
+ },
+ ] as IRouteCommand[])
+ : []),
+ ]
+ : [],
{ ...options, deps: [ref] }
)
}
diff --git a/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx b/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx
index 1fa0957006e..36176eb3da8 100644
--- a/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx
+++ b/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx
@@ -1,10 +1,13 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
+import { useParams } from 'common'
import { PropsWithChildren } from 'react'
import { ProjectLayout } from '../ProjectLayout'
import { LogsSidebarMenuV2 } from './LogsSidebarMenuV2'
import NoPermission from '@/components/ui/NoPermission'
+import { UnknownInterface } from '@/components/ui/UnknownInterface'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
+import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { withAuth } from '@/hooks/misc/withAuth'
interface LogsLayoutProps {
@@ -12,11 +15,22 @@ interface LogsLayoutProps {
}
const LogsLayout = ({ title, children }: PropsWithChildren<LogsLayoutProps>) => {
+ const { ref } = useParams()
+ const logsEnabled = useIsFeatureEnabled('logs:all')
+
const { isLoading, can: canUseLogsExplorer } = useAsyncCheckPermissions(
PermissionAction.ANALYTICS_READ,
'logflare'
)
+ if (!logsEnabled) {
+ return (
+ <ProjectLayout product="Logs & Analytics" browserTitle={{ section: title }}>
+ <UnknownInterface urlBack={`/project/${ref}`} />
+ </ProjectLayout>
+ )
+ }
+
if (!canUseLogsExplorer) {
if (isLoading) {
return (
diff --git a/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
index 63725b7570d..19a16c8d88d 100644
--- a/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
@@ -27,6 +27,7 @@ interface OtherFeatures {
isPlatform?: boolean
unifiedLogs?: boolean
showReports?: boolean
+ showLogs?: boolean
}
interface SettingsFeatures {
@@ -161,6 +162,7 @@ export const generateOtherRoutes = (
const isPlatform = features?.isPlatform ?? IS_PLATFORM
const unifiedLogsEnabled = features?.unifiedLogs ?? false
const reportsEnabled = features?.showReports ?? true
+ const logsEnabled = features?.showLogs ?? true
return [
{
key: 'advisors',
@@ -183,14 +185,20 @@ export const generateOtherRoutes = (
},
]
: []),
- {
- key: 'logs',
- label: 'Logs',
- disabled: false,
- icon: <List size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
- link: ref && (unifiedLogsEnabled ? `/project/${ref}/logs` : `/project/${ref}/logs/explorer`),
- shortcutId: SHORTCUT_IDS.NAV_LOGS,
- },
+ ...(logsEnabled
+ ? [
+ {
+ key: 'logs',
+ label: 'Logs',
+ disabled: false,
+ icon: <List size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
+ link:
+ ref &&
+ (unifiedLogsEnabled ? `/project/${ref}/logs` : `/project/${ref}/logs/explorer`),
+ shortcutId: SHORTCUT_IDS.NAV_LOGS,
+ },
+ ]
+ : []),
{
key: 'integrations',
label: 'Integrations',
diff --git a/apps/studio/pages/project/[ref]/logs/index.tsx b/apps/studio/pages/project/[ref]/logs/index.tsx
index c82d487dc2d..123db944bb7 100644
--- a/apps/studio/pages/project/[ref]/logs/index.tsx
+++ b/apps/studio/pages/project/[ref]/logs/index.tsx
@@ -6,20 +6,33 @@ import { useUnifiedLogsPreview } from '@/components/interfaces/App/FeaturePrevie
import { UnifiedLogs } from '@/components/interfaces/UnifiedLogs/UnifiedLogs'
import DefaultLayout from '@/components/layouts/DefaultLayout'
import { ProjectLayout } from '@/components/layouts/ProjectLayout'
+import { UnknownInterface } from '@/components/ui/UnknownInterface'
+import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import type { NextPageWithLayout } from '@/types'
export const LogPage: NextPageWithLayout = () => {
const router = useRouter()
const { ref } = useParams()
+ const logsEnabled = useIsFeatureEnabled('logs:all')
const { isEnabled: isUnifiedLogsEnabled, isLoading } = useUnifiedLogsPreview()
useEffect(() => {
- if (!isLoading && !isUnifiedLogsEnabled && ref) {
+ if (logsEnabled && !isLoading && !isUnifiedLogsEnabled && ref) {
router.replace(`/project/${ref}/logs/explorer`)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [isLoading, isUnifiedLogsEnabled, ref])
+ }, [logsEnabled, isLoading, isUnifiedLogsEnabled, ref])
+
+ if (!logsEnabled) {
+ return (
+ <DefaultLayout>
+ <ProjectLayout browserTitle={{ section: 'Logs' }}>
+ <UnknownInterface urlBack={`/project/${ref}`} />
+ </ProjectLayout>
+ </DefaultLayout>
+ )
+ }
if (isUnifiedLogsEnabled) {
return (
diff --git a/packages/common/enabled-features/enabled-features.json b/packages/common/enabled-features/enabled-features.json
index cbde9cf7e1f..579eae29e4f 100644
--- a/packages/common/enabled-features/enabled-features.json
+++ b/packages/common/enabled-features/enabled-features.json
@@ -77,6 +77,7 @@
"infrastructure:read_replicas": true,
+ "logs:all": true,
"logs:templates": true,
"logs:collections": true,
"logs:metadata": true,
diff --git a/packages/common/enabled-features/enabled-features.schema.json b/packages/common/enabled-features/enabled-features.schema.json
index 54b715085d2..8ce7bab0442 100644
--- a/packages/common/enabled-features/enabled-features.schema.json
+++ b/packages/common/enabled-features/enabled-features.schema.json
@@ -266,6 +266,10 @@
"description": "Enable read replicas management"
},
+ "logs:all": {
+ "type": "boolean",
+ "description": "Enable the logs pages and navigation. Disable to hide all logs pages, for example when Logflare is not configured."
+ },
"logs:templates": {
"type": "boolean",
"description": "Enable the logs templates page"
@@ -488,6 +492,7 @@
"profile:show_information",
"profile:show_analytics_and_marketing",
"profile:show_account_deletion",
+ "logs:all",
"logs:templates",
"logs:collections",
"logs:metadata",