Skip to content

Commit

Permalink
Added telemetry for Data team
Browse files Browse the repository at this point in the history
  • Loading branch information
SohamDas2021 committed Apr 8, 2024
1 parent c243131 commit 14100ee
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
using CommunityToolkit.Mvvm.Input;
using DevHome.Common.Extensions;
using DevHome.Common.Services;
using DevHome.Common.TelemetryEvents;
using DevHome.Telemetry;
using Microsoft.UI.Xaml.Controls;
using Serilog;
using Windows.Media.Protection;
using Windows.Storage.Pickers;
using WinUIEx;

Expand Down Expand Up @@ -88,7 +91,7 @@ private async Task BrowseButtonClick(object sender)
}
}

private void MoveDirectory(string sourceDirectory, string targetDirectory)
private int MoveDirectory(string sourceDirectory, string targetDirectory)
{
try
{
Expand Down Expand Up @@ -120,10 +123,13 @@ private void MoveDirectory(string sourceDirectory, string targetDirectory)

// Delete the source directory
Directory.Delete(sourceDirectory, true);
return 0;
}
catch (Exception ex)
{
Log.Error($"Error in MoveDirectory. Error: {ex}");
TelemetryFactory.Get<ITelemetry>().LogError("DevDriveInsights_PackageCacheMove_Error", LogLevel.Critical, new ExceptionEvent(ex.HResult, sourceDirectory));
return ex.HResult;
}
}

Expand Down Expand Up @@ -163,10 +169,12 @@ private void DirectoryInputConfirmed()
// TODO: If chosen folder not a dev drive location, currently we no-op and log the error. Instead we should display the error.
if (ChosenDirectoryInDevDrive(directoryPath))
{
MoveDirectory(ExistingCacheLocation, directoryPath);
SetEnvironmentVariable(EnvironmentVariableToBeSet, directoryPath);

Log.Debug($"Moved cache from {ExistingCacheLocation} to {directoryPath}");
if (MoveDirectory(ExistingCacheLocation, directoryPath) == 0)
{
SetEnvironmentVariable(EnvironmentVariableToBeSet, directoryPath);
Log.Debug($"Moved cache from {ExistingCacheLocation} to {directoryPath}");
TelemetryFactory.Get<ITelemetry>().Log("DevDriveInsights_PackageCacheMoved_Event", LogLevel.Critical, new ExceptionEvent(0, ExistingCacheLocation));
}
}
else
{
Expand Down

0 comments on commit 14100ee

Please sign in to comment.