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

Commit 57bf0f7

Browse files
committed
Merge pull request #227 from github/feature/metrics
Collect anonymous metrics
2 parents a4673c1 + 427e315 commit 57bf0f7

22 files changed

+1023
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,4 @@ WiX.Toolset.DummyFile.txt
238238
nunit-UnitTests.xml
239239
nunit-TrackingCollectionTests.xml
240240
GitHubVS.sln.DotSettings
241+
**/generated/*.cs
55.3 KB
Binary file not shown.

lib/Microsoft.TextTemplating.targets

Lines changed: 535 additions & 0 deletions
Large diffs are not rendered by default.
52.3 KB
Binary file not shown.

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,17 @@
9595
<None Include="..\..\script\Key.snk" Condition="$(Buildtype) == 'Internal'">
9696
<Link>Key.snk</Link>
9797
</None>
98+
<None Include="..\common\settings.json">
99+
<Link>Properties\settings.json</Link>
100+
</None>
98101
<Compile Include="Collections\ICopyable.cs" />
99102
<Compile Include="ExceptionExtensions.cs" />
100103
<Compile Include="Extensions\VSExtensions.cs" />
101104
<Compile Include="GlobalSuppressions.cs" />
102105
<Compile Include="Helpers\INotifyPropertySource.cs" />
103106
<Compile Include="Extensions\PropertyNotifierExtensions.cs" />
104107
<Compile Include="Extensions\SimpleRepositoryModelExtensions.cs" />
108+
<Compile Include="Helpers\SettingsStore.cs" />
105109
<Compile Include="Info\ApplicationInfo.cs" />
106110
<Compile Include="Models\IAccount.cs" />
107111
<Compile Include="Models\IConnectionManager.cs" />
@@ -134,6 +138,11 @@
134138
<ItemGroup>
135139
<Compile Include="Authentication\AuthenticationResultExtensions.cs" />
136140
<Compile Include="Extensions\ServiceProviderExtensions.cs" />
141+
<Compile Include="Settings\generated\IPackageSettings.cs">
142+
<AutoGen>True</AutoGen>
143+
<DesignTime>True</DesignTime>
144+
<DependentUpon>IPackageSettings.tt</DependentUpon>
145+
</Compile>
137146
<Compile Include="ViewModels\IServiceProviderAware.cs" />
138147
<Compile Include="UI\IView.cs" />
139148
<Compile Include="UI\Octicon.cs" />
@@ -178,7 +187,18 @@
178187
<Private>True</Private>
179188
</ProjectReference>
180189
</ItemGroup>
190+
<ItemGroup>
191+
<Content Include="Settings\generated\IPackageSettings.tt">
192+
<Generator>TextTemplatingFileGenerator</Generator>
193+
<LastGenOutput>IPackageSettings.cs</LastGenOutput>
194+
</Content>
195+
</ItemGroup>
196+
<ItemGroup>
197+
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
198+
</ItemGroup>
181199
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
200+
<Import Project="$(SolutionDir)\src\common\t4.targets" />
201+
<Import Project="$(SolutionDir)\lib\Microsoft.TextTemplating.targets" />
182202
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
183203
Other similar extension points exist, see Microsoft.Common.targets.
184204
<Target Name="BeforeBuild">
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System.IO;
2+
using Microsoft.VisualStudio.Settings;
3+
using GitHub.Extensions;
4+
5+
namespace GitHub.Helpers
6+
{
7+
public class SettingsStore
8+
{
9+
readonly WritableSettingsStore store;
10+
readonly string root;
11+
public SettingsStore(WritableSettingsStore store, string root)
12+
{
13+
Guard.ArgumentNotNull(store, nameof(store));
14+
Guard.ArgumentNotNull(root, nameof(root));
15+
Guard.ArgumentNotEmptyString(root, nameof(root));
16+
this.store = store;
17+
this.root = root;
18+
}
19+
20+
public object Read(string property, object defaultValue)
21+
{
22+
return Read(null, property, defaultValue);
23+
}
24+
25+
/// <summary>
26+
/// Read from a settings store
27+
/// </summary>
28+
/// <typeparam name="T"></typeparam>
29+
/// <param name="subpath">The subcollection path (appended to the path passed to the constructor)</param>
30+
/// <param name="property">The property name to read</param>
31+
/// <param name="defaultValue">The default value to use in case the property doesn't exist.
32+
/// The type of the default value will be used to figure out the proper way to read the property, so if pass null,
33+
/// the property will be read as a string (which may or may not be what you want)</param>
34+
/// <returns></returns>
35+
public object Read(string subpath, string property, object defaultValue)
36+
{
37+
Guard.ArgumentNotNull(property, nameof(property));
38+
Guard.ArgumentNotEmptyString(property, nameof(property));
39+
40+
var collection = subpath != null ? Path.Combine(root, subpath) : root;
41+
store.CreateCollection(collection);
42+
43+
if (defaultValue is bool)
44+
return store.GetBoolean(collection, property, (bool)defaultValue);
45+
else if (defaultValue is int)
46+
return store.GetInt32(collection, property, (int)defaultValue);
47+
else if (defaultValue is uint)
48+
return store.GetUInt32(collection, property, (uint)defaultValue);
49+
else if (defaultValue is long)
50+
return store.GetInt64(collection, property, (long)defaultValue);
51+
else if (defaultValue is ulong)
52+
return store.GetUInt64(collection, property, (ulong)defaultValue);
53+
return store.GetString(collection, property, defaultValue?.ToString() ?? "");
54+
}
55+
56+
public void Write(string property, object value)
57+
{
58+
Write(null, property, value);
59+
}
60+
61+
public void Write(string subpath, string property, object value)
62+
{
63+
Guard.ArgumentNotNull(property, nameof(property));
64+
Guard.ArgumentNotEmptyString(property, nameof(property));
65+
66+
var collection = subpath != null ? Path.Combine(root, subpath) : root;
67+
store.CreateCollection(collection);
68+
69+
if (value is bool)
70+
store.SetBoolean(collection, property, (bool)value);
71+
else if (value is int)
72+
store.SetInt32(collection, property, (int)value);
73+
else if (value is uint)
74+
store.SetUInt32(collection, property, (uint)value);
75+
else if (value is long)
76+
store.SetInt64(collection, property, (long)value);
77+
else if (value is ulong)
78+
store.SetUInt64(collection, property, (ulong)value);
79+
else
80+
store.SetString(collection, property, value?.ToString() ?? "");
81+
}
82+
}
83+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<#@ template debug="false" hostspecific="true" language="C#" #>
2+
<#@ assembly name="System.Core" #>
3+
<#@ import namespace="System.Linq" #>
4+
<#@ import namespace="System.Text" #>
5+
<#@ import namespace="System.Collections.Generic" #>
6+
<#@ import namespace="System.IO" #>
7+
<#@ assembly name="$(PackageDir)\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll" #>
8+
<#@ import namespace="Newtonsoft.Json.Linq" #>
9+
<#@ output extension=".cs" #>
10+
<#
11+
var file = this.Host.ResolvePath(@"..\..\..\common\settings.json");
12+
var json = JObject.Parse(File.ReadAllText(file));
13+
#>
14+
// This is an automatically generated file, based on settings.json and PackageSettingsGen.tt
15+
/* settings.json content:
16+
<#@ include file="..\..\..\common\settings.json" #>
17+
*/
18+
namespace GitHub.Settings
19+
{
20+
public interface IPackageSettings
21+
{
22+
void Save();
23+
<#
24+
foreach (var j in json["settings"].Children()) {
25+
#>
26+
<#= j["type"] #> <#= j["name"] #> { get; set; }
27+
<#
28+
}
29+
#>
30+
}
31+
}

