Skip to content

Commit

Permalink
Implement simple telemetry (no additional context beyond event type)
Browse files Browse the repository at this point in the history
- prompt run
- prompt finished
- new prompt added
- new local prompt added
  • Loading branch information
ColinMcNeil committed Aug 16, 2024
1 parent 3ce7090 commit 7dcda3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/extension/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LABEL org.opencontainers.image.title="Labs: AI Tools for Devs" \
org.opencontainers.image.description="Agentic workflows with Dockerized tools" \
org.opencontainers.image.vendor="Docker Inc" \
com.docker.desktop.extension.api.version="0.3.4" \
com.docker.extension.screenshots='[{"alt":"screenshot of the extension UI", "url":"https://raw.githubusercontent.com/docker/labs-ai-tools-for-devs/main/src/extension/Screenshot1.png"}, {"alt":"screenshot of the extension output", "url":"https://raw.githubusercontent.com/docker/labs-ai-tools-for-devs/main/src/extension/screenshot2.png"}]' \
com.docker.extension.screenshots='[{"alt":"screenshot of the extension UI", "url":"https://raw.githubusercontent.com/docker/labs-ai-tools-for-devs/main/src/extension/Screenshot1.png"}, {"alt":"screenshot of the extension output", "url":"https://raw.githubusercontent.com/docker/labs-ai-tools-for-devs/main/src/extension/Screenshot2.png"}]' \
com.docker.desktop.extension.icon="https://raw.githubusercontent.com/docker/labs-ai-tools-for-devs/main/src/extension/docker.svg" \
com.docker.extension.detailed-description="Run AI-powered workflows with Dockerized tools in Docker Desktop." \
com.docker.extension.publisher-url="https://www.docker.com/" \
Expand Down
7 changes: 7 additions & 0 deletions src/extension/ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ type RPCMessage = {
// If you're running this React app in a browser, it won't work properly.
const client = createDockerDesktopClient();

const track = (event: string) =>
client.extension.vm?.service?.post('/analytics/track', { event });

const debounce = (fn: Function, ms: number) => {
let timeout: NodeJS.Timeout;
return function (...args: any) {
Expand Down Expand Up @@ -97,6 +100,7 @@ export function App() {
const delim = client.host.platform === 'win32' ? '\\' : '/';

const startPrompt = async () => {
track('start-prompt');
let output: RPCMessage[] = []
const updateOutput = (line: RPCMessage) => {
if (line.method === 'functions') {
Expand Down Expand Up @@ -182,6 +186,7 @@ export function App() {
},
}
});
track('end-prompt');
}

return (
Expand Down Expand Up @@ -249,6 +254,7 @@ export function App() {
<Button onClick={() => {
setPrompts([...prompts, promptInput]);
setPromptInput('');
track('add-prompt');
}}>Add prompt</Button>
)}
<Button onClick={() => {
Expand All @@ -258,6 +264,7 @@ export function App() {
if (result.canceled) {
return;
}
track('add-local-prompt');
setPrompts([...prompts, ...result.filePaths.map(p => `local://${p}`)]);
});
}}>Add local prompt</Button>
Expand Down

0 comments on commit 7dcda3f

Please sign in to comment.