The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): add dashboard error events (#41431)
kemal.earth4c3b21107669
diff --git a/apps/studio/components/ui/AlertError.tsx b/apps/studio/components/ui/AlertError.tsxindex c37b2c79b73..09cd64cfaf0 100644--- a/apps/studio/components/ui/AlertError.tsx+++ b/apps/studio/components/ui/AlertError.tsx@@ -1,10 +1,11 @@import { SupportCategories } from '@supabase/shared-types/out/constants'import { SupportLink } from 'components/interfaces/Support/SupportLink'-import { PropsWithChildren } from 'react'+import { PropsWithChildren, useEffect, useRef } from 'react'import { Admonition } from 'ui-patterns/admonition'import { Button } from 'ui'+import { useTrack } from 'lib/telemetry/track'export interface AlertErrorProps {projectRef?: string@@ -52,10 +53,22 @@ export const AlertError = ({children,additionalActions,}: PropsWithChildren<AlertErrorProps>) => {+ const track = useTrack()+ const hasTrackedRef = useRef(false)+const formattedErrorMessage = error?.message?.includes('503')? '503 Service Temporarily Unavailable': error?.message+ useEffect(() => {+ if (!hasTrackedRef.current) {+ hasTrackedRef.current = true+ track('dashboard_error_created', {+ source: 'admonition',+ })+ }+ }, [track])+return (<Admonitiontype="warning"diff --git a/apps/studio/lib/toast-errors.tsx b/apps/studio/lib/toast-errors.tsxnew file mode 100644index 00000000000..6c8724046d4--- /dev/null+++ b/apps/studio/lib/toast-errors.tsx@@ -0,0 +1,22 @@+import { useEffect, useRef } from 'react'+import { useSonner } from 'sonner'+import { useTrack } from 'lib/telemetry/track'++export const ToastErrorTracker = () => {+ const track = useTrack()+ const { toasts } = useSonner()+ const trackRef = useRef(new Set<string | number>())++ useEffect(() => {+ toasts.forEach((toast) => {+ if (toast.type === 'error' && !trackRef.current.has(toast.id)) {+ trackRef.current.add(toast.id)+ track('dashboard_error_created', {+ source: 'toast',+ })+ }+ })+ }, [toasts, track])++ return null+}diff --git a/apps/studio/pages/_app.tsx b/apps/studio/pages/_app.tsxindex 47f66371bd9..c5e43132a0d 100644--- a/apps/studio/pages/_app.tsx+++ b/apps/studio/pages/_app.tsx@@ -61,6 +61,7 @@ import { Telemetry } from 'lib/telemetry'import { AiAssistantStateContextProvider } from 'state/ai-assistant-state'import type { AppPropsWithLayout } from 'types'import { SonnerToaster, TooltipProvider } from 'ui'+import { ToastErrorTracker } from 'lib/toast-errors'dayjs.extend(customParseFormat)dayjs.extend(utc)diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.tsindex 3d8be8c9a00..f9a0eee2e98 100644--- a/packages/common/telemetry-constants.ts+++ b/packages/common/telemetry-constants.ts@@ -2601,6 +2601,24 @@ export interface RequestUpgradeSubmittedEvent {groups: Omit<TelemetryGroups, 'project'>}+/**+ * Triggered when a Studio error UI element is displayed (mounted).+ * This includes error Admonitions and Toast notifications.+ *+ * @group Events+ * @source studio+ */+export interface DashboardErrorCreatedEvent {+ action: 'dashboard_error_created'+ properties: {+ /**+ * Source of the error+ */+ source?: 'admonition' | 'toast'+ }+ groups: TelemetryGroups+}+/*** User successfully installed an integration via the integrations marketplace in the dashboard.* Note: This excludes Wrappers and Postgres Extensions.@@ -2838,6 +2856,7 @@ export type TelemetryEvent =| QueryPerformanceAIExplanationButtonClickedEvent| RequestUpgradeModalOpenedEvent| RequestUpgradeSubmittedEvent+ | DashboardErrorCreatedEvent| IntegrationInstalledEvent| IntegrationInstallStartedEvent| IntegrationUninstallStartedEvent