CmdPalSessionDuration.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Diagnostics.CodeAnalysis; 6 using System.Diagnostics.Tracing; 7 using Microsoft.PowerToys.Telemetry; 8 using Microsoft.PowerToys.Telemetry.Events; 9 10 namespace Microsoft.CmdPal.UI.Events; 11 12 /// <summary> 13 /// Tracks Command Palette session duration from launch to close. 14 /// Purpose: Understand user engagement patterns - quick actions vs. browsing behavior. 15 /// </summary> 16 [EventData] 17 [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] 18 public class CmdPalSessionDuration : EventBase, IEvent 19 { 20 /// <summary> 21 /// Gets or sets the session duration in milliseconds. 22 /// </summary> 23 public ulong DurationMs { get; set; } 24 25 /// <summary> 26 /// Gets or sets the number of commands executed during the session. 27 /// </summary> 28 public int CommandsExecuted { get; set; } 29 30 /// <summary> 31 /// Gets or sets the number of pages visited during the session. 32 /// </summary> 33 public int PagesVisited { get; set; } 34 35 /// <summary> 36 /// Gets or sets the reason for dismissal (Escape, LostFocus, Command, etc.). 37 /// </summary> 38 public string DismissalReason { get; set; } 39 40 /// <summary> 41 /// Gets or sets the number of search queries executed during the session. 42 /// </summary> 43 public int SearchQueriesCount { get; set; } 44 45 /// <summary> 46 /// Gets or sets the maximum navigation depth reached during the session. 47 /// </summary> 48 public int MaxNavigationDepth { get; set; } 49 50 /// <summary> 51 /// Gets or sets the number of errors encountered during the session. 52 /// </summary> 53 public int ErrorCount { get; set; } 54 55 public CmdPalSessionDuration(ulong durationMs, int commandsExecuted, int pagesVisited, string dismissalReason, int searchQueriesCount, int maxNavigationDepth, int errorCount) 56 { 57 EventName = "CmdPal_SessionDuration"; 58 DurationMs = durationMs; 59 CommandsExecuted = commandsExecuted; 60 PagesVisited = pagesVisited; 61 DismissalReason = dismissalReason; 62 SearchQueriesCount = searchQueriesCount; 63 MaxNavigationDepth = maxNavigationDepth; 64 ErrorCount = errorCount; 65 } 66 67 public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; 68 }