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

Commit f3d3f52

Browse files
authored
Merge branch 'master' into fixes/remove-experimental-PR-file-margin
2 parents 613f30b + 6b9da32 commit f3d3f52

File tree

7 files changed

+75
-13
lines changed

7 files changed

+75
-13
lines changed

Directory.Build.Props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<Product>GitHub Extension for Visual Studio</Product>
4-
<Version>2.10.2.0</Version>
4+
<Version>2.10.3.0</Version>
55
<Copyright>Copyright © GitHub, Inc. 2014-2018</Copyright>
66
<LangVersion>7.3</LangVersion>
77
</PropertyGroup>

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
os: Visual Studio 2019 Preview
2-
version: '2.10.2.{build}'
2+
version: '2.10.3.{build}'
33
skip_tags: true
44

55
install:

src/GitHub.VisualStudio.16/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
2020
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="Project" d:ProjectName="GitHub.VisualStudio.UI.16" d:VsixSubPath="UI" Path="|GitHub.VisualStudio.UI.16|" AssemblyName="|GitHub.VisualStudio.UI.16;AssemblyName|" />
2121
</Assets>
22-
</PackageManifest>
22+
</PackageManifest>

src/GitHub.VisualStudio.Vsix/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="c3d3dc68-c977-411f-b3e8-03b0dccf7dfc" Version="2.10.2.0" Language="en-US" Publisher="GitHub, Inc" />
4+
<Identity Id="c3d3dc68-c977-411f-b3e8-03b0dccf7dfc" Version="2.10.3.0" Language="en-US" Publisher="GitHub, Inc" />
55
<DisplayName>GitHub Extension for Visual Studio</DisplayName>
66
<Description xml:space="preserve">A Visual Studio Extension that brings the GitHub Flow into Visual Studio.</Description>
77
<PackageId>GitHub.VisualStudio</PackageId>

src/GitHub.VisualStudio/GitHub.VisualStudio.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@
296296
</ItemGroup>
297297
<ItemGroup>
298298
<PackageReference Include="Madskristensen.VisualStudio.SDK" Version="14.3.75-pre" />
299+
<PackageReference Include="Microsoft.VisualStudio.Telemetry">
300+
<Version>15.0.691-master31907920</Version>
301+
</PackageReference>
299302
<PackageReference Include="Microsoft.VSSDK.BuildTools">
300303
<Version>15.8.3252</Version>
301304
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

