inlining recordGoogleAuthEnd

This commit is contained in:
Srinath Padmanabhan
2026-03-05 16:44:45 -08:00
parent 192b1a630f
commit 2bd1d45f08

View File

@@ -117,12 +117,6 @@ async function initOauthClient(
authType: AuthType, authType: AuthType,
config: Config, config: Config,
): Promise<AuthClient> { ): Promise<AuthClient> {
const recordGoogleAuthEndIfApplicable = () => {
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
recordGoogleAuthEnd(config);
}
};
const credentials = await fetchCachedCredentials(); const credentials = await fetchCachedCredentials();
if ( if (
@@ -167,6 +161,9 @@ async function initOauthClient(
access_token: process.env['GOOGLE_CLOUD_ACCESS_TOKEN'], access_token: process.env['GOOGLE_CLOUD_ACCESS_TOKEN'],
}); });
await fetchAndCacheUserInfo(client); await fetchAndCacheUserInfo(client);
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
recordGoogleAuthEnd(config);
}
return client; return client;
} }
@@ -203,7 +200,9 @@ async function initOauthClient(
debugLogger.log('Loaded cached credentials.'); debugLogger.log('Loaded cached credentials.');
await triggerPostAuthCallbacks(credentials as Credentials); await triggerPostAuthCallbacks(credentials as Credentials);
recordGoogleAuthEndIfApplicable(); if (authType === AuthType.LOGIN_WITH_GOOGLE) {
recordGoogleAuthEnd(config);
}
return client; return client;
} }
} catch (error) { } catch (error) {
@@ -295,7 +294,9 @@ async function initOauthClient(
} }
await triggerPostAuthCallbacks(client.credentials); await triggerPostAuthCallbacks(client.credentials);
recordGoogleAuthEndIfApplicable(); if (authType === AuthType.LOGIN_WITH_GOOGLE) {
recordGoogleAuthEnd(config);
}
} else { } else {
// In ACP mode, we skip the interactive consent and directly open the browser // In ACP mode, we skip the interactive consent and directly open the browser
if (!config.getAcpMode()) { if (!config.getAcpMode()) {
@@ -402,7 +403,9 @@ async function initOauthClient(
}); });
await triggerPostAuthCallbacks(client.credentials); await triggerPostAuthCallbacks(client.credentials);
recordGoogleAuthEndIfApplicable(); if (authType === AuthType.LOGIN_WITH_GOOGLE) {
recordGoogleAuthEnd(config);
}
} }
return client; return client;