Metric(extension) - Add logging for uninstalling extension (#8293)

Co-authored-by: Shi Shu <shii@google.com>
This commit is contained in:
shishu314
2025-09-12 13:38:54 -04:00
committed by GitHub
parent c99539b991
commit 8a5e692373
6 changed files with 78 additions and 9 deletions
@@ -26,6 +26,7 @@ import type {
ContentRetryFailureEvent,
ExtensionInstallEvent,
ToolOutputTruncatedEvent,
ExtensionUninstallEvent,
} from '../types.js';
import { EventMetadataKey } from './event-metadata-key.js';
import type { Config } from '../../config/config.js';
@@ -59,6 +60,7 @@ export enum EventNames {
CONTENT_RETRY = 'content_retry',
CONTENT_RETRY_FAILURE = 'content_retry_failure',
EXTENSION_INSTALL = 'extension_install',
EXTENSION_UNINSTALL = 'extension_uninstall',
TOOL_OUTPUT_TRUNCATED = 'tool_output_truncated',
}
@@ -863,6 +865,24 @@ export class ClearcutLogger {
this.flushIfNeeded();
}
logExtensionUninstallEvent(event: ExtensionUninstallEvent): void {
const data: EventValue[] = [
{
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_NAME,
value: event.extension_name,
},
{
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_UNINSTALL_STATUS,
value: event.status,
},
];
this.enqueueLogEvent(
this.createLogEvent(EventNames.EXTENSION_UNINSTALL, data),
);
this.flushIfNeeded();
}
logToolOutputTruncatedEvent(event: ToolOutputTruncatedEvent): void {
const data: EventValue[] = [
{
@@ -350,6 +350,9 @@ export enum EventMetadataKey {
// Logs the status of the extension install.
GEMINI_CLI_EXTENSION_INSTALL_STATUS = 88,
// Logs the status of the extension uninstall
GEMINI_CLI_EXTENSION_UNINSTALL_STATUS = 96,
// ==========================================================================
// Tool Output Truncated Event Keys
// ===========================================================================
+15
View File
@@ -535,6 +535,7 @@ export type TelemetryEvent =
| ContentRetryEvent
| ContentRetryFailureEvent
| ExtensionInstallEvent
| ExtensionUninstallEvent
| ToolOutputTruncatedEvent;
export class ExtensionInstallEvent implements BaseTelemetryEvent {
@@ -590,3 +591,17 @@ export class ToolOutputTruncatedEvent implements BaseTelemetryEvent {
this.lines = details.lines;
}
}
export class ExtensionUninstallEvent implements BaseTelemetryEvent {
'event.name': 'extension_uninstall';
'event.timestamp': string;
extension_name: string;
status: 'success' | 'error';
constructor(extension_name: string, status: 'success' | 'error') {
this['event.name'] = 'extension_uninstall';
this['event.timestamp'] = new Date().toISOString();
this.extension_name = extension_name;
this.status = status;
}
}