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

Commit 871bba1

Browse files
committed
Add metrics to PullRequestFileMargin
Increment NumberOfPullRequestFileMarginToggleInlineCommentMargin when checkbox is toggled. Increment NumberOfPullRequestFileMarginViewChanges when view changes/comments is clicked.
1 parent 7b4c565 commit 871bba1

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

src/GitHub.Exports/Models/UsageModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public class MeasuresModel
7272
public int NumberOfTeamExplorerHomeOpenPullRequestList { get; set; }
7373
public int NumberOfNavigateToPullRequestFileDiff { get; set; }
7474
public int ExecuteToggleInlineCommentMarginCommand { get; set; }
75+
public int NumberOfPullRequestFileMarginToggleInlineCommentMargin { get; set; }
76+
public int NumberOfPullRequestFileMarginViewChanges { get; set; }
7577
}
7678
}
7779
}

src/GitHub.InlineReviews/Margins/PullRequestFileMargin.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using GitHub.Extensions;
1010
using GitHub.InlineReviews.Views;
1111
using GitHub.InlineReviews.ViewModels;
12-
using GitHub.InlineReviews.Commands;
1312
using Microsoft.VisualStudio.Text.Editor;
1413
using ReactiveUI;
1514
using Task = System.Threading.Tasks.Task;
@@ -38,12 +37,13 @@ public PullRequestFileMargin(
3837
IWpfTextView textView,
3938
IToggleInlineCommentMarginCommand toggleInlineCommentMarginCommand,
4039
IGoToSolutionOrPullRequestFileCommand goToSolutionOrPullRequestFileCommand,
41-
IPullRequestSessionManager sessionManager)
40+
IPullRequestSessionManager sessionManager,
41+
Lazy<IUsageTracker> usageTracker)
4242
{
4343
this.textView = textView;
4444
this.sessionManager = sessionManager;
4545

46-
viewModel = new PullRequestFileMarginViewModel(toggleInlineCommentMarginCommand, goToSolutionOrPullRequestFileCommand);
46+
viewModel = new PullRequestFileMarginViewModel(toggleInlineCommentMarginCommand, goToSolutionOrPullRequestFileCommand, usageTracker);
4747
visualElement = new PullRequestFileMarginView { DataContext = viewModel, ClipToBounds = true };
4848

4949
visibilitySubscription = viewModel.WhenAnyValue(x => x.Enabled).Subscribe(enabled =>

src/GitHub.InlineReviews/Margins/PullRequestFileMarginProvider.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using GitHub.Commands;
44
using GitHub.Services;
55
using GitHub.Settings;
6-
using GitHub.InlineReviews.Commands;
76
using Microsoft.VisualStudio.Utilities;
87
using Microsoft.VisualStudio.Text.Editor;
98

@@ -24,18 +23,21 @@ internal sealed class PullRequestFileMarginProvider : IWpfTextViewMarginProvider
2423
readonly IToggleInlineCommentMarginCommand enableInlineCommentsCommand;
2524
readonly IGoToSolutionOrPullRequestFileCommand goToSolutionOrPullRequestFileCommand;
2625
readonly IPackageSettings packageSettings;
26+
readonly Lazy<IUsageTracker> usageTracker;
2727

2828
[ImportingConstructor]
2929
public PullRequestFileMarginProvider(
3030
IToggleInlineCommentMarginCommand enableInlineCommentsCommand,
3131
IGoToSolutionOrPullRequestFileCommand goToSolutionOrPullRequestFileCommand,
3232
IPullRequestSessionManager sessionManager,
33-
IPackageSettings packageSettings)
33+
IPackageSettings packageSettings,
34+
Lazy<IUsageTracker> usageTracker)
3435
{
3536
this.enableInlineCommentsCommand = enableInlineCommentsCommand;
3637
this.goToSolutionOrPullRequestFileCommand = goToSolutionOrPullRequestFileCommand;
3738
this.sessionManager = sessionManager;
3839
this.packageSettings = packageSettings;
40+
this.usageTracker = usageTracker;
3941
}
4042

4143
/// <summary>
@@ -60,8 +62,8 @@ public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTex
6062
return null;
6163
}
6264

63-
return new PullRequestFileMargin(wpfTextViewHost.TextView, enableInlineCommentsCommand, goToSolutionOrPullRequestFileCommand,
64-
sessionManager);
65+
return new PullRequestFileMargin(
66+
wpfTextViewHost.TextView, enableInlineCommentsCommand, goToSolutionOrPullRequestFileCommand, sessionManager, usageTracker);
6567
}
6668

6769
bool IsDiffView(ITextView textView) => textView.Roles.Contains("DIFF");

src/GitHub.InlineReviews/ViewModels/PullRequestFileMarginViewModel.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System.Windows.Input;
1+
using System;
2+
using System.Windows.Input;
3+
using GitHub.Commands;
4+
using GitHub.Services;
25
using ReactiveUI;
36

47
namespace GitHub.InlineReviews.ViewModels
@@ -10,10 +13,13 @@ public class PullRequestFileMarginViewModel : ReactiveObject
1013
int commentsInFile;
1114
bool marginEnabled;
1215

13-
public PullRequestFileMarginViewModel(ICommand toggleInlineCommentMarginCommand, ICommand viewChangesCommand)
16+
public PullRequestFileMarginViewModel(ICommand toggleInlineCommentMarginCommand, ICommand viewChangesCommand,
17+
Lazy<IUsageTracker> usageTracker)
1418
{
15-
ToggleInlineCommentMarginCommand = toggleInlineCommentMarginCommand;
16-
ViewChangesCommand = viewChangesCommand;
19+
ToggleInlineCommentMarginCommand = toggleInlineCommentMarginCommand = new UsageTrackingCommand(
20+
usageTracker, x => x.NumberOfPullRequestFileMarginToggleInlineCommentMargin, toggleInlineCommentMarginCommand);
21+
ViewChangesCommand = viewChangesCommand = new UsageTrackingCommand(
22+
usageTracker, x => x.NumberOfPullRequestFileMarginViewChanges, viewChangesCommand);
1723
}
1824

1925
public bool Enabled

0 commit comments

Comments
 (0)