mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-27 13:34:15 -07:00
feat(plan): telemetry to track adoption and usage of plan mode (#16863)
This commit is contained in:
@@ -64,6 +64,8 @@ import { logRipgrepFallback, logFlashFallback } from '../telemetry/loggers.js';
|
||||
import {
|
||||
RipgrepFallbackEvent,
|
||||
FlashFallbackEvent,
|
||||
ApprovalModeSwitchEvent,
|
||||
ApprovalModeDurationEvent,
|
||||
} from '../telemetry/types.js';
|
||||
import type { FallbackModelHandler } from '../fallback/types.js';
|
||||
import { ModelAvailabilityService } from '../availability/modelAvailabilityService.js';
|
||||
@@ -105,6 +107,10 @@ import { debugLogger } from '../utils/debugLogger.js';
|
||||
import { SkillManager, type SkillDefinition } from '../skills/skillManager.js';
|
||||
import { startupProfiler } from '../telemetry/startupProfiler.js';
|
||||
import type { AgentDefinition } from '../agents/types.js';
|
||||
import {
|
||||
logApprovalModeSwitch,
|
||||
logApprovalModeDuration,
|
||||
} from '../telemetry/loggers.js';
|
||||
import { fetchAdminControls } from '../code_assist/admin/admin_controls.js';
|
||||
|
||||
export interface AccessibilitySettings {
|
||||
@@ -544,6 +550,7 @@ export class Config {
|
||||
private terminalBackground: string | undefined = undefined;
|
||||
private remoteAdminSettings: FetchAdminControlsResponse | undefined;
|
||||
private latestApiRequest: GenerateContentParameters | undefined;
|
||||
private lastModeSwitchTime: number = Date.now();
|
||||
|
||||
constructor(params: ConfigParameters) {
|
||||
this.sessionId = params.sessionId;
|
||||
@@ -1348,9 +1355,32 @@ export class Config {
|
||||
'Cannot enable privileged approval modes in an untrusted folder.',
|
||||
);
|
||||
}
|
||||
|
||||
const currentMode = this.getApprovalMode();
|
||||
if (currentMode !== mode) {
|
||||
this.logCurrentModeDuration(this.getApprovalMode());
|
||||
logApprovalModeSwitch(
|
||||
this,
|
||||
new ApprovalModeSwitchEvent(currentMode, mode),
|
||||
);
|
||||
this.lastModeSwitchTime = Date.now();
|
||||
}
|
||||
|
||||
this.policyEngine.setApprovalMode(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the duration of the current approval mode.
|
||||
*/
|
||||
logCurrentModeDuration(mode: ApprovalMode): void {
|
||||
const now = Date.now();
|
||||
const duration = now - this.lastModeSwitchTime;
|
||||
logApprovalModeDuration(
|
||||
this,
|
||||
new ApprovalModeDurationEvent(mode, duration),
|
||||
);
|
||||
}
|
||||
|
||||
isYoloModeDisabled(): boolean {
|
||||
return this.disableYoloMode || !this.isTrustedFolder();
|
||||
}
|
||||
@@ -2054,6 +2084,7 @@ export class Config {
|
||||
* Disposes of resources and removes event listeners.
|
||||
*/
|
||||
async dispose(): Promise<void> {
|
||||
this.logCurrentModeDuration(this.getApprovalMode());
|
||||
coreEvents.off(CoreEvent.AgentsRefreshed, this.onAgentsRefreshed);
|
||||
this.agentRegistry?.dispose();
|
||||
this.geminiClient?.dispose();
|
||||
|
||||
Reference in New Issue
Block a user