Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit dcc31fd

Browse files
committed
Cleanup some code
1 parent a863cf2 commit dcc31fd

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/GitHub.Exports/Services/UsageTracker.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.VisualStudio.ComponentModelHost;
1111
using Microsoft.VisualStudio.Shell;
1212
using Task = System.Threading.Tasks.Task;
13+
using GitHub.Extensions;
1314

1415
namespace 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

Comments
 (0)