mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(telemetry): correct onboarding and token storage metrics
This commit addresses two issues with telemetry recording: 1. The metric was missing the attribute, causing a TypeScript error when was called. The attribute has been added back to the metric definition. 2. The metric was being incorrectly called on every token refresh. This has been corrected by removing the calls from the token refresh listener and refactoring the valid success paths to call a new helper function to avoid code duplication.
This commit is contained in:
@@ -117,6 +117,12 @@ async function initOauthClient(
|
||||
authType: AuthType,
|
||||
config: Config,
|
||||
): Promise<AuthClient> {
|
||||
const recordOnboardingEndIfApplicable = () => {
|
||||
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
|
||||
recordOnboardingEnd(config);
|
||||
}
|
||||
};
|
||||
|
||||
const credentials = await fetchCachedCredentials();
|
||||
|
||||
if (
|
||||
@@ -172,10 +178,6 @@ async function initOauthClient(
|
||||
}
|
||||
|
||||
await triggerPostAuthCallbacks(tokens);
|
||||
|
||||
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
|
||||
recordOnboardingEnd(config);
|
||||
}
|
||||
});
|
||||
|
||||
if (credentials) {
|
||||
@@ -201,10 +203,6 @@ async function initOauthClient(
|
||||
debugLogger.log('Loaded cached credentials.');
|
||||
await triggerPostAuthCallbacks(credentials as Credentials);
|
||||
|
||||
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
|
||||
recordOnboardingEnd(config);
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -296,9 +294,7 @@ async function initOauthClient(
|
||||
}
|
||||
|
||||
await triggerPostAuthCallbacks(client.credentials);
|
||||
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
|
||||
recordOnboardingEnd(config);
|
||||
}
|
||||
recordOnboardingEndIfApplicable();
|
||||
} else {
|
||||
// In ACP mode, we skip the interactive consent and directly open the browser
|
||||
if (!config.getAcpMode()) {
|
||||
@@ -405,9 +401,7 @@ async function initOauthClient(
|
||||
});
|
||||
|
||||
await triggerPostAuthCallbacks(client.credentials);
|
||||
if (authType === AuthType.LOGIN_WITH_GOOGLE) {
|
||||
recordOnboardingEnd(config);
|
||||
}
|
||||
recordOnboardingEndIfApplicable();
|
||||
}
|
||||
|
||||
return client;
|
||||
|
||||
@@ -266,6 +266,7 @@ const COUNTER_DEFINITIONS = {
|
||||
assign: (c: Counter) => (tokenStorageTypeCounter = c),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
attributes: {} as {
|
||||
type: string;
|
||||
forced: boolean;
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user