Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import type {
ToolOutputMaskingEvent,
KeychainAvailabilityEvent,
TokenStorageInitializationEvent,
StartupStatsEvent,
} from '../types.js';
import { EventMetadataKey } from './event-metadata-key.js';
import type { Config } from '../../config/config.js';
Expand Down Expand Up @@ -117,6 +118,7 @@ export enum EventNames {
TOKEN_STORAGE_INITIALIZATION = 'token_storage_initialization',
CONSECA_POLICY_GENERATION = 'conseca_policy_generation',
CONSECA_VERDICT = 'conseca_verdict',
STARTUP_STATS = 'startup_stats',
}

export interface LogResponse {
Expand Down Expand Up @@ -1691,6 +1693,30 @@ export class ClearcutLogger {
this.flushIfNeeded();
}

logStartupStatsEvent(event: StartupStatsEvent): void {
const data: EventValue[] = [
{
gemini_cli_key: EventMetadataKey.GEMINI_CLI_STARTUP_PHASES,
value: JSON.stringify(event.phases),
},
{
gemini_cli_key: EventMetadataKey.GEMINI_CLI_STARTUP_OS_PLATFORM,
value: event.os_platform,
},
{
gemini_cli_key: EventMetadataKey.GEMINI_CLI_STARTUP_OS_RELEASE,
value: event.os_release,
},
{
gemini_cli_key: EventMetadataKey.GEMINI_CLI_STARTUP_IS_DOCKER,
value: JSON.stringify(event.is_docker),
},
];

this.enqueueLogEvent(this.createLogEvent(EventNames.STARTUP_STATS, data));
this.flushIfNeeded();
}

/**
* Adds default fields to data, and returns a new data array. This fields
* should exist on all log events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Defines valid event metadata keys for Clearcut logging.
export enum EventMetadataKey {
// Deleted enums: 24
// Next ID: 172
// Next ID: 176

GEMINI_CLI_KEY_UNKNOWN = 0,

Expand Down Expand Up @@ -54,6 +54,22 @@ export enum EventMetadataKey {
// Logs the output format of the session.
GEMINI_CLI_START_SESSION_OUTPUT_FORMAT = 94,

// ==========================================================================
// Startup Stats Event Keys
// ==========================================================================

// Logs the array of startup phases.
GEMINI_CLI_STARTUP_PHASES = 172,

// Logs the OS platform for startup stats.
GEMINI_CLI_STARTUP_OS_PLATFORM = 173,

// Logs the OS release for startup stats.
GEMINI_CLI_STARTUP_OS_RELEASE = 174,

// Logs whether the CLI is running in docker for startup stats.
GEMINI_CLI_STARTUP_IS_DOCKER = 175,

// ==========================================================================
// User Prompt Event Keys
// ===========================================================================
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/telemetry/loggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ export function logStartupStats(
config: Config,
event: StartupStatsEvent,
): void {
ClearcutLogger.getInstance(config)?.logStartupStatsEvent(event);
bufferTelemetryEvent(() => {
// Wait for experiments to load before emitting so we capture experimentIds
void config
Expand Down
Loading