@@ -23,7 +23,7 @@ import { handlePublish } from './commands/publish'
2323import { runPlainLogin } from './login/plain-login'
2424import { initializeApp } from './init/init-app'
2525import { getProjectRoot , setProjectRoot } from './project-files'
26- import { initAnalytics , trackEvent } from './utils/analytics'
26+ import { trackEvent } from './utils/analytics'
2727import { getAuthToken , getAuthTokenDetails } from './utils/auth'
2828import { resetCodebuffClient } from './utils/codebuff-client'
2929import { setApiClientAuthToken } from './utils/codebuff-api'
@@ -66,7 +66,7 @@ function loadPackageVersion(): string {
6666// Without this, refetchInterval won't work because TanStack Query thinks the app is "unfocused"
6767focusManager . setEventListener ( ( ) => {
6868 // No-op: no event listeners in CLI environment (no window focus/visibility events)
69- return ( ) => { }
69+ return ( ) => { }
7070} )
7171focusManager . setFocused ( true )
7272
@@ -222,26 +222,17 @@ async function main(): Promise<void> {
222222 const startCwd = process . cwd ( )
223223 const showProjectPicker = shouldShowProjectPicker ( startCwd , homeDir )
224224
225- // Initialize analytics early, before anything that might use the logger
226- // (the logger calls trackEvent, which throws if analytics isn't initialized)
227- try {
228- initAnalytics ( )
229-
230- // Track app launch event
231- trackEvent ( AnalyticsEvent . APP_LAUNCHED , {
232- version : loadPackageVersion ( ) ,
233- platform : process . platform ,
234- arch : process . arch ,
235- hasInitialPrompt : Boolean ( initialPrompt ) ,
236- hasAgentOverride : hasAgentOverride ,
237- continueChat,
238- initialMode : initialMode ?? 'DEFAULT' ,
239- isFreeBuff : IS_FREEBUFF ,
240- } )
241- } catch ( error ) {
242- // Analytics initialization is optional - don't fail the app if it errors
243- logger . debug ( error , 'Failed to initialize analytics' )
244- }
225+ // Requires analytics to be initialized, which is done in initializeApp
226+ trackEvent ( AnalyticsEvent . APP_LAUNCHED , {
227+ version : loadPackageVersion ( ) ,
228+ platform : process . platform ,
229+ arch : process . arch ,
230+ hasInitialPrompt : Boolean ( initialPrompt ) ,
231+ hasAgentOverride : hasAgentOverride ,
232+ continueChat,
233+ initialMode : initialMode ?? 'DEFAULT' ,
234+ isFreeBuff : IS_FREEBUFF ,
235+ } )
245236
246237 // Initialize agent registry (loads user agents via SDK).
247238 // When --agent is provided, skip local .agents to avoid overrides.
0 commit comments