2025-10-09 16:02:58 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-10-10 12:06:08 -04:00
|
|
|
import type { Attributes } from '@opentelemetry/api';
|
2025-10-09 16:02:58 -07:00
|
|
|
import type { Config } from '../config/config.js';
|
2025-10-10 12:06:08 -04:00
|
|
|
import { InstallationManager } from '../utils/installationManager.js';
|
2025-10-09 16:02:58 -07:00
|
|
|
import { UserAccountManager } from '../utils/userAccountManager.js';
|
|
|
|
|
|
2025-10-10 12:06:08 -04:00
|
|
|
const userAccountManager = new UserAccountManager();
|
|
|
|
|
const installationManager = new InstallationManager();
|
|
|
|
|
|
|
|
|
|
export function getCommonAttributes(config: Config): Attributes {
|
2025-10-09 16:02:58 -07:00
|
|
|
const email = userAccountManager.getCachedGoogleAccount();
|
2026-02-10 13:01:35 -08:00
|
|
|
const experiments = config.getExperiments();
|
2026-02-27 10:15:06 -08:00
|
|
|
const authType = config.getContentGeneratorConfig()?.authType;
|
2025-10-09 16:02:58 -07:00
|
|
|
return {
|
|
|
|
|
'session.id': config.getSessionId(),
|
2025-10-10 12:06:08 -04:00
|
|
|
'installation.id': installationManager.getInstallationId(),
|
2025-11-11 02:03:32 -08:00
|
|
|
interactive: config.isInteractive(),
|
2025-10-09 16:02:58 -07:00
|
|
|
...(email && { 'user.email': email }),
|
2026-02-27 10:15:06 -08:00
|
|
|
...(authType && { auth_type: authType }),
|
2026-02-10 13:01:35 -08:00
|
|
|
...(experiments &&
|
|
|
|
|
experiments.experimentIds.length > 0 && {
|
|
|
|
|
'experiments.ids': experiments.experimentIds,
|
|
|
|
|
}),
|
2025-10-09 16:02:58 -07:00
|
|
|
};
|
|
|
|
|
}
|