feat(telemetry): anonymous posthog usage telemetry across node cli and python daemon (#205)

* feat: add telemetry phase 1

* feat: add node telemetry event catalog

* feat: add telemetry event helpers

* feat: emit setup and connection telemetry

* feat: emit connection and stack telemetry

* feat: emit ingest and scan telemetry

* feat: emit query telemetry

* feat: emit sampled mcp telemetry

* docs: expand telemetry event catalog

* feat: add telemetry schema sync artifact

* feat: pass telemetry project id to semantic daemon

* feat: add daemon telemetry foundation

* feat: emit semantic daemon telemetry

* feat: emit daemon lifecycle telemetry

* docs: document full telemetry event catalog

* feat(telemetry): dim first-run notice

* feat(telemetry): show first-run notice before command output

* feat(telemetry): wire ktx PostHog project for live ingestion

* docs(telemetry): drop posthog project name and host from storage section

* docs(telemetry): trim to general overview and disclaimer

* docs(agents): add short telemetry guidelines

* feat(telemetry): enable posthog geoip enrichment

* docs(telemetry): drop ip-geoip note from public overview

* refactor(telemetry): drop no-op groupIdentify, rely on capture groups field

* fix(telemetry): respect CI kill switch in python daemon identity

* fix(sql): route table-count analysis to existing analyze-batch endpoint

* fix(telemetry): emit install_first_run from notice path and derive flagsPresent from commander

* fix(telemetry): read package info via getKtxCliPackageInfo to satisfy boundary check

* fix(telemetry): make python identity env={} bypass os.environ and unset CI in tests

* fix(telemetry): unset CI kill switch in cli-program-telemetry tests
This commit is contained in:
Andrey Avtomonov 2026-05-22 18:18:47 +02:00 committed by GitHub
parent c87d14a554
commit b0dd13ce7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
73 changed files with 6576 additions and 48 deletions

View file

@ -19,6 +19,8 @@ import { withMultiselectNavigation, withTextInputNavigation } from './prompt-nav
import { runKtxScan } from './scan.js';
import { applySetupDatabaseContextDepth } from './setup-database-context-depth.js';
import { writeProjectLocalSecretReference } from './setup-secrets.js';
import { isDemoConnection } from './telemetry/demo-detect.js';
import { emitTelemetryEvent } from './telemetry/index.js';
import {
createKtxSetupPromptAdapter,
type KtxSetupPromptOption,
@ -1283,6 +1285,7 @@ async function writeConnectionConfig(input: {
projectDir: string;
connectionId: string;
connection: KtxProjectConnectionConfig;
io?: KtxCliIo;
}): Promise<void> {
const project = await loadKtxProject({ projectDir: input.projectDir });
const migratedConnections = Object.fromEntries(
@ -1300,6 +1303,17 @@ async function writeConnectionConfig(input: {
},
};
await writeFile(project.configPath, serializeKtxProjectConfig(config), 'utf-8');
if (input.io) {
await emitTelemetryEvent({
name: 'connection_added',
projectDir: input.projectDir,
io: input.io,
fields: {
driver: String(nextConnection.driver ?? 'unknown').toLowerCase(),
isDemoConnection: isDemoConnection(input.connectionId, nextConnection),
},
});
}
const queryHistory = queryHistoryConfigRecord(nextConnection);
if (queryHistory?.enabled === true) {
@ -1556,6 +1570,7 @@ async function maybeConfigureDatabaseScope(input: {
projectDir: input.projectDir,
connectionId: input.connectionId,
connection: { ...currentConnection, enabled_tables: enabledTables },
io: input.io,
});
if (spec && activeSchemas.length > 0) {
@ -1988,6 +2003,7 @@ async function runPrimarySourceFullEdit(input: {
},
driver,
}),
io: input.io,
});
const validated = await validateAndScanConnection({
@ -2223,6 +2239,7 @@ export async function runKtxSetupDatabasesStep(
projectDir: args.projectDir,
connectionId: connectionChoice.connectionId,
connection: withContextDepth,
io,
});
} else {
const existing = project.config.connections[connectionChoice.connectionId];
@ -2248,6 +2265,7 @@ export async function runKtxSetupDatabasesStep(
projectDir: args.projectDir,
connectionId: connectionChoice.connectionId,
connection: withContextDepth,
io,
});
}
@ -2331,6 +2349,7 @@ export async function runKtxSetupDatabasesStep(
projectDir: args.projectDir,
connectionId: connectionChoice.connectionId,
connection: withContextDepth,
io,
});
setupStatus = await validateAndScanConnection({
projectDir: args.projectDir,