File tree Expand file tree Collapse file tree 6 files changed +107
-1
lines changed Expand file tree Collapse file tree 6 files changed +107
-1
lines changed Original file line number Diff line number Diff line change 2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
- using Windows . UI ;
5
+ using CommunityToolkit . App . Shared . Helpers ;
6
+
7
+ #if WINAPPSDK
8
+ using UnhandledExceptionEventArgs = Microsoft . UI . Xaml . UnhandledExceptionEventArgs ;
9
+ #else
10
+ using UnhandledExceptionEventArgs = Windows . UI . Xaml . UnhandledExceptionEventArgs ;
11
+ #endif
6
12
7
13
namespace CommunityToolkit . App . Shared ;
8
14
@@ -26,6 +32,13 @@ public sealed partial class App : Application
26
32
public App ( )
27
33
{
28
34
this . InitializeComponent ( ) ;
35
+
36
+ UnhandledException += this . App_UnhandledException ;
37
+ }
38
+
39
+ private void App_UnhandledException ( object sender , UnhandledExceptionEventArgs e )
40
+ {
41
+ TrackingManager . TrackException ( e . Exception ) ;
29
42
}
30
43
31
44
/// <summary>
Original file line number Diff line number Diff line change 32
32
<Compile Include =" $(MSBuildThisFileDirectory)DocOrSampleTemplateSelector.cs" />
33
33
<Compile Include =" $(MSBuildThisFileDirectory)Helpers\IconHelper.cs" />
34
34
<Compile Include =" $(MSBuildThisFileDirectory)Helpers\NavigationViewHelper.cs" />
35
+ <Compile Include =" $(MSBuildThisFileDirectory)Helpers\TrackingManager.cs" />
35
36
<Compile Include =" $(MSBuildThisFileDirectory)Pages\GettingStartedPage.xaml.cs" >
36
37
<DependentUpon >GettingStartedPage.xaml</DependentUpon >
37
38
</Compile >
Original file line number Diff line number Diff line change
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation 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 ;
6
+
7
+ #if ! DEBUG && WINDOWS_UWP && ! HAS_UNO
8
+ // See https://learn.microsoft.com/windows/uwp/monetize/log-custom-events-for-dev-center
9
+ using Microsoft . Services . Store . Engagement ;
10
+ #endif
11
+
12
+ namespace CommunityToolkit . App . Shared . Helpers ;
13
+
14
+ #if DEBUG || ! WINDOWS_UWP || HAS_UNO
15
+ // Stub for non-UWP platforms and DEBUG mode
16
+ internal class StoreServicesCustomEventLogger
17
+ {
18
+ public static StoreServicesCustomEventLogger GetDefault ( ) => new ( ) ;
19
+
20
+ public void Log ( string message )
21
+ {
22
+ Debug . WriteLine ( $ "Log - { message } ") ;
23
+ }
24
+ }
25
+ #endif
26
+
27
+ public static class TrackingManager
28
+ {
29
+ private static StoreServicesCustomEventLogger ? logger ;
30
+
31
+ static TrackingManager ( )
32
+ {
33
+ try
34
+ {
35
+ logger = StoreServicesCustomEventLogger . GetDefault ( ) ;
36
+ }
37
+ catch
38
+ {
39
+ // Ignoring error
40
+ }
41
+ }
42
+
43
+ public static void TrackException ( Exception ex )
44
+ {
45
+ try
46
+ {
47
+ logger ? . Log ( $ "exception - { ex . Message } - { ex . StackTrace } ") ;
48
+ }
49
+ catch
50
+ {
51
+ // Ignore error
52
+ }
53
+ }
54
+
55
+ public static void TrackSample ( string name )
56
+ {
57
+ try
58
+ {
59
+ logger ? . Log ( $ "sample - { name } ") ;
60
+ }
61
+ catch
62
+ {
63
+ // Ignore error
64
+ }
65
+ }
66
+
67
+ public static void TrackPage ( string pageName )
68
+ {
69
+ try
70
+ {
71
+ logger ? . Log ( $ "openpage - { pageName } ") ;
72
+ }
73
+ catch
74
+ {
75
+ // Ignore error
76
+ }
77
+ }
78
+ }
Original file line number Diff line number Diff line change @@ -71,20 +71,23 @@ private void NavView_ItemInvoked(MUXC.NavigationView sender, MUXC.NavigationView
71
71
if ( NavigationFrame . CurrentSourcePageType != typeof ( SettingsPage ) )
72
72
{
73
73
NavigationFrame . Navigate ( typeof ( SettingsPage ) ) ;
74
+ TrackingManager . TrackPage ( "Settings" ) ;
74
75
}
75
76
}
76
77
77
78
// Check if Getting Started page
78
79
else if ( selectedItem . Tag != null && selectedItem . Tag . GetType ( ) == typeof ( string ) )
79
80
{
80
81
NavigationFrame . Navigate ( typeof ( GettingStartedPage ) , samplePages ) ;
82
+ TrackingManager . TrackPage ( "GettingStarted" ) ;
81
83
}
82
84
else
83
85
{
84
86
var selectedMetadata = selectedItem . Tag as ToolkitFrontMatter ;
85
87
if ( selectedMetadata is null )
86
88
return ;
87
89
NavigationFrame . Navigate ( typeof ( ToolkitDocumentationRenderer ) , selectedMetadata ) ;
90
+ TrackingManager . TrackSample ( selectedMetadata . Title ! ) ;
88
91
}
89
92
}
90
93
@@ -93,10 +96,12 @@ public void NavigateToSample(ToolkitFrontMatter? sample)
93
96
if ( sample is null )
94
97
{
95
98
NavigationFrame . Navigate ( typeof ( GettingStartedPage ) , samplePages ) ;
99
+ TrackingManager . TrackPage ( "GettingStarted" ) ;
96
100
}
97
101
else
98
102
{
99
103
NavigationFrame . Navigate ( typeof ( ToolkitDocumentationRenderer ) , sample ) ;
104
+ TrackingManager . TrackSample ( sample . Title ! ) ;
100
105
}
101
106
102
107
EnsureNavigationSelection ( sample ? . FilePath ) ;
Original file line number Diff line number Diff line change 10
10
<WinUIMajorVersion >2</WinUIMajorVersion >
11
11
12
12
<IsAllExperimentHead >true</IsAllExperimentHead >
13
+ <AppxBundle >Always</AppxBundle >
14
+ <AppxBundlePlatforms >x86|x64|arm64</AppxBundlePlatforms >
13
15
</PropertyGroup >
14
16
15
17
<Import Project =" $(ToolingDirectory)\MultiTarget\EnabledTargetFrameworks.props" />
Original file line number Diff line number Diff line change 6
6
<PackageReference Include =" Microsoft.Xaml.Behaviors.Uwp.Managed" Version =" 3.0.0" />
7
7
<PackageReference Include =" System.Collections.Immutable" Version =" 9.0.0" />
8
8
</ItemGroup >
9
+
10
+ <ItemGroup Condition =" '$(Configuration)' == 'Release' " >
11
+ <PackageReference Include =" Microsoft.Services.Store.Engagement" Version =" 10.2307.3001" />
12
+ <SDKReference Include =" Microsoft.Services.Store.Engagement, Version=10.0" >
13
+ <Name >Microsoft Engagement Framework</Name >
14
+ </SDKReference >
15
+ </ItemGroup >
9
16
</Project >
You can’t perform that action at this time.
0 commit comments