Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Telemetry for File Explorer Source Control Integration feature inside Dev Home #3484

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
ssparach marked this conversation as resolved.
Show resolved Hide resolved

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
Loading