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

Commit ec46954

Browse files
committed
Restore missing metrics
1 parent 5730008 commit ec46954

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

src/GitHub.InlineReviews/Services/PullRequestStatusBarManager.cs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Windows;
3+
using System.Windows.Input;
34
using System.Windows.Controls;
45
using System.Windows.Controls.Primitives;
56
using System.ComponentModel.Composition;
@@ -9,6 +10,7 @@
910
using GitHub.Services;
1011
using GitHub.Models;
1112
using GitHub.Logging;
13+
using GitHub.Extensions;
1214
using Serilog;
1315
using ReactiveUI;
1416

@@ -69,12 +71,17 @@ void RefreshCurrentSession()
6971

7072
PullRequestStatusViewModel CreatePullRequestStatusViewModel(IPullRequestModel pullRequest)
7173
{
72-
var pullRequestStatusViewModel = new PullRequestStatusViewModel(showCurrentPullRequestCommand);
74+
var trackingCommand = new UsageTrackingCommand(showCurrentPullRequestCommand, usageTracker);
75+
var pullRequestStatusViewModel = new PullRequestStatusViewModel(trackingCommand);
7376
pullRequestStatusViewModel.Number = pullRequest.Number;
7477
pullRequestStatusViewModel.Title = pullRequest.Title;
7578
return pullRequestStatusViewModel;
7679
}
7780

81+
void IncrementNumberOfShowCurrentPullRequest()
82+
{
83+
}
84+
7885
void ShowStatus(PullRequestStatusViewModel pullRequestStatusViewModel = null)
7986
{
8087
var statusBar = FindSccStatusBar(Application.Current.MainWindow);
@@ -113,5 +120,41 @@ StatusBar FindSccStatusBar(Window mainWindow)
113120
var contentControl = mainWindow?.Template?.FindName(StatusBarPartName, mainWindow) as ContentControl;
114121
return contentControl?.Content as StatusBar;
115122
}
123+
124+
class UsageTrackingCommand : ICommand
125+
{
126+
readonly ICommand command;
127+
readonly IUsageTracker usageTracker;
128+
129+
internal UsageTrackingCommand(ICommand command, IUsageTracker usageTracker)
130+
{
131+
this.command = command;
132+
this.usageTracker = usageTracker;
133+
}
134+
135+
public event EventHandler CanExecuteChanged
136+
{
137+
add
138+
{
139+
command.CanExecuteChanged += value;
140+
}
141+
142+
remove
143+
{
144+
command.CanExecuteChanged -= value;
145+
}
146+
}
147+
148+
public bool CanExecute(object parameter)
149+
{
150+
return command.CanExecute(parameter);
151+
}
152+
153+
public void Execute(object parameter)
154+
{
155+
command.Execute(parameter);
156+
usageTracker.IncrementCounter(x => x.NumberOfShowCurrentPullRequest).Forget();
157+
}
158+
}
116159
}
117160
}

0 commit comments

Comments
 (0)