The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): add a banner to promote unified logs (#46847)
kemal.earth3162cad71501
diff --git a/apps/studio/components/layouts/ProjectLayout/index.test.tsx b/apps/studio/components/layouts/ProjectLayout/index.test.tsxindex adc6ee2d47c..8fca42fbcc8 100644--- a/apps/studio/components/layouts/ProjectLayout/index.test.tsx+++ b/apps/studio/components/layouts/ProjectLayout/index.test.tsx@@ -79,6 +79,7 @@ vi.mock('common', () => ({`free-micro-upgrade-banner-dismissed-${ref}`,PROJECT_INTEGRATION_BANNER_DISMISSED: (ref: string, integrationSource: string) =>`project-integration-banner-dismissed-${ref}-${integrationSource}`,+ UNIFIED_LOGS_BANNER_DISMISSED: 'unified-logs-banner-dismissed',},isFeatureEnabled: () => false,}))@@ -170,7 +171,10 @@ vi.mock('@/hooks/misc/useLocalStorage', () => ({}))vi.mock('@/components/ui/BannerStack/BannerStackProvider', () => ({- BANNER_ID: { FREE_MICRO_UPGRADE: 'free-micro-upgrade-banner' },+ BANNER_ID: {+ FREE_MICRO_UPGRADE: 'free-micro-upgrade-banner',+ UNIFIED_LOGS: 'unified-logs-banner',+ },useBannerStack: () => ({addBanner: mockAddBanner,dismissBanner: mockDismissBanner,@@ -182,6 +186,20 @@ vi.mock('@/components/ui/BannerStack/Banners/BannerFreeMicroUpgrade', () => ({BannerFreeMicroUpgrade: () => null,}))+vi.mock('@/components/ui/BannerStack/Banners/BannerUnifiedLogs', () => ({+ BannerUnifiedLogs: () => null,+}))++vi.mock('@/components/interfaces/App/FeaturePreview/FeaturePreviewContext', () => ({+ useUnifiedLogsPreview: () => ({+ isEnabled: false,+ isEligible: false,+ isLoading: false,+ enable: () => {},+ disable: () => {},+ }),+}))+vi.mock('@/data/usage/resource-warnings-query', () => ({useResourceWarningsQuery: () => ({ data: mockResourceWarningsState.current }),}))diff --git a/apps/studio/components/layouts/ProjectLayout/index.tsx b/apps/studio/components/layouts/ProjectLayout/index.tsxindex 7e831ada5f1..f7de0dd72ad 100644--- a/apps/studio/components/layouts/ProjectLayout/index.tsx+++ b/apps/studio/components/layouts/ProjectLayout/index.tsx@@ -41,9 +41,11 @@ import { RestoreFailedState } from './RestoreFailedState'import { RestoringState } from './RestoringState'import { UnhealthyState } from './UnhealthyState'import { UpgradingState } from './UpgradingState'+import { useUnifiedLogsPreview } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'import { CreateBranchModal } from '@/components/interfaces/BranchManagement/CreateBranchModal'import { ProjectAPIDocs } from '@/components/interfaces/ProjectAPIDocs/ProjectAPIDocs'import { BannerFreeMicroUpgrade } from '@/components/ui/BannerStack/Banners/BannerFreeMicroUpgrade'+import { BannerUnifiedLogs } from '@/components/ui/BannerStack/Banners/BannerUnifiedLogs'import { BANNER_ID, useBannerStack } from '@/components/ui/BannerStack/BannerStackProvider'import { ButtonTooltip } from '@/components/ui/ButtonTooltip'import PartnerIcon from '@/components/ui/PartnerIcon'@@ -155,6 +157,11 @@ export const ProjectLayout = forwardRef<HTMLDivElement, PropsWithChildren<ProjecLOCAL_STORAGE_KEYS.FREE_MICRO_UPGRADE_BANNER_DISMISSED(selectedProject?.ref ?? ''),false)+ const [isUnifiedLogsBannerDismissed] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.UNIFIED_LOGS_BANNER_DISMISSED,+ false+ )+ const { isEligible: showUnifiedLogsBanner } = useUnifiedLogsPreview()const [isProjectIntegrationBannerDismissed, setIsProjectIntegrationBannerDismissed] =useLocalStorageQuery(getProjectIntegrationBannerDismissKey({@@ -232,6 +239,26 @@ export const ProjectLayout = forwardRef<HTMLDivElement, PropsWithChildren<ProjecdismissBanner,])+ useEffect(() => {+ if (!selectedProject?.ref) return+ if (showUnifiedLogsBanner && !isUnifiedLogsBannerDismissed) {+ addBanner({+ id: BANNER_ID.UNIFIED_LOGS,+ isDismissed: false,+ content: <BannerUnifiedLogs />,+ priority: 1,+ })+ } else {+ dismissBanner(BANNER_ID.UNIFIED_LOGS)+ }+ }, [+ selectedProject?.ref,+ showUnifiedLogsBanner,+ isUnifiedLogsBannerDismissed,+ addBanner,+ dismissBanner,+ ])+useLayoutEffect(() => {const unregister = registerOpenMenu(() => {setMobileSheetContent(diff --git a/apps/studio/components/ui/BannerStack/BannerStack.tsx b/apps/studio/components/ui/BannerStack/BannerStack.tsxindex 664f8e40f79..28420784fe6 100644--- a/apps/studio/components/ui/BannerStack/BannerStack.tsx+++ b/apps/studio/components/ui/BannerStack/BannerStack.tsx@@ -1,76 +1,78 @@-import { AnimatePresence, motion } from 'framer-motion'+import { AnimatePresence, motion, useReducedMotion } from 'framer-motion'import { useState } from 'react'import { useBannerStack } from './BannerStackProvider'+const PEEK_OFFSET = 8+const MAX_PEEKS = 2++const SPRING = { type: 'spring', stiffness: 300, damping: 30 } as const+export const BannerStack = () => {const { banners } = useBannerStack()const [isHovered, setIsHovered] = useState(false)+ const reduceMotion = useReducedMotion()const activeBanners = banners.filter((b) => !b.isDismissed)+ if (activeBanners.length === 0) return null- const PEEK_HEIGHT = 4- const CARD_GAP = 4- const CARD_HEIGHT = 212+ const [frontBanner, ...extraBanners] = activeBanners+ const peekCount = Math.min(extraBanners.length, MAX_PEEKS)+ // Deepest sliver first so the closer ones paint on top of it.+ const peeks = Array.from({ length: peekCount }, (_, i) => peekCount - i)- if (activeBanners.length === 0) return null+ const transition = reduceMotion ? { duration: 0 } : SPRINGreturn (<motion.div- className="fixed bottom-4 right-4 z-50"+ className="fixed bottom-4 right-4 z-50 flex flex-col-reverse items-end gap-2"onMouseEnter={() => setIsHovered(true)}onMouseLeave={() => setIsHovered(false)}- animate={{- y: isHovered ? -8 : 0,- }}- transition={{- type: 'spring',- stiffness: 300,- damping: 25,- }}+ animate={{ y: isHovered ? -8 : 0 }}+ transition={transition}>- <div className="relative">- <AnimatePresence mode="popLayout">- {activeBanners.map((banner, index) => {- const isBottomBanner = index === 0- const reverseIndex = activeBanners.length - 1 - index- const collapsedY = index * PEEK_HEIGHT- const expandedY = index * (CARD_HEIGHT + CARD_GAP)-- return (+ <div className="relative w-full max-w-72">+ <AnimatePresence>+ {!isHovered &&+ peeks.map((depth) => (<motion.div- key={banner.id}- initial={{ opacity: 0, scale: 0.99, y: 8 }}- animate={{- opacity: 1,- scale: isHovered ? 1 : 1 - index * 0.07,- x: 0,- y: isHovered ? -expandedY : -collapsedY,- }}- exit={{ opacity: 0, scale: 0.99, y: 8 }}- transition={{- type: 'spring',- stiffness: 300,- damping: 30,- delay: 0.25,- }}- onMouseEnter={() => setIsHovered(true)}- onMouseLeave={() => setIsHovered(false)}- style={{- position: isBottomBanner ? 'relative' : 'absolute',- bottom: isBottomBanner ? undefined : 0,- right: isBottomBanner ? undefined : 0,- zIndex: 30 + reverseIndex,- transformOrigin: 'center bottom',- }}- className="w-full max-w-72"- >- {banner.content}- </motion.div>- )- })}+ key={`peek-${depth}`}+ className="absolute inset-0 rounded-2xl border bg-surface-75 shadow-lg"+ style={{ transformOrigin: 'center top' }}+ initial={{ opacity: 0 }}+ animate={{ opacity: 1, y: -depth * PEEK_OFFSET, scaleX: 1 - depth * 0.06 }}+ exit={{ opacity: 0, y: 0, scaleX: 1 }}+ transition={transition}+ />+ ))}</AnimatePresence>++ <motion.div+ className="relative z-10"+ initial={{ opacity: 0, scale: 0.99, y: 8 }}+ animate={{ opacity: 1, scale: 1, y: 0 }}+ exit={{ opacity: 0, scale: 0.99, y: 8 }}+ transition={transition}+ >+ {frontBanner.content}+ </motion.div></div>++ <AnimatePresence>+ {isHovered &&+ extraBanners.map((banner, index) => (+ <motion.div+ key={banner.id}+ className="w-full max-w-72"+ initial={{ opacity: 0, scale: 0.98, y: 8 }}+ animate={{ opacity: 1, scale: 1, y: 0 }}+ exit={{ opacity: 0, scale: 0.98, y: 8 }}+ transition={reduceMotion ? { duration: 0 } : { ...SPRING, delay: index * 0.04 }}+ >+ {banner.content}+ </motion.div>+ ))}+ </AnimatePresence></motion.div>)}diff --git a/apps/studio/components/ui/BannerStack/BannerStackProvider.tsx b/apps/studio/components/ui/BannerStack/BannerStackProvider.tsxindex eef631513f0..b8aa2e24b7a 100644--- a/apps/studio/components/ui/BannerStack/BannerStackProvider.tsx+++ b/apps/studio/components/ui/BannerStack/BannerStackProvider.tsx@@ -8,6 +8,7 @@ export const BANNER_ID = {RLS_TESTER: 'rls-tester-banner',FREE_MICRO_UPGRADE: 'free-micro-upgrade-banner',TOS_UPDATE: 'tos-update-banner',+ UNIFIED_LOGS: 'unified-logs-banner',} as constexport type BannerId = (typeof BANNER_ID)[keyof typeof BANNER_ID]diff --git a/apps/studio/components/ui/BannerStack/Banners/BannerUnifiedLogs.tsx b/apps/studio/components/ui/BannerStack/Banners/BannerUnifiedLogs.tsxnew file mode 100644index 00000000000..d8317e6b268--- /dev/null+++ b/apps/studio/components/ui/BannerStack/Banners/BannerUnifiedLogs.tsx@@ -0,0 +1,76 @@+import { LOCAL_STORAGE_KEYS } from 'common'+import { useParams } from 'common/hooks'+import Link from 'next/link'+import { Badge, Button } from 'ui'++import { BannerCard } from '../BannerCard'+import { useBannerStack } from '../BannerStackProvider'+import { UnifiedLogsCarousel } from './UnifiedLogsCarousel'+import {+ useFeaturePreviewModal,+ useUnifiedLogsPreview,+} from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'+import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'+import { useTrack } from '@/lib/telemetry/track'++export const BannerUnifiedLogs = () => {+ const { ref } = useParams()+ const track = useTrack()+ const { dismissBanner } = useBannerStack()+ const { isEnabled } = useUnifiedLogsPreview()+ const { selectFeaturePreview } = useFeaturePreviewModal()+ const [, setIsDismissed] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.UNIFIED_LOGS_BANNER_DISMISSED,+ false+ )++ return (+ <BannerCard+ onDismiss={() => {+ setIsDismissed(true)+ dismissBanner('unified-logs-banner')+ track('unified_logs_banner_dismiss_button_clicked')+ }}+ >+ <div className="flex flex-col gap-y-4">+ <div className="flex flex-col gap-y-2 items-start">+ <Badge variant="success" className="-ml-0.5 uppercase inline-flex items-center">+ Beta+ </Badge>+ <div className="-mx-6 w-[calc(100%+3rem)] bg-linear-to-t from-background to-transparent px-6 py-2 border-b">+ <UnifiedLogsCarousel />+ </div>+ </div>+ <div className="flex flex-col gap-y-1 mb-2">+ <p className="text-sm font-medium">Unified Logs is here</p>+ <p className="text-xs text-foreground-lighter text-balance">+ Search and correlate logs across all of your services from a single place.+ </p>+ </div>+ <div className="flex gap-2">+ {isEnabled ? (+ <Button type="default" size="tiny" asChild>+ <Link+ href={`/project/${ref}/logs`}+ onClick={() => track('unified_logs_banner_cta_button_clicked')}+ >+ Explore Unified Logs+ </Link>+ </Button>+ ) : (+ <Button+ type="default"+ size="tiny"+ onClick={() => {+ track('unified_logs_banner_cta_button_clicked')+ selectFeaturePreview(LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS)+ }}+ >+ Enable Unified Logs+ </Button>+ )}+ </div>+ </div>+ </BannerCard>+ )+}diff --git a/apps/studio/components/ui/BannerStack/Banners/UnifiedLogsCarousel.tsx b/apps/studio/components/ui/BannerStack/Banners/UnifiedLogsCarousel.tsxnew file mode 100644index 00000000000..55958c3fb49--- /dev/null+++ b/apps/studio/components/ui/BannerStack/Banners/UnifiedLogsCarousel.tsx@@ -0,0 +1,95 @@+import dayjs from 'dayjs'+import { AnimatePresence, motion } from 'framer-motion'+import { useEffect, useRef, useState } from 'react'+import { cn } from 'ui'++// Number of rows visible in the carousel viewport. We keep one extra row in+// state so the row sliding out of view has something to animate towards.+const VISIBLE_ROWS = 3+const ROW_HEIGHT = 28+const TICK_MS = 3000++const SAMPLES = [200, 200, 201, 200, 304, 400, 200, 500] as const++interface LogEntry {+ id: number+ timestamp: string+ status: number+}++const makeEntry = (id: number, offsetSeconds = 0): LogEntry => ({+ id,+ timestamp: dayjs().subtract(offsetSeconds, 'second').format('DD MMM YY HH:mm:ss'),+ status: SAMPLES[id % SAMPLES.length],+})++const LogRow = ({ entry }: { entry: LogEntry }) => {+ const isDestructive = entry.status >= 500+ const isWarning = entry.status >= 400 && entry.status < 500+ return (+ <div+ className="flex items-center gap-x-3 font-mono text-xs whitespace-nowrap text-foreground-light"+ style={{ height: ROW_HEIGHT }}+ >+ <span+ className={cn(+ 'size-1.5 shrink-0 rounded-full bg-foreground-muted',+ isWarning && 'bg-warning',+ isDestructive && 'bg-destructive'+ )}+ />+ <span+ className={cn(+ 'tabular-nums',+ isWarning && 'text-warning',+ isDestructive && 'text-destructive'+ )}+ >+ {entry.timestamp}+ </span>+ <span+ className={cn(+ 'tabular-nums',+ isWarning && 'text-warning',+ isDestructive && 'text-destructive'+ )}+ >+ {entry.status}+ </span>+ </div>+ )+}++export const UnifiedLogsCarousel = () => {+ const counter = useRef(VISIBLE_ROWS)+ const [logs, setLogs] = useState<LogEntry[]>(() =>+ Array.from({ length: VISIBLE_ROWS + 1 }, (_, i) => makeEntry(VISIBLE_ROWS - i, i))+ )++ useEffect(() => {+ const interval = setInterval(() => {+ counter.current += 1+ const next = makeEntry(counter.current)+ setLogs((prev) => [next, ...prev].slice(0, VISIBLE_ROWS + 1))+ }, TICK_MS)+ return () => clearInterval(interval)+ }, [])++ return (+ <div className="relative w-full overflow-hidden" style={{ height: ROW_HEIGHT * VISIBLE_ROWS }}>+ <AnimatePresence initial={false}>+ {logs.map((entry, index) => (+ <motion.div+ key={entry.id}+ layout+ initial={{ opacity: 0 }}+ animate={{ opacity: Math.max(1 - index * 0.4, 0) }}+ exit={{ opacity: 0 }}+ >+ <LogRow entry={entry} />+ </motion.div>+ ))}+ </AnimatePresence>+ </div>+ )+}diff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.tsindex 415dcf936d8..2c370016f34 100644--- a/packages/common/constants/local-storage.ts+++ b/packages/common/constants/local-storage.ts@@ -116,6 +116,7 @@ export const LOCAL_STORAGE_KEYS = {`table-editor-queue-operations-banner-dismissed-${ref}`,FREE_MICRO_UPGRADE_BANNER_DISMISSED: (ref: string) =>`free-micro-upgrade-banner-dismissed-${ref}`,+ UNIFIED_LOGS_BANNER_DISMISSED: 'unified-logs-banner-dismissed',STORAGE_PUBLIC_BUCKET_SELECT_POLICY_WARNING_DISMISSED: (ref: string, bucketId: string) =>`storage-public-bucket-select-policy-warning-dismissed-${ref}-${bucketId}`,diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.tsindex f90428deb79..45de2d9d97a 100644--- a/packages/common/telemetry-constants.ts+++ b/packages/common/telemetry-constants.ts@@ -1245,6 +1245,30 @@ export interface MetricsAPIBannerDismissButtonClickedEvent {groups: TelemetryGroups}+/**+ * User clicks on the Unified Logs banner CTA button in studio project pages.+ *+ * @group Events+ * @source studio+ * @page /project/[ref]/*+ */+export interface UnifiedLogsBannerCtaButtonClickedEvent {+ action: 'unified_logs_banner_cta_button_clicked'+ groups: TelemetryGroups+}++/**+ * User clicked the dismiss button on the Unified Logs banner in studio project pages.+ *+ * @group Events+ * @source studio+ * @page /project/[ref]/*+ */+export interface UnifiedLogsBannerDismissButtonClickedEvent {+ action: 'unified_logs_banner_dismiss_button_clicked'+ groups: TelemetryGroups+}+/*** User clicked the enable button for Index Advisor, either from the banner or the confirmation dialog.*@@ -3466,6 +3490,8 @@ export type TelemetryEvent =| ReportsDatabaseGrafanaBannerClickedEvent| MetricsAPIBannerCtaButtonClickedEvent| MetricsAPIBannerDismissButtonClickedEvent+ | UnifiedLogsBannerCtaButtonClickedEvent+ | UnifiedLogsBannerDismissButtonClickedEvent| IndexAdvisorEnableButtonClickedEvent| IndexAdvisorBannerDismissButtonClickedEvent| IndexAdvisorTabClickedEvent