From ba2c83decca26abfd12b8caeec2f9701de49d1d2 Mon Sep 17 00:00:00 2001
From: Joshen Lim
Date: Fri, 18 Jul 2025 01:08:13 +0800
Subject: [PATCH] Gate unified logs to team and above (#37260)
---
.../App/FeaturePreview/FeaturePreviewContext.tsx | 7 ++++++-
.../interfaces/App/FeaturePreview/UnifiedLogsPreview.tsx | 3 +++
.../components/layouts/LogsLayout/LogsSidebarMenuV2.tsx | 7 ++++++-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
index 0ab0b040922..2578ca33fa2 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
@@ -11,6 +11,7 @@ import {
} from 'react'
import { FeatureFlagContext, LOCAL_STORAGE_KEYS } from 'common'
+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { useFlag, useIsRealtimeSettingsFFEnabled } from 'hooks/ui/useFlag'
import { EMPTY_OBJ } from 'lib/void'
import { FEATURE_PREVIEWS } from './FeaturePreview.constants'
@@ -91,8 +92,12 @@ export const useIsInlineEditorEnabled = () => {
}
export const useUnifiedLogsPreview = () => {
+ const organization = useSelectedOrganization()
const { flags, onUpdateFlag } = useFeaturePreviewContext()
- const isEnabled = flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS]
+
+ const isTeamsOrEnterprise = ['team', 'enterprise'].includes(organization?.plan.id ?? '')
+ const isEnabled = isTeamsOrEnterprise && flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS]
+
const enable = () => onUpdateFlag(LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS, true)
const disable = () => onUpdateFlag(LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS, false)
return { isEnabled, enable, disable }
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/UnifiedLogsPreview.tsx b/apps/studio/components/interfaces/App/FeaturePreview/UnifiedLogsPreview.tsx
index 981d98ad42e..b757cba8f45 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/UnifiedLogsPreview.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/UnifiedLogsPreview.tsx
@@ -19,6 +19,9 @@ export const UnifiedLogsPreview = () => {
Experience our enhanced logs interface with improved filtering, real-time updates, and a
unified view across all your services. Built for better performance and easier debugging.
+
+ This interface will only be available for organizations on the Team plan or above.
+
Enabling this preview will:
diff --git a/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx b/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx
index b9f02d6b4a0..e29eaa8b793 100644
--- a/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx
+++ b/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx
@@ -91,7 +91,7 @@ export function LogsSidebarMenuV2() {
const { ref } = useParams() as { ref: string }
const warehouseEnabled = useFlag('warehouse')
- const isUnifiedLogsPreviewAvailable = useFlag('unifiedLogs')
+ const unifiedLogsFlagEnabled = useFlag('unifiedLogs')
const { selectFeaturePreview } = useFeaturePreviewModal()
const { enable: enableUnifiedLogs } = useUnifiedLogsPreview()
@@ -115,6 +115,11 @@ export function LogsSidebarMenuV2() {
const { plan: orgPlan, isLoading: isOrgPlanLoading } = useCurrentOrgPlan()
const isFreePlan = !isOrgPlanLoading && orgPlan?.id === 'free'
+ const isUnifiedLogsPreviewAvailable =
+ unifiedLogsFlagEnabled &&
+ !isOrgPlanLoading &&
+ ['team', 'enterprise'].includes(orgPlan?.id ?? '')
+
const { data: savedQueriesRes, isLoading: savedQueriesLoading } = useContentQuery({
projectRef: ref,
type: 'log_sql',