src/GitHub.VisualStudio/Services/UsageTracker.cs

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using GitHub.Logging;
88
using GitHub.Models;
99
using GitHub.Settings;
10+
using Microsoft.VisualStudio.Telemetry;
11+
using Microsoft.VisualStudio.Text.Editor;
1012
using Microsoft.VisualStudio.Threading;
1113
using Serilog;
1214
using Task = System.Threading.Tasks.Task;
@@ -15,14 +17,33 @@ namespace GitHub.Services
1517
{
1618
public sealed class UsageTracker : IUsageTracker, IDisposable
1719
{
20+
private const int TelemetryVersion = 1; // Please update the version every time you want to indicate a change in telemetry logic when the extension itself is updated
21+
22+
private const string EventNamePrefix = "vs/github/usagetracker/";
23+
private const string PropertyPrefix = "vs.github.";
24+
25+
static class Event
26+
{
27+
public const string UsageTracker = EventNamePrefix + "increment-counter";
28+
}
29+
30+
static class Property
31+
{
32+
public const string TelemetryVersion = PropertyPrefix + nameof(TelemetryVersion);
33+
public const string CounterName = PropertyPrefix + nameof(CounterName);
34+
public const string ExtensionVersion = PropertyPrefix + nameof(ExtensionVersion);
35+
public const string IsGitHubUser = PropertyPrefix + nameof(IsGitHubUser);
36+
public const string IsEnterpriseUser = PropertyPrefix + nameof(IsEnterpriseUser);
37+
}
38+
1839
static readonly ILogger log = LogManager.ForContext<UsageTracker>();
1940
readonly IGitHubServiceProvider gitHubServiceProvider;
2041

2142
bool initialized;
2243
IMetricsService client;
23-
IUsageService service;
44+
readonly IUsageService service;
2445
IConnectionManager connectionManager;
25-
IPackageSettings userSettings;
46+
readonly IPackageSettings userSettings;
2647
IVSServices vsservices;
2748
IDisposable timer;
2849
bool firstTick = true;
@@ -48,13 +69,51 @@ public void Dispose()
4869
public async Task IncrementCounter(Expression<Func<UsageModel.MeasuresModel, int>> counter)
4970
{
5071
await Initialize();
51-
var data = await service.ReadLocalData();
52-
var usage = await GetCurrentReport(data);
72+
5373
var property = (MemberExpression)counter.Body;
5474
var propertyInfo = (PropertyInfo)property.Member;
55-
log.Verbose("Increment counter {Name}", propertyInfo.Name);
56-
var value = (int)propertyInfo.GetValue(usage.Measures);
75+
var counterName = propertyInfo.Name;
76+
log.Verbose("Increment counter {Name}", counterName);
77+
78+
var updateTask = UpdateUsageMetrics(propertyInfo);
79+
80+
LogTelemetryEvent(counterName);
81+
82+
await updateTask;
83+
}
84+
85+
void LogTelemetryEvent(string counterName)
86+
{
87+
const string numberOfPrefix = "numberof";
88+
if (counterName.StartsWith(numberOfPrefix, StringComparison.OrdinalIgnoreCase))
89+
{
90+
counterName = counterName.Substring(numberOfPrefix.Length);
91+
}
92+
93+
var operation = new TelemetryEvent(Event.UsageTracker);
94+
operation.Properties[Property.TelemetryVersion] = TelemetryVersion;
95+
operation.Properties[Property.CounterName] = counterName;
96+
operation.Properties[Property.ExtensionVersion] = AssemblyVersionInformation.Version;
97+
operation.Properties[Property.IsGitHubUser] = IsGitHubUser;
98+
operation.Properties[Property.IsEnterpriseUser] = IsEnterpriseUser;
99+
100+
TelemetryService.DefaultSession.PostEvent(operation);
101+
}
102+
103+
bool IsEnterpriseUser =>
104+
this.connectionManager?.Connections.Any(x => !x.HostAddress.IsGitHubDotCom()) ?? false;
105+
106+
bool IsGitHubUser =>
107+
this.connectionManager?.Connections.Any(x => x.HostAddress.IsGitHubDotCom()) ?? false;
108+
109+
async Task UpdateUsageMetrics(PropertyInfo propertyInfo)
110+
{
111+
var data = await service.ReadLocalData();
112+
var usage = await GetCurrentReport(data);
113+
114+
var value = (int) propertyInfo.GetValue(usage.Measures);
57115
propertyInfo.SetValue(usage.Measures, value + 1);
116+
58117
await service.WriteLocalData(data);
59118
}
60119

@@ -138,8 +197,8 @@ async Task<UsageModel> GetCurrentReport(UsageData data)
138197
current.Dimensions.AppVersion = AssemblyVersionInformation.Version;
139198
current.Dimensions.VSVersion = vsservices.VSVersion;
140199

141-
current.Dimensions.IsGitHubUser = connectionManager.Connections.Any(x => x.HostAddress.IsGitHubDotCom());
142-
current.Dimensions.IsEnterpriseUser = connectionManager.Connections.Any(x => !x.HostAddress.IsGitHubDotCom());
200+
current.Dimensions.IsGitHubUser = IsGitHubUser;
201+
current.Dimensions.IsEnterpriseUser = IsEnterpriseUser;
143202
return current;
144203
}
145204

src/common/SolutionInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
namespace System
1919
{
2020
internal static class AssemblyVersionInformation {
21-
internal const string Version = "2.10.2.0";
21+
internal const string Version = "2.10.3.0";
2222
}
2323
}

0 commit comments

Comments
 (0)