mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-10 08:05:14 +02:00
feat: emit setup and connection telemetry
This commit is contained in:
parent
bbea0b2746
commit
a8b497eb90
9 changed files with 253 additions and 7 deletions
|
|
@ -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,
|
||||
|
|
@ -1198,6 +1200,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(
|
||||
|
|
@ -1215,6 +1218,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) {
|
||||
|
|
@ -1479,6 +1493,7 @@ async function maybeConfigureDatabaseScope(input: {
|
|||
projectDir: input.projectDir,
|
||||
connectionId: input.connectionId,
|
||||
connection: { ...currentConnection, enabled_tables: enabledTables },
|
||||
io: input.io,
|
||||
});
|
||||
|
||||
if (spec && activeSchemas.length > 0) {
|
||||
|
|
@ -1911,6 +1926,7 @@ async function runPrimarySourceFullEdit(input: {
|
|||
},
|
||||
driver,
|
||||
}),
|
||||
io: input.io,
|
||||
});
|
||||
|
||||
const validated = await validateAndScanConnection({
|
||||
|
|
@ -2146,6 +2162,7 @@ export async function runKtxSetupDatabasesStep(
|
|||
projectDir: args.projectDir,
|
||||
connectionId: connectionChoice.connectionId,
|
||||
connection: withContextDepth,
|
||||
io,
|
||||
});
|
||||
} else {
|
||||
const existing = project.config.connections[connectionChoice.connectionId];
|
||||
|
|
@ -2171,6 +2188,7 @@ export async function runKtxSetupDatabasesStep(
|
|||
projectDir: args.projectDir,
|
||||
connectionId: connectionChoice.connectionId,
|
||||
connection: withContextDepth,
|
||||
io,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -2254,6 +2272,7 @@ export async function runKtxSetupDatabasesStep(
|
|||
projectDir: args.projectDir,
|
||||
connectionId: connectionChoice.connectionId,
|
||||
connection: withContextDepth,
|
||||
io,
|
||||
});
|
||||
setupStatus = await validateAndScanConnection({
|
||||
projectDir: args.projectDir,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue