Skip to content

Commit

Permalink
Basic Telemetry for File Explorer Source Control Integration feature …
Browse files Browse the repository at this point in the history
…inside Dev Home (#3484)

* proposed telemetry changes for add/remove repository

* remove unrequired using statements

* address PR feedback

* address PR feedback

* adjust comment

* add count of repos tracked inside Dev Home to event
  • Loading branch information
ssparach authored Jul 26, 2024
1 parent a27d47a commit b956d2d
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Diagnostics.Tracing;
using DevHome.Telemetry;
using Microsoft.Diagnostics.Telemetry;
using Microsoft.Diagnostics.Telemetry.Internal;

namespace DevHome.Common.TelemetryEvents.SourceControlIntegration;

[EventData]
public class SourceControlIntegrationEvent : EventBase
{
public override PartA_PrivTags PartA_PrivTags => PrivTags.ProductAndServicePerformance;

public string RepositoryRootPath
{
get;
}

public int TrackedRepositoryCount
{
get;
}

public SourceControlIntegrationEvent(string sourceControlProviderClassId, string repositoryRootPath, int trackedRepositoryCount)
{
RepositoryRootPath = SourceControlIntegrationHelper.GetSafeRootPath(repositoryRootPath);
TrackedRepositoryCount = trackedRepositoryCount;
}

public override void ReplaceSensitiveStrings(Func<string, string> replaceSensitiveStrings)
{
// The only sensitive strings is the repository root path. GetSafeRootPath is used to potentially remove PII and
// keep last part of path.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.IO;
using System.Linq;

namespace DevHome.Common.TelemetryEvents.SourceControlIntegration;

public static class SourceControlIntegrationHelper
{
public static string GetSafeRootPath(string rootPath)
{
var parts = rootPath.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
return parts.LastOrDefault() ?? string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Diagnostics.Tracing;
using DevHome.Telemetry;
using Microsoft.Diagnostics.Telemetry;
using Microsoft.Diagnostics.Telemetry.Internal;

namespace DevHome.Common.TelemetryEvents.SourceControlIntegration;

[EventData]
public class SourceControlIntegrationUserEvent : EventBase
{
public override PartA_PrivTags PartA_PrivTags => PrivTags.ProductAndServicePerformance;

public string RepositoryRootPath
{
get;
}

public int TrackedRepositoryCount
{
get;
}

public SourceControlIntegrationUserEvent(string sourceControlProviderClassId, string repositoryRootPath, int trackedRepositoryCount)
{
RepositoryRootPath = SourceControlIntegrationHelper.GetSafeRootPath(repositoryRootPath);
TrackedRepositoryCount = trackedRepositoryCount;
}

public override void ReplaceSensitiveStrings(Func<string, string> replaceSensitiveStrings)
{
// The only sensitive strings is the repository root path. GetSafeRootPath is used to potentially remove PII and
// keep last part of path.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using DevHome.Common.Helpers;
using DevHome.Common.Services;
using DevHome.Common.TelemetryEvents.SourceControlIntegration;
using DevHome.Telemetry;
using Serilog;
using Windows.Storage;

Expand Down Expand Up @@ -101,13 +103,16 @@ public void AddRepositoryPath(string extensionCLSID, string rootPath)
log.Warning("Repository root path already registered in the repo store");
}
}

TelemetryFactory.Get<ITelemetry>().Log("AddEnhancedRepository_Event", LogLevel.Critical, new SourceControlIntegrationEvent(extensionCLSID, rootPath, TrackedRepositories.Count));
}

public void RemoveRepositoryPath(string rootPath)
{
var extensionCLSID = string.Empty;
lock (trackRepoLock)
{
TrackedRepositories.TryGetValue(rootPath, out var extensionCLSID);
TrackedRepositories.TryGetValue(rootPath, out extensionCLSID);
TrackedRepositories.Remove(rootPath);
fileService.Save(RepoStoreOptions.RepoStoreFolderPath, RepoStoreOptions.RepoStoreFileName, TrackedRepositories);
log.Information("Repository removed from repo store");
Expand All @@ -120,6 +125,8 @@ public void RemoveRepositoryPath(string rootPath)
log.Error(ex, $"Removed event signaling failed: ");
}
}

TelemetryFactory.Get<ITelemetry>().Log("RemoveEnhancedRepository_Event", LogLevel.Critical, new SourceControlIntegrationEvent(extensionCLSID ?? string.Empty, rootPath, TrackedRepositories.Count));
}

public Dictionary<string, string> GetAllTrackedRepositories()
Expand Down

0 comments on commit b956d2d

Please sign in to comment.