The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
add realtime toggle tracking (#33573)
Saxon Fletcher1f7c7389b42e
diff --git a/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx b/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsxindex 79a8dd44c08..72e3eb1181e 100644--- a/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/GridHeaderActions.tsx@@ -14,6 +14,8 @@ import { useDatabasePoliciesQuery } from 'data/database-policies/database-policiimport { useDatabasePublicationsQuery } from 'data/database-publications/database-publications-query'import { useDatabasePublicationUpdateMutation } from 'data/database-publications/database-publications-update-mutation'import { useProjectLintsQuery } from 'data/lint/lint-query'+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'+import { TelemetryActions } from 'common/telemetry-constants'import {Entity,isTableLike,@@ -39,6 +41,7 @@ import ConfirmModal from 'ui-patterns/Dialogs/ConfirmDialog'import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'import { RoleImpersonationPopover } from '../RoleImpersonationSelector'import ViewEntityAutofixSecurityModal from './ViewEntityAutofixSecurityModal'+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'export interface GridHeaderActionsProps {table: Entity@@ -48,6 +51,7 @@ export interface GridHeaderActionsProps {const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {const { ref } = useParams()const { project } = useProjectContext()+ const org = useSelectedOrganization()// need project lints to get security status for viewsconst { data: lints = [] } = useProjectLintsQuery({@@ -131,6 +135,8 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {table.schema)+ const { mutate: sendEvent } = useSendEventMutation()+const toggleRealtime = async () => {if (!project) return console.error('Project is required')if (!realtimePublication) return console.error('Unable to find realtime publication')@@ -144,6 +150,18 @@ const GridHeaderActions = ({ table }: GridHeaderActionsProps) => {.filter((x: any) => x.id != table.id).map((x: any) => `${x.schema}.${x.name}`)+ sendEvent({+ action: TelemetryActions.REALTIME_TOGGLE_TABLE_CLICKED,+ properties: {+ newState: exists ? 'disabled' : 'enabled',+ origin: 'tableGridHeader',+ },+ groups: {+ project: project?.ref ?? 'Unknown',+ organization: org?.slug ?? 'Unknown',+ },+ })+updatePublications({projectRef: project?.ref,connectionString: project?.connectionString,diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsxindex 053cb75979d..cbd89aa0a32 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx@@ -41,6 +41,9 @@ import {generateTableFieldFromPostgresTable,validateFields,} from './TableEditor.utils'+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'+import { TelemetryActions } from 'common/telemetry-constants'+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'export interface TableEditorProps {table?: PostgresTable@@ -80,9 +83,11 @@ const TableEditor = ({}: TableEditorProps) => {const snap = useTableEditorStateSnapshot()const { project } = useProjectContext()+ const org = useSelectedOrganization()const { selectedSchema } = useQuerySchemaState()const isNewRecord = isUndefined(table)const realtimeEnabled = useIsFeatureEnabled('realtime:all')+ const { mutate: sendEvent } = useSendEventMutation()const [params, setParams] = useUrlState()useEffect(() => {@@ -352,7 +357,20 @@ const TableEditor = ({label="Enable Realtime"description="Broadcast changes on this table to authorized subscribers"checked={tableFields.isRealtimeEnabled}- onChange={() => onUpdateField({ isRealtimeEnabled: !tableFields.isRealtimeEnabled })}+ onChange={() => {+ sendEvent({+ action: TelemetryActions.REALTIME_TOGGLE_TABLE_CLICKED,+ properties: {+ newState: tableFields.isRealtimeEnabled ? 'disabled' : 'enabled',+ origin: 'tableSidePanel',+ },+ groups: {+ project: project?.ref ?? 'Unknown',+ organization: org?.slug ?? 'Unknown',+ },+ })+ onUpdateField({ isRealtimeEnabled: !tableFields.isRealtimeEnabled })+ }}size="medium"/>)}diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.tsindex b6e9cfd7901..a8fa96870aa 100644--- a/packages/common/telemetry-constants.ts+++ b/packages/common/telemetry-constants.ts@@ -39,6 +39,7 @@ export enum TelemetryActions {REALTIME_INSPECTOR_COPY_MESSAGE_CLICKED = 'realtime_inspector_copy_message_clicked',REALTIME_INSPECTOR_FILTERS_APPLIED = 'realtime_inspector_filters_applied',REALTIME_INSPECTOR_DATABASE_ROLE_UPDATED = 'realtime_inspector_database_role_updated',+ REALTIME_TOGGLE_TABLE_CLICKED = 'realtime_toggle_table_clicked',SQL_EDITOR_QUICKSTART_CLICKED = 'sql_editor_quickstart_clicked',SQL_EDITOR_TEMPLATE_CLICKED = 'sql_editor_template_clicked',@@ -485,6 +486,31 @@ export interface RealtimeInspectorDatabaseRoleUpdatedEvent {}}+/**+ * User clicked to toggle realtime on a table.+ *+ * @group Events+ * @source studio+ * @page /dashboard/project/{ref}/editor+ */+export interface RealtimeToggleTableClickedEvent {+ action: TelemetryActions.REALTIME_TOGGLE_TABLE_CLICKED+ properties: {+ /**+ * The state of the toggle.+ */+ newState: 'enabled' | 'disabled'+ /**+ * Where the toggle was clicked from+ */+ origin: 'tableSidePanel' | 'tableGridHeader'+ }+ groups: {+ project: string+ organization: string+ }+}+/*** User clicked the quickstart card in the SQL editor.*@@ -528,7 +554,7 @@ export interface SqlEditorTemplateClickedEvent {}/**- * User clicked the “Result download CSV” button in the SQL editor.+ * User clicked the "Result download CSV" button in the SQL editor.** @group Events* @source studio@@ -543,7 +569,7 @@ export interface SqlEditorResultDownloadCsvClickedEvent {}/**- * User clicked the “Result copy Markdown” button in the SQL editor.+ * User clicked the "Result copy Markdown" button in the SQL editor.** @group Events* @source studio@@ -558,7 +584,7 @@ export interface SqlEditorResultCopyMarkdownClickedEvent {}/**- * User clicked the “Result copy JSON” button in the SQL editor+ * User clicked the "Result copy JSON" button in the SQL editor** @group Events* @source studio@@ -873,7 +899,7 @@ export interface OpenSourceRepoCardClickedEvent {}/**- * User clicked the green “Start Project” button in various locations described in properties.+ * User clicked the green "Start Project" button in various locations described in properties.** @group Events* @source www@@ -1105,6 +1131,7 @@ export type TelemetryEvent =| RealtimeInspectorCopyMessageClickedEvent| RealtimeInspectorFiltersAppliedEvent| RealtimeInspectorDatabaseRoleUpdatedEvent+ | RealtimeToggleTableClickedEvent| SqlEditorQuickstartClickedEvent| SqlEditorTemplateClickedEvent| SqlEditorResultDownloadCsvClickedEvent