Skip to content

Commit 7cbb45b

Browse files
committed
feature: Add ApplicationInsights telemetry
Relates to gitextensions#6021 * Capture (selected) application telemetry information * Prompt user to allow telemetry upon start up, if it isn't configured * Allow telemetry information capture be toggled via a About menu * 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
1 parent 903acb9 commit 7cbb45b

23 files changed

Lines changed: 533 additions & 14 deletions

GitCommands/Settings/AppSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ static AppSettings()
108108
}
109109
}
110110

111+
public static bool? TelemetryEnabled
112+
{
113+
get => GetBool("TelemetryEnabled");
114+
set => SetBool("TelemetryEnabled", value);
115+
}
116+
111117
public static bool AutoNormaliseBranchName
112118
{
113119
get => GetBool("AutoNormaliseBranchName", true);

GitExtensions.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
158158
GitExtensionsTest.ruleset = GitExtensionsTest.ruleset
159159
LICENSE.md = LICENSE.md
160160
PrivacyPolicy.rtf = PrivacyPolicy.rtf
161+
PrivacyPolicy.md = PrivacyPolicy.md
161162
README.md = README.md
162163
EndProjectSection
163164
EndProject

GitExtensions/Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
using GitUI;
1010
using GitUI.CommandsDialogs.SettingsDialog;
1111
using GitUI.CommandsDialogs.SettingsDialog.Pages;
12+
using GitUI.Infrastructure.Telemetry;
1213
using JetBrains.Annotations;
1314
using Microsoft.VisualStudio.Threading;
15+
using ResourceManager;
1416

1517
namespace GitExtensions
1618
{
@@ -29,6 +31,8 @@ private static void Main()
2931

3032
try
3133
{
34+
DiagnosticsClient.Initialize(ThisAssembly.Git.IsDirty);
35+
3236
if (!Debugger.IsAttached)
3337
{
3438
AppDomain.CurrentDomain.UnhandledException += (s, e) => ReportBug((Exception)e.ExceptionObject);
@@ -67,6 +71,7 @@ private static void RunApplication()
6771
}
6872

6973
AppSettings.LoadSettings();
74+
7075
if (EnvUtils.RunningOnWindows())
7176
{
7277
WebBrowserEmulationMode.SetBrowserFeatureControl();
@@ -81,6 +86,13 @@ private static void RunApplication()
8186
}
8287
}
8388

89+
if (!AppSettings.TelemetryEnabled.HasValue)
90+
{
91+
AppSettings.TelemetryEnabled = MessageBox.Show(null, Strings.TelemetryPersmissionMessage,
92+
Strings.TelemetryPersmissionCaption, MessageBoxButtons.YesNo,
93+
MessageBoxIcon.Question) == DialogResult.Yes;
94+
}
95+
8496
try
8597
{
8698
// Ensure we can find the git command to execute,

GitUI/ApplicationInsights.config

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
3+
<InstrumentationKey>3d09f612-9640-4682-829c-3f6ac1ed3e86</InstrumentationKey>
4+
<TelemetryInitializers>
5+
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.DeviceTelemetryInitializer, AppInsights.WindowsDesktop"/>
6+
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.SessionTelemetryInitializer, AppInsights.WindowsDesktop"/>
7+
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.VersionTelemetryInitializer, AppInsights.WindowsDesktop"/>
8+
</TelemetryInitializers>
9+
<TelemetryModules>
10+
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.DeveloperModeWithDebuggerAttachedTelemetryModule, AppInsights.WindowsDesktop"/>
11+
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.UnhandledExceptionTelemetryModule, AppInsights.WindowsDesktop"/>
12+
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.UnobservedExceptionTelemetryModule, AppInsights.WindowsDesktop" />
13+
<!--<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.FirstChanceExceptionStatisticsTelemetryModule, AppInsights.WindowsDesktop" />-->
14+
</TelemetryModules>
15+
<TelemetryProcessors>
16+
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>
17+
</TelemetryProcessors>
18+
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.PersistenceChannel, AppInsights.WindowsDesktop"/>
19+
</ApplicationInsights>

GitUI/CommandsDialogs/FormBrowse.Designer.cs

Lines changed: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GitUI/CommandsDialogs/FormBrowse.cs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using GitUI.CommandsDialogs.BrowseDialog.DashboardControl;
2525
using GitUI.CommandsDialogs.WorktreeDialog;
2626
using GitUI.Hotkey;
27+
using GitUI.Infrastructure.Telemetry;
2728
using GitUI.Properties;
2829
using GitUI.Script;
2930
using GitUI.UserControls;
@@ -85,6 +86,7 @@ public sealed partial class FormBrowse : GitModuleForm, IBrowseRepo
8586

8687
private readonly TranslationString _undoLastCommitText = new TranslationString("You will still be able to find all the commit's changes in the staging area\n\nDo you want to continue?");
8788
private readonly TranslationString _undoLastCommitCaption = new TranslationString("Undo last commit");
89+
8890
#endregion
8991

9092
private readonly SplitterManager _splitterManager = new SplitterManager(new AppSettingsPath("FormBrowse"));
@@ -99,7 +101,7 @@ public sealed partial class FormBrowse : GitModuleForm, IBrowseRepo
99101
[CanBeNull] private readonly IAheadBehindDataProvider _aheadBehindDataProvider;
100102
private readonly WindowsJumpListManager _windowsJumpListManager;
101103
private readonly SubmoduleStatusProvider _submoduleStatusProvider;
102-
104+
private readonly FormBrowseDiagnosticsReporter _formBrowseDiagnosticsReporter;
103105
[CanBeNull] private BuildReportTabPageExtension _buildReportTabPageExtension;
104106
private ConEmuControl _terminal;
105107
private Dashboard _dashboard;
@@ -137,6 +139,8 @@ public FormBrowse([NotNull] GitUICommands commands, string filter, ObjectId sele
137139
recoverLostObjectsToolStripMenuItem.Image = light ? Images.RecoverLostObjects : Images.RecoverLostObjects_inv;
138140
branchSelect.Image = light ? Resources.branch : Resources.branch_inv;
139141

142+
_formBrowseDiagnosticsReporter = new FormBrowseDiagnosticsReporter(this);
143+
140144
commandsToolStripMenuItem.DropDownOpening += CommandsToolStripMenuItem_DropDownOpening;
141145

142146
MainSplitContainer.Visible = false;
@@ -522,6 +526,8 @@ protected override void OnLoad(EventArgs e)
522526
toolStripButtonPush.Initialize(_aheadBehindDataProvider);
523527
toolStripButtonPush.DisplayAheadBehindInformation(Module.GetSelectedBranch());
524528

529+
_formBrowseDiagnosticsReporter.Report();
530+
525531
base.OnLoad(e);
526532
}
527533

@@ -656,6 +662,8 @@ private void ShowDashboard()
656662
_dashboard.RefreshContent();
657663
_dashboard.Visible = true;
658664
_dashboard.BringToFront();
665+
666+
DiagnosticsClient.TrackPageView("Dashboard");
659667
}
660668

661669
private void HideDashboard()
@@ -673,6 +681,8 @@ private void HideDashboard()
673681
toolPanel.LeftToolStripPanelVisible = true;
674682
toolPanel.RightToolStripPanelVisible = true;
675683
toolPanel.ResumeLayout();
684+
685+
DiagnosticsClient.TrackPageView("Revision graph");
676686
}
677687

678688
private void UpdatePluginMenu(bool validWorkingDir)
@@ -1320,12 +1330,6 @@ private void PushToolStripMenuItemClick(object sender, EventArgs e)
13201330
UICommands.StartPushDialog(this, pushOnShow: ModifierKeys.HasFlag(Keys.Shift));
13211331
}
13221332

