Skip to content

Commit

Permalink
feature: Add ApplicationInsights telemetry
Browse files Browse the repository at this point in the history
Relates to #6021

* Capture (seleted) application telemetry information
* Allow telemetry information capture be toggled via a toolbar button
* Allow telemetry information capture be toggled via the settings dialog

The following information is captured:

Application-Level includes:
* Exception information
* Version number (e.g. 2.0.x.x)
* Is portable version
* Build type (whether the application is an official release build or not)
* Selected layout settings (such as visibility of the left panel,
commit info position etc)
* Change of selected layout settings
* Git version (e.g. 2.19.0)
* SSH client (e.g. OpenSSH or PuTTY)

Operating System-Level includes:
    * Version (e.g. Windows 10.0.17763.0)
    * Machine Name (e.g. MyFastPC)
    * .NET CLR version (e.g. 4.0.30319.42000)
    * .NET SDK version (e.g. dotnet:2.10.0-24102)
    * Current culture
    * Current UI culture
    * Number of monitors
    * Resolution of all monitors
    * Primary monitor DPI / scale factor
  • Loading branch information
RussKie committed May 7, 2019
1 parent 2175f79 commit 53c0a0b
Show file tree
Hide file tree
Showing 17 changed files with 448 additions and 5 deletions.
6 changes: 6 additions & 0 deletions GitCommands/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ static AppSettings()
}
}

public static bool TelemetryEnabled
{
get => GetBool("TelemetryEnabled", true);
set => SetBool("TelemetryEnabled", value);
}

public static bool AutoNormaliseBranchName
{
get => GetBool("AutoNormaliseBranchName", true);
Expand Down
1 change: 1 addition & 0 deletions GitExtensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
GitExtensions.ruleset = GitExtensions.ruleset
GitExtensionsTest.ruleset = GitExtensionsTest.ruleset
LICENSE.md = LICENSE.md
PrivacyPolicy.md = PrivacyPolicy.md
README.md = README.md
EndProjectSection
EndProject
Expand Down
6 changes: 6 additions & 0 deletions GitExtensions/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using GitUI;
using GitUI.CommandsDialogs.SettingsDialog;
using GitUI.CommandsDialogs.SettingsDialog.Pages;
using GitUI.Infrastructure.Telemetry;
using JetBrains.Annotations;
using Microsoft.VisualStudio.Threading;
using ResourceManager;
Expand Down Expand Up @@ -48,6 +49,8 @@ private static void Main()
return UserEnvironmentInformation.GetInformation();
};

DiagnosticsClient.Initialize(ThisAssembly.Git.IsDirty);

if (!Debugger.IsAttached)
{
AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;
Expand Down Expand Up @@ -86,6 +89,9 @@ private static void RunApplication()
}

AppSettings.LoadSettings();

new AppStartDiagnosticsReporter().Report();

if (EnvUtils.RunningOnWindows())
{
WebBrowserEmulationMode.SetBrowserFeatureControl();
Expand Down
19 changes: 19 additions & 0 deletions GitUI/ApplicationInsights.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
<InstrumentationKey>2ef275e3-8850-4305-9d7c-825a60c3d296</InstrumentationKey>
<TelemetryInitializers>
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.DeviceTelemetryInitializer, AppInsights.WindowsDesktop"/>
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.SessionTelemetryInitializer, AppInsights.WindowsDesktop"/>
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.VersionTelemetryInitializer, AppInsights.WindowsDesktop"/>
</TelemetryInitializers>
<TelemetryModules>
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.DeveloperModeWithDebuggerAttachedTelemetryModule, AppInsights.WindowsDesktop"/>
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.UnhandledExceptionTelemetryModule, AppInsights.WindowsDesktop"/>
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.UnobservedExceptionTelemetryModule, AppInsights.WindowsDesktop" />
<!--<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.FirstChanceExceptionStatisticsTelemetryModule, AppInsights.WindowsDesktop" />-->
</TelemetryModules>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>
</TelemetryProcessors>
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.PersistenceChannel, AppInsights.WindowsDesktop"/>
</ApplicationInsights>
19 changes: 17 additions & 2 deletions GitUI/CommandsDialogs/FormBrowse.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion GitUI/CommandsDialogs/FormBrowse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using GitUI.CommandsDialogs.BrowseDialog.DashboardControl;
using GitUI.CommandsDialogs.WorktreeDialog;
using GitUI.Hotkey;
using GitUI.Infrastructure.Telemetry;
using GitUI.Properties;
using GitUI.Script;
using GitUI.UserControls;
Expand Down Expand Up @@ -98,7 +99,7 @@ public sealed partial class FormBrowse : GitModuleForm, IBrowseRepo
[CanBeNull] private readonly IAheadBehindDataProvider _aheadBehindDataProvider;
private readonly WindowsJumpListManager _windowsJumpListManager;
private readonly SubmoduleStatusProvider _submoduleStatusProvider;

private readonly FormBrowseDiagnosticsReporter _formBrowseDiagnosticsReporter;
[CanBeNull] private BuildReportTabPageExtension _buildReportTabPageExtension;
private ConEmuControl _terminal;
private Dashboard _dashboard;
Expand Down Expand Up @@ -131,6 +132,8 @@ public FormBrowse([NotNull] GitUICommands commands, string filter, ObjectId sele
{
InitializeComponent();

_formBrowseDiagnosticsReporter = new FormBrowseDiagnosticsReporter(this);

commandsToolStripMenuItem.DropDownOpening += CommandsToolStripMenuItem_DropDownOpening;

MainSplitContainer.Visible = false;
Expand Down Expand Up @@ -506,6 +509,9 @@ protected override void OnLoad(EventArgs e)

toolStripButtonPush.Initialize(_aheadBehindDataProvider);
toolStripButtonPush.DisplayAheadBehindInformation(Module.GetSelectedBranch());
tsbtnEnableTelemetry.Checked = AppSettings.TelemetryEnabled;

_formBrowseDiagnosticsReporter.Report();

base.OnLoad(e);
}
Expand Down Expand Up @@ -641,6 +647,8 @@ private void ShowDashboard()
_dashboard.RefreshContent();
_dashboard.Visible = true;
_dashboard.BringToFront();

DiagnosticsClient.TrackPageView("Dashboard");
}

private void HideDashboard()
Expand All @@ -658,6 +666,8 @@ private void HideDashboard()
toolPanel.LeftToolStripPanelVisible = true;
toolPanel.RightToolStripPanelVisible = true;
toolPanel.ResumeLayout();

DiagnosticsClient.TrackPageView("Revision graph");
}

