The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(assistant): track chat IDs in PostHog events (#43983)
Matt Rossmanccb12de25bf0
diff --git a/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx b/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsxindex 9916de1310f..b5a3dccff51 100644--- a/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx+++ b/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx@@ -13,7 +13,7 @@ import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/Layimport { useCheckOpenAIKeyQuery } from 'data/ai/check-api-key-query'import { useRateMessageMutation } from 'data/ai/rate-message-mutation'import { useTablesQuery } from 'data/tables/tables-query'-import { useSendEventMutation } from 'data/telemetry/send-event-mutation'+import { useTrack } from 'lib/telemetry/track'import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'import { useOrgAiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi'import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'@@ -142,7 +142,7 @@ export const AIAssistant = ({ className }: AIAssistantProps) => {})}, [project?.ref, project?.connectionString, selectedOrganizationRef.current?.slug, state])- const { mutate: sendEvent } = useSendEventMutation()+ const track = useTrack()const {messages: chatMessages,@@ -234,17 +234,11 @@ export const AIAssistant = ({ className }: AIAssistantProps) => {spanId: state.messageSpanIds[messageId],})- sendEvent({- action: 'assistant_message_rating_submitted',- properties: {- rating,- category: result.category,- ...(reason && { reason }),- },- groups: {- project: project.ref,- organization: selectedOrganization.slug,- },+ track('assistant_message_rating_submitted', {+ rating,+ category: result.category,+ ...(reason && { reason }),+ chatId: state.activeChatId,})} catch (error) {console.error('Failed to rate message:', error)@@ -255,7 +249,7 @@ export const AIAssistant = ({ className }: AIAssistantProps) => {})}},- [chatMessages, project?.ref, selectedOrganization?.slug, rateMessage, sendEvent, state]+ [chatMessages, project?.ref, selectedOrganization?.slug, rateMessage, track, state])const isContextExceededError =@@ -333,21 +327,9 @@ export const AIAssistant = ({ className }: AIAssistantProps) => {setValue('')if (finalContent.includes('Help me to debug')) {- sendEvent({- action: 'assistant_debug_submitted',- groups: {- project: ref ?? 'Unknown',- organization: selectedOrganization?.slug ?? 'Unknown',- },- })+ track('assistant_debug_submitted', { chatId: snap.activeChatId })} else {- sendEvent({- action: 'assistant_prompt_submitted',- groups: {- project: ref ?? 'Unknown',- organization: selectedOrganization?.slug ?? 'Unknown',- },- })+ track('assistant_prompt_submitted', { chatId: snap.activeChatId })}}diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.tsindex 20473e5c35d..4ccbee941c3 100644--- a/packages/common/telemetry-constants.ts+++ b/packages/common/telemetry-constants.ts@@ -667,6 +667,10 @@ export interface SqlEditorResultCopyJsonClickedEvent {*/export interface AssistantPromptSubmittedEvent {action: 'assistant_prompt_submitted'+ properties: {+ /** UUID of the chat session in which the prompt was submitted */+ chatId?: string+ }groups: TelemetryGroups}@@ -678,6 +682,10 @@ export interface AssistantPromptSubmittedEvent {*/export interface AssistantDebugSubmittedEvent {action: 'assistant_debug_submitted'+ properties: {+ /** UUID of the chat session in which the debug request was submitted */+ chatId?: string+ }groups: TelemetryGroups}@@ -1479,6 +1487,10 @@ export interface AssistantMessageRatingSubmittedEvent {| 'debugging'| 'general_help'| 'other'+ /** Optional reason provided by the user when rating negatively */+ reason?: string+ /** UUID of the chat session in which the message was rated */+ chatId?: string}groups: TelemetryGroups}