mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[Telemetry]Re-add preview handlers telemetry logs and add tracers (#35597)
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Common;
|
||||
using Common.Utilities;
|
||||
using Microsoft.PowerToys.PreviewHandler.Pdf.Properties;
|
||||
using Microsoft.PowerToys.PreviewHandler.Pdf.Telemetry.Events;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Windows.Data.Pdf;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.UI.ViewManagement;
|
||||
@@ -149,9 +158,25 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
memStream.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new PdfFilePreviewed());
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new PdfFilePreviewError { Message = ex.Message });
|
||||
}
|
||||
catch
|
||||
{ // Should not crash if sending telemetry is failing. Ignore the exception.
|
||||
}
|
||||
|
||||
Controls.Clear();
|
||||
_infoBar = GetTextBoxControl(Resources.PdfNotPreviewedError);
|
||||
Controls.Add(_infoBar);
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Globalization;
|
||||
using System.Windows.Threading;
|
||||
|
||||
using Common.UI;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using PowerToys.Interop;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
@@ -26,6 +27,8 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
{
|
||||
if (args.Length == 6)
|
||||
{
|
||||
ETWTrace etwTrace = new ETWTrace(Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "AppData", "LocalLow", "Microsoft", "PowerToys", "etw"));
|
||||
|
||||
string filePath = args[0];
|
||||
IntPtr hwnd = IntPtr.Parse(args[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
|
||||
@@ -51,12 +54,16 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
Rectangle s = default;
|
||||
if (!_previewHandlerControl.SetRect(s))
|
||||
{
|
||||
etwTrace?.Dispose();
|
||||
|
||||
// When the parent HWND became invalid, the application won't respond to Application.Exit().
|
||||
Environment.Exit(0);
|
||||
}
|
||||
},
|
||||
Dispatcher.CurrentDispatcher,
|
||||
_tokenSource.Token);
|
||||
|
||||
etwTrace?.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Pdf.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event that is triggered when a pdf file is viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class PdfFileHandlerLoaded : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Pdf.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event that is triggered when an error occurs while attempting to view a markdown file in the preview pane.
|
||||
/// </summary>
|
||||
public class PdfFilePreviewError : EventBase, IEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the error message.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Diagnostics.Tracing;
|
||||
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry.Events;
|
||||
|
||||
namespace Microsoft.PowerToys.PreviewHandler.Pdf.Telemetry.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// A telemetry event that is triggered when a markdown file is viewed in the preview pane.
|
||||
/// </summary>
|
||||
[EventData]
|
||||
public class PdfFilePreviewed : EventBase, IEvent
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user