Skip to content

Commit 8ce5643

Browse files
feat(telemetry): add CodeQ telemetry collection system
Add qBraid-specific telemetry module to collect session data for analysis and model improvement. Components: - config: Add qbraid.telemetry config section under a separate namespace to maintain upstream compatibility when merging from opencode - types: TypeScript types matching the telemetry service schema - sanitizer: Strip secrets, redact sensitive files, truncate large content - signals: Track implicit feedback (retries, errors, abandonment) - uploader: Batch and upload data with retry logic and offline handling - consent: Tier-based consent (free=forced opt-in, paid=opt-in) - collector: Main module that coordinates all components Design choices for upstream compatibility: - All telemetry code is in a separate src/telemetry/ directory - Config uses qbraid.* namespace that upstream will ignore - No modifications to existing session/processor logic yet Implements: [CodeQ] Add telemetry config schema Implements: [CodeQ] Implement TelemetryCollector module Implements: [CodeQ] Implement content sanitizer Implements: [CodeQ] Implement batch uploader with retry
1 parent bae0732 commit 8ce5643

8 files changed

Lines changed: 1638 additions & 0 deletions

File tree

packages/opencode/src/config/config.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,54 @@ export namespace Config {
11831183
.describe("Timeout in milliseconds for model context protocol (MCP) requests"),
11841184
})
11851185
.optional(),
1186+
// qBraid-specific configuration (CodeQ customizations)
1187+
// This section is ignored by upstream opencode and contains qBraid-specific features
1188+
qbraid: z
1189+
.object({
1190+
telemetry: z
1191+
.object({
1192+
enabled: z
1193+
.union([z.boolean(), z.literal("tier-default")])
1194+
.optional()
1195+
.describe(
1196+
"Enable telemetry collection. 'tier-default' uses tier-based defaults (free=enabled, paid=disabled). Default: 'tier-default'",
1197+
),
1198+
endpoint: z
1199+
.string()
1200+
.url()
1201+
.optional()
1202+
.describe("Telemetry service endpoint. Default: https://telemetry.qbraid.com"),
1203+
dataLevel: z
1204+
.enum(["full", "metrics-only"])
1205+
.optional()
1206+
.describe(
1207+
"Level of data to collect. 'full' includes message content, 'metrics-only' only collects usage stats. Default: 'full'",
1208+
),
1209+
excludePatterns: z
1210+
.array(z.string())
1211+
.optional()
1212+
.describe(
1213+
"Glob patterns for files/directories to exclude from telemetry (e.g., ['**/secrets/**', '**/.env*'])",
1214+
),
1215+
batchSize: z
1216+
.number()
1217+
.int()
1218+
.min(1)
1219+
.max(100)
1220+
.optional()
1221+
.describe("Number of turns to batch before uploading. Default: 5"),
1222+
flushIntervalMs: z
1223+
.number()
1224+
.int()
1225+
.min(1000)
1226+
.optional()
1227+
.describe("Maximum time (ms) to wait before flushing buffered data. Default: 30000"),
1228+
})
1229+
.optional()
1230+
.describe("Telemetry settings for CodeQ session data collection"),
1231+
})
1232+
.optional()
1233+
.describe("qBraid-specific configuration for CodeQ"),
11861234
})
11871235
.strict()
11881236
.meta({

0 commit comments

Comments
 (0)