private void UpdatePluginMenu(bool validWorkingDir)
Expand Down Expand Up @@ -2985,12 +2995,18 @@ private void toolStripMenuItemReflog_Click(object sender, EventArgs e)
private void toggleSplitViewLayout_Click(object sender, EventArgs e)
{
AppSettings.ShowSplitViewLayout = !AppSettings.ShowSplitViewLayout;
DiagnosticsClient.TrackEvent("Layout change",
new Dictionary<string, string> { { nameof(AppSettings.ShowSplitViewLayout), AppSettings.ShowSplitViewLayout.ToString() } });

RefreshSplitViewLayout();
}

private void toggleBranchTreePanel_Click(object sender, EventArgs e)
{
MainSplitContainer.Panel1Collapsed = !MainSplitContainer.Panel1Collapsed;
DiagnosticsClient.TrackEvent("Layout change",
new Dictionary<string, string> { { "ShowLeftPanel", MainSplitContainer.Panel1Collapsed.ToString() } });

RefreshLayoutToggleButtonStates();
}

Expand All @@ -3016,13 +3032,19 @@ private void CommitInfoPositionClick(object sender, EventArgs e)
private void SetCommitInfoPosition(CommitInfoPosition position)
{
AppSettings.CommitInfoPosition = position;
DiagnosticsClient.TrackEvent("Layout change",
new Dictionary<string, string> { { nameof(AppSettings.CommitInfoPosition), AppSettings.CommitInfoPosition.ToString() } });

LayoutRevisionInfo();
RefreshLayoutToggleButtonStates();
}

private void RefreshSplitViewLayout()
{
RightSplitContainer.Panel2Collapsed = !AppSettings.ShowSplitViewLayout;
DiagnosticsClient.TrackEvent("Layout change",
new Dictionary<string, string> { { nameof(AppSettings.ShowSplitViewLayout), AppSettings.ShowSplitViewLayout.ToString() } });

RefreshLayoutToggleButtonStates();
}

Expand Down Expand Up @@ -3194,5 +3216,10 @@ private void FormBrowse_DragEnter(object sender, DragEventArgs e)
e.Effect = DragDropEffects.Move;
}
}

private void TsbtnEnableTelemetry_Click(object sender, EventArgs e)
{
AppSettings.TelemetryEnabled = tsbtnEnableTelemetry.Checked;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using GitCommands;
Expand Down Expand Up @@ -38,7 +39,8 @@ protected override void OnRuntimeLoad()
base.OnRuntimeLoad();

// align 1st columns across all tables
tlpnlBehaviour.AdjustWidthToSize(0, lblCommitsLimit, lblDefaultCloneDestination);
tlpnlBehaviour.AdjustWidthToSize(0, lblDefaultCloneDestination);
tlpnlTelemetry.AdjustWidthToSize(0, lblDefaultCloneDestination);
}

private void SetSubmoduleStatus()
Expand Down Expand Up @@ -69,6 +71,8 @@ protected override void SettingsToPage()
cbDefaultCloneDestination.Text = AppSettings.DefaultCloneDestinationPath;
chkFollowRenamesInFileHistoryExact.Checked = AppSettings.FollowRenamesInFileHistoryExactOnly;
SetSubmoduleStatus();

chkTelemetry.Checked = AppSettings.TelemetryEnabled;
}

protected override void PageToSettings()
Expand All @@ -92,6 +96,8 @@ protected override void PageToSettings()

AppSettings.DefaultCloneDestinationPath = cbDefaultCloneDestination.Text;
AppSettings.FollowRenamesInFileHistoryExactOnly = chkFollowRenamesInFileHistoryExact.Checked;

AppSettings.TelemetryEnabled = chkTelemetry.Checked;
}

private static Func<Repository, string> GetParentPath()
Expand Down Expand Up @@ -127,5 +133,10 @@ private void ShowGitStatus_CheckedChanged(object sender, System.EventArgs e)
{
SetSubmoduleStatus();
}

private void LlblTelemetryPrivacyLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://github.com/gitextensions/gitextensions/blob/master/PrivacyPolicy.md");
}
}
}
2 changes: 2 additions & 0 deletions GitUI/GitModuleForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Windows.Forms;
using GitCommands;
using GitUI.Infrastructure.Telemetry;
using GitUI.Script;
using JetBrains.Annotations;

Expand Down Expand Up @@ -62,6 +63,7 @@ protected GitModuleForm([NotNull] GitUICommands commands)
: base(enablePositionRestore: true)
{
_uiCommands = commands;
DiagnosticsClient.TrackPageView(GetType().FullName);
}

protected override CommandStatus ExecuteCommand(int command)
Expand Down
Loading

0 comments on commit 53c0a0b

Please sign in to comment.