mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 06:54:15 -07:00
feat(telemetry): add keychain availability and token storage metrics (#18971)
This commit is contained in:
@@ -47,6 +47,8 @@ import type {
|
||||
ApprovalModeDurationEvent,
|
||||
PlanExecutionEvent,
|
||||
ToolOutputMaskingEvent,
|
||||
KeychainAvailabilityEvent,
|
||||
TokenStorageInitializationEvent,
|
||||
} from '../types.js';
|
||||
import { EventMetadataKey } from './event-metadata-key.js';
|
||||
import type { Config } from '../../config/config.js';
|
||||
@@ -111,6 +113,8 @@ export enum EventNames {
|
||||
APPROVAL_MODE_DURATION = 'approval_mode_duration',
|
||||
PLAN_EXECUTION = 'plan_execution',
|
||||
TOOL_OUTPUT_MASKING = 'tool_output_masking',
|
||||
KEYCHAIN_AVAILABILITY = 'keychain_availability',
|
||||
TOKEN_STORAGE_INITIALIZATION = 'token_storage_initialization',
|
||||
}
|
||||
|
||||
export interface LogResponse {
|
||||
@@ -1613,6 +1617,40 @@ export class ClearcutLogger {
|
||||
this.flushIfNeeded();
|
||||
}
|
||||
|
||||
logKeychainAvailabilityEvent(event: KeychainAvailabilityEvent): void {
|
||||
const data: EventValue[] = [
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_KEYCHAIN_AVAILABLE,
|
||||
value: JSON.stringify(event.available),
|
||||
},
|
||||
];
|
||||
|
||||
this.enqueueLogEvent(
|
||||
this.createLogEvent(EventNames.KEYCHAIN_AVAILABILITY, data),
|
||||
);
|
||||
this.flushIfNeeded();
|
||||
}
|
||||
|
||||
logTokenStorageInitializationEvent(
|
||||
event: TokenStorageInitializationEvent,
|
||||
): void {
|
||||
const data: EventValue[] = [
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_TOKEN_STORAGE_TYPE,
|
||||
value: event.type,
|
||||
},
|
||||
{
|
||||
gemini_cli_key: EventMetadataKey.GEMINI_CLI_TOKEN_STORAGE_FORCED,
|
||||
value: JSON.stringify(event.forced),
|
||||
},
|
||||
];
|
||||
|
||||
this.enqueueLogEvent(
|
||||
this.createLogEvent(EventNames.TOKEN_STORAGE_INITIALIZATION, data),
|
||||
);
|
||||
this.flushIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds default fields to data, and returns a new data array. This fields
|
||||
* should exist on all log events.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// Defines valid event metadata keys for Clearcut logging.
|
||||
export enum EventMetadataKey {
|
||||
// Deleted enums: 24
|
||||
// Next ID: 156
|
||||
// Next ID: 159
|
||||
|
||||
GEMINI_CLI_KEY_UNKNOWN = 0,
|
||||
|
||||
@@ -578,7 +578,6 @@ export enum EventMetadataKey {
|
||||
// Logs the total prunable tokens identified at the trigger point.
|
||||
GEMINI_CLI_TOOL_OUTPUT_MASKING_TOTAL_PRUNABLE_TOKENS = 151,
|
||||
|
||||
// ==========================================================================
|
||||
// Ask User Stats Event Keys
|
||||
// ==========================================================================
|
||||
|
||||
@@ -593,4 +592,17 @@ export enum EventMetadataKey {
|
||||
|
||||
// Logs the number of questions answered in the ask_user tool.
|
||||
GEMINI_CLI_ASK_USER_ANSWER_COUNT = 155,
|
||||
|
||||
// ==========================================================================
|
||||
// Keychain & Token Storage Event Keys
|
||||
// ==========================================================================
|
||||
|
||||
// Logs whether the keychain is available.
|
||||
GEMINI_CLI_KEYCHAIN_AVAILABLE = 156,
|
||||
|
||||
// Logs the type of token storage initialized.
|
||||
GEMINI_CLI_TOKEN_STORAGE_TYPE = 157,
|
||||
|
||||
// Logs whether the token storage type was forced by an environment variable.
|
||||
GEMINI_CLI_TOKEN_STORAGE_FORCED = 158,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user