@@ -11,7 +11,6 @@ abstract class ApplicationManagerBase : IApplicationManager
1111 protected static ILogging Logger { get ; } = Logging . GetLogger < IApplicationManager > ( ) ;
1212
1313 private IEnvironment environment ;
14- private AppConfiguration appConfiguration ;
1514 private RepositoryManager repositoryManager ;
1615
1716 public ApplicationManagerBase ( SynchronizationContext synchronizationContext )
@@ -36,7 +35,7 @@ protected void Initialize()
3635 LocalSettings . Initialize ( ) ;
3736 SystemSettings . Initialize ( ) ;
3837
39- Logging . TracingEnabled = UserSettings . Get ( "EnableTraceLogging" , false ) ;
38+ Logging . TracingEnabled = UserSettings . Get ( Constants . TraceLoggingKey , false ) ;
4039 ProcessManager = new ProcessManager ( Environment , Platform . GitEnvironment , CancellationToken ) ;
4140 Platform . Initialize ( ProcessManager , TaskManager ) ;
4241 GitClient = new GitClient ( Environment , ProcessManager , Platform . CredentialManager , TaskManager ) ;
@@ -93,7 +92,7 @@ public virtual ITask RestartRepository()
9392 var gitConfig = new GitConfig ( repositoryPathConfiguration . DotGitConfig ) ;
9493
9594 var repositoryWatcher = new RepositoryWatcher ( Platform , repositoryPathConfiguration , TaskManager . Token ) ;
96- repositoryManager = new RepositoryManager ( Platform , TaskManager , gitConfig , repositoryWatcher ,
95+ repositoryManager = new RepositoryManager ( Platform , TaskManager , UsageTracker , gitConfig , repositoryWatcher ,
9796 GitClient , repositoryPathConfiguration , TaskManager . Token ) ;
9897
9998 await repositoryManager . Initialize ( ) . SafeAwait ( ) ;
@@ -135,7 +134,7 @@ private async Task SetupAndRestart(ProgressReport progress)
135134 private async Task < NPath > LookForGitInstallationPath ( )
136135 {
137136 NPath cachedGitInstallPath = null ;
138- var path = SystemSettings . Get ( "GitInstallPath" ) ;
137+ var path = SystemSettings . Get ( Constants . GitInstallPathKey ) ;
139138 if ( ! String . IsNullOrEmpty ( path ) )
140139 cachedGitInstallPath = path . ToNPath ( ) ;
141140
@@ -147,6 +146,32 @@ private async Task<NPath> LookForGitInstallationPath()
147146 return await GitClient . FindGitInstallation ( ) . SafeAwait ( ) ;
148147 }
149148
149+ protected void SetupMetrics ( string unityVersion , bool firstRun )
150+ {
151+ Logger . Trace ( "Setup metrics" ) ;
152+
153+ var usagePath = Environment . UserCachePath . Combine ( Constants . UsageFile ) ;
154+
155+ string id = null ;
156+ if ( UserSettings . Exists ( Constants . GuidKey ) )
157+ {
158+ id = UserSettings . Get ( Constants . GuidKey ) ;
159+ }
160+
161+ if ( String . IsNullOrEmpty ( id ) )
162+ {
163+ id = Guid . NewGuid ( ) . ToString ( ) ;
164+ UserSettings . Set ( Constants . GuidKey , id ) ;
165+ }
166+
167+ UsageTracker = new UsageTracker ( UserSettings , usagePath , id , unityVersion ) ;
168+
169+ if ( firstRun )
170+ {
171+ UsageTracker . IncrementLaunchCount ( ) ;
172+ }
173+ }
174+
150175 private bool disposed = false ;
151176 protected virtual void Dispose ( bool disposing )
152177 {
@@ -164,14 +189,6 @@ public void Dispose()
164189 Dispose ( true ) ;
165190 }
166191
167- public AppConfiguration AppConfiguration
168- {
169- get
170- {
171- return appConfiguration ?? ( appConfiguration = new AppConfiguration ( ) ) ;
172- }
173- }
174-
175192 public IEnvironment Environment
176193 {
177194 get
@@ -209,5 +226,6 @@ public IEnvironment Environment
209226 public ISettings LocalSettings { get ; protected set ; }
210227 public ISettings SystemSettings { get ; protected set ; }
211228 public ISettings UserSettings { get ; protected set ; }
229+ public IUsageTracker UsageTracker { get ; protected set ; }
212230 }
213231}
0 commit comments