Remove analytics service from WinUI sample app
このコミットが含まれているのは:
1 親
5b901df5cb
コミット
aa15871666
7ファイル変更
+6
-156
検索条件に一致するファイルはありません
@@ -1,10 +0,0 @@
|
||||
namespace ComputeSharp.SwapChain.Core.Constants;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> with the collection of tracked errors for analytics.
|
||||
/// </summary>
|
||||
public static class Error
|
||||
{
|
||||
public const string RenderingFailedOnMainPanel = "[SHELL] RenderingFailed (main panel)";
|
||||
public const string RenderingFailedOnSelectionPanel = "[SHELL] RenderingFailed (selection panel)";
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
namespace ComputeSharp.SwapChain.Core.Constants;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> with the collection of tracked events for analytics.
|
||||
/// </summary>
|
||||
public static class Event
|
||||
{
|
||||
public const string SelectedRenderingModeChanged = "[SETTINGS] SelectedRenderingMode";
|
||||
public const string IsVerticalSyncEnabledChanged = "[SETTINGS] IsVerticalSyncEnabled";
|
||||
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";
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace ComputeSharp.SwapChain.Core.Services;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that manages the analytics service in a test environment.
|
||||
/// </summary>
|
||||
public sealed class DebugAnalyticsService : IAnalyticsService
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void Log(string title, params (string Property, object? Value)[]? data)
|
||||
{
|
||||
StringBuilder builder = new();
|
||||
|
||||
_ = builder.AppendLine($"[EVENT]: \"{title}\"");
|
||||
|
||||
if (data is not null)
|
||||
{
|
||||
foreach ((string Property, object? Value) info in data)
|
||||
{
|
||||
_ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? "<NULL>"}\"");
|
||||
}
|
||||
}
|
||||
|
||||
Trace.Write(builder);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Log(Exception exception, params (string Property, object? Value)[]? data)
|
||||
{
|
||||
StringBuilder builder = new();
|
||||
|
||||
_ = builder.AppendLine($"[EXCEPTION]: \"{exception.GetType()}\"");
|
||||
_ = builder.AppendLine(">> Stack trace");
|
||||
_ = builder.AppendLine(exception.StackTrace);
|
||||
|
||||
if (data is not null)
|
||||
{
|
||||
foreach ((string Property, object? Value) info in data)
|
||||
{
|
||||
_ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? "<NULL>"}\"");
|
||||
}
|
||||
}
|
||||
|
||||
Trace.Write(builder);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.SwapChain.Core.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The default <see langword="interface"/> for an analytics service.
|
||||
/// </summary>
|
||||
public interface IAnalyticsService
|
||||
{
|
||||
/// <summary>
|
||||
/// Logs an event with a specified title and optional properties.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the event to track.</param>
|
||||
/// <param name="data">The optional event properties.</param>
|
||||
void Log(string title, params (string Property, object? Value)[]? data);
|
||||
|
||||
/// <summary>
|
||||
/// Logs an exception with optional properties.
|
||||
/// </summary>
|
||||
/// <param name="exception">The exception that has been thrown.</param>
|
||||
/// <param name="data">The optional event properties.</param>
|
||||
void Log(Exception exception, params (string Property, object? Value)[]? data);
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using ComputeSharp.SwapChain.Core.Constants;
|
||||
using ComputeSharp.SwapChain.Core.Enums;
|
||||
using ComputeSharp.SwapChain.Core.Services;
|
||||
using ComputeSharp.SwapChain.Core.Shaders;
|
||||
using ComputeSharp.SwapChain.Core.Shaders.Runners;
|
||||
using ComputeSharp.SwapChain.Shaders;
|
||||
@@ -17,19 +14,11 @@ namespace ComputeSharp.SwapChain.Core.ViewModels;
|
||||
/// </summary>
|
||||
public sealed partial class MainViewModel : ObservableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IAnalyticsService"/> instance currently in use.
|
||||
/// </summary>
|
||||
private readonly IAnalyticsService analyticsService;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MainViewModel"/> instance.
|
||||
/// </summary>
|
||||
public MainViewModel(IAnalyticsService analyticsService)
|
||||
public MainViewModel()
|
||||
{
|
||||
Guard.IsNotNull(analyticsService);
|
||||
|
||||
this.analyticsService = analyticsService;
|
||||
this.selectedRenderingMode = RenderingMode.DirectX12;
|
||||
this.isVerticalSyncEnabled = true;
|
||||
this.isDynamicResolutionEnabled = true;
|
||||
@@ -157,46 +146,10 @@ public sealed partial class MainViewModel : ObservableObject
|
||||
IsRenderingPaused = !IsRenderingPaused;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial void OnSelectedRenderingModeChanged(RenderingMode value)
|
||||
{
|
||||
this.analyticsService.Log(Event.SelectedRenderingModeChanged, (nameof(value), value));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial void OnIsVerticalSyncEnabledChanged(bool value)
|
||||
{
|
||||
this.analyticsService.Log(Event.IsVerticalSyncEnabledChanged, (nameof(value), value));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial void OnIsDynamicResolutionEnabledChanged(bool value)
|
||||
{
|
||||
this.analyticsService.Log(Event.IsDynamicResolutionEnabledChanged, (nameof(value), value));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial void OnSelectedResolutionScaleChanged(int value)
|
||||
{
|
||||
this.analyticsService.Log(Event.SelectedResolutionScaleChanged, (nameof(value), value));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial void OnSelectedComputeShaderChanging(ShaderRunnerViewModel? oldValue, ShaderRunnerViewModel newValue)
|
||||
{
|
||||
oldValue!.IsSelected = false;
|
||||
newValue.IsSelected = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial void OnSelectedComputeShaderChanged(ShaderRunnerViewModel value)
|
||||
{
|
||||
this.analyticsService.Log(Event.SelectedComputeShaderChanged, (nameof(value.ShaderType), value.ShaderType));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial void OnIsRenderingPausedChanged(bool value)
|
||||
{
|
||||
this.analyticsService.Log(Event.IsRenderingPausedChanged, (nameof(value), value));
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,14 @@
|
||||
xmlns:enums="using:ComputeSharp.SwapChain.Core.Enums"
|
||||
xmlns:media="using:CommunityToolkit.WinUI.UI.Media"
|
||||
xmlns:ui="using:CommunityToolkit.WinUI.UI"
|
||||
xmlns:viewmodels="using:ComputeSharp.SwapChain.Core.ViewModels"
|
||||
xmlns:viewModels="using:ComputeSharp.SwapChain.Core.ViewModels"
|
||||
xmlns:views="using:ComputeSharp.SwapChain.WinUI.Views"
|
||||
SizeChanged="Window_SizeChanged">
|
||||
|
||||
<Grid x:Name="Root">
|
||||
<Grid.DataContext>
|
||||
<viewModels:MainViewModel x:Name="ViewModel"/>
|
||||
</Grid.DataContext>
|
||||
<Grid.Resources>
|
||||
|
||||
<!--
|
||||
@@ -109,7 +112,7 @@
|
||||
<ListView.ItemTemplate>
|
||||
|
||||
<!-- Shader template -->
|
||||
<DataTemplate x:DataType="viewmodels:ShaderRunnerViewModel">
|
||||
<DataTemplate x:DataType="viewModels:ShaderRunnerViewModel">
|
||||
<controls:ConstrainedBox
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.SwapChain.Core.Services;
|
||||
using ComputeSharp.SwapChain.Core.ViewModels;
|
||||
using ComputeSharp.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
@@ -25,15 +24,8 @@ public sealed partial class MainWindow : Window
|
||||
ExtendsContentIntoTitleBar = true;
|
||||
|
||||
SetTitleBar(this.TitleBarRectangle);
|
||||
|
||||
this.Root.DataContext = new MainViewModel(new DebugAnalyticsService());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="MainViewModel"/> instance for the current view.
|
||||
/// </summary>
|
||||
public MainViewModel ViewModel => (MainViewModel)this.Root.DataContext;
|
||||
|
||||
/// <summary>
|
||||
/// Stops all rendering when the application is closing.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする