diff --git a/apps/docs/hooks/useDocsCommandMenuTelemetry.ts b/apps/docs/hooks/useDocsCommandMenuTelemetry.ts index c2b8371d18337..6514699fc7a8f 100644 --- a/apps/docs/hooks/useDocsCommandMenuTelemetry.ts +++ b/apps/docs/hooks/useDocsCommandMenuTelemetry.ts @@ -4,7 +4,7 @@ import { useCallback } from 'react' import type { CommandMenuOpenedEvent, - CommandMenuCommandSelectedEvent, + CommandMenuCommandClickedEvent, CommandMenuSearchSubmittedEvent, } from 'common/telemetry-constants' import { useSendTelemetryEvent } from 'lib/telemetry' @@ -16,7 +16,7 @@ export function useDocsCommandMenuTelemetry() { ( event: | CommandMenuOpenedEvent - | CommandMenuCommandSelectedEvent + | CommandMenuCommandClickedEvent | CommandMenuSearchSubmittedEvent ) => { sendTelemetryEvent(event) diff --git a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SearchList.tsx b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SearchList.tsx index 1f6020cd8ef4d..643f1cf76a181 100644 --- a/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SearchList.tsx +++ b/apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SearchList.tsx @@ -45,13 +45,12 @@ export const SearchList = ({ search }: SearchListProps) => { const { data: count, isLoading: isLoadingCount } = useContentCountQuery( { projectRef, - cumulative: true, type: 'sql', name: search, }, { keepPreviousData: true } ) - const totalNumber = (count as unknown as { count: number })?.count ?? 0 + const totalNumber = count ? count.private + count.shared : 0 const snippets = useMemo( // [Joshen] Set folder_id to null to ensure flat list diff --git a/apps/studio/data/content/content-count-query.ts b/apps/studio/data/content/content-count-query.ts index d6201e01f699f..513e42b54f85e 100644 --- a/apps/studio/data/content/content-count-query.ts +++ b/apps/studio/data/content/content-count-query.ts @@ -8,11 +8,10 @@ import { contentKeys } from './keys' type GetContentCountVariables = operations['ContentController_getContentCountV2']['parameters']['query'] & { projectRef?: string - cumulative?: boolean } export async function getContentCount( - { projectRef, cumulative, type, name }: GetContentCountVariables, + { projectRef, type, name }: GetContentCountVariables, signal?: AbortSignal ) { if (typeof projectRef === 'undefined') throw new Error('projectRef is required') @@ -25,7 +24,7 @@ export async function getContentCount( ...(name && { name }), }, }, - ...(cumulative ? {} : { headers: { Version: '2' } }), + headers: { Version: '2' }, signal, }) @@ -37,15 +36,14 @@ export type ContentIdData = Awaited> export type ContentIdError = ResponseError export const useContentCountQuery = ( - { projectRef, cumulative, type, name }: GetContentCountVariables, + { projectRef, type, name }: GetContentCountVariables, { enabled = true, ...options }: UseQueryOptions = {} ) => useQuery( contentKeys.count(projectRef, type, { - cumulative, name, }), - ({ signal }) => getContentCount({ projectRef, cumulative, type, name }, signal), + ({ signal }) => getContentCount({ projectRef, type, name }, signal), { enabled: enabled && typeof projectRef !== 'undefined', ...options, diff --git a/apps/studio/data/content/keys.ts b/apps/studio/data/content/keys.ts index 5becc1afcbcca..6c14043edb224 100644 --- a/apps/studio/data/content/keys.ts +++ b/apps/studio/data/content/keys.ts @@ -37,7 +37,6 @@ export const contentKeys = { projectRef: string | undefined, type?: string, options?: { - cumulative?: boolean visibility?: string favorite?: boolean name?: string diff --git a/apps/studio/hooks/misc/useStudioCommandMenuTelemetry.ts b/apps/studio/hooks/misc/useStudioCommandMenuTelemetry.ts index 925c9c600a861..4b5457a9eeae1 100644 --- a/apps/studio/hooks/misc/useStudioCommandMenuTelemetry.ts +++ b/apps/studio/hooks/misc/useStudioCommandMenuTelemetry.ts @@ -5,7 +5,7 @@ import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization import { useSendEventMutation } from 'data/telemetry/send-event-mutation' import type { CommandMenuOpenedEvent, - CommandMenuCommandSelectedEvent, + CommandMenuCommandClickedEvent, CommandMenuSearchSubmittedEvent, } from 'common/telemetry-constants' @@ -18,7 +18,7 @@ export function useStudioCommandMenuTelemetry() { ( event: | CommandMenuOpenedEvent - | CommandMenuCommandSelectedEvent + | CommandMenuCommandClickedEvent | CommandMenuSearchSubmittedEvent ) => { // Add studio-specific groups (project and organization) diff --git a/apps/www/hooks/useWwwCommandMenuTelemetry.ts b/apps/www/hooks/useWwwCommandMenuTelemetry.ts index cf7a6037efff7..a2bb7a625be5a 100644 --- a/apps/www/hooks/useWwwCommandMenuTelemetry.ts +++ b/apps/www/hooks/useWwwCommandMenuTelemetry.ts @@ -2,7 +2,7 @@ import { useCallback } from 'react' import type { CommandMenuOpenedEvent, - CommandMenuCommandSelectedEvent, + CommandMenuCommandClickedEvent, CommandMenuSearchSubmittedEvent, } from 'common/telemetry-constants' import { useSendTelemetryEvent } from 'lib/telemetry' @@ -14,7 +14,7 @@ export function useWwwCommandMenuTelemetry() { ( event: | CommandMenuOpenedEvent - | CommandMenuCommandSelectedEvent + | CommandMenuCommandClickedEvent | CommandMenuSearchSubmittedEvent ) => { sendTelemetryEvent(event) diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.ts index 300f25a189e78..1d7f654a71afc 100644 --- a/packages/common/telemetry-constants.ts +++ b/packages/common/telemetry-constants.ts @@ -1953,7 +1953,7 @@ export interface AuthUsersSearchSubmittedEvent { * User opened the command menu. * * @group Events - * @source ui-patterns + * @source studio, docs, www * @page any */ export interface CommandMenuOpenedEvent { @@ -1979,7 +1979,7 @@ export interface CommandMenuOpenedEvent { * User typed a search term in the command menu input. * * @group Events - * @source ui-patterns + * @source studio, docs, www * @page any */ export interface CommandMenuSearchSubmittedEvent { @@ -1998,17 +1998,17 @@ export interface CommandMenuSearchSubmittedEvent { } /** - * User selected a command from the command menu. + * User clicked a command from the command menu. * * @group Events - * @source ui-patterns + * @source studio, docs, www * @page any */ -export interface CommandMenuCommandSelectedEvent { - action: 'command_menu_command_selected' +export interface CommandMenuCommandClickedEvent { + action: 'command_menu_command_clicked' properties: { /** - * The selected command + * The clicked command */ command_name: string command_value?: string @@ -2137,4 +2137,4 @@ export type TelemetryEvent = | AuthUsersSearchSubmittedEvent | CommandMenuOpenedEvent | CommandMenuSearchSubmittedEvent - | CommandMenuCommandSelectedEvent + | CommandMenuCommandClickedEvent diff --git a/packages/ui-patterns/src/CommandMenu/api/hooks/useCommandMenuTelemetry.ts b/packages/ui-patterns/src/CommandMenu/api/hooks/useCommandMenuTelemetry.ts index 1ec7f51d8a7b6..44308c39b8fbc 100644 --- a/packages/ui-patterns/src/CommandMenu/api/hooks/useCommandMenuTelemetry.ts +++ b/packages/ui-patterns/src/CommandMenu/api/hooks/useCommandMenuTelemetry.ts @@ -6,12 +6,12 @@ import { useCommandMenuOpen } from './viewHooks' import type { CommandMenuOpenedEvent, - CommandMenuCommandSelectedEvent, + CommandMenuCommandClickedEvent, CommandMenuSearchSubmittedEvent, } from 'common/telemetry-constants' export type CommandMenuTelemetryCallback = ( - event: CommandMenuOpenedEvent | CommandMenuCommandSelectedEvent | CommandMenuSearchSubmittedEvent + event: CommandMenuOpenedEvent | CommandMenuCommandClickedEvent | CommandMenuSearchSubmittedEvent ) => void export interface UseCommandMenuTelemetryOptions { diff --git a/packages/ui-patterns/src/CommandMenu/internal/Command.tsx b/packages/ui-patterns/src/CommandMenu/internal/Command.tsx index 9fa962fa79c95..e0c5d03942fdb 100644 --- a/packages/ui-patterns/src/CommandMenu/internal/Command.tsx +++ b/packages/ui-patterns/src/CommandMenu/internal/Command.tsx @@ -61,7 +61,7 @@ const CommandItem = forwardRef< // Send telemetry event if (telemetryContext?.onTelemetry) { const event = { - action: 'command_menu_command_selected' as const, + action: 'command_menu_command_clicked' as const, properties: { command_name: command.name, command_value: command.value,