( options: InitializeServerTelemetryOptions, )
| 83 | * fire the startup event) share the same underlying client + sink. |
| 84 | */ |
| 85 | export function initializeServerTelemetry( |
| 86 | options: InitializeServerTelemetryOptions, |
| 87 | ): TelemetryClient { |
| 88 | const bootstrap = createCliTelemetryBootstrap(); |
| 89 | const configPath = resolveConfigPath({ homeDir: bootstrap.homeDir }); |
| 90 | const config = readServerTelemetryConfig(configPath); |
| 91 | const auth = new KimiAuthFacade({ |
| 92 | homeDir: bootstrap.homeDir, |
| 93 | configPath, |
| 94 | identity: createKimiCodeHostIdentity(options.version), |
| 95 | }); |
| 96 | |
| 97 | initializeTelemetry({ |
| 98 | homeDir: bootstrap.homeDir, |
| 99 | deviceId: bootstrap.deviceId, |
| 100 | enabled: config.telemetry !== false, |
| 101 | appName: CLI_USER_AGENT_PRODUCT, |
| 102 | version: options.version, |
| 103 | uiMode: WEB_UI_MODE, |
| 104 | model: config.defaultModel, |
| 105 | getAccessToken: async () => (await auth.getCachedAccessToken(KIMI_CODE_PROVIDER_NAME)) ?? null, |
| 106 | }); |
| 107 | |
| 108 | return { |
| 109 | track, |
| 110 | withContext: withTelemetryContext, |
| 111 | setContext: setTelemetryContext, |
| 112 | }; |
| 113 | } |
| 114 | |
| 115 | function readServerTelemetryConfig( |
| 116 | configPath: string, |
no test coverage detected