The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Reinstate SQL editor results events (#33736)
Joshen Limae2203b5e76b
diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsxindex 954059ffb99..27cc2312686 100644--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx@@ -1,9 +1,12 @@import { toast } from 'sonner'import { useParams } from 'common'+import { TelemetryActions } from 'common/telemetry-constants'import { DownloadResultsButton } from 'components/ui/DownloadResultsButton'import { useContentUpsertMutation } from 'data/content/content-upsert-mutation'import { Snippet } from 'data/content/sql-folders-query'+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2'import { TabsContent_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_, Tabs_Shadcn_ } from 'ui'import { ChartConfig } from './ChartConfig'@@ -41,11 +44,14 @@ const UtilityPanel = ({onDebug,}: UtilityPanelProps) => {const { ref } = useParams()+ const org = useSelectedOrganization()const snapV2 = useSqlEditorV2StateSnapshot()const snippet = snapV2.snippets[id]?.snippetconst result = snapV2.results[id]?.[0]+ const { mutate: sendEvent } = useSendEventMutation()+const { mutate: upsertContent } = useContentUpsertMutation({invalidateQueriesOnSuccess: false,// Optimistic update to the cache@@ -119,6 +125,24 @@ const UtilityPanel = ({type="text"results={result.rows as any[]}fileName={`Supabase Snippet ${snippet.name}`}+ onDownloadAsCSV={() =>+ sendEvent({+ action: TelemetryActions.SQL_EDITOR_RESULT_DOWNLOAD_CSV_CLICKED,+ groups: { project: ref ?? '', organization: org?.slug ?? '' },+ })+ }+ onCopyAsMarkdown={() => {+ sendEvent({+ action: TelemetryActions.SQL_EDITOR_RESULT_COPY_MARKDOWN_CLICKED,+ groups: { project: ref ?? '', organization: org?.slug ?? '' },+ })+ }}+ onCopyAsJSON={() => {+ sendEvent({+ action: TelemetryActions.SQL_EDITOR_RESULT_COPY_JSON_CLICKED,+ groups: { project: ref ?? '', organization: org?.slug ?? '' },+ })+ }}/>)}</div>diff --git a/apps/studio/components/ui/DownloadResultsButton.tsx b/apps/studio/components/ui/DownloadResultsButton.tsxindex 2adbc6942c4..eea79d08d1c 100644--- a/apps/studio/components/ui/DownloadResultsButton.tsx+++ b/apps/studio/components/ui/DownloadResultsButton.tsx@@ -18,6 +18,7 @@ interface DownloadResultsButtonProps {align?: 'start' | 'center' | 'end'results: any[]fileName: string+ onDownloadAsCSV?: () => voidonCopyAsMarkdown?: () => voidonCopyAsJSON?: () => void}@@ -27,6 +28,7 @@ export const DownloadResultsButton = ({align = 'start',results,fileName,+ onDownloadAsCSV,onCopyAsMarkdown,onCopyAsJSON,}: DownloadResultsButtonProps) => {@@ -93,6 +95,7 @@ export const DownloadResultsButton = ({onClick={() => {csvRef.current?.link.click()toast.success('Downloading results as CSV')+ onDownloadAsCSV?.()}}><Download size={14} />diff --git a/apps/studio/data/sql/execute-sql-mutation.ts b/apps/studio/data/sql/execute-sql-mutation.tsindex 9486c6c8eb0..01df31c8bc1 100644--- a/apps/studio/data/sql/execute-sql-mutation.ts+++ b/apps/studio/data/sql/execute-sql-mutation.ts@@ -43,7 +43,6 @@ export const useExecuteSqlMutation = ({// [Joshen] Default to false for now, only used for SQL editor to dynamically invalidateif (contextualInvalidation && projectRef) {const invalidationKeys = inferInvalidationKeys(projectRef, sql)- console.log({ invalidationKeys })await Promise.all(invalidationKeys.map((key) => queryClient.invalidateQueries(key)))}await onSuccess?.(data, variables, context)diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.tsindex a8fa96870aa..ece1f7686fa 100644--- a/packages/common/telemetry-constants.ts+++ b/packages/common/telemetry-constants.ts@@ -45,7 +45,7 @@ export enum TelemetryActions {SQL_EDITOR_TEMPLATE_CLICKED = 'sql_editor_template_clicked',SQL_EDITOR_RESULT_DOWNLOAD_CSV_CLICKED = 'sql_editor_result_download_csv_clicked',SQL_EDITOR_RESULT_COPY_MARKDOWN_CLICKED = 'sql_editor_result_copy_markdown_clicked',- SQL_EDITOR_RESULT_COPY_JSON_CLICKED = 'sql_editor_result_copy_markdown_clicked',+ SQL_EDITOR_RESULT_COPY_JSON_CLICKED = 'sql_editor_result_copy_json_clicked',DOCS_FEEDBACK_CLICKED = 'docs_feedback_clicked',