1010using Microsoft . VisualStudio . ComponentModelHost ;
1111using Microsoft . VisualStudio . Shell ;
1212using Task = System . Threading . Tasks . Task ;
13+ using GitHub . Extensions ;
1314
1415namespace GitHub . Services
1516{
@@ -21,7 +22,7 @@ public class UsageTracker : IUsageTracker
2122 static readonly Calendar cal = CultureInfo . InvariantCulture . Calendar ;
2223
2324 readonly IMetricsService client ;
24- readonly Lazy < IConnectionManager > connectionManager ;
25+ readonly IConnectionManager connectionManager ;
2526 readonly IPackageSettings userSettings ;
2627 readonly DispatcherTimer timer ;
2728 readonly string storePath ;
@@ -34,20 +35,18 @@ public class UsageTracker : IUsageTracker
3435 [ ImportingConstructor ]
3536 public UsageTracker (
3637 IProgram program ,
37- Lazy < IConnectionManager > connectionManager ,
38+ IConnectionManager connectionManager ,
3839 IPackageSettings userSettings ,
3940 [ Import ( typeof ( SVsServiceProvider ) ) ] IServiceProvider serviceProvider )
4041 {
41- var componentModel = serviceProvider . GetService ( typeof ( SComponentModel ) ) as IComponentModel ;
42-
4342 fileExists = ( path ) => System . IO . File . Exists ( path ) ;
4443 readAllText = ( path , encoding ) => System . IO . File . ReadAllText ( path , encoding ) ;
4544 writeAllText = ( path , content , encoding ) => System . IO . File . WriteAllText ( path , content , encoding ) ;
4645 dirCreate = ( path ) => System . IO . Directory . CreateDirectory ( path ) ;
4746
4847 this . connectionManager = connectionManager ;
4948 this . userSettings = userSettings ;
50- this . client = componentModel ? . DefaultExportProvider . GetExportedValue < IMetricsService > ( ) ;
49+ this . client = serviceProvider . GetExportedValue < IMetricsService > ( ) ;
5150 this . timer = new DispatcherTimer (
5251 TimeSpan . FromMinutes ( 1 ) ,
5352 DispatcherPriority . Background ,
@@ -206,8 +205,6 @@ async Task SendUsage(UsageModel usage, bool weekly, bool monthly)
206205 {
207206 Debug . Assert ( client != null , "SendUsage should not be called when there is no IMetricsService" ) ;
208207
209- var connectionManager = this . connectionManager . Value ;
210-
211208 if ( connectionManager . Connections . Any ( x => x . HostAddress . IsGitHubDotCom ( ) ) )
212209 {
213210 usage . IsGitHubUser = true ;
0 commit comments