src/GitHub.VisualStudio/GitHub.VisualStudio.csproj

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,21 @@
241241
<Compile Include="Base\TeamExplorerNavigationItemBase.cs" />
242242
<Compile Include="Base\TeamExplorerSectionBase.cs" />
243243
<Compile Include="Helpers\Browser.cs" />
244-
<Compile Include="Helpers\Colors.cs" />
245-
<Compile Include="Helpers\Constants.cs" />
244+
<Compile Include="Settings\Colors.cs" />
245+
<Compile Include="Settings\Constants.cs" />
246246
<Compile Include="Services\ConnectionManager.cs" />
247+
<Compile Include="Settings\OptionsPage.cs">
248+
<SubType>Component</SubType>
249+
</Compile>
247250
<Compile Include="Services\Program.cs" />
248251
<Compile Include="Services\SharedResources.cs" />
249-
<Compile Include="Settings.cs" />
252+
<Compile Include="Settings\PackageSettings.cs" />
253+
<Compile Include="Settings\generated\PackageSettings.cs">
254+
<AutoGen>True</AutoGen>
255+
<DesignTime>True</DesignTime>
256+
<DependentUpon>PackageSettings.tt</DependentUpon>
257+
</Compile>
258+
<Compile Include="Settings\Settings.cs" />
250259
<Compile Include="Base\PackageBase.cs" />
251260
<Compile Include="Resources.Designer.cs">
252261
<AutoGen>True</AutoGen>
@@ -273,6 +282,9 @@
273282
<Compile Include="Base\EnsureLoggedInSection.cs" />
274283
<Compile Include="UI\DrawingExtensions.cs" />
275284
<Compile Include="UI\GitHubPane.cs" />
285+
<Compile Include="UI\Settings\OptionsControl.xaml.cs">
286+
<DependentUpon>OptionsControl.xaml</DependentUpon>
287+
</Compile>
276288
<Compile Include="UI\Views\Controls\RepositoryCloneControl.xaml.cs">
277289
<DependentUpon>RepositoryCloneControl.xaml</DependentUpon>
278290
</Compile>
@@ -333,9 +345,16 @@
333345
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
334346
<IncludeInVSIX>true</IncludeInVSIX>
335347
</Content>
348+
<Content Include="Settings\generated\PackageSettings.tt">
349+
<Generator>TextTemplatingFileGenerator</Generator>
350+
<CustomToolNamespace>GitHub.VisualStudio.Settings</CustomToolNamespace>
351+
</Content>
336352
<None Include="packages.config">
337353
<SubType>Designer</SubType>
338354
</None>
355+
<None Include="..\common\settings.json">
356+
<Link>Properties\settings.json</Link>
357+
</None>
339358
<None Include="source.extension.vsixmanifest">
340359
<SubType>Designer</SubType>
341360
</None>
@@ -410,6 +429,11 @@
410429
<Generator>MSBuild:Compile</Generator>
411430
<SubType>Designer</SubType>
412431
</Page>
432+
<Page Include="UI\Settings\OptionsControl.xaml">
433+
<SubType>Designer</SubType>
434+
<Generator>MSBuild:Compile</Generator>
435+
<CustomToolNamespace>GitHub.VisualStudio.UI</CustomToolNamespace>
436+
</Page>
413437
<Page Include="UI\Views\Controls\ActionLinkButton.xaml">
414438
<SubType>Designer</SubType>
415439
<Generator>MSBuild:Compile</Generator>
@@ -578,12 +602,18 @@
578602
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup;</IncludeOutputGroupsInVSIXLocalOnly>
579603
</ProjectReference>
580604
</ItemGroup>
605+
<ItemGroup>
606+
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
607+
</ItemGroup>
581608
<PropertyGroup>
582609
<UseCodebase>true</UseCodebase>
583610
</PropertyGroup>
584611
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
585612
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
586613
<Import Project="packaging.targets" />
614+
<!-- For regenerating templates on build -->
615+
<Import Project="$(SolutionDir)\src\common\t4.targets" />
616+
<Import Project="$(SolutionDir)\lib\Microsoft.TextTemplating.targets" />
587617
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
588618
<PropertyGroup>
589619
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>

