@@ -47,7 +47,7 @@ protected void Initialize()
4747 ApplicationConfiguration . WebTimeout = UserSettings . Get ( Constants . WebTimeoutKey , ApplicationConfiguration . WebTimeout ) ;
4848 Platform . Initialize ( ProcessManager , TaskManager ) ;
4949 progress . OnProgress += progressReporter . UpdateProgress ;
50- UsageTracker = new UsageTracker ( UserSettings , Environment , InstanceId . ToString ( ) ) ;
50+ UsageTracker = new UsageTracker ( TaskManager , UserSettings , Environment , InstanceId . ToString ( ) ) ;
5151
5252#if ENABLE_METRICS
5353 var metricsService = new MetricsService ( ProcessManager ,
@@ -64,12 +64,16 @@ public void Run()
6464 isBusy = true ;
6565 progress . UpdateProgress ( 0 , 100 , "Initializing..." ) ;
6666
67+ if ( firstRun )
68+ {
69+ UsageTracker . IncrementNumberOfStartups ( ) ;
70+ }
71+
6772 var thread = new Thread ( ( ) =>
6873 {
6974 GitInstallationState state = new GitInstallationState ( ) ;
7075 try
7176 {
72- SetupMetrics ( ) ;
7377 if ( Environment . IsMac )
7478 {
7579 var getEnvPath = new SimpleProcessTask ( TaskManager . Token , "bash" . ToNPath ( ) , "-c \" /usr/libexec/path_helper\" " )
@@ -187,6 +191,7 @@ public void SetupGit(GitInstaller.GitInstallationState state)
187191 if ( Environment . RepositoryPath . IsInitialized )
188192 {
189193 ConfigureMergeSettings ( ) ;
194+ CaptureRepoSize ( ) ;
190195
191196 GitClient . LfsInstall ( )
192197 . Catch ( e =>
@@ -255,7 +260,6 @@ public void InitializeRepository()
255260 GitClient . Commit ( "Initial commit" , null ) . RunSynchronously ( ) ;
256261 progress . UpdateProgress ( 70 , 100 , "Initializing..." ) ;
257262 Environment . InitializeRepository ( ) ;
258- UsageTracker . IncrementProjectsInitialized ( ) ;
259263 }
260264 catch ( Exception ex )
261265 {
@@ -269,6 +273,7 @@ public void InitializeRepository()
269273 progress . UpdateProgress ( 90 , 100 , "Initializing..." ) ;
270274 RestartRepository ( ) ;
271275 TaskManager . RunInUI ( InitializeUI ) ;
276+ UsageTracker . IncrementProjectsInitialized ( ) ;
272277 progress . UpdateProgress ( 100 , 100 , "Initialized" ) ;
273278 }
274279 isBusy = false ;
@@ -295,6 +300,37 @@ private void ConfigureMergeSettings()
295300 } ) . RunSynchronously ( ) ;
296301 }
297302
303+ private void CaptureRepoSize ( )
304+ {
305+ GitClient . CountObjects ( )
306+ . Finally ( ( success , gitObjects ) =>
307+ {
308+ if ( success )
309+ {
310+ UsageTracker . UpdateRepoSize ( gitObjects . kilobytes ) ;
311+ }
312+ } )
313+ . Start ( ) ;
314+
315+ var gitLfsDataPath = Environment . RepositoryPath . Combine ( ".git" , "lfs" ) ;
316+ if ( gitLfsDataPath . Exists ( ) )
317+ {
318+ var diskUsageTask = Environment . IsWindows
319+ ? ( IProcessTask < int > ) new WindowsDiskUsageTask ( gitLfsDataPath , TaskManager . Token )
320+ : new LinuxDiskUsageTask ( gitLfsDataPath , TaskManager . Token ) ;
321+
322+ diskUsageTask
323+ . Configure ( ProcessManager )
324+ . Finally ( ( success , kilobytes ) =>
325+ {
326+ if ( success )
327+ {
328+ UsageTracker . UpdateLfsDiskUsage ( kilobytes ) ;
329+ }
330+ } ) . Start ( ) ;
331+ }
332+ }
333+
298334 public void RestartRepository ( )
299335 {
300336 if ( ! Environment . RepositoryPath . IsInitialized )
@@ -310,14 +346,6 @@ public void RestartRepository()
310346 Logger . Trace ( $ "Got a repository? { ( Environment . Repository != null ? Environment . Repository . LocalPath : "null" ) } ") ;
311347 }
312348
313- protected void SetupMetrics ( )
314- {
315- if ( firstRun )
316- {
317- UsageTracker . IncrementNumberOfStartups ( ) ;
318- }
319- }
320-
321349 protected abstract void InitializeUI ( ) ;
322350 protected abstract void InitializationComplete ( ) ;
323351
0 commit comments