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

Commit fa692bc

Browse files
Updating the user guid with the rest of the user data
1 parent 7406d70 commit fa692bc

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/GitHub.Exports/Models/UsageModel.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace GitHub.Models
1+
using System;
2+
3+
namespace GitHub.Models
24
{
35
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes", Justification = "It'll use reflection by default and we're fine with that")]
46
public struct UsageModel
@@ -41,9 +43,9 @@ public struct UsageModel
4143
public int NumberOfPRReviewDiffViewInlineCommentOpen { get; set; }
4244
public int NumberOfPRReviewDiffViewInlineCommentPost { get; set; }
4345

44-
public UsageModel Clone(Guid guid, bool includeWeekly, bool includeMonthly)
46+
public UsageModel Clone(bool includeWeekly, bool includeMonthly)
4547
{
46-
var result = Create(guid);
48+
var result = this;
4749
if (!includeWeekly)
4850
result.NumberOfStartupsWeek = 0;
4951
if (!includeMonthly)
@@ -66,13 +68,5 @@ public UsageModel ClearCounters(bool clearWeekly, bool clearMonthly)
6668
result.Lang = Lang;
6769
return result;
6870
}
69-
70-
public static UsageModel Create(Guid guid)
71-
{
72-
return new UsageModel
73-
{
74-
Guid = guid
75-
};
76-
}
7771
}
7872
}

src/GitHub.VisualStudio/Services/UsageTracker.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async Task TimerTick()
127127
// Only send stats once a day.
128128
if (!service.IsSameDay(usage.LastUpdated))
129129
{
130-
usage.Model = UpdateModelUserData(usage.Model);
130+
usage.Model = await UpdateModelUserData(usage.Model);
131131

132132
await SendUsage(usage.Model, includeWeekly, includeMonthly);
133133

@@ -144,13 +144,14 @@ async Task SendUsage(UsageModel usage, bool includeWeekly, bool includeMonthly)
144144
throw new GitHubLogicException("SendUsage should not be called when there is no IMetricsService");
145145
}
146146

147-
var guid = await service.GetUserGuid();
148-
var model = usage.Clone(weekly, monthly);
147+
var model = usage.Clone(includeWeekly, includeMonthly);
149148
await client.PostUsage(model);
150149
}
151150

152-
UsageModel UpdateModelUserData(UsageModel model)
151+
async Task<UsageModel> UpdateModelUserData(UsageModel model)
153152
{
153+
model.Guid = await service.GetUserGuid();
154+
154155
if (connectionManager.Connections.Any(x => x.HostAddress.IsGitHubDotCom()))
155156
{
156157
model.IsGitHubUser = true;
@@ -160,6 +161,7 @@ UsageModel UpdateModelUserData(UsageModel model)
160161
{
161162
model.IsEnterpriseUser = true;
162163
}
164+
163165
return model;
164166
}
165167
}

0 commit comments

Comments
 (0)