Skip to content

Commit 2f65230

Browse files
committed
Report a bit more telemetry
1 parent db677c7 commit 2f65230

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/IncompatibleProjectNotifier.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Microsoft.CodeAnalysis.Razor;
1212
using Microsoft.CodeAnalysis.Razor.Cohost;
1313
using Microsoft.CodeAnalysis.Razor.Logging;
14+
using Microsoft.CodeAnalysis.Razor.Telemetry;
1415
using WorkspacesSR = Microsoft.CodeAnalysis.Razor.Workspaces.Resources.SR;
1516

1617
namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
@@ -19,14 +20,17 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
1920
[Export(typeof(IIncompatibleProjectNotifier))]
2021
[method: ImportingConstructor]
2122
internal sealed class IncompatibleProjectNotifier(
23+
ITelemetryReporter telemetryReporter,
2224
ILoggerFactory loggerFactory) : IIncompatibleProjectNotifier, IProjectCapabilityListener
2325
{
2426
private readonly ILogger _logger = loggerFactory.GetOrCreateLogger<IncompatibleProjectNotifier>();
2527

2628
private readonly HashSet<string> _frameworkProjects = new(PathUtilities.OSSpecificPathComparer);
29+
private readonly ITelemetryReporter _telemetryReporter = telemetryReporter;
2730

2831
public void NotifyMiscFilesDocument(TextDocument textDocument)
2932
{
33+
_telemetryReporter.ReportEvent("cohost/miscFilesDocument", Severity.Normal);
3034
_logger.Log(LogLevel.Error, $"{WorkspacesSR.FormatIncompatibleProject_MiscFiles(Path.GetFileName(textDocument.FilePath))}");
3135
}
3236

@@ -41,11 +45,13 @@ public void NotifyMissingDocument(Project project, string filePath)
4145
if (_frameworkProjects.Contains(project.FilePath.AssumeNotNull()))
4246
{
4347
// This project doesn't have the .NET Core C# capability, so it's a .NET Framework project and we don't want
48+
4449
// to notify the user, as those projects use a different editor.
4550
return;
4651
}
4752
}
4853

54+
_telemetryReporter.ReportEvent("cohost/missingDocument", Severity.Normal);
4955
_logger.Log(LogLevel.Error, $"{(
5056
project.AdditionalDocuments.Any(d => d.FilePath is not null && d.FilePath.IsRazorFilePath())
5157
? WorkspacesSR.FormatIncompatibleProject_NotAnAdditionalFile(Path.GetFileName(filePath), project.Name)

src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Services/IncompatibleProjectNotifier.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,29 @@
1010
using Microsoft.CodeAnalysis.Razor;
1111
using Microsoft.CodeAnalysis.Razor.Cohost;
1212
using Microsoft.CodeAnalysis.Razor.Logging;
13+
using Microsoft.CodeAnalysis.Razor.Telemetry;
1314
using WorkspacesSR = Microsoft.CodeAnalysis.Razor.Workspaces.Resources.SR;
1415

1516
namespace Microsoft.VisualStudioCode.RazorExtension.Services;
1617

1718
[Export(typeof(IIncompatibleProjectNotifier))]
1819
[method: ImportingConstructor]
19-
internal sealed class IncompatibleProjectNotifier(ILoggerFactory loggerFactory) : IIncompatibleProjectNotifier
20+
internal sealed class IncompatibleProjectNotifier(
21+
ITelemetryReporter telemetryReporter,
22+
ILoggerFactory loggerFactory) : IIncompatibleProjectNotifier
2023
{
2124
private readonly ILogger _logger = loggerFactory.GetOrCreateLogger<IncompatibleProjectNotifier>();
25+
private readonly ITelemetryReporter _telemetryReporter = telemetryReporter;
2226

2327
public void NotifyMiscFilesDocument(TextDocument textDocument)
2428
{
29+
_telemetryReporter.ReportEvent("cohost/miscFilesDocument", Severity.Normal);
2530
_logger.Log(LogLevel.Error, $"{WorkspacesSR.FormatIncompatibleProject_MiscFiles(Path.GetFileName(textDocument.FilePath))}");
2631
}
2732

2833
public void NotifyMissingDocument(Project project, string filePath)
2934
{
35+
_telemetryReporter.ReportEvent("cohost/missingDocument", Severity.Normal);
3036
_logger.Log(LogLevel.Error, $"{(
3137
project.AdditionalDocuments.Any(d => d.FilePath is not null && d.FilePath.IsRazorFilePath())
3238
? WorkspacesSR.FormatIncompatibleProject_NotAnAdditionalFile(Path.GetFileName(filePath), project.Name)

0 commit comments

Comments
 (0)