diff --git a/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts b/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts index 8c3ea14da8..d6468816d9 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,25 +323,12 @@ export class ClearcutLogger { }); } - return { + const logEvent: LogEvent = { console_type: 'GEMINI_CLI', application: 102, // GEMINI_CLI event_name: eventName as string, event_metadata: [baseMetadata], }; - } - - createLogEvent(eventName: EventNames, data: EventValue[] = []): LogEvent { - const email = this.userAccountManager.getCachedGoogleAccount(); - - if (eventName !== EventNames.START_SESSION) { - data.push(...this.sessionData); - } - const totalAccounts = this.userAccountManager.getLifetimeGoogleAccounts(); - - 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) { @@ -351,6 +340,17 @@ export class ClearcutLogger { return logEvent; } + createLogEvent(eventName: EventNames, data: EventValue[] = []): LogEvent { + if (eventName !== EventNames.START_SESSION) { + data.push(...this.sessionData); + } + const totalAccounts = this.userAccountManager.getLifetimeGoogleAccounts(); + + data = this.addDefaultFields(data, totalAccounts); + + return this.createBasicLogEvent(eventName, data); + } + flushIfNeeded(): void { if (Date.now() - this.lastFlushTime < FLUSH_INTERVAL_MS) { return;