Added App Center events for the export of screenshot, this only stored which export was used and no sensitive information.

This commit is contained in:
Robin Krom 2019-09-06 15:30:16 +02:00
commit 51041f0f83
3 changed files with 39 additions and 4 deletions

View file

@ -45,7 +45,7 @@ namespace Greenshot.Addons.Extensions
/// Find the matching IDestination /// Find the matching IDestination
/// </summary> /// </summary>
/// <param name="destinations">IEnumerable of IDestination</param> /// <param name="destinations">IEnumerable of IDestination</param>
/// <param name="destination">strng with the destination</param> /// <param name="destination">string with the destination</param>
/// <returns>IDestination or null</returns> /// <returns>IDestination or null</returns>
public static IDestination Find(this IEnumerable<IDestination> destinations, string destination) public static IDestination Find(this IEnumerable<IDestination> destinations, string destination)
{ {

View file

@ -0,0 +1,32 @@
using System.Collections.Generic;
using Greenshot.Addons.Interfaces;
using Microsoft.AppCenter.Analytics;
namespace Greenshot.Helpers
{
public static class AppCenterExtensions
{
public static void HandleAppCenterEvent(this ExportInformation exportInformation)
{
if (exportInformation == null)
{
return;
}
if (exportInformation.IsError)
{
Analytics.TrackEvent("ExportError", new Dictionary<string, string> {
{ "DestinationDescription", exportInformation.DestinationDescription },
{ "Destination", exportInformation.DestinationDesignation},
{ "ErrorMessage", exportInformation.ErrorMessage}
});
return;
}
Analytics.TrackEvent("Export", new Dictionary<string, string> {
{ "DestinationDescription", exportInformation.DestinationDescription },
{ "Destination", exportInformation.DestinationDesignation}
});
}
}
}

View file

@ -433,11 +433,11 @@ namespace Greenshot.Helpers
{ {
if (filename.ToLower().EndsWith("." + OutputFormats.greenshot)) if (filename.ToLower().EndsWith("." + OutputFormats.greenshot))
{ {
var surface = ImageOutput.SurfaceFactory(); var surface = ImageOutput.SurfaceFactory();
surface = ImageOutput.LoadGreenshotSurface(filename, surface); surface = ImageOutput.LoadGreenshotSurface(filename, surface);
surface.CaptureDetails = _capture.CaptureDetails; surface.CaptureDetails = _capture.CaptureDetails;
_destinationHolder.SortedActiveDestinations.Find("Editor")?.ExportCaptureAsync(true, surface, _capture.CaptureDetails).Wait(); var exportInformation = _destinationHolder.SortedActiveDestinations.Find("Editor")?.ExportCaptureAsync(true, surface, _capture.CaptureDetails).Result;
exportInformation.HandleAppCenterEvent();
break; break;
} }
} }
@ -627,7 +627,9 @@ namespace Greenshot.Helpers
if (captureDetails.HasDestination(typeof(PickerDestination).GetDesignation())) if (captureDetails.HasDestination(typeof(PickerDestination).GetDesignation()))
{ {
_destinationHolder.SortedActiveDestinations.Find(typeof(PickerDestination))?.ExportCaptureAsync(false, surface, captureDetails).Wait(); var exportInformation = _destinationHolder.SortedActiveDestinations.Find(typeof(PickerDestination))?.ExportCaptureAsync(false, surface, captureDetails).Result;
exportInformation.HandleAppCenterEvent();
captureDetails.CaptureDestinations.Clear(); captureDetails.CaptureDestinations.Clear();
canDisposeSurface = false; canDisposeSurface = false;
} }
@ -652,6 +654,7 @@ namespace Greenshot.Helpers
Log.Info().WriteLine("Calling destination {0}", destination.Description); Log.Info().WriteLine("Calling destination {0}", destination.Description);
var exportInformation = destination.ExportCaptureAsync(false, surface, captureDetails).Result; var exportInformation = destination.ExportCaptureAsync(false, surface, captureDetails).Result;
exportInformation.HandleAppCenterEvent();
if ("Editor".Equals(destination.Designation) && exportInformation.ExportMade) if ("Editor".Equals(destination.Designation) && exportInformation.ExportMade)
{ {
canDisposeSurface = false; canDisposeSurface = false;