diff --git a/lib/shared/src/sourcegraph-api/graphql/client.ts b/lib/shared/src/sourcegraph-api/graphql/client.ts index 32085034f97f..0f3a34d4a4b1 100644 --- a/lib/shared/src/sourcegraph-api/graphql/client.ts +++ b/lib/shared/src/sourcegraph-api/graphql/client.ts @@ -457,6 +457,7 @@ export interface Prompt { description?: string draft: boolean autoSubmit?: boolean + builtin?: boolean mode?: PromptMode definition: { text: string diff --git a/vscode/src/prompts/prompts.ts b/vscode/src/prompts/prompts.ts index 62ac38e50522..879f0bb35618 100644 --- a/vscode/src/prompts/prompts.ts +++ b/vscode/src/prompts/prompts.ts @@ -148,7 +148,7 @@ async function getLocalCommands(input: LocalCommandsInput): Promise { // Fetch standards (built-in) prompts from prompts library API if (remoteBuiltinPrompts) { const remoteStandardPrompts = await graphqlClient.queryBuiltinPrompts({ query }) - return remoteStandardPrompts.map(prompt => ({ ...prompt, actionType: 'prompt' })) + return remoteStandardPrompts.map(prompt => ({ ...prompt, actionType: 'prompt', builtin: true })) } // Fallback on local commands (prompts-like or not is controlled by CodyUnifiedPrompts feature flag) diff --git a/vscode/webviews/components/promptList/PromptList.tsx b/vscode/webviews/components/promptList/PromptList.tsx index 5a0382edf48c..9e9473b8a177 100644 --- a/vscode/webviews/components/promptList/PromptList.tsx +++ b/vscode/webviews/components/promptList/PromptList.tsx @@ -21,6 +21,13 @@ import type { PromptsInput } from '@sourcegraph/cody-shared' import { useLocalStorage } from '../../components/hooks' import styles from './PromptList.module.css' +const BUILT_IN_PROMPTS_CODE: Record = { + 'document-code': 1, + 'explain-code': 2, + 'find-code-smells': 3, + 'generate-unit-tests': 4, +} + interface PromptListProps { showSearch: boolean showFirstNItems?: number @@ -91,6 +98,7 @@ export const PromptList: FC = props => { } const isPrompt = action.actionType === 'prompt' + const isBuiltinPrompt = isPrompt && action.builtin const isPromptAutoSubmit = action.actionType === 'prompt' && action.autoSubmit const isCommand = action.actionType === 'command' const isBuiltInCommand = isCommand && action.type === 'default' @@ -99,6 +107,8 @@ export const PromptList: FC = props => { metadata: { isPrompt: isPrompt ? 1 : 0, isPromptAutoSubmit: isPromptAutoSubmit ? 1 : 0, + isPromptBuiltin: isBuiltinPrompt ? 1 : 0, + builtinPromptType: isBuiltinPrompt ? BUILT_IN_PROMPTS_CODE[action.name] : 0, isCommand: isCommand ? 1 : 0, isCommandBuiltin: isBuiltInCommand ? 1 : 0, isCommandCustom: !isBuiltInCommand ? 1 : 0, diff --git a/web/CHANGELOG.md b/web/CHANGELOG.md index 30eadb63b01b..59b532959b90 100644 --- a/web/CHANGELOG.md +++ b/web/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.14.0 +- Add prompts analytics over built-in prompts + ## 0.13.0 - Fix openctx mention by mocking Cody Web workspace root - Disable non-runnable prompts in Cody Web diff --git a/web/package.json b/web/package.json index 3bb1830049e0..51aa2d128f2a 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "@sourcegraph/cody-web", - "version": "0.13.0", + "version": "0.14.0", "description": "Cody standalone web app", "license": "Apache-2.0", "repository": {