Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Standardize PH events (#31067)

Joshen Limec72485ca9e1
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
index c04cdd98f66..f6423222942 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
@@ -4,7 +4,7 @@ import { useEffect, useState } from 'react'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useFlag } from 'hooks/ui/useFlag'
-import { TELEMETRY_EVENTS } from 'lib/constants/telemetry'
+import { TelemetryActions } from 'lib/constants/telemetry'
import { useAppStateSnapshot } from 'state/app-state'
import { Badge, Button, Modal, ScrollArea, cn } from 'ui'
import { FEATURE_PREVIEWS, useFeaturePreviewContext } from './FeaturePreviewContext'
@@ -37,9 +37,10 @@ const FeaturePreviewModal = () => {
const toggleFeature = () => {
onUpdateFlag(selectedFeatureKey, !isSelectedFeatureEnabled)
sendEvent({
- action: TELEMETRY_EVENTS.FEATURE_PREVIEWS,
- label: selectedFeatureKey,
- value: isSelectedFeatureEnabled ? 'disabled' : 'enabled',
+ action: isSelectedFeatureEnabled
+ ? TelemetryActions.FEATURE_PREVIEW_DISABLED
+ : TelemetryActions.FEATURE_PREVIEW_ENABLED,
+ properties: { feature: selectedFeatureKey },
})
}
diff --git a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
index 7fea9fd2029..b2c0b6d8a8b 100644
--- a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
+++ b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx
@@ -10,6 +10,7 @@ import { usePoolingConfigurationQuery } from 'data/database/pooling-configuratio
import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'
import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import { TelemetryActions } from 'lib/constants/telemetry'
import { pluckObjectFields } from 'lib/helpers'
import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
import {
@@ -93,11 +94,10 @@ export const DatabaseConnectionString = () => {
const connectionInfo = pluckObjectFields(selectedDatabase || emptyState, DB_FIELDS)
const handleCopy = (id: string) => {
- const labelValue = DATABASE_CONNECTION_TYPES.find((type) => type.id === id)?.label
+ const connectionType = DATABASE_CONNECTION_TYPES.find((type) => type.id === id)?.label
sendEvent({
- category: 'settings',
- action: 'copy_connection_string',
- label: labelValue ?? '',
+ action: TelemetryActions.CONNECTION_STRING_COPIED,
+ properties: { connectionType },
})
}
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CreateCronJobSheet.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CreateCronJobSheet.tsx
index 1088e079d95..3d90ab978d5 100644
--- a/apps/studio/components/interfaces/Integrations/CronJobs/CreateCronJobSheet.tsx
+++ b/apps/studio/components/interfaces/Integrations/CronJobs/CreateCronJobSheet.tsx
@@ -15,7 +15,7 @@ import { CronJob, useCronJobsQuery } from 'data/database-cron-jobs/database-cron
import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
-import { TELEMETRY_EVENTS, TELEMETRY_VALUES } from 'lib/constants/telemetry'
+import { TelemetryActions } from 'lib/constants/telemetry'
import {
Button,
Form_Shadcn_,
@@ -264,16 +264,13 @@ export const CreateCronJobSheet = ({
toast.success(`Successfully created cron job ${name}`)
}
- // We should allow sending custom properties with events
sendEvent({
- action: TELEMETRY_EVENTS.CRON_JOBS,
- value: isEditing
- ? TELEMETRY_VALUES.CRON_JOB_UPDATED
- : TELEMETRY_VALUES.CRON_JOB_CREATED,
- label: isEditing ? 'Cron job was updated' : 'Cron job was created',
+ action: isEditing
+ ? TelemetryActions.CRON_JOB_UPDATED
+ : TelemetryActions.CRON_JOB_CREATED,
properties: {
- cron_job_type: values.type,
- cron_job_schedule: schedule,
+ type: values.type,
+ schedule: schedule,
},
})
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobCard.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobCard.tsx
index d4acb0c9c80..b5f316f2b65 100644
--- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobCard.tsx
+++ b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobCard.tsx
@@ -9,7 +9,7 @@ import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectConte
import { CronJob } from 'data/database-cron-jobs/database-cron-jobs-query'
import { useDatabaseCronJobToggleMutation } from 'data/database-cron-jobs/database-cron-jobs-toggle-mutation'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
-import { TELEMETRY_EVENTS, TELEMETRY_VALUES } from 'lib/constants/telemetry'
+import { TelemetryActions } from 'lib/constants/telemetry'
import {
Button,
DropdownMenu,
@@ -78,11 +78,7 @@ export const CronJobCard = ({ job, onEditCronJob, onDeleteCronJob }: CronJobCard
type="default"
icon={<History />}
onClick={() => {
- sendEvent({
- action: TELEMETRY_EVENTS.CRON_JOBS,
- value: TELEMETRY_VALUES.CRON_JOBS_VIEW_PREVIOUS_RUNS,
- label: 'User clicked view previous runs button',
- })
+ sendEvent({ action: TelemetryActions.CRON_JOBS_VIEW_PREVIOUS_RUNS_CLICKED })
}}
>
<Link href={`/project/${ref}/integrations/cron/jobs/${job.jobname}`}>History</Link>
@@ -94,11 +90,7 @@ export const CronJobCard = ({ job, onEditCronJob, onDeleteCronJob }: CronJobCard
<DropdownMenuContent align="end" className="w-36">
<DropdownMenuItem
onClick={() => {
- sendEvent({
- action: TELEMETRY_EVENTS.CRON_JOBS,
- value: TELEMETRY_VALUES.CRON_JOB_UPDATE_CLICKED,
- label: 'User clicked edit cron job button',
- })
+ sendEvent({ action: TelemetryActions.CRON_JOB_UPDATE_CLICKED })
onEditCronJob(job)
}}
>
@@ -107,11 +99,7 @@ export const CronJobCard = ({ job, onEditCronJob, onDeleteCronJob }: CronJobCard
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => {
- sendEvent({
- action: TELEMETRY_EVENTS.CRON_JOBS,
- value: TELEMETRY_VALUES.CRON_JOB_DELETE_CLICKED,
- label: 'User clicked delete cron job button',
- })
+ sendEvent({ action: TelemetryActions.CRON_JOB_DELETE_CLICKED })
onDeleteCronJob(job)
}}
>
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsTab.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsTab.tsx
index 510c8542644..96952fd468e 100644
--- a/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsTab.tsx
+++ b/apps/studio/components/interfaces/Integrations/CronJobs/CronJobsTab.tsx
@@ -8,7 +8,7 @@ import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { CronJob, useCronJobsQuery } from 'data/database-cron-jobs/database-cron-jobs-query'
import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-extensions-query'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
-import { TELEMETRY_EVENTS, TELEMETRY_VALUES } from 'lib/constants/telemetry'
+import { TelemetryActions } from 'lib/constants/telemetry'
import { Button, Input, Sheet, SheetContent } from 'ui'
import { CronJobCard } from './CronJobCard'
import { DeleteCronJob } from './DeleteCronJob'
@@ -63,11 +63,7 @@ export const CronjobsTab = () => {
const filteredCronJobs = (cronJobs ?? []).filter((cj) => cj?.jobname?.includes(searchQuery || ''))
const onOpenCreateJobSheet = () => {
- sendEvent({
- action: TELEMETRY_EVENTS.CRON_JOBS,
- value: TELEMETRY_VALUES.CRON_JOB_CREATE_CLICKED,
- label: 'User clicked create job',
- })
+ sendEvent({ action: TelemetryActions.CRON_JOB_CREATE_CLICKED })
setCreateCronJobSheetShown(true)
}
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/DeleteCronJob.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/DeleteCronJob.tsx
index 63702a500da..41e333b7dae 100644
--- a/apps/studio/components/interfaces/Integrations/CronJobs/DeleteCronJob.tsx
+++ b/apps/studio/components/interfaces/Integrations/CronJobs/DeleteCronJob.tsx
@@ -3,9 +3,9 @@ import { toast } from 'sonner'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { useDatabaseCronJobDeleteMutation } from 'data/database-cron-jobs/database-cron-jobs-delete-mutation'
import { CronJob } from 'data/database-cron-jobs/database-cron-jobs-query'
-import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
-import { TELEMETRY_EVENTS, TELEMETRY_VALUES } from 'lib/constants/telemetry'
+import { TelemetryActions } from 'lib/constants/telemetry'
+import TextConfirmModal from 'ui-patterns/Dialogs/TextConfirmModal'
interface DeleteCronJobProps {
cronJob: CronJob
@@ -19,11 +19,7 @@ export const DeleteCronJob = ({ cronJob, visible, onClose }: DeleteCronJobProps)
const { mutate: sendEvent } = useSendEventMutation()
const { mutate: deleteDatabaseCronJob, isLoading } = useDatabaseCronJobDeleteMutation({
onSuccess: () => {
- sendEvent({
- action: TELEMETRY_EVENTS.CRON_JOBS,
- value: TELEMETRY_VALUES.CRON_JOB_DELETED,
- label: 'User deleted cron job',
- })
+ sendEvent({ action: TelemetryActions.CRON_JOB_DELETED })
toast.success(`Successfully removed cron job ${cronJob.jobname}`)
onClose()
},
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/ChooseChannelPopover/index.tsx b/apps/studio/components/interfaces/Realtime/Inspector/ChooseChannelPopover/index.tsx
index 463f700c670..fd6b45f9ca6 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/ChooseChannelPopover/index.tsx
+++ b/apps/studio/components/interfaces/Realtime/Inspector/ChooseChannelPopover/index.tsx
@@ -21,6 +21,7 @@ import {
} from 'ui'
import { RealtimeConfig } from '../useRealtimeMessages'
import { DocsButton } from 'components/ui/DocsButton'
+import { TelemetryActions } from 'lib/constants/telemetry'
interface ChooseChannelPopoverProps {
config: RealtimeConfig
@@ -51,11 +52,7 @@ export const ChooseChannelPopover = ({ config, onChangeConfig }: ChooseChannelPo
const onSubmit = () => {
setOpen(false)
- sendEvent({
- category: 'realtime_inspector',
- action: 'started_listening_to_channel_in_input_channel_popover',
- label: 'realtime_inspector_config',
- })
+ sendEvent({ action: TelemetryActions.REALTIME_INSPECTOR_LISTEN_CHANNEL_CLICKED })
onChangeConfig({
...config,
channelName: form.getValues('channel'),
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/Header.tsx b/apps/studio/components/interfaces/Realtime/Inspector/Header.tsx
index e953b6b310e..637bca2ce23 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/Header.tsx
+++ b/apps/studio/components/interfaces/Realtime/Inspector/Header.tsx
@@ -3,6 +3,7 @@ import { PlayCircle, StopCircle } from 'lucide-react'
import { Dispatch, SetStateAction } from 'react'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import { TelemetryActions } from 'lib/constants/telemetry'
import { Button } from 'ui'
import { ChooseChannelPopover } from './ChooseChannelPopover'
import { RealtimeFilterPopover } from './RealtimeFilterPopover'
@@ -34,11 +35,7 @@ export const Header = ({ config, onChangeConfig }: HeaderProps) => {
onChangeConfig({ ...config, enabled: !config.enabled })
if (!config.enabled) {
// the user has clicked to start listening
- sendEvent({
- category: 'realtime_inspector',
- action: 'started_listening',
- label: 'realtime_inspector_config',
- })
+ sendEvent({ action: TelemetryActions.REALTIME_INSPECTOR_LISTEN_CHANNEL_CLICKED })
}
}}
>
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/MessageSelection.tsx b/apps/studio/components/interfaces/Realtime/Inspector/MessageSelection.tsx
index facba5b2015..12b94305a53 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/MessageSelection.tsx
+++ b/apps/studio/components/interfaces/Realtime/Inspector/MessageSelection.tsx
@@ -6,6 +6,7 @@ import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { Button, cn } from 'ui'
import type { LogData } from './Messages.types'
import { SelectedRealtimeMessagePanel } from './SelectedRealtimeMessagePanel'
+import { TelemetryActions } from 'lib/constants/telemetry'
export interface MessageSelectionProps {
log: LogData | null
@@ -73,11 +74,7 @@ const MessageSelection = ({ log, onClose }: MessageSelectionProps) => {
type="default"
title="Copy log to clipboard"
onClick={() => {
- sendEvent({
- category: 'realtime_inspector',
- action: 'copied_message',
- label: 'realtime_inspector_results',
- })
+ sendEvent({ action: TelemetryActions.REALTIME_INSPECTOR_COPY_MESSAGE_CLICKED })
}}
/>
</div>
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/MessagesTable.tsx b/apps/studio/components/interfaces/Realtime/Inspector/MessagesTable.tsx
index b70c6d08831..bf2d3378d90 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/MessagesTable.tsx
+++ b/apps/studio/components/interfaces/Realtime/Inspector/MessagesTable.tsx
@@ -13,6 +13,7 @@ import type { LogData } from './Messages.types'
import NoChannelEmptyState from './NoChannelEmptyState'
import { ColumnRenderer } from './RealtimeMessageColumnRenderer'
import { DocsButton } from 'components/ui/DocsButton'
+import { TelemetryActions } from 'lib/constants/telemetry'
export const isErrorLog = (l: LogData) => {
return l.message === 'SYSTEM' && l.metadata?.status === 'error'
@@ -177,11 +178,7 @@ const MessagesTable = ({
isRowSelected={false}
selectedCellIdx={undefined}
onClick={() => {
- sendEvent({
- category: 'realtime_inspector',
- action: 'focused-specific-message',
- label: 'realtime_inspector_results',
- })
+ sendEvent({ action: TelemetryActions.REALTIME_INSPECTOR_MESSAGE_CLICKED })
setFocusedLog(row)
}}
/>
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/RealtimeFilterPopover/index.tsx b/apps/studio/components/interfaces/Realtime/Inspector/RealtimeFilterPopover/index.tsx
index d8b7e5e90ef..d78a39de764 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/RealtimeFilterPopover/index.tsx
+++ b/apps/studio/components/interfaces/Realtime/Inspector/RealtimeFilterPopover/index.tsx
@@ -20,6 +20,7 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { RealtimeConfig } from '../useRealtimeMessages'
import { FilterSchema } from './FilterSchema'
import { FilterTable } from './FilterTable'
+import { TelemetryActions } from 'lib/constants/telemetry'
interface RealtimeFilterPopoverProps {
config: RealtimeConfig
@@ -200,11 +201,7 @@ export const RealtimeFilterPopover = ({ config, onChangeConfig }: RealtimeFilter
visible={applyConfigOpen}
onCancel={() => setApplyConfigOpen(false)}
onConfirm={() => {
- sendEvent({
- category: 'realtime_inspector',
- action: 'applied_filters',
- label: 'realtime_inspector_config',
- })
+ sendEvent({ action: TelemetryActions.REALTIME_INSPECTOR_FILTERS_APPLIED })
onChangeConfig(tempConfig)
setApplyConfigOpen(false)
setOpen(false)
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/RealtimeTokensPopover/index.tsx b/apps/studio/components/interfaces/Realtime/Inspector/RealtimeTokensPopover/index.tsx
index fa395823fd3..637a00827ef 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/RealtimeTokensPopover/index.tsx
+++ b/apps/studio/components/interfaces/Realtime/Inspector/RealtimeTokensPopover/index.tsx
@@ -6,6 +6,7 @@ import { useProjectPostgrestConfigQuery } from 'data/config/project-postgrest-co
import { getAPIKeys, useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { IS_PLATFORM } from 'lib/constants'
+import { TelemetryActions } from 'lib/constants/telemetry'
import { getRoleImpersonationJWT } from 'lib/role-impersonation'
import { useRoleImpersonationStateSnapshot } from 'state/role-impersonation-state'
import { RealtimeConfig } from '../useRealtimeMessages'
@@ -34,13 +35,10 @@ export const RealtimeTokensPopover = ({ config, onChangeConfig }: RealtimeTokens
useEffect(() => {
if (isMounted.current) {
- sendEvent({
- category: 'realtime_inspector',
- action: 'changed_database_role',
- label: 'realtime_inspector_config',
- })
+ sendEvent({ action: TelemetryActions.REALTIME_INSPECTOR_DATABASE_ROLE_UPDATED })
}
isMounted.current = true
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [snap.role])
useEffect(() => {
@@ -67,6 +65,7 @@ export const RealtimeTokensPopover = ({ config, onChangeConfig }: RealtimeTokens
}
triggerUpdateTokenBearer()
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [snap.role, anonKey, serviceKey])
return <RoleImpersonationPopover align="start" variant="connected-on-both" />
diff --git a/apps/studio/components/interfaces/Realtime/Inspector/index.tsx b/apps/studio/components/interfaces/Realtime/Inspector/index.tsx
index 5e4eec941ae..ef289600bcf 100644
--- a/apps/studio/components/interfaces/Realtime/Inspector/index.tsx
+++ b/apps/studio/components/interfaces/Realtime/Inspector/index.tsx
@@ -2,6 +2,7 @@ import { useParams } from 'common'
import { useState } from 'react'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import { TelemetryActions } from 'lib/constants/telemetry'
import { Header } from './Header'
import MessagesTable from './MessagesTable'
import { SendMessageModal } from './SendMessageModal'
@@ -50,11 +51,7 @@ export const RealtimeInspector = () => {
visible={sendMessageShown}
onSelectCancel={() => setSendMessageShown(false)}
onSelectConfirm={(v) => {
- sendEvent({
- category: 'realtime_inspector',
- action: 'send_broadcast_message',
- label: 'realtime_inspector_results',
- })
+ sendEvent({ action: TelemetryActions.REALTIME_INSPECTOR_BROADCAST_SENT })
sendMessage(v.message, v.payload, () => setSendMessageShown(false))
}}
/>
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
index fd6408d24b0..3fda4b48718 100644
--- a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
@@ -26,6 +26,7 @@ import { useSchemasForAi } from 'hooks/misc/useSchemasForAi'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
import { IS_PLATFORM, LOCAL_STORAGE_KEYS } from 'lib/constants'
+import { TelemetryActions } from 'lib/constants/telemetry'
import { uuidv4 } from 'lib/helpers'
import { useProfile } from 'lib/profile'
import { wrapWithRoleImpersonation } from 'lib/role-impersonation'
@@ -450,11 +451,7 @@ export const SQLEditor = () => {
}
}
- sendEvent({
- category: 'sql_editor',
- action: 'ai_suggestion_accepted',
- label: 'edit_snippet',
- })
+ sendEvent({ action: TelemetryActions.ASSISTANT_SUGGESTION_ACCEPTED })
setSelectedDiffType(DiffType.Modification)
setSourceSqlDiff(undefined)
@@ -474,12 +471,7 @@ export const SQLEditor = () => {
])
const discardAiHandler = useCallback(() => {
- sendEvent({
- category: 'sql_editor',
- action: 'ai_suggestion_rejected',
- label: 'edit_snippet',
- })
-
+ sendEvent({ action: TelemetryActions.ASSISTANT_SUGGESTION_REJECTED })
setSourceSqlDiff(undefined)
setPendingTitle(undefined)
}, [router])
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx
index f0fc3ed86ef..bab650bf1db 100644
--- a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLQuickstarts.tsx
@@ -8,6 +8,7 @@ import { SQL_TEMPLATES } from 'components/interfaces/SQLEditor/SQLEditor.queries
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
+import { TelemetryActions } from 'lib/constants/telemetry'
import { uuidv4 } from 'lib/helpers'
import { useProfile } from 'lib/profile'
import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2'
@@ -76,9 +77,8 @@ const SQLQuickstarts = () => {
onClick={(sql, title) => {
handleNewQuery(sql, title)
sendEvent({
- category: 'quickstart',
- action: 'quickstart_clicked',
- label: x.title,
+ action: TelemetryActions.SQL_EDITOR_QUICKSTART_CLICKED,
+ properties: { title },
})
}}
/>
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx
index fd3c18223f6..df51faca0d2 100644
--- a/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/SQLTemplates/SQLTemplates.tsx
@@ -13,6 +13,7 @@ import { useProfile } from 'lib/profile'
import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2'
import { createSqlSnippetSkeletonV2 } from '../SQLEditor.utils'
import SQLCard from './SQLCard'
+import { TelemetryActions } from 'lib/constants/telemetry'
const SQLTemplates = () => {
const router = useRouter()
@@ -76,9 +77,8 @@ const SQLTemplates = () => {
onClick={(sql, title) => {
handleNewQuery(sql, title)
sendEvent({
- category: 'scripts',
- action: 'script_clicked',
- label: x.title,
+ action: TelemetryActions.SQL_EDITOR_TEMPLATE_CLICKED,
+ properties: { title },
})
}}
/>
diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/ResultsDropdown.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/ResultsDropdown.tsx
index 0e08655db60..3a81ef9f474 100644
--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/ResultsDropdown.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/ResultsDropdown.tsx
@@ -16,6 +16,7 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from 'ui'
+import { TelemetryActions } from 'lib/constants/telemetry'
export type ResultsDropdownProps = {
id: string
@@ -66,7 +67,7 @@ const ResultsDropdown = ({ id }: ResultsDropdownProps) => {
function onDownloadCSV() {
csvRef.current?.link.click()
- sendEvent({ category: 'sql_editor', action: 'sql_download_csv', label: '' })
+ sendEvent({ action: TelemetryActions.SQL_EDITOR_RESULT_DOWNLOAD_CSV_CLICKED })
}
function onCopyAsMarkdown() {
@@ -86,7 +87,7 @@ const ResultsDropdown = ({ id }: ResultsDropdownProps) => {
copyToClipboard(markdownData, () => {
toast.success('Copied results to clipboard')
- sendEvent({ category: 'sql_editor', action: 'sql_copy_as_markdown', label: '' })
+ sendEvent({ action: TelemetryActions.SQL_EDITOR_RESULT_COPY_MARKDOWN_CLICKED })
})
}
}
@@ -99,7 +100,7 @@ const ResultsDropdown = ({ id }: ResultsDropdownProps) => {
copyToClipboard(JSON.stringify(result.rows, null, 2), () => {
toast.success('Copied results to clipboard')
- sendEvent({ category: 'sql_editor', action: 'sql_copy_as_json', label: '' })
+ sendEvent({ action: TelemetryActions.SQL_EDITOR_RESULT_COPY_JSON_CLICKED })
})
}
}
diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx
index 14793602a19..d980728ce25 100644
--- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseConnectionString.tsx
@@ -40,6 +40,7 @@ import {
getConnectionStrings,
getPoolerTld,
} from './DatabaseSettings.utils'
+import { TelemetryActions } from 'lib/constants/telemetry'
const CONNECTION_TYPES = [
{ id: 'uri', label: 'URI' },
@@ -104,12 +105,8 @@ export const DatabaseConnectionString = ({ appearance }: DatabaseConnectionStrin
: 'co'
const handleCopy = (id: string) => {
- const labelValue = CONNECTION_TYPES.find((type) => type.id === id)?.label
- sendEvent({
- category: 'settings',
- action: 'copy_connection_string',
- label: labelValue ? labelValue : '',
- })
+ const connectionType = CONNECTION_TYPES.find((type) => type.id === id)?.label
+ sendEvent({ action: TelemetryActions.CONNECTION_STRING_COPIED, properties: { connectionType } })
}
const connectionStrings =
diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx
index 9fb82b60a3f..8af5db0eb03 100644
--- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/DatabaseSettings.tsx
@@ -20,8 +20,10 @@ import {
IPv4DeprecationNotice,
} from '../DatabaseConnectionNotices'
import { UsePoolerCheckbox } from '../UsePoolerCheckbox'
-import ResetDbPassword from './ResetDbPassword'
+/**O
+ * @deprecated Will be removed once `connectDialogUpdate` flag is persisted
+ */
const DatabaseSettings = () => {
const { ref: projectRef, connectionString } = useParams()
const snap = useDatabaseSettingsStateSnapshot()
@@ -81,13 +83,6 @@ const DatabaseSettings = () => {
}
: dbConnectionInfo
- const handleCopy = (labelValue?: string) =>
- sendEvent({
- category: 'settings',
- action: 'copy_connection_string',
- label: labelValue ? labelValue : '',
- })
-
useEffect(() => {
if (connectionString !== undefined && connectionStringsRef.current !== undefined) {
state.setSelectedDatabaseId(connectionString)
@@ -166,9 +161,6 @@ const DatabaseSettings = () => {
disabled
value={connectionInfo.db_host}
label="Host"
- onCopy={() => {
- handleCopy('Host')
- }}
/>
<Input
className="input-mono"
diff --git a/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx b/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx
index 1371592b395..8bba8a7456b 100644
--- a/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx
+++ b/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx
@@ -10,7 +10,6 @@ import AlertError from 'components/ui/AlertError'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useMfaChallengeAndVerifyMutation } from 'data/profile/mfa-challenge-and-verify-mutation'
import { useMfaListFactorsQuery } from 'data/profile/mfa-list-factors-query'
-import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useSignOut } from 'lib/auth'
import { getReturnToPath } from 'lib/gotrue'
import { Button, Form, Input } from 'ui'
@@ -25,8 +24,6 @@ const SignInMfaForm = () => {
const queryClient = useQueryClient()
const [selectedFactor, setSelectedFactor] = useState<Factor | null>(null)
- const { mutate: sendEvent } = useSendEventMutation()
-
const {
data: factors,
error: factorsError,
@@ -40,7 +37,6 @@ const SignInMfaForm = () => {
isSuccess,
} = useMfaChallengeAndVerifyMutation({
onSuccess: async () => {
- sendEvent({ category: 'account', action: 'sign_in', label: '' })
await queryClient.resetQueries()
router.push(getReturnToPath())
},
diff --git a/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx b/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx
index 78e1b2d1a5e..2bb77ae57da 100644
--- a/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx
+++ b/apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx
@@ -1,8 +1,8 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { AnimatePresence, motion } from 'framer-motion'
import { last } from 'lodash'
-import { FileText, Info, X, ArrowDown } from 'lucide-react'
-import { memo, useEffect, useMemo, useRef, useState, useCallback } from 'react'
+import { ArrowDown, FileText, Info, X } from 'lucide-react'
+import { memo, useEffect, useMemo, useRef, useState } from 'react'
import { toast } from 'sonner'
import type { Message as MessageType } from 'ai/react'
@@ -24,7 +24,7 @@ import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
import { useFlag } from 'hooks/ui/useFlag'
import { BASE_PATH, IS_PLATFORM, OPT_IN_TAGS } from 'lib/constants'
-import { TELEMETRY_EVENTS, TELEMETRY_VALUES } from 'lib/constants/telemetry'
+import { TelemetryActions } from 'lib/constants/telemetry'
import uuidv4 from 'lib/uuid'
import { useRouter } from 'next/router'
import { useAppStateSnapshot } from 'state/app-state'
@@ -118,11 +118,10 @@ export const AIAssistant = ({
const currentSchema = searchParams?.get('schema') ?? 'public'
const { mutate: sendEvent } = useSendEventMutation()
- const sendTelemetryEvent = (value: string) => {
+ const sendTelemetryEvent = (action: TelemetryActions) => {
sendEvent({
- value,
- action: TELEMETRY_EVENTS.AI_ASSISTANT_V2,
- ...((sqlSnippets ?? []).length > 0 ? { label: 'context-added' } : {}),
+ action,
+ properties: { contextAdded: (sqlSnippets ?? []).length > 0 },
})
}
@@ -195,9 +194,9 @@ export const AIAssistant = ({
setLastSentMessage(payload)
if (content.includes('Help me to debug')) {
- sendTelemetryEvent(TELEMETRY_VALUES.DEBUG_SUBMITTED)
+ sendTelemetryEvent(TelemetryActions.ASSISTANT_DEBUG_SUBMITTED)
} else {
- sendTelemetryEvent(TELEMETRY_VALUES.PROMPT_SUBMITTED)
+ sendTelemetryEvent(TelemetryActions.ASSISTANT_PROMPT_SUBMITTED)
}
}
diff --git a/apps/studio/components/ui/AIAssistantPanel/MessagePre.tsx b/apps/studio/components/ui/AIAssistantPanel/MessagePre.tsx
deleted file mode 100644
index bd392a584b6..00000000000
--- a/apps/studio/components/ui/AIAssistantPanel/MessagePre.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-import { InsertCode } from 'icons'
-import { Check, Copy, Edit } from 'lucide-react'
-import { useEffect, useState } from 'react'
-import { format } from 'sql-formatter'
-import {
- Button,
- CodeBlock,
- TooltipContent_Shadcn_,
- TooltipTrigger_Shadcn_,
- Tooltip_Shadcn_,
- cn,
-} from 'ui'
-
-import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
-import { DiffType } from 'components/interfaces/SQLEditor/SQLEditor.types'
-
-interface MessagePreProps {
- onDiff: (type: DiffType, s: string) => void
- children: string[]
- className?: string
-}
-
-export const MessagePre = ({ onDiff, children, className }: MessagePreProps) => {
- const [copied, setCopied] = useState(false)
-
- const { mutate: sendEvent } = useSendEventMutation()
-
- useEffect(() => {
- if (!copied) return
- const timer = setTimeout(() => setCopied(false), 2000)
- return () => clearTimeout(timer)
- }, [copied])
-
- let formatted = (children || [''])[0]
- try {
- formatted = format(formatted, { language: 'postgresql', keywordCase: 'upper' })
- } catch {}
-
- if (formatted.length === 0) {
- return null
- }
-
- function handleCopy(formatted: string) {
- navigator.clipboard.writeText(formatted).then()
- setCopied(true)
- }
-
- return (
- <pre className={cn('rounded-md relative group', className)}>
- <CodeBlock
- value={formatted}
- language="sql"
- className={cn(
- '!bg-transparent !py-3 !px-3.5 prose dark:prose-dark',
- // change the look of the code block. The flex hack is so that the code is wrapping since
- // every word is a separate span
- '[&>code]:m-0 [&>code>span]:flex [&>code>span]:flex-wrap [&>code]:block'
- )}
- hideCopy
- hideLineNumbers
- />
- <div className="absolute top-2 right-2 bg-surface-100 border-muted border rounded-lg h-[28px] hidden group-hover:block">
- <Tooltip_Shadcn_>
- <TooltipTrigger_Shadcn_ asChild>
- <Button
- type="text"
- size="tiny"
- onClick={() => {
- onDiff(DiffType.Addition, formatted)
- sendEvent({
- category: 'sql_editor_ai_assistant_v2',
- label: 'sql-editor-ai-assistant-v2',
- action: 'ai_suggestion_inserted',
- })
- }}
- >
- <Edit className="h-4 w-4 text-foreground-light" strokeWidth={1.5} />
- </Button>
- </TooltipTrigger_Shadcn_>
- <TooltipContent_Shadcn_ side="bottom" className="font-sans">
- Edit
- </TooltipContent_Shadcn_>
- </Tooltip_Shadcn_>
-
- <Tooltip_Shadcn_>
- <TooltipTrigger_Shadcn_ asChild>
- <Button
- type="text"
- size="tiny"
- onClick={() => {
- handleCopy(formatted)
- sendEvent({
- category: 'sql_editor_ai_assistant_v2',
- label: 'sql-editor-ai-assistant-v2',
- action: 'ai_suggestion_copied',
- })
- }}
- >
- {copied ? (
- <Check size={16} className="text-brand-600" />
- ) : (
- <Copy size={16} className="text-foreground-light" strokeWidth={1.5} />
- )}
- </Button>
- </TooltipTrigger_Shadcn_>
- <TooltipContent_Shadcn_ side="bottom" className="font-sans">
- Copy code
- </TooltipContent_Shadcn_>
- </Tooltip_Shadcn_>
- </div>
- </pre>
- )
-}
diff --git a/apps/studio/components/ui/AIAssistantPanel/SqlSnippet.tsx b/apps/studio/components/ui/AIAssistantPanel/SqlSnippet.tsx
index a948822e79e..47b3d10a056 100644
--- a/apps/studio/components/ui/AIAssistantPanel/SqlSnippet.tsx
+++ b/apps/studio/components/ui/AIAssistantPanel/SqlSnippet.tsx
@@ -3,12 +3,17 @@ import { useRouter } from 'next/router'
import { useCallback, useEffect, useState } from 'react'
import { Bar, BarChart, CartesianGrid, XAxis } from 'recharts'
+import { useQueryClient } from '@tanstack/react-query'
+import { useParams } from 'common'
+import { Markdown } from 'components/interfaces/Markdown'
import useNewQuery from 'components/interfaces/SQLEditor/hooks'
import { DiffType } from 'components/interfaces/SQLEditor/SQLEditor.types'
import { suffixWithLimit } from 'components/interfaces/SQLEditor/SQLEditor.utils'
import Results from 'components/interfaces/SQLEditor/UtilityPanel/Results'
import { QueryResponseError, useExecuteSqlMutation } from 'data/sql/execute-sql-mutation'
+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
+import { TelemetryActions } from 'lib/constants/telemetry'
import { useAppStateSnapshot } from 'state/app-state'
import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2'
import {
@@ -32,11 +37,6 @@ import {
identifyQueryType,
isReadOnlySelect,
} from './AIAssistant.utils'
-import { useParams } from 'common'
-import { useQueryClient } from '@tanstack/react-query'
-import { Markdown } from 'components/interfaces/Markdown'
-import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
-import { TELEMETRY_EVENTS, TELEMETRY_VALUES } from 'lib/constants/telemetry'
interface SqlSnippetWrapperProps {
sql: string
@@ -213,10 +213,11 @@ export const SqlCard = ({
})
sendEvent({
- action: TELEMETRY_EVENTS.AI_ASSISTANT_V2,
- value: TELEMETRY_VALUES.RAN_SQL_SUGGESTION,
- label: 'mutation',
- category: identifyQueryType(sql) ?? 'unknown',
+ action: TelemetryActions.ASSISTANT_SUGGESTION_RAN,
+ properties: {
+ type: 'mutation',
+ category: identifyQueryType(sql) ?? 'unknown',
+ },
})
}}
>
@@ -260,10 +261,7 @@ export const SqlCard = ({
icon={<Edit size={14} />}
onClick={() => {
handleEditInSQLEditor()
- sendEvent({
- action: TELEMETRY_EVENTS.AI_ASSISTANT_V2,
- value: TELEMETRY_VALUES.EDIT_IN_SQL_EDITOR,
- })
+ sendEvent({ action: TelemetryActions.ASSISTANT_EDIT_SQL_CLICKED })
}}
tooltip={{ content: { side: 'bottom', text: 'Edit in SQL Editor' } }}
/>
@@ -308,9 +306,8 @@ export const SqlCard = ({
handleExecute()
if (isReadOnlySelect(sql)) {
sendEvent({
- action: TELEMETRY_EVENTS.AI_ASSISTANT_V2,
- value: TELEMETRY_VALUES.RAN_SQL_SUGGESTION,
- label: 'select',
+ action: TelemetryActions.ASSISTANT_SUGGESTION_RAN,
+ properties: { type: 'select' },
})
}
}}
diff --git a/apps/studio/data/telemetry/send-event-mutation.ts b/apps/studio/data/telemetry/send-event-mutation.ts
index 36afd7e929c..4b91d4a0e02 100644
--- a/apps/studio/data/telemetry/send-event-mutation.ts
+++ b/apps/studio/data/telemetry/send-event-mutation.ts
@@ -4,25 +4,16 @@ import { components } from 'api-types'
import { isBrowser, LOCAL_STORAGE_KEYS } from 'common'
import { handleError, post } from 'data/fetchers'
import { IS_PLATFORM } from 'lib/constants'
+import { TelemetryActions } from 'lib/constants/telemetry'
import { useRouter } from 'next/router'
import type { ResponseError } from 'types'
-type SendEvent = components['schemas']['TelemetryEventBodyV2']
-
export type SendEventVariables = {
- /** Defines the name of the event, refer to TELEMETRY_EVENTS in lib/constants */
- action: string
- /** These are all under the event's properties (customizable on the FE) */
- /** value: refer to TELEMETRY_VALUES in lib/constants */
- value?: string
- /** label: secondary tag to the event for further identification */
- label?: string
- /** To deprecate - seems unnecessary */
- category?: string
- properties?: Record<string, any>
+ action: TelemetryActions
+ properties?: Record<string, any> // Is arbitrary, but always aim to be self-explanatory with custom properties
}
-type SendEventPayload = any
+type SendEventPayload = components['schemas']['TelemetryEventBodyV2']
export async function sendEvent({ body }: { body: SendEventPayload }) {
const consent =
@@ -34,6 +25,7 @@ export async function sendEvent({ body }: { body: SendEventPayload }) {
const headers = { Version: '2' }
const { data, error } = await post(`/platform/telemetry/event`, { body, headers })
+
if (error) handleError(error)
return data
}
@@ -55,9 +47,9 @@ export const useSendEventMutation = ({
return useMutation<SendEventData, ResponseError, SendEventVariables>(
(vars) => {
- const { action, ...otherVars } = vars
+ const { action, properties } = vars
- const body: SendEvent = {
+ const body: SendEventPayload = {
action,
page_url: window.location.href,
page_title: title,
@@ -70,8 +62,7 @@ export const useSendEventMutation = ({
viewport_height: isBrowser ? window.innerHeight : 0,
viewport_width: isBrowser ? window.innerWidth : 0,
},
- // @ts-expect-error - API is returning a wrong type
- custom_properties: otherVars,
+ custom_properties: (properties || {}) as any,
}
return sendEvent({ body })
diff --git a/apps/studio/lib/constants/telemetry.ts b/apps/studio/lib/constants/telemetry.ts
index 2030c342b8d..81ad6fc5257 100644
--- a/apps/studio/lib/constants/telemetry.ts
+++ b/apps/studio/lib/constants/telemetry.ts
@@ -1,3 +1,43 @@
+// Standardization as per document: https://www.notion.so/supabase/Event-tracking-standardization-1195004b775f80f98ee3fa9e70cf4d05
+
+export enum TelemetryActions {
+ SIGN_UP = 'sign_up',
+ SIGN_IN = 'sign_in',
+
+ ASSISTANT_PROMPT_SUBMITTED = 'assistant_prompt_submitted',
+ ASSISTANT_DEBUG_SUBMITTED = 'assistant_debug_submitted',
+ ASSISTANT_SUGGESTION_RAN = 'assistant_suggestion_ran',
+ ASSISTANT_SUGGESTION_ACCEPTED = 'assistant_suggestion_accepted',
+ ASSISTANT_SUGGESTION_REJECTED = 'assistant_suggestion_rejected',
+ ASSISTANT_SUGGESTION_COPIED = 'assistant_suggestion_copied',
+ ASSISTANT_EDIT_SQL_CLICKED = 'assistant_edit_sql_clicked',
+
+ CONNECTION_STRING_COPIED = 'connection_string_copied',
+ CRON_JOB_CREATED = 'cron_job_created',
+ CRON_JOB_UPDATED = 'cron_job_updated',
+ CRON_JOB_DELETED = 'cron_job_deleted',
+ CRON_JOB_DELETE_CLICKED = 'cron_job_delete_clicked',
+ CRON_JOB_UPDATE_CLICKED = 'cron_job_update_clicked',
+ CRON_JOB_CREATE_CLICKED = 'cron_job_create_clicked',
+ CRON_JOBS_VIEW_PREVIOUS_RUNS_CLICKED = 'cron_job_view_previous_runs_clicked',
+
+ FEATURE_PREVIEW_ENABLED = 'feature_preview_enabled',
+ FEATURE_PREVIEW_DISABLED = 'feature_preview_disabled',
+
+ REALTIME_INSPECTOR_LISTEN_CHANNEL_CLICKED = 'realtime_inspector_listen_channel_clicked',
+ REALTIME_INSPECTOR_BROADCAST_SENT = 'realtime_inspector_broadcast_sent',
+ REALTIME_INSPECTOR_MESSAGE_CLICKED = 'realtime_inspector_message_clicked',
+ 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',
+
+ SQL_EDITOR_QUICKSTART_CLICKED = 'sql_editor_quickstart_clicked',
+ 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',
+}
+
// [Joshen] Just adding these to start consolidating our telemetry configs
// may change depending on how we choose to standardize across all apps
// Events define the name of the event and it'll be used as the primary identification
diff --git a/apps/studio/lib/profile.tsx b/apps/studio/lib/profile.tsx
index eab9cd5e4ff..dc6149975bb 100644
--- a/apps/studio/lib/profile.tsx
+++ b/apps/studio/lib/profile.tsx
@@ -6,9 +6,10 @@ import { usePermissionsQuery } from 'data/permissions/permissions-query'
import { useProfileCreateMutation } from 'data/profile/profile-create-mutation'
import { useProfileQuery } from 'data/profile/profile-query'
import type { Profile } from 'data/profile/types'
-import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useSendIdentifyMutation } from 'data/telemetry/send-identify-mutation'
import type { ResponseError } from 'types'
+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import { TelemetryActions } from './constants/telemetry'
export type ProfileContextType = {
profile: Profile | undefined
@@ -31,14 +32,11 @@ export const ProfileProvider = ({ children }: PropsWithChildren<{}>) => {
const { mutate: sendEvent } = useSendEventMutation()
const { mutate: sendIdentify } = useSendIdentifyMutation()
-
const { mutate: createProfile, isLoading: isCreatingProfile } = useProfileCreateMutation({
- async onSuccess() {
- sendEvent({ category: 'conversion', action: 'sign_up', label: '' })
- },
- onError() {
- toast.error('Failed to create your profile. Please refresh to try again.')
+ onSuccess: () => {
+ sendEvent({ action: TelemetryActions.SIGN_UP, properties: { category: 'conversion' } })
},
+ onError: () => toast.error('Failed to create your profile. Please refresh to try again.'),
})
// Track telemetry for the current user
diff --git a/apps/studio/pages/sign-in-mfa.tsx b/apps/studio/pages/sign-in-mfa.tsx
index 4a37aa30fd3..18fe5f4384a 100644
--- a/apps/studio/pages/sign-in-mfa.tsx
+++ b/apps/studio/pages/sign-in-mfa.tsx
@@ -6,16 +6,18 @@ import { toast } from 'sonner'
import SignInMfaForm from 'components/interfaces/SignIn/SignInMfaForm'
import SignInLayout from 'components/layouts/SignInLayout/SignInLayout'
import { Loading } from 'components/ui/Loading'
-import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { auth, buildPathWithParams, getAccessToken, getReturnToPath } from 'lib/gotrue'
import type { NextPageWithLayout } from 'types'
+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import { TelemetryActions } from 'lib/constants/telemetry'
const SignInMfaPage: NextPageWithLayout = () => {
const router = useRouter()
const queryClient = useQueryClient()
- const [loading, setLoading] = useState(true)
const { mutate: sendEvent } = useSendEventMutation()
+ const [loading, setLoading] = useState(true)
+
// This useEffect redirects the user to MFA if they're already halfway signed in
useEffect(() => {
auth
@@ -41,7 +43,7 @@ const SignInMfaPage: NextPageWithLayout = () => {
}
if (data.currentLevel === data.nextLevel) {
- sendEvent({ category: 'account', action: 'sign_in', label: '' })
+ sendEvent({ action: TelemetryActions.SIGN_IN, properties: { category: 'account' } })
await queryClient.resetQueries()
router.push(getReturnToPath())
return