1323-
private void RefreshStatus()
1324-
{
1325-
UpdateSubmodulesStructure();
1326-
UpdateStashCount();
1327-
}
1328-
13291333
private void RefreshToolStripMenuItemClick(object sender, EventArgs e)
13301334
{
13311335
// Broadcast RepoChanged in case repo was changed outside of GE
@@ -3023,12 +3027,18 @@ private void toolStripMenuItemReflog_Click(object sender, EventArgs e)
30233027
private void toggleSplitViewLayout_Click(object sender, EventArgs e)
30243028
{
30253029
AppSettings.ShowSplitViewLayout = !AppSettings.ShowSplitViewLayout;
3030+
DiagnosticsClient.TrackEvent("Layout change",
3031+
new Dictionary<string, string> { { nameof(AppSettings.ShowSplitViewLayout), AppSettings.ShowSplitViewLayout.ToString() } });
3032+
30263033
RefreshSplitViewLayout();
30273034
}
30283035

30293036
private void toggleBranchTreePanel_Click(object sender, EventArgs e)
30303037
{
30313038
MainSplitContainer.Panel1Collapsed = !MainSplitContainer.Panel1Collapsed;
3039+
DiagnosticsClient.TrackEvent("Layout change",
3040+
new Dictionary<string, string> { { "ShowLeftPanel", MainSplitContainer.Panel1Collapsed.ToString() } });
3041+
30323042
RefreshLayoutToggleButtonStates();
30333043
}
30343044

@@ -3054,13 +3064,19 @@ private void CommitInfoRightwardClick(object sender, EventArgs e) =>
30543064
private void SetCommitInfoPosition(CommitInfoPosition position)
30553065
{
30563066
AppSettings.CommitInfoPosition = position;
3067+
DiagnosticsClient.TrackEvent("Layout change",
3068+
new Dictionary<string, string> { { nameof(AppSettings.CommitInfoPosition), AppSettings.CommitInfoPosition.ToString() } });
3069+
30573070
LayoutRevisionInfo();
30583071
RefreshLayoutToggleButtonStates();
30593072
}
30603073

30613074
private void RefreshSplitViewLayout()
30623075
{
30633076
RightSplitContainer.Panel2Collapsed = !AppSettings.ShowSplitViewLayout;
3077+
DiagnosticsClient.TrackEvent("Layout change",
3078+
new Dictionary<string, string> { { nameof(AppSettings.ShowSplitViewLayout), AppSettings.ShowSplitViewLayout.ToString() } });
3079+
30643080
RefreshLayoutToggleButtonStates();
30653081
}
30663082

@@ -3232,5 +3248,15 @@ private void FormBrowse_DragEnter(object sender, DragEventArgs e)
32323248
e.Effect = DragDropEffects.Move;
32333249
}
32343250
}
3251+
3252+
private void TsmiTelemetryEnabled_Click(object sender, EventArgs e)
3253+
{
3254+
UICommands.StartGeneralSettingsDialog(this);
3255+
}
3256+
3257+
private void HelpToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
3258+
{
3259+
tsmiTelemetryEnabled.Checked = AppSettings.TelemetryEnabled ?? false;
3260+
}
32353261
}
32363262
}

GitUI/CommandsDialogs/FormBrowse.resx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,15 @@
126126
<metadata name="toolStripSeparator14.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
127127
<value>False</value>
128128
</metadata>
129-
<metadata name="ToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
130-
<value>251, 17</value>
131-
</metadata>
132129
<metadata name="toolStripSeparator11.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
133130
<value>False</value>
134131
</metadata>
132+
<metadata name="toolStripMenuItem3.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
133+
<value>False</value>
134+
</metadata>
135+
<metadata name="ToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
136+
<value>251, 17</value>
137+
</metadata>
135138
<metadata name="FilterToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
136139
<value>17, 17</value>
137140
</metadata>

0 commit comments

Comments
 (0)