diff --git a/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts b/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts index 8c3ea14da87..d6468816d93 100644 --- a/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts +++ b/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts @@ -292,8 +292,10 @@ export class ClearcutLogger { eventName: EventNames, data: EventValue[] = [], ): LogEvent { + const email = this.userAccountManager.getCachedGoogleAccount(); const surface = determineSurface(); const ghWorkflowName = determineGHWorkflowName(); + const baseMetadata: EventValue[] = [ ...data, { @@ -321,17 +323,24 @@ export class ClearcutLogger { }); } - return { + const logEvent: LogEvent = { console_type: 'GEMINI_CLI', application: 102, // GEMINI_CLI event_name: eventName as string, event_metadata: [baseMetadata], }; + + // Should log either email or install ID, not both. See go/cloudmill-1p-oss-instrumentation#define-sessionable-id + if (email) { + logEvent.client_email = email; + } else { + logEvent.client_install_id = this.installationManager.getInstallationId(); + } + + return logEvent; } createLogEvent(eventName: EventNames, data: EventValue[] = []): LogEvent { - const email = this.userAccountManager.getCachedGoogleAccount(); - if (eventName !== EventNames.START_SESSION) { data.push(...this.sessionData); } @@ -339,16 +348,7 @@ export class ClearcutLogger { data = this.addDefaultFields(data, totalAccounts); - const logEvent = this.createBasicLogEvent(eventName, data); - - // Should log either email or install ID, not both. See go/cloudmill-1p-oss-instrumentation#define-sessionable-id - if (email) { - logEvent.client_email = email; - } else { - logEvent.client_install_id = this.installationManager.getInstallationId(); - } - - return logEvent; + return this.createBasicLogEvent(eventName, data); } flushIfNeeded(): void {