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

Commit 9dfea16

Browse files
committed
MetricsService may not exist.
So use TryGetService. Also removed unnecessary braces.
1 parent aac6964 commit 9dfea16

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/GitHub.App/Services/UsageTracker.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public UsageTracker(
5252
this.cache = cache;
5353
this.repositoryHosts = repositoryHosts;
5454
this.userSettings = userSettings;
55-
this.client = (IMetricsService)serviceProvider.GetService(typeof(IMetricsService));
55+
this.client = serviceProvider.TryGetService<IMetricsService>();
5656

5757
userSettings.WhenAny(x => x.CollectMetrics, x => x.Value)
5858
// If SendUsageData is true we'll subscribe to the Run()
@@ -262,9 +262,7 @@ IObservable<int> IncrementCounter(string key)
262262
{
263263
// Don't even store data locally if the user opts out.
264264
if (!userSettings.CollectMetrics)
265-
{
266265
return Observable.Empty<int>();
267-
}
268266

269267
return GetCounter(key)
270268
.Select(x => x + 1)

0 commit comments

Comments
 (0)