From 63ad37d1dcbcaa34b0f74e486c95cdfa683243d9 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Wed, 12 Feb 2020 17:34:04 -0800 Subject: [PATCH 1/7] Added telemetry base class and markdown telemetry class --- .../MarkDownPreviewHandler.csproj | 1 + .../MarkdownPreviewHandlerControl.cs | 1 + .../MarkdownTelemetry.cs | 43 +++++++++++++++++++ .../common/PreviewHandlerCommon.csproj | 1 + .../common/Telemetry/TelemetryBase.cs | 41 ++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs create mode 100644 src/modules/previewpane/common/Telemetry/TelemetryBase.cs diff --git a/src/modules/previewpane/MarkDownPreviewHandler/MarkDownPreviewHandler.csproj b/src/modules/previewpane/MarkDownPreviewHandler/MarkDownPreviewHandler.csproj index 889a9927111f..5f0adad69e83 100644 --- a/src/modules/previewpane/MarkDownPreviewHandler/MarkDownPreviewHandler.csproj +++ b/src/modules/previewpane/MarkDownPreviewHandler/MarkDownPreviewHandler.csproj @@ -60,6 +60,7 @@ Form + True diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs index 9adf6c8d876d..98ea14c3a2ad 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs +++ b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs @@ -116,6 +116,7 @@ public override void DoPreview(T dataSource) this.Resize += this.FormResized; base.DoPreview(dataSource); + MarkdownTelemetry.Log.MarkdownFilePreviewed(); }); } diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs new file mode 100644 index 000000000000..4d485ce3a076 --- /dev/null +++ b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs @@ -0,0 +1,43 @@ +// 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 PreviewHandlerCommon.Telemetry; + +namespace MarkdownPreviewHandler +{ + /// + /// Telemetry helper class for markdown renderer. + /// + public class MarkdownTelemetry : TelemetryBase + { + private const string EventSourceName = "Microsoft.PowerToys"; + + /// + /// Initializes a new instance of the class. + /// + public MarkdownTelemetry() + : base(EventSourceName) + { + return; + } + + /// + /// Gets an instance of the class. + /// + public static MarkdownTelemetry Log { get; } = new MarkdownTelemetry(); + + /// + /// Publishes ETW event when markdown is previewed successfully. + /// + public void MarkdownFilePreviewed() + { + this.Write("PowerPreview_PreviewPane_MDRendererPreviewed", new EventSourceOptions() + { + Keywords = TelemetryBase.PROJECTKEYWORDMEASURE, + Tags = TelemetryBase.ProjectTelemetryTagProductAndServicePerformance, + }); + } + } +} diff --git a/src/modules/previewpane/common/PreviewHandlerCommon.csproj b/src/modules/previewpane/common/PreviewHandlerCommon.csproj index b3d2f9e1e824..e3ea92add2a2 100644 --- a/src/modules/previewpane/common/PreviewHandlerCommon.csproj +++ b/src/modules/previewpane/common/PreviewHandlerCommon.csproj @@ -79,6 +79,7 @@ + diff --git a/src/modules/previewpane/common/Telemetry/TelemetryBase.cs b/src/modules/previewpane/common/Telemetry/TelemetryBase.cs new file mode 100644 index 000000000000..64c2a1b84d72 --- /dev/null +++ b/src/modules/previewpane/common/Telemetry/TelemetryBase.cs @@ -0,0 +1,41 @@ +// 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.Eventing.Reader; +using System.Diagnostics.Tracing; + +namespace PreviewHandlerCommon.Telemetry +{ + /// + /// Base class for telemetry events. + /// + public class TelemetryBase : EventSource + { + /// + /// The event tag for this event source. + /// + public const EventTags ProjectTelemetryTagProductAndServicePerformance = (EventTags)0x0u; + + /// + /// The event keyword for this event source. + /// + public const EventKeywords PROJECTKEYWORDMEASURE = (EventKeywords)0x0; + + private static readonly string[] PowerToysTelemetryTraits = { "ETW_GROUP", "{42749043-438c-46a2-82be-c6cbeb192ff2}" }; + + /// + /// Initializes a new instance of the class. + /// + /// . + public TelemetryBase( + string eventSourceName) + : base( + eventSourceName, + EventSourceSettings.EtwSelfDescribingEventFormat, + PowerToysTelemetryTraits) + { + return; + } + } +} From 34b1edd254775ee96d6ed8de313a52197ac27533 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Thu, 13 Feb 2020 09:32:26 -0800 Subject: [PATCH 2/7] Updated docstring for telemetry event. --- .../previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs | 3 +++ src/modules/previewpane/common/Telemetry/TelemetryBase.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs index 4d485ce3a076..2580fad0886d 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs +++ b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs @@ -12,6 +12,9 @@ namespace MarkdownPreviewHandler /// public class MarkdownTelemetry : TelemetryBase { + /// + /// Name for ETW event. + /// private const string EventSourceName = "Microsoft.PowerToys"; /// diff --git a/src/modules/previewpane/common/Telemetry/TelemetryBase.cs b/src/modules/previewpane/common/Telemetry/TelemetryBase.cs index 64c2a1b84d72..664d8cb97a9e 100644 --- a/src/modules/previewpane/common/Telemetry/TelemetryBase.cs +++ b/src/modules/previewpane/common/Telemetry/TelemetryBase.cs @@ -22,6 +22,9 @@ public class TelemetryBase : EventSource /// public const EventKeywords PROJECTKEYWORDMEASURE = (EventKeywords)0x0; + /// + /// Group ID for Powertoys project. + /// private static readonly string[] PowerToysTelemetryTraits = { "ETW_GROUP", "{42749043-438c-46a2-82be-c6cbeb192ff2}" }; /// From 6f11a33c8cb898135fa5ecbbfccdc85e441a2e3e Mon Sep 17 00:00:00 2001 From: Divyansh Date: Thu, 13 Feb 2020 10:31:03 -0800 Subject: [PATCH 3/7] Added telemetry to markdown for error --- .../Properties/AssemblyInfo.cs | 4 ++-- .../MarkdownPreviewHandler/MarkdownTelemetry.cs | 16 ++++++++++++++++ .../common/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/modules/previewpane/MarkDownPreviewHandler/Properties/AssemblyInfo.cs b/src/modules/previewpane/MarkDownPreviewHandler/Properties/AssemblyInfo.cs index 9b60e01ac060..5d921a3f7aea 100644 --- a/src/modules/previewpane/MarkDownPreviewHandler/Properties/AssemblyInfo.cs +++ b/src/modules/previewpane/MarkDownPreviewHandler/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.8")] +[assembly: AssemblyFileVersion("1.0.0.8")] diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs index 2580fad0886d..315058e0dba8 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs +++ b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics.Tracing; +using System.Windows.Forms; using PreviewHandlerCommon.Telemetry; namespace MarkdownPreviewHandler @@ -42,5 +43,20 @@ public void MarkdownFilePreviewed() Tags = TelemetryBase.ProjectTelemetryTagProductAndServicePerformance, }); } + + /// + /// Publishes ETW event when markdown could not be previewed. + /// + public void MarkdownFilePreviewError(string message) + { + this.Write( + "PowerPreview_PreviewPane_MDRendererError", + new EventSourceOptions() + { + Keywords = TelemetryBase.PROJECTKEYWORDMEASURE, + Tags = TelemetryBase.ProjectTelemetryTagProductAndServicePerformance, + }, + new { Message = message, }); + } } } diff --git a/src/modules/previewpane/common/Properties/AssemblyInfo.cs b/src/modules/previewpane/common/Properties/AssemblyInfo.cs index 0afe1c322bbb..418546782834 100644 --- a/src/modules/previewpane/common/Properties/AssemblyInfo.cs +++ b/src/modules/previewpane/common/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.8")] +[assembly: AssemblyFileVersion("1.0.0.8")] From 7681fdc1484d8390e7a596f0b8de47698811fd2f Mon Sep 17 00:00:00 2001 From: Divyansh Date: Thu, 13 Feb 2020 14:56:22 -0800 Subject: [PATCH 4/7] Added try catch for markdown preview handler and display error bar --- src/common/Telemetry/PowerToys.wprp | Bin 1533 -> 393216 bytes .../Properties/AssemblyInfo.cs | 4 +- .../MarkdownPreviewHandlerControl.cs | 102 +++++++++++------- .../MarkdownTelemetry.cs | 9 +- .../Properties/Resources.Designer.cs | 9 ++ .../Properties/Resources.resx | 4 + .../common/Properties/AssemblyInfo.cs | 4 +- 7 files changed, 84 insertions(+), 48 deletions(-) diff --git a/src/common/Telemetry/PowerToys.wprp b/src/common/Telemetry/PowerToys.wprp index 70ccf172aa159e305ad73bb810820d4e3de03cb2..6f49e9929c852917e29ed8ed70b8b6513894aa75 100644 GIT binary patch literal 393216 zcmeI*34Bv!xvVKYYW^vj?6~^m2pM~@_$ZB0ofNpmfty_ znNCkibWNv^(88jYk(d&6u?JtZ;aVH@sf2G-`e$VapgkPWNL! z^}XUbG^AWQ?m_ZGK8iYW&>ZgVd`v_$sGeGRUJKPwBM&IhuqE7 z^x8eUwhMx9ibzj>zkT@dgiM;p%j$WMc6k1O>;H3`^two*C!g}EXEM?7YNF3JKHT{@ z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##AOHafKmY;|fB*y_009U<00Izz00bZa z0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV= z5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHaf zKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_ z009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz g00bZa0SG_<0uX=z1Rwwb2tWV=5P$##E+c{e4{R;sv;Y7A literal 1533 zcmb_c(Qbk;6n*zAn!W=X=fngwQ@6xK7qczyaY49X6X2Q_b?)m|g(5Q0W%IGU?LFt7 zb6RWg8HHpETriAn+R~epK_Ha*|^$l2&~+yQ^Xy`bdTiJ$;eD5ZU6=i$cpfxogZAPXnl$m92Slo+MD zP{mWtGR_$knM(Fsc2F)Ss&+2%Y@1-3W^bwWy6u+MY5N@wdd-#wrqgv>-A=pNEx>0A z9U&@)*QIGo6revz880b8#vokI)(7{hwIWjt0-2T>dQzUW-xv~yg;UrIWcjgAYOcCbKq=ck@f11BD35I!nMqkT zvQ@2R)5Ej5g<(TSROh~wifhIm3FWUrJ<3}CDsnT3knjH)xVxW4 Y|B3wK>D+FLq8E9vWH2qG{^#z017v;#*Z=?k diff --git a/src/modules/previewpane/MarkDownPreviewHandler/Properties/AssemblyInfo.cs b/src/modules/previewpane/MarkDownPreviewHandler/Properties/AssemblyInfo.cs index 5d921a3f7aea..9b60e01ac060 100644 --- a/src/modules/previewpane/MarkDownPreviewHandler/Properties/AssemblyInfo.cs +++ b/src/modules/previewpane/MarkDownPreviewHandler/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.8")] -[assembly: AssemblyFileVersion("1.0.0.8")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs index 98ea14c3a2ad..c775d8a0d320 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs +++ b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownPreviewHandlerControl.cs @@ -12,7 +12,6 @@ using System.Xml.Linq; using Common; using Markdig; -using Markdig.Helpers; using MarkdownPreviewHandler.Properties; namespace MarkdownPreviewHandler @@ -55,7 +54,7 @@ public class MarkdownPreviewHandlerControl : FormHandlerControl /// /// True if external image is blocked, false otherwise. /// - private bool imagesBlocked = false; + private bool infoBarDisplayed = false; /// /// Initializes a new instance of the class. @@ -75,48 +74,51 @@ public override void DoPreview(T dataSource) { this.InvokeOnControlThread(() => { - this.imagesBlocked = false; + try + { + this.infoBarDisplayed = false; - StringBuilder sb = new StringBuilder(); - string filePath = dataSource as string; - string fileText = File.ReadAllText(filePath); - this.extension.BaseUrl = Path.GetDirectoryName(filePath); + StringBuilder sb = new StringBuilder(); + string filePath = dataSource as string; + string fileText = File.ReadAllText(filePath); + this.extension.BaseUrl = Path.GetDirectoryName(filePath); - MarkdownPipeline pipeline = this.pipelineBuilder.Build(); - string parsedMarkdown = Markdown.ToHtml(fileText, pipeline); - sb.AppendFormat("{0}{1}{2}", this.htmlHeader, parsedMarkdown, this.htmlFooter); - string markdownHTML = this.RemoveScriptFromHTML(sb.ToString()); + MarkdownPipeline pipeline = this.pipelineBuilder.Build(); + string parsedMarkdown = Markdown.ToHtml(fileText, pipeline); + sb.AppendFormat("{0}{1}{2}", this.htmlHeader, parsedMarkdown, this.htmlFooter); + string markdownHTML = this.RemoveScriptFromHTML(sb.ToString()); - this.browser = new WebBrowser - { - DocumentText = markdownHTML, - Dock = DockStyle.Fill, - IsWebBrowserContextMenuEnabled = false, - ScriptErrorsSuppressed = true, - ScrollBarsEnabled = true, - }; - this.browser.Navigating += this.WebBrowserNavigating; - this.Controls.Add(this.browser); - - if (this.imagesBlocked) - { - this.infoBar = new RichTextBox + this.browser = new WebBrowser { - Text = Resources.BlockedImageInfoText, - BackColor = Color.LightYellow, - Multiline = true, - Dock = DockStyle.Top, - ReadOnly = true, + DocumentText = markdownHTML, + Dock = DockStyle.Fill, + IsWebBrowserContextMenuEnabled = false, + ScriptErrorsSuppressed = true, + ScrollBarsEnabled = true, }; - this.infoBar.ContentsResized += this.RTBContentsResized; - this.infoBar.ScrollBars = RichTextBoxScrollBars.None; - this.infoBar.BorderStyle = BorderStyle.None; + this.browser.Navigating += this.WebBrowserNavigating; + this.Controls.Add(this.browser); + + if (this.infoBarDisplayed) + { + this.infoBar = this.GetTextBoxControl(Resources.BlockedImageInfoText); + this.Controls.Add(this.infoBar); + } + + this.Resize += this.FormResized; + base.DoPreview(dataSource); + MarkdownTelemetry.Log.MarkdownFilePreviewed(); + } + catch (Exception e) + { + MarkdownTelemetry.Log.MarkdownFilePreviewError(e.Message); + this.infoBarDisplayed = true; + this.infoBar = this.GetTextBoxControl(Resources.MarkdownNotPreviewedError); + this.Resize += this.FormResized; + this.Controls.Clear(); this.Controls.Add(this.infoBar); + base.DoPreview(dataSource); } - - this.Resize += this.FormResized; - base.DoPreview(dataSource); - MarkdownTelemetry.Log.MarkdownFilePreviewed(); }); } @@ -140,6 +142,28 @@ public string RemoveScriptFromHTML(string html) return doc.ToString(); } + /// + /// Gets a textbox control. + /// + /// Message to be displayed in textbox. + /// An object of type . + private RichTextBox GetTextBoxControl(string message) + { + RichTextBox richTextBox = new RichTextBox + { + Text = message, + BackColor = Color.LightYellow, + Multiline = true, + Dock = DockStyle.Top, + ReadOnly = true, + }; + richTextBox.ContentsResized += this.RTBContentsResized; + richTextBox.ScrollBars = RichTextBoxScrollBars.None; + richTextBox.BorderStyle = BorderStyle.None; + + return richTextBox; + } + /// /// Callback when RichTextBox is resized. /// @@ -158,7 +182,7 @@ private void RTBContentsResized(object sender, ContentsResizedEventArgs e) /// Provides data for the event. private void FormResized(object sender, EventArgs e) { - if (this.imagesBlocked) + if (this.infoBarDisplayed) { this.infoBar.Width = this.Width; } @@ -169,7 +193,7 @@ private void FormResized(object sender, EventArgs e) /// private void ImagesBlockedCallBack() { - this.imagesBlocked = true; + this.infoBarDisplayed = true; } /// diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs index 315058e0dba8..b3ba97944caf 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs +++ b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics.Tracing; -using System.Windows.Forms; using PreviewHandlerCommon.Telemetry; namespace MarkdownPreviewHandler @@ -39,8 +38,8 @@ public void MarkdownFilePreviewed() { this.Write("PowerPreview_PreviewPane_MDRendererPreviewed", new EventSourceOptions() { - Keywords = TelemetryBase.PROJECTKEYWORDMEASURE, - Tags = TelemetryBase.ProjectTelemetryTagProductAndServicePerformance, + Keywords = PROJECTKEYWORDMEASURE, + Tags = ProjectTelemetryTagProductAndServicePerformance, }); } @@ -53,8 +52,8 @@ public void MarkdownFilePreviewError(string message) "PowerPreview_PreviewPane_MDRendererError", new EventSourceOptions() { - Keywords = TelemetryBase.PROJECTKEYWORDMEASURE, - Tags = TelemetryBase.ProjectTelemetryTagProductAndServicePerformance, + Keywords = PROJECTKEYWORDMEASURE, + Tags = ProjectTelemetryTagProductAndServicePerformance, }, new { Message = message, }); } diff --git a/src/modules/previewpane/MarkdownPreviewHandler/Properties/Resources.Designer.cs b/src/modules/previewpane/MarkdownPreviewHandler/Properties/Resources.Designer.cs index 65505e0aca13..ea7599efd60a 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/Properties/Resources.Designer.cs +++ b/src/modules/previewpane/MarkdownPreviewHandler/Properties/Resources.Designer.cs @@ -68,5 +68,14 @@ internal static string BlockedImageInfoText { return ResourceManager.GetString("BlockedImageInfoText", resourceCulture); } } + + /// + /// Looks up a localized string similar to The markdown could not be preview due to an internal error.. + /// + internal static string MarkdownNotPreviewedError { + get { + return ResourceManager.GetString("MarkdownNotPreviewedError", resourceCulture); + } + } } } diff --git a/src/modules/previewpane/MarkdownPreviewHandler/Properties/Resources.resx b/src/modules/previewpane/MarkdownPreviewHandler/Properties/Resources.resx index 0eabfcdae9ff..9beb635bd91e 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/Properties/Resources.resx +++ b/src/modules/previewpane/MarkdownPreviewHandler/Properties/Resources.resx @@ -121,4 +121,8 @@ Some pictures have been blocked to help prevent the sender from identifying this computer. Open this item to view pictures. This text is displayed if image is blocked from being displayed. + + The markdown could not be preview due to an internal error. + This text is displayed if markdown fails to preview + \ No newline at end of file diff --git a/src/modules/previewpane/common/Properties/AssemblyInfo.cs b/src/modules/previewpane/common/Properties/AssemblyInfo.cs index 418546782834..0afe1c322bbb 100644 --- a/src/modules/previewpane/common/Properties/AssemblyInfo.cs +++ b/src/modules/previewpane/common/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.8")] -[assembly: AssemblyFileVersion("1.0.0.8")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] From d7f698ea62497c79f17e8d8a9cc14e64301f1552 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Thu, 13 Feb 2020 16:27:04 -0800 Subject: [PATCH 5/7] Updated markdown telemetry to make event names global variable --- .../MarkdownPreviewHandler/MarkdownTelemetry.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs index b3ba97944caf..f3e6ef7e394d 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs +++ b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs @@ -17,6 +17,16 @@ public class MarkdownTelemetry : TelemetryBase /// private const string EventSourceName = "Microsoft.PowerToys"; + /// + /// ETW event name when markdown is previewed. + /// + private const string MarkdownFilePreviewedEventName = "PowerPreview_PreviewPane_MDRendererPreviewed"; + + /// + /// ETW event name when error is thrown during markdown preview. + /// + private const string MarkdownFilePreviewErrorEventName = "PowerPreview_PreviewPane_MDRendererError"; + /// /// Initializes a new instance of the class. /// @@ -36,7 +46,7 @@ public MarkdownTelemetry() /// public void MarkdownFilePreviewed() { - this.Write("PowerPreview_PreviewPane_MDRendererPreviewed", new EventSourceOptions() + this.Write(MarkdownFilePreviewedEventName, new EventSourceOptions() { Keywords = PROJECTKEYWORDMEASURE, Tags = ProjectTelemetryTagProductAndServicePerformance, @@ -49,7 +59,7 @@ public void MarkdownFilePreviewed() public void MarkdownFilePreviewError(string message) { this.Write( - "PowerPreview_PreviewPane_MDRendererError", + MarkdownFilePreviewErrorEventName, new EventSourceOptions() { Keywords = PROJECTKEYWORDMEASURE, From d4fe2fae6818c8f6d8adff175abb413340114a01 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Fri, 14 Feb 2020 11:43:10 -0800 Subject: [PATCH 6/7] Updated parameter name to camel casing and telemetry event name naming. --- .../MarkdownPreviewHandler/MarkdownTelemetry.cs | 8 ++++---- .../SvgPreviewHandler/Properties/AssemblyInfo.cs | 4 ++-- src/modules/previewpane/common/Telemetry/TelemetryBase.cs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs index f3e6ef7e394d..07bf17cd242a 100644 --- a/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs +++ b/src/modules/previewpane/MarkdownPreviewHandler/MarkdownTelemetry.cs @@ -20,12 +20,12 @@ public class MarkdownTelemetry : TelemetryBase /// /// ETW event name when markdown is previewed. /// - private const string MarkdownFilePreviewedEventName = "PowerPreview_PreviewPane_MDRendererPreviewed"; + private const string MarkdownFilePreviewedEventName = "PowerPreview_MDRenderer_Previewed"; /// /// ETW event name when error is thrown during markdown preview. /// - private const string MarkdownFilePreviewErrorEventName = "PowerPreview_PreviewPane_MDRendererError"; + private const string MarkdownFilePreviewErrorEventName = "PowerPreview_MDRenderer_Error"; /// /// Initializes a new instance of the class. @@ -48,7 +48,7 @@ public void MarkdownFilePreviewed() { this.Write(MarkdownFilePreviewedEventName, new EventSourceOptions() { - Keywords = PROJECTKEYWORDMEASURE, + Keywords = ProjectKeywordMeasure, Tags = ProjectTelemetryTagProductAndServicePerformance, }); } @@ -62,7 +62,7 @@ public void MarkdownFilePreviewError(string message) MarkdownFilePreviewErrorEventName, new EventSourceOptions() { - Keywords = PROJECTKEYWORDMEASURE, + Keywords = ProjectKeywordMeasure, Tags = ProjectTelemetryTagProductAndServicePerformance, }, new { Message = message, }); diff --git a/src/modules/previewpane/SvgPreviewHandler/Properties/AssemblyInfo.cs b/src/modules/previewpane/SvgPreviewHandler/Properties/AssemblyInfo.cs index 0bc87e35c8eb..8c7fe1213d0e 100644 --- a/src/modules/previewpane/SvgPreviewHandler/Properties/AssemblyInfo.cs +++ b/src/modules/previewpane/SvgPreviewHandler/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.15")] +[assembly: AssemblyFileVersion("1.0.0.15")] diff --git a/src/modules/previewpane/common/Telemetry/TelemetryBase.cs b/src/modules/previewpane/common/Telemetry/TelemetryBase.cs index 664d8cb97a9e..1440aec9d620 100644 --- a/src/modules/previewpane/common/Telemetry/TelemetryBase.cs +++ b/src/modules/previewpane/common/Telemetry/TelemetryBase.cs @@ -20,7 +20,7 @@ public class TelemetryBase : EventSource /// /// The event keyword for this event source. /// - public const EventKeywords PROJECTKEYWORDMEASURE = (EventKeywords)0x0; + public const EventKeywords ProjectKeywordMeasure = (EventKeywords)0x0; /// /// Group ID for Powertoys project. From fbbb99f42616f0dc1daf843b86d1f02d54acee6c Mon Sep 17 00:00:00 2001 From: Divyansh Date: Fri, 14 Feb 2020 12:00:47 -0800 Subject: [PATCH 7/7] Corrected assembbly version for svg renderer --- .../previewpane/SvgPreviewHandler/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/previewpane/SvgPreviewHandler/Properties/AssemblyInfo.cs b/src/modules/previewpane/SvgPreviewHandler/Properties/AssemblyInfo.cs index 8c7fe1213d0e..0bc87e35c8eb 100644 --- a/src/modules/previewpane/SvgPreviewHandler/Properties/AssemblyInfo.cs +++ b/src/modules/previewpane/SvgPreviewHandler/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.15")] -[assembly: AssemblyFileVersion("1.0.0.15")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]