Add git repo information to events (#136)

Context
This PR adds support for git repository information in the analytics system by adding the necessary columns to the ClickHouse database and updating the UI to handle these properties appropriately.

Implementation
Updated .docker/scripts/clickhouse/001-create-tables.sql to include git properties in the schema for new database instances. Migrated package.json's to support new type schema.
Modified apps/web/src/components/task-sharing/TaskDetails.tsx to display git properties when available (message if not).
Added some claude-code typing.

How to Test
Run the migration by rebuilding docker and pnpm. If this still doesn't work try deleting .docker/data/clickhouse
Create a new task in a git tracked repo on Roo Code extension while signed in-- verify this is logged correctly.
This commit is contained in:
Will Li 2025-06-25 12:29:02 -07:00 committed by GitHub
parent 331d0a38e8
commit 680a96fc9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 45 additions and 18 deletions

View file

@ -21,6 +21,9 @@ CREATE TABLE IF NOT EXISTS default.events
`modelId` Nullable(String),
`diffStrategy` Nullable(String),
`isSubtask` Nullable(Bool),
`repositoryUrl` Nullable(String),
`repositoryName` Nullable(String),
`defaultBranch` Nullable(String),
-- Completion
`inputTokens` Nullable(Int32),

View file

@ -16,7 +16,7 @@
"dependencies": {
"@roo-code-cloud/db": "workspace:^",
"@roo-code-cloud/ipc": "workspace:^",
"@roo-code/types": "^1.26.0",
"@roo-code/types": "^1.29.0",
"bullmq": "^5.37.0",
"drizzle-orm": "^0.44.2",
"execa": "^9.6.0",

View file

@ -32,7 +32,7 @@
"@radix-ui/react-toast": "^1.2.14",
"@radix-ui/react-tooltip": "^1.2.7",
"@roo-code-cloud/db": "workspace:^",
"@roo-code/types": "^1.28.0",
"@roo-code/types": "^1.29.0",
"@sentry/nextjs": "^9.23.0",
"@t3-oss/env-nextjs": "^0.13.6",
"@tailwindcss/postcss": "^4.1.8",

View file

@ -311,6 +311,9 @@ const taskSchema = z.object({
tokens: z.coerce.number(),
cost: z.coerce.number(),
timestamp: z.coerce.number(),
repositoryUrl: z.string().nullable().optional(),
repositoryName: z.string().nullable().optional(),
defaultBranch: z.string().nullable().optional(),
});
export type TaskWithUser = z.infer<typeof taskSchema> & { user: User };
@ -404,7 +407,10 @@ export const getTasks = async ({
SUM(CASE WHEN e.type = 'LLM Completion' THEN ${tokenSumSql('e')} ELSE 0 END) AS tokens,
SUM(CASE WHEN e.type = 'LLM Completion' THEN COALESCE(e.cost, 0) ELSE 0 END) AS cost,
MIN(e.timestamp) AS timestamp,
any(fm.title) AS title
any(fm.title) AS title,
any(e.repositoryUrl) AS repositoryUrl,
any(e.repositoryName) AS repositoryName,
any(e.defaultBranch) AS defaultBranch
FROM events e
LEFT JOIN first_messages fm ON e.taskId = fm.taskId
WHERE

View file

@ -53,7 +53,7 @@ export const TaskDetails = ({
</div>
</CardHeader>
<CardContent>
<div className="grid grid-cols-2 md:grid-cols-5 gap-4 text-sm">
<div className="grid grid-cols-2 md:grid-cols-6 gap-4 text-sm">
<div>
<p className="text-muted-foreground">Developer</p>
<p className="font-mono truncate">{task.user.name}</p>
@ -74,6 +74,17 @@ export const TaskDetails = ({
<p className="text-muted-foreground">Cost</p>
<p className="font-mono">{formatCurrency(task.cost)}</p>
</div>
<div>
<p className="text-muted-foreground">Git Workspace</p>
{task.repositoryName ? (
<p className="font-mono truncate">{task.repositoryName}</p>
) : (
<p className="text-muted-foreground text-xs italic">
Not available
</p>
)}
</div>
</div>
{task.mode && (
<div className="mt-4 pt-4 border-t">

View file

@ -75,4 +75,8 @@ export const PROVIDERS: Record<
litellm: { id: 'litellm', label: 'LiteLLM', models: [] },
unbound: { id: 'unbound', label: 'Unbound', models: [] },
glama: { id: 'glama', label: 'Glama', models: [] },
};
'claude-code': { id: 'claude-code', label: 'Claude Code', models: [] },
} as Record<
Exclude<ProviderName, 'fake-ai' | 'human-relay'>,
{ id: ProviderName; label: string; models: string[] }
>;

View file

@ -21,6 +21,9 @@ CREATE TABLE default.events
`modelId` Nullable(String),
`diffStrategy` Nullable(String),
`isSubtask` Nullable(Bool),
`repositoryUrl` Nullable(String),
`repositoryName` Nullable(String),
`defaultBranch` Nullable(String),
-- Completion
`inputTokens` Nullable(Int32),

View file

@ -26,7 +26,7 @@
"db:test:push": "dotenvx run -f .env.test -- drizzle-kit push"
},
"dependencies": {
"@roo-code/types": "^1.26.0",
"@roo-code/types": "^1.29.0",
"drizzle-orm": "^0.44.2",
"postgres": "^3.4.7",
"zod": "^3.25.41"

View file

@ -9,7 +9,7 @@
"clean": "rimraf .turbo"
},
"dependencies": {
"@roo-code/types": "^1.26.0",
"@roo-code/types": "^1.29.0",
"node-ipc": "^12.0.0"
},
"devDependencies": {

22
pnpm-lock.yaml generated
View file

@ -46,8 +46,8 @@ importers:
specifier: workspace:^
version: link:../../packages/ipc
'@roo-code/types':
specifier: ^1.26.0
version: 1.26.0
specifier: ^1.29.0
version: 1.29.0
bullmq:
specifier: ^5.37.0
version: 5.54.3
@ -201,8 +201,8 @@ importers:
specifier: workspace:^
version: link:../../packages/db
'@roo-code/types':
specifier: ^1.28.0
version: 1.28.0
specifier: ^1.29.0
version: 1.29.0
'@sentry/nextjs':
specifier: ^9.23.0
version: 9.23.0(@opentelemetry/context-async-hooks@1.30.1(@opentelemetry/api@1.9.0))(@opentelemetry/core@1.30.1(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.57.2(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.30.1(@opentelemetry/api@1.9.0))(next@15.3.3(@babel/core@7.27.3)(@opentelemetry/api@1.9.0)(@playwright/test@1.52.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react@19.1.0)(webpack@5.99.9)
@ -435,8 +435,8 @@ importers:
packages/db:
dependencies:
'@roo-code/types':
specifier: ^1.26.0
version: 1.26.0
specifier: ^1.29.0
version: 1.29.0
drizzle-orm:
specifier: ^0.44.2
version: 0.44.2(@electric-sql/pglite@0.3.0)(@libsql/client-wasm@0.15.5)(@opentelemetry/api@1.9.0)(@types/pg@8.15.2)(pg@8.15.6)(postgres@3.4.7)
@ -463,8 +463,8 @@ importers:
packages/ipc:
dependencies:
'@roo-code/types':
specifier: ^1.26.0
version: 1.26.0
specifier: ^1.29.0
version: 1.29.0
node-ipc:
specifier: ^12.0.0
version: 12.0.0
@ -2291,8 +2291,8 @@ packages:
cpu: [x64]
os: [win32]
'@roo-code/types@1.26.0':
resolution: {integrity: sha512-FX+9jl+PRpZG0n+MUFXjlelDdzEVLQULfHAdBCT7npOs0MrC5IaBGxtuZMYRKWYzEvgwRM96oqXgr6CYkNIWZQ==}
'@roo-code/types@1.29.0':
resolution: {integrity: sha512-bovFOCVQYuWnV2Cvdcx5tWp8aUpF0tEoxN0rS05hzzwdDeDxB6F6q5orKsQqghTS0yqv5pYclQLZRyAV7oBsbw==}
'@roo-code/types@1.28.0':
resolution: {integrity: sha512-kJAWDaY80BLPRxVa1Nz3Fuj7tvnSVMsRlpgNq3YXvFyQwWsui7DZz/AgX5qm+CwcAHXHBPmCUn5oV5XnEAEykw==}
@ -8357,7 +8357,7 @@ snapshots:
'@rollup/rollup-win32-x64-msvc@4.41.1':
optional: true
'@roo-code/types@1.26.0': {}
'@roo-code/types@1.29.0': {}
'@roo-code/types@1.28.0': {}