src/GitHub.VisualStudio/GitHubPackage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace GitHub.VisualStudio
3535
//[ProvideAutoLoad(UIContextGuids.NoSolution)]
3636
[ProvideAutoLoad("11B8E6D7-C08B-4385-B321-321078CDD1F8")]
3737
[ProvideToolWindow(typeof(GitHubPane), Orientation = ToolWindowOrientation.Right, Style = VsDockStyle.Tabbed, Window = EnvDTE.Constants.vsWindowKindSolutionExplorer)]
38+
[ProvideOptionPage(typeof(OptionsPage), "GitHub for Visual Studio", "General", 0, 0, supportsAutomation: true)]
3839
public class GitHubPackage : PackageBase
3940
{
4041
public GitHubPackage()

src/GitHub.VisualStudio/LICENSE.txt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ IF YOU DO NOT AGREE TO ALL OF THE TERMS OF THIS EULA, DO NOT INSTALL, USE OR COP
99
• You must agree to all of the terms of this EULA to use this Software.
1010
• If so, you may use the Software for free and for any lawful purpose.
1111
• This Software automatically communicates with GitHub servers
12-
for three reasons: (1) to receive and install updates; (2) to send error
13-
reports; and (3) to send anonymized usage information. You can view
12+
for two reasons: (1) to send error reports; and
13+
(2) to send anonymized usage information. You can view
1414
sample data to see what information is sent, and you may opt out of
1515
sending the anonymized usage data.
1616
• This Software is provided "as-is" with no warranties, and you agree
@@ -42,6 +42,25 @@ This EULA entitles you to install as many copies of the Software as you want, an
4242
4. You may not remove or alter any proprietary notices or marks on
4343
the Software.
4444

45+
PRIVACY NOTICES
46+
47+
The Software automatically communicates with GitHub servers for two purposes: (1) sending error reports; and (2) sending anonymized usage data so we may improve the Software. If you would like to learn more about the specific information we send, please visit https://visualstudio.github.com/samples.html. You may opt out of sending the anonymized usage data, but if you do not want the Software to send error reports, you must uninstall the Software.
48+
49+
1. ERROR REPORTS. In order to help us improve the Software, when the
50+
Software encounters certain errors, it will automatically send some
51+
information to GitHub about the error (as described at the URL
52+
above).
53+
This feature may not be disabled. If you do not want to send error
54+
reports to GitHub, you must uninstall the Software.
55+
56+
2. ANONYMIZED USAGE DATA. GitHub collects anonymized data about
57+
your usage of the Software to help us make it more awesome.
58+
Approximately once a day the Software sends such data
59+
(as described in more detail at the URL above) to GitHub's servers.
60+
If you do not want to send anonymized usage data to GitHub,
61+
you may opt out by changing your settings in the
62+
Visual Studio Options dialog under the GitHub section.
63+
4564
OPEN-SOURCE NOTICES
4665

4766
Certain components of the Software may be subject to open-source software licenses ("Open-Source Components"), which means any software license approved as open-source licenses by the Open Source Initiative or any substantially similar licenses, including without limitation any license that, as a condition of distribution of the software licensed under such license, requires that the distributor make the software available in source code format. If you would like to see copies of the licenses applicable to the Open-Source Components, please visit https://visualstudio.github.com/credits.html.

0 commit comments

Comments
 (0)