diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems b/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems
index aa773398..80039491 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems
@@ -9,6 +9,7 @@
ComputeSharp.SwapChain.Core.Shared
+
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs
new file mode 100644
index 00000000..35cec680
--- /dev/null
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs
@@ -0,0 +1,16 @@
+namespace ComputeSharp.SwapChain.Core.Constants;
+
+///
+/// A with the collection of tracked events for analytics.
+///
+public static class Event
+{
+ public const string IsDynamicResolutionEnabledChanged = "[SETTINGS] IsDynamicResolutionEnabled";
+ public const string SelectedResolutionScaleChanged = "[SETTINGS] SelectedResolutionScale";
+ public const string SelectedComputeShaderChanged = "[SETTINGS] SelectedComputeShader";
+ public const string IsRenderingPausedChanged = "[SETTINGS] IsRenderingPaused";
+ public const string OpenShaderSelectionPanel = "[SHELL] Open ShaderSelectionPanel";
+ public const string CloseShaderSelectionPanel = "[SHELL] Close ShaderSelectionPanel";
+ public const string RenderingFailedOnMainPanel = "[SHELL] RenderingFailed (main panel)";
+ public const string RenderingFailedOnSelectionPanel = "[SHELL] RenderingFailed (selection panel)";
+}
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs
index fbe016e7..fdd0b425 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs
@@ -1,4 +1,5 @@
-using System.Diagnostics;
+using System;
+using System.Diagnostics;
using System.Text;
#nullable enable
@@ -11,7 +12,7 @@ namespace ComputeSharp.SwapChain.Core.Services;
public sealed class DebugAnalyticsService : IAnalyticsService
{
///
- public void Log(string title, params (string Property, string Value)[]? data)
+ public void Log(string title, params (string Property, object? Value)[]? data)
{
StringBuilder builder = new();
@@ -21,7 +22,28 @@ public sealed class DebugAnalyticsService : IAnalyticsService
{
foreach (var info in data)
{
- builder.AppendLine($">> {info.Property}: \"{info.Value}\"");
+ builder.AppendLine($">> {info.Property}: \"{info.Value ?? ""}\"");
+ }
+ }
+
+ Trace.Write(builder);
+ }
+
+ ///
+ public void Log(string title, Exception exception, params (string Property, object? Value)[]? data)
+ {
+ StringBuilder builder = new();
+
+ builder.AppendLine($"[EXCEPTION]: \"{title}\"");
+ builder.AppendLine($">> Type: \"{exception.GetType()}\"");
+ builder.AppendLine(">> Stack trace");
+ builder.AppendLine(exception.StackTrace);
+
+ if (data is not null)
+ {
+ foreach (var info in data)
+ {
+ builder.AppendLine($">> {info.Property}: \"{info.Value ?? ""}\"");
}
}
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs
index 28c6aa7d..53081e62 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs
@@ -1,4 +1,6 @@
-#nullable enable
+using System;
+
+#nullable enable
namespace ComputeSharp.SwapChain.Core.Services;
@@ -12,5 +14,13 @@ public interface IAnalyticsService
///
/// The title of the event to track.
/// The optional event properties.
- void Log(string title, params (string Property, string Value)[]? data);
+ void Log(string title, params (string Property, object? Value)[]? data);
+
+ ///
+ /// Logs an exception with a specified title and optional properties.
+ ///
+ /// The title of the event to track.
+ /// The exception that has been thrown.
+ /// The optional event properties.
+ void Log(string title, Exception exception, params (string Property, object? Value)[]? data);
}
diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/MainViewModel.cs b/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/MainViewModel.cs
index 233d4a51..259a499f 100644
--- a/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/MainViewModel.cs
+++ b/samples/ComputeSharp.SwapChain.Core.Shared/ViewModels/MainViewModel.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
+using ComputeSharp.SwapChain.Core.Constants;
using ComputeSharp.SwapChain.Core.Models;
using ComputeSharp.SwapChain.Core.Services;
using ComputeSharp.SwapChain.Core.Shaders.Runners;
@@ -56,7 +57,13 @@ public sealed class MainViewModel : ObservableObject
public bool IsDynamicResolutionEnabled
{
get => this.isDynamicResolutionEnabled;
- set => SetProperty(ref this.isDynamicResolutionEnabled, value);
+ set
+ {
+ if (SetProperty(ref this.isDynamicResolutionEnabled, value))
+ {
+ this.analyticsService.Log(Event.IsDynamicResolutionEnabledChanged, (nameof(value), value));
+ }
+ }
}
private int selectedResolutionScale;
@@ -67,7 +74,13 @@ public sealed class MainViewModel : ObservableObject
public int SelectedResolutionScale
{
get => this.selectedResolutionScale;
- private set => SetProperty(ref this.selectedResolutionScale, value);
+ private set
+ {
+ if (SetProperty(ref this.selectedResolutionScale, value))
+ {
+ this.analyticsService.Log(Event.SelectedResolutionScaleChanged, (nameof(value), value));
+ }
+ }
}
///
@@ -115,6 +128,8 @@ public sealed class MainViewModel : ObservableObject
if (SetProperty(ref this.selectedComputeShader, value) &&
value is not null)
{
+ this.analyticsService.Log(Event.SelectedComputeShaderChanged, (nameof(value.ShaderRunner), value.ShaderRunner));
+
value.IsSelected = true;
}
}
@@ -128,7 +143,13 @@ public sealed class MainViewModel : ObservableObject
public bool IsRenderingPaused
{
get => this.isRenderingPaused;
- set => SetProperty(ref this.isRenderingPaused, value);
+ set
+ {
+ if (SetProperty(ref this.isRenderingPaused, value))
+ {
+ this.analyticsService.Log(Event.IsRenderingPausedChanged, (nameof(value), value));
+ }
+ }
}
///
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Extensions/AssemblyExtensions.cs b/samples/ComputeSharp.SwapChain.Uwp/Extensions/AssemblyExtensions.cs
index 93146eda..90415cab 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Extensions/AssemblyExtensions.cs
+++ b/samples/ComputeSharp.SwapChain.Uwp/Extensions/AssemblyExtensions.cs
@@ -25,7 +25,7 @@ public static class AssemblyExtensions
try
{
- string manifestFilename = $"{assembly.FullName}.{filename.Replace('/', '.').Replace('\\', '.')}";
+ string manifestFilename = $"{assembly.GetName().Name}.{filename.Replace('/', '.').Replace('\\', '.')}";
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(manifestFilename);
using StreamReader reader = new(stream);
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Package.appxmanifest b/samples/ComputeSharp.SwapChain.Uwp/Package.appxmanifest
index eb50ef1e..01ddbc8d 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Package.appxmanifest
+++ b/samples/ComputeSharp.SwapChain.Uwp/Package.appxmanifest
@@ -10,7 +10,7 @@
+ Version="0.0.5.0" />
@@ -48,4 +48,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Properties/Default.rd.xml b/samples/ComputeSharp.SwapChain.Uwp/Properties/Default.rd.xml
index 819be7a4..d77eadfd 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Properties/Default.rd.xml
+++ b/samples/ComputeSharp.SwapChain.Uwp/Properties/Default.rd.xml
@@ -17,5 +17,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs b/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs
index 7846efcb..ba7f26b2 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs
+++ b/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs
@@ -1,6 +1,6 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
-using System.Threading;
using ComputeSharp.SwapChain.Core.Services;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
@@ -28,14 +28,34 @@ public sealed class AppCenterService : IAnalyticsService
}
///
- public void Log(string title, params (string Property, string Value)[]? data)
+ public void Log(string title, params (string Property, object? Value)[]? data)
{
- IDictionary? properties = data?.ToDictionary(
- pair => pair.Property,
- pair => pair.Value.Length <= PropertyStringMaxLength
- ? pair.Value
- : $"|{pair.Value.Substring(pair.Value.Length - PropertyStringMaxLength)}");
+ Analytics.TrackEvent(title, GetProperties(data));
+ }
- Analytics.TrackEvent(title, properties);
+ ///
+ public void Log(string title, Exception exception, params (string Property, object? Value)[]? data)
+ {
+ Crashes.TrackError(exception, GetProperties(data));
+ }
+
+ ///
+ /// Gets the additional logging properties from the input data.
+ ///
+ /// The optional event properties.
+ /// The additional logging properties to track.
+ private static IDictionary? GetProperties((string Property, object? Value)[]? data)
+ {
+ return
+ data?.ToDictionary(
+ pair => pair.Property,
+ pair =>
+ {
+ string text = (pair.Value ?? "").ToString();
+
+ return text.Length <= PropertyStringMaxLength
+ ? text
+ : $"|{text.Substring(text.Length - PropertyStringMaxLength)}";
+ });
}
}
diff --git a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml
index 9705fdcc..f453cc71 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml
+++ b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml
@@ -121,7 +121,7 @@
-
+