Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/docs/hooks/useDocsCommandMenuTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useCallback } from 'react'

import type {
CommandMenuOpenedEvent,
CommandMenuCommandSelectedEvent,
CommandMenuCommandClickedEvent,
CommandMenuSearchSubmittedEvent,
} from 'common/telemetry-constants'
import { useSendTelemetryEvent } from 'lib/telemetry'
Expand All @@ -16,7 +16,7 @@ export function useDocsCommandMenuTelemetry() {
(
event:
| CommandMenuOpenedEvent
| CommandMenuCommandSelectedEvent
| CommandMenuCommandClickedEvent
| CommandMenuSearchSubmittedEvent
) => {
sendTelemetryEvent(event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions apps/studio/data/content/content-count-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -25,7 +24,7 @@ export async function getContentCount(
...(name && { name }),
},
},
...(cumulative ? {} : { headers: { Version: '2' } }),
headers: { Version: '2' },
signal,
})

Expand All @@ -37,15 +36,14 @@ export type ContentIdData = Awaited<ReturnType<typeof getContentCount>>
export type ContentIdError = ResponseError

export const useContentCountQuery = <TData = ContentIdData>(
{ projectRef, cumulative, type, name }: GetContentCountVariables,
{ projectRef, type, name }: GetContentCountVariables,
{ enabled = true, ...options }: UseQueryOptions<ContentIdData, ContentIdError, TData> = {}
) =>
useQuery<ContentIdData, ContentIdError, TData>(
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,
Expand Down
1 change: 0 additions & 1 deletion apps/studio/data/content/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const contentKeys = {
projectRef: string | undefined,
type?: string,
options?: {
cumulative?: boolean
visibility?: string
favorite?: boolean
name?: string
Expand Down
4 changes: 2 additions & 2 deletions apps/studio/hooks/misc/useStudioCommandMenuTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -18,7 +18,7 @@ export function useStudioCommandMenuTelemetry() {
(
event:
| CommandMenuOpenedEvent
| CommandMenuCommandSelectedEvent
| CommandMenuCommandClickedEvent
| CommandMenuSearchSubmittedEvent
) => {
// Add studio-specific groups (project and organization)
Expand Down
4 changes: 2 additions & 2 deletions apps/www/hooks/useWwwCommandMenuTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback } from 'react'

import type {
CommandMenuOpenedEvent,
CommandMenuCommandSelectedEvent,
CommandMenuCommandClickedEvent,
CommandMenuSearchSubmittedEvent,
} from 'common/telemetry-constants'
import { useSendTelemetryEvent } from 'lib/telemetry'
Expand All @@ -14,7 +14,7 @@ export function useWwwCommandMenuTelemetry() {
(
event:
| CommandMenuOpenedEvent
| CommandMenuCommandSelectedEvent
| CommandMenuCommandClickedEvent
| CommandMenuSearchSubmittedEvent
) => {
sendTelemetryEvent(event)
Expand Down
16 changes: 8 additions & 8 deletions packages/common/telemetry-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -2137,4 +2137,4 @@ export type TelemetryEvent =
| AuthUsersSearchSubmittedEvent
| CommandMenuOpenedEvent
| CommandMenuSearchSubmittedEvent
| CommandMenuCommandSelectedEvent
| CommandMenuCommandClickedEvent
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-patterns/src/CommandMenu/internal/Command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading