From 58607b92dfe76dd657338b5433d0fd33800f9272 Mon Sep 17 00:00:00 2001 From: matt korwel Date: Wed, 9 Jul 2025 21:51:37 -0700 Subject: Revert "fix: Use Email for Clearcut Logging and Refactor User Info Fetching" (#3744) --- packages/core/src/utils/user_id.ts | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'packages/core/src/utils/user_id.ts') diff --git a/packages/core/src/utils/user_id.ts b/packages/core/src/utils/user_id.ts index 045cbd77..42bbee35 100644 --- a/packages/core/src/utils/user_id.ts +++ b/packages/core/src/utils/user_id.ts @@ -8,11 +8,8 @@ import * as os from 'os'; import * as fs from 'fs'; import * as path from 'path'; import { randomUUID } from 'crypto'; -import { createRequire } from 'module'; import { GEMINI_DIR } from './paths.js'; -const require = createRequire(import.meta.url); - const homeDir = os.homedir() ?? ''; const geminiDir = path.join(homeDir, GEMINI_DIR); const installationIdFile = path.join(geminiDir, 'installation_id'); @@ -61,23 +58,24 @@ export function getInstallationId(): string { } /** - * Retrieves the email for the currently authenticated user. - * When OAuth is available, returns the user's cached email. Otherwise, returns an empty string. - * @returns A string email for the user (Google Account email if available, otherwise empty string). + * Retrieves the obfuscated Google Account ID for the currently authenticated user. + * When OAuth is available, returns the user's cached Google Account ID. Otherwise, returns the installation ID. + * @returns A string ID for the user (Google Account ID if available, otherwise installation ID). */ -export function getGoogleAccountEmail(): string { - // Try to get cached Google Account email first +export async function getGoogleAccountId(): Promise { + // Try to get cached Google Account ID first try { - // Dynamically import to avoid circular dependencies - // eslint-disable-next-line no-restricted-syntax - const { getCachedGoogleAccountEmail } = require('../code_assist/oauth2.js'); - const googleAccountEmail = getCachedGoogleAccountEmail(); - if (googleAccountEmail) { - return googleAccountEmail; + // Dynamic import to avoid circular dependencies + const { getCachedGoogleAccountId } = await import( + '../code_assist/oauth2.js' + ); + const googleAccountId = getCachedGoogleAccountId(); + if (googleAccountId) { + return googleAccountId; } } catch (error) { - // If there's any error accessing Google Account email, just return empty string - console.debug('Could not get cached Google Account email:', error); + // If there's any error accessing Google Account ID, just return empty string + console.debug('Could not get cached Google Account ID:', error); } return ''; -- cgit v1.2.3