From 51d7c85f82bc7084319e03a9c286aa1e29fe3f4e Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono Date: Tue, 6 Jan 2026 22:14:24 +0700 Subject: [PATCH 1/7] [Sentry] Add loaded plugins information Signed-off-by: Bagus Nur Listiyono --- .../Classes/Plugins/PluginInfo.cs | 4 ++- .../SentryHelper/CollapsePluginExtension.cs | 29 +++++++++++++++++++ .../Classes/SentryHelper/SentryHelper.cs | 7 +++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Hi3Helper.Core/Classes/SentryHelper/CollapsePluginExtension.cs diff --git a/CollapseLauncher/Classes/Plugins/PluginInfo.cs b/CollapseLauncher/Classes/Plugins/PluginInfo.cs index dd551975a..8a28c1e7c 100644 --- a/CollapseLauncher/Classes/Plugins/PluginInfo.cs +++ b/CollapseLauncher/Classes/Plugins/PluginInfo.cs @@ -5,6 +5,7 @@ using Hi3Helper.Plugin.Core.Management.PresetConfig; using Hi3Helper.Plugin.Core.Update; using Hi3Helper.Plugin.Core.Utility; +using Hi3Helper.SentryHelper; using Hi3Helper.Shared.Region; using Hi3Helper.Win32.ManagedTools; using Microsoft.Extensions.Logging; @@ -229,7 +230,8 @@ public unsafe PluginInfo(string pluginFilePath, string pluginRelName, PluginMani pluginInstance.SetPluginLocaleId(LauncherConfig.GetAppConfigValue("AppLanguage")); - Logger.LogWriteLine($"[PluginInfo] Successfully loaded plugin: {Name} from: {pluginRelName}@0x{libraryHandle:x8} with version {Version} and standard version {StandardVersion}.", LogType.Debug, true); + Logger.LogWriteLine($"[PluginInfo] Successfully loaded plugin: {Name} from: {pluginRelName}@0x{libraryHandle:x8} with version {Version} and standard version {StandardVersion}.", LogType.Info, true); + PluginListBreadcrumb.Add(Name, Version.ToString(), StandardVersion.ToString()); PresetConfigs = new PluginPresetConfigWrapper[presetConfigCount]; for (int i = 0; i < presetConfigCount; i++) diff --git a/Hi3Helper.Core/Classes/SentryHelper/CollapsePluginExtension.cs b/Hi3Helper.Core/Classes/SentryHelper/CollapsePluginExtension.cs new file mode 100644 index 000000000..4c875941b --- /dev/null +++ b/Hi3Helper.Core/Classes/SentryHelper/CollapsePluginExtension.cs @@ -0,0 +1,29 @@ +using Sentry; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.Linq; + +namespace Hi3Helper.SentryHelper; + +public static class PluginListBreadcrumb +{ + private static readonly ObservableCollection<(string Name, string Version, string StdVersion)> List = []; + + + public static void Add(string name, string version, string stdVersion) + { + List.Add((name, version, stdVersion)); + + List.CollectionChanged += ListOnCollectionChanged; + } + + private static void ListOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + SentryHelper.PluginInfo = new Breadcrumb("Plugin Info", "app.plugins", + List.ToDictionary( + item => item.Name, + item => $"{item.Version}-{item.StdVersion}" + ), + "PluginInfo"); + } +} \ No newline at end of file diff --git a/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs b/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs index 39e5313ef..5d71ac276 100644 --- a/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs +++ b/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs @@ -506,6 +506,10 @@ private static string CpuName { "CdnOption", AppCdnOption } }, "GameInfo"); + #pragma warning disable CA2211 + public static Breadcrumb? PluginInfo = null; + #pragma warning restore CA2211 + #endregion private static SentryId ExceptionHandlerInner(Exception ex, ExceptionType exT = ExceptionType.Handled) @@ -514,6 +518,9 @@ private static SentryId ExceptionHandlerInner(Exception ex, ExceptionType exT = SentrySdk.AddBreadcrumb(GameInfo); SentrySdk.AddBreadcrumb(CpuInfo); SentrySdk.AddBreadcrumb(GpuInfo); + + if (PluginInfo != null) + SentrySdk.AddBreadcrumb(PluginInfo); ex.Data[Mechanism.HandledKey] ??= exT == ExceptionType.Handled; From 43d419aeb97729d12593158ee7aac6773ed875e3 Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono Date: Tue, 6 Jan 2026 23:31:22 +0700 Subject: [PATCH 2/7] [Sentry] Move breadcrumb definitions off main SentryHelper.cs Signed-off-by: Bagus Nur Listiyono --- .../CollapseBreadcrumbExtension.cs | 160 ++++++++++++++++++ .../SentryHelper/CollapsePluginExtension.cs | 29 ---- .../Classes/SentryHelper/SentryHelper.cs | 125 -------------- 3 files changed, 160 insertions(+), 154 deletions(-) create mode 100644 Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs delete mode 100644 Hi3Helper.Core/Classes/SentryHelper/CollapsePluginExtension.cs diff --git a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs new file mode 100644 index 000000000..5f413d156 --- /dev/null +++ b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs @@ -0,0 +1,160 @@ +using Microsoft.Win32; +using Sentry; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net; +using static Hi3Helper.Shared.Region.LauncherConfig; + +namespace Hi3Helper.SentryHelper; + +// Migrated from main SentryHelper.cs file +public static partial class SentryHelper +{ + #nullable enable + private static int CpuThreadsTotal => Environment.ProcessorCount; + + private static string CpuName + { + get + { + try + { + string cpuName; + string env = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER") ?? "Unknown CPU"; + object? reg = + Registry.GetValue(@"HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\SYSTEM\CentralProcessor\0", + "ProcessorNameString", null); + if (reg != null) + { + cpuName = reg.ToString() ?? env; + cpuName = cpuName.Trim(); + } + else cpuName = env; + + return cpuName; + } + catch (Exception ex) + { + Logger.LogWriteLine("Failed when trying to get CPU Name!\r\n" + ex, LogType.Error, true); + return "Unknown CPU"; + } + } + } + + private static List<(string GpuName, string DriverVersion)> GetGpuInfo + { + get + { + List<(string GpuName, string DriverVersion)> gpuInfoList = []; + try + { + using RegistryKey? baseKey = + Registry.LocalMachine + .OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\"); + if (baseKey != null) + { + foreach (string subKeyName in baseKey.GetSubKeyNames()) + { + if (!int.TryParse(subKeyName, out int subKeyInt) || subKeyInt < 0 || subKeyInt > 9999) + continue; + + string? gpuName = "Unknown GPU"; + string? driverVersion = "Unknown Driver Version"; + try + { + using RegistryKey? subKey = baseKey.OpenSubKey(subKeyName); + if (subKey == null) continue; + + gpuName = subKey.GetValue("DriverDesc") as string; + driverVersion = subKey.GetValue("DriverVersion") as string; + if (!string.IsNullOrEmpty(gpuName) && !string.IsNullOrEmpty(driverVersion)) + { + gpuInfoList.Add((subKeyName + gpuName, driverVersion)); + } + } + catch (Exception) + { + gpuInfoList.Add((subKeyName + gpuName, driverVersion)!); + throw; + } + } + } + } + catch (Exception ex) + { + Logger.LogWriteLine($"Failed to retrieve GPU info from registry: {ex.Message}", LogType.Error, + true); + } + + return gpuInfoList; + } + } + + private static Breadcrumb? _buildInfo; + + private static Breadcrumb BuildInfo => + _buildInfo ??= new Breadcrumb("Build Info", "commit", new Dictionary + { + { "Branch", AppBuildBranch }, + { "Commit", AppBuildCommit }, + { "Repository", AppBuildRepo }, + { "IsPreview", IsPreview.ToString() } + }, "BuildInfo"); + + private static Breadcrumb? _cpuInfo; + + private static Breadcrumb CpuInfo => + _cpuInfo ??= new Breadcrumb("CPU Info", "system.cpu", new Dictionary + { + { "CPU Name", CpuName }, + { "Total Thread", CpuThreadsTotal.ToString() } + }, "CPUInfo"); + + private static Breadcrumb? _gpuInfo; + + private static Breadcrumb GpuInfo => + _gpuInfo ??= new Breadcrumb("GPU Info", "system.gpu", + GetGpuInfo.ToDictionary(item => item.GpuName, + item => item.DriverVersion), + "GPUInfo"); + + private static Breadcrumb GameInfo => + new("Current Loaded Game Info", "game", new Dictionary + { + { "Category", CurrentGameCategory }, + { "Region", CurrentGameRegion }, + { "Installed", CurrentGameInstalled.ToString() }, + { "Updated", CurrentGameUpdated.ToString() }, + { "HasPreload", CurrentGameHasPreload.ToString() }, + { "HasDelta", CurrentGameHasDelta.ToString() }, + { "IsGameFromPlugin", CurrentGameIsPlugin.ToString() }, + { "Location", CurrentGameLocation }, + { "CdnOption", AppCdnOption } + }, "GameInfo"); + + +public static class PluginListBreadcrumb +{ + private static readonly ObservableCollection<(string Name, string Version, string StdVersion)> List = []; + + public static void Add(string name, string version, string stdVersion) + { + List.Add((name, version, stdVersion)); + + List.CollectionChanged += ListOnCollectionChanged; + } + + private static void ListOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + SentryHelper.PluginInfo = new Breadcrumb("Plugin Info", "app.plugins", + List.ToDictionary( + item => item.Name, + item => $"{item.Version}-{item.StdVersion}" + ), + "PluginInfo"); + } +} \ No newline at end of file diff --git a/Hi3Helper.Core/Classes/SentryHelper/CollapsePluginExtension.cs b/Hi3Helper.Core/Classes/SentryHelper/CollapsePluginExtension.cs deleted file mode 100644 index 4c875941b..000000000 --- a/Hi3Helper.Core/Classes/SentryHelper/CollapsePluginExtension.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Sentry; -using System.Collections.ObjectModel; -using System.Collections.Specialized; -using System.Linq; - -namespace Hi3Helper.SentryHelper; - -public static class PluginListBreadcrumb -{ - private static readonly ObservableCollection<(string Name, string Version, string StdVersion)> List = []; - - - public static void Add(string name, string version, string stdVersion) - { - List.Add((name, version, stdVersion)); - - List.CollectionChanged += ListOnCollectionChanged; - } - - private static void ListOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - SentryHelper.PluginInfo = new Breadcrumb("Plugin Info", "app.plugins", - List.ToDictionary( - item => item.Name, - item => $"{item.Version}-{item.StdVersion}" - ), - "PluginInfo"); - } -} \ No newline at end of file diff --git a/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs b/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs index 5d71ac276..1600c29c3 100644 --- a/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs +++ b/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs @@ -1,13 +1,10 @@ using Hi3Helper.Shared.Region; -using Microsoft.Win32; using Sentry; using Sentry.Protocol; using System; using System.Buffers; -using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -385,131 +382,9 @@ public static async Task ExceptionHandler_ForLoopAsync(Exception ex, public static bool CurrentGameHasDelta { get; set; } public static bool CurrentGameIsPlugin { get; set; } - private static int CpuThreadsTotal => Environment.ProcessorCount; - - private static string CpuName - { - get - { - try - { - string cpuName; - string env = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER") ?? "Unknown CPU"; - object? reg = - Registry.GetValue(@"HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\SYSTEM\CentralProcessor\0", - "ProcessorNameString", null); - if (reg != null) - { - cpuName = reg.ToString() ?? env; - cpuName = cpuName.Trim(); - } - else cpuName = env; - - return cpuName; - } - catch (Exception ex) - { - Logger.LogWriteLine("Failed when trying to get CPU Name!\r\n" + ex, LogType.Error, true); - return "Unknown CPU"; - } - } - } - - private static List<(string GpuName, string DriverVersion)> GetGpuInfo - { - get - { - List<(string GpuName, string DriverVersion)> gpuInfoList = []; - try - { - using RegistryKey? baseKey = - Registry.LocalMachine - .OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\"); - if (baseKey != null) - { - foreach (string subKeyName in baseKey.GetSubKeyNames()) - { - if (!int.TryParse(subKeyName, out int subKeyInt) || subKeyInt < 0 || subKeyInt > 9999) - continue; - - string? gpuName = "Unknown GPU"; - string? driverVersion = "Unknown Driver Version"; - try - { - using RegistryKey? subKey = baseKey.OpenSubKey(subKeyName); - if (subKey == null) continue; - - gpuName = subKey.GetValue("DriverDesc") as string; - driverVersion = subKey.GetValue("DriverVersion") as string; - if (!string.IsNullOrEmpty(gpuName) && !string.IsNullOrEmpty(driverVersion)) - { - gpuInfoList.Add((subKeyName + gpuName, driverVersion)); - } - } - catch (Exception) - { - gpuInfoList.Add((subKeyName + gpuName, driverVersion)!); - throw; - } - } - } - } - catch (Exception ex) - { - Logger.LogWriteLine($"Failed to retrieve GPU info from registry: {ex.Message}", LogType.Error, - true); - } - - return gpuInfoList; - } - } - - private static Breadcrumb? _buildInfo; - - private static Breadcrumb BuildInfo => - _buildInfo ??= new Breadcrumb("Build Info", "commit", new Dictionary - { - { "Branch", AppBuildBranch }, - { "Commit", AppBuildCommit }, - { "Repository", AppBuildRepo }, - { "IsPreview", IsPreview.ToString() } - }, "BuildInfo"); - - private static Breadcrumb? _cpuInfo; - - private static Breadcrumb CpuInfo => - _cpuInfo ??= new Breadcrumb("CPU Info", "system.cpu", new Dictionary - { - { "CPU Name", CpuName }, - { "Total Thread", CpuThreadsTotal.ToString() } - }, "CPUInfo"); - - private static Breadcrumb? _gpuInfo; - - private static Breadcrumb GpuInfo => - _gpuInfo ??= new Breadcrumb("GPU Info", "system.gpu", - GetGpuInfo.ToDictionary(item => item.GpuName, - item => item.DriverVersion), - "GPUInfo"); - - private static Breadcrumb GameInfo => - new("Current Loaded Game Info", "game", new Dictionary - { - { "Category", CurrentGameCategory }, - { "Region", CurrentGameRegion }, - { "Installed", CurrentGameInstalled.ToString() }, - { "Updated", CurrentGameUpdated.ToString() }, - { "HasPreload", CurrentGameHasPreload.ToString() }, - { "HasDelta", CurrentGameHasDelta.ToString() }, - { "IsGameFromPlugin", CurrentGameIsPlugin.ToString() }, - { "Location", CurrentGameLocation }, - { "CdnOption", AppCdnOption } - }, "GameInfo"); - #pragma warning disable CA2211 public static Breadcrumb? PluginInfo = null; #pragma warning restore CA2211 - #endregion private static SentryId ExceptionHandlerInner(Exception ex, ExceptionType exT = ExceptionType.Handled) From 3019bb9eef92246b797b039cf6efae5ebe45fd75 Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono Date: Tue, 6 Jan 2026 23:35:09 +0700 Subject: [PATCH 3/7] [Sentry] Add app config breadcrumbs Signed-off-by: Bagus Nur Listiyono --- .../CollapseBreadcrumbExtension.cs | 62 +++++++++++++++++++ .../Classes/SentryHelper/SentryHelper.cs | 1 + 2 files changed, 63 insertions(+) diff --git a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs index 5f413d156..ca04a2371 100644 --- a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs +++ b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs @@ -137,6 +137,38 @@ private static string CpuName }, "GameInfo"); + [field: AllowNull, MaybeNull] + private static Breadcrumb AppConfig + { + get + { + field ??= new Breadcrumb("Collapse App Config", "app.config", new Dictionary + { + { "Proxy", ProxyBreadcrumb.IsUsingProxy ?? "" }, + { "Waifu2x", GetAppConfigValue("EnableWaifu2X") ? "enabled" : "disabled" }, + { + "HttpCache", + AppNetworkCacheEnabled + ? "enabled" + (AppNetworkCacheAggressiveModeEnabled ? "+agg" : "") + : "disabled" + }, + { "AppThread", $"{AppCurrentDownloadThread},{AppCurrentThread}" }, + { "SophonThread", $"{GetAppConfigValue("SophonHttpConnInt")},{GetAppConfigValue("SophonCpuThread")}" }, + { "DownloadPreallocated", (IsUsePreallocatedDownloader) ? "enabled" : "disabled" }, + { + "HttpOpts", + $"{(GetAppConfigValue("IsAllowHttpRedirections")? "Redirect" : "")}" + + $"{(GetAppConfigValue("IsAllowHttpCookies") ? "Cookie" : "" )}" + + $"{(GetAppConfigValue("IsAllowUntrustedCert") ? "Insecure" : "")}" + }, + { "ExternalDNS", GetAppConfigValue("IsUseExternalDns") ? "enabled" : "disabled" } + }, "AppConfig"); + return field; + } + } +} + +#nullable disable public static class PluginListBreadcrumb { private static readonly ObservableCollection<(string Name, string Version, string StdVersion)> List = []; @@ -157,4 +189,34 @@ private static void ListOnCollectionChanged(object sender, NotifyCollectionChang ), "PluginInfo"); } +} + +#nullable enable +public static class ProxyBreadcrumb +{ + [field: AllowNull, MaybeNull] + public static string IsUsingProxy + { + get + { + field ??= string.Concat( + GetCollapseProxy() ? "cl" : "", + GetSystemProxy() ? "+sys" : "" + ); + return field; + } + } + + private static bool GetSystemProxy() + { + var sysProxy = (WebProxy?) WebRequest.DefaultWebProxy; + if (sysProxy == null) return false; + + return !string.IsNullOrEmpty(sysProxy.Address?.AbsoluteUri); + } + + private static bool GetCollapseProxy() + { + return GetAppConfigValue("IsUseProxy").ToBool() && !string.IsNullOrEmpty(GetAppConfigValue("HttpProxyUrl")); + } } \ No newline at end of file diff --git a/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs b/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs index 1600c29c3..284ab2159 100644 --- a/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs +++ b/Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs @@ -393,6 +393,7 @@ private static SentryId ExceptionHandlerInner(Exception ex, ExceptionType exT = SentrySdk.AddBreadcrumb(GameInfo); SentrySdk.AddBreadcrumb(CpuInfo); SentrySdk.AddBreadcrumb(GpuInfo); + SentrySdk.AddBreadcrumb(AppConfig); if (PluginInfo != null) SentrySdk.AddBreadcrumb(PluginInfo); From 3064c62afaa0db1dccf5b6eaec5518e0798f5cfc Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono Date: Wed, 7 Jan 2026 00:04:54 +0700 Subject: [PATCH 4/7] [Sentry] Fix hard crash on proxy breadcrumb getter Signed-off-by: Bagus Nur Listiyono --- .../SentryHelper/CollapseBreadcrumbExtension.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs index ca04a2371..73dab82e5 100644 --- a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs +++ b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs @@ -209,14 +209,17 @@ public static string IsUsingProxy private static bool GetSystemProxy() { - var sysProxy = (WebProxy?) WebRequest.DefaultWebProxy; - if (sysProxy == null) return false; + using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings"); - return !string.IsNullOrEmpty(sysProxy.Address?.AbsoluteUri); + return (key?.GetValue("ProxyEnable") as int? ?? 0) == 1; } - + private static bool GetCollapseProxy() { - return GetAppConfigValue("IsUseProxy").ToBool() && !string.IsNullOrEmpty(GetAppConfigValue("HttpProxyUrl")); + var useProxy = GetAppConfigValue("IsUseProxy").ToBool(); + if (!useProxy) + return false; + + return !string.IsNullOrEmpty(GetAppConfigValue("HttpProxyUrl")); } } \ No newline at end of file From 2c08dbabb68b43acc5cf92294836460adc58c7e1 Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono Date: Wed, 7 Jan 2026 00:13:08 +0700 Subject: [PATCH 5/7] [Sentry] Simplify PluginList breadcrumb builder Signed-off-by: Bagus Nur Listiyono --- .../Classes/SentryHelper/CollapseBreadcrumbExtension.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs index 73dab82e5..65631f2f4 100644 --- a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs +++ b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs @@ -171,22 +171,17 @@ private static Breadcrumb AppConfig #nullable disable public static class PluginListBreadcrumb { - private static readonly ObservableCollection<(string Name, string Version, string StdVersion)> List = []; + private static readonly Collection<(string Name, string Version, string StdVersion)> List = []; public static void Add(string name, string version, string stdVersion) { List.Add((name, version, stdVersion)); - List.CollectionChanged += ListOnCollectionChanged; - } - - private static void ListOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { SentryHelper.PluginInfo = new Breadcrumb("Plugin Info", "app.plugins", List.ToDictionary( item => item.Name, item => $"{item.Version}-{item.StdVersion}" - ), + ), "PluginInfo"); } } From f9b0176cf0319c68328197bac9bba6593762f65b Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono Date: Wed, 7 Jan 2026 00:25:32 +0700 Subject: [PATCH 6/7] [Sentry] Wrap GetSystemProxy in trycatch Signed-off-by: Bagus Nur Listiyono --- .../SentryHelper/CollapseBreadcrumbExtension.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs index 65631f2f4..1d2e4edef 100644 --- a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs +++ b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs @@ -204,9 +204,18 @@ public static string IsUsingProxy private static bool GetSystemProxy() { - using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings"); + try + { + using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings"); - return (key?.GetValue("ProxyEnable") as int? ?? 0) == 1; + return (key?.GetValue("ProxyEnable") as int? ?? 0) == 1; + } + catch (Exception ex) + { + Logger.LogWriteLine($"[CollapseSentryExtension::GetSystemProxy] Failure when grabbing system proxy settings! returning false...\r\n" + + $"{ex}", LogType.Error, true); + return false; + } } private static bool GetCollapseProxy() From 3c32eb3f26ef8018d894baca307918862f6a2a78 Mon Sep 17 00:00:00 2001 From: Bagus Nur Listiyono Date: Wed, 7 Jan 2026 05:31:25 +0700 Subject: [PATCH 7/7] [Sentry] Add proxy type to breadcrumb Signed-off-by: Bagus Nur Listiyono --- .../CollapseBreadcrumbExtension.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs index 1d2e4edef..18b8958e3 100644 --- a/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs +++ b/Hi3Helper.Core/Classes/SentryHelper/CollapseBreadcrumbExtension.cs @@ -195,7 +195,7 @@ public static string IsUsingProxy get { field ??= string.Concat( - GetCollapseProxy() ? "cl" : "", + GetCollapseProxy() ? $"cl({GetCollapseProxyType()}" : "", GetSystemProxy() ? "+sys" : "" ); return field; @@ -226,4 +226,24 @@ private static bool GetCollapseProxy() return !string.IsNullOrEmpty(GetAppConfigValue("HttpProxyUrl")); } + + private static string GetCollapseProxyType() + { + var cfg = GetAppConfigValue("HttpProxyUrl").ToString(); + + if (string.IsNullOrEmpty(cfg)) return string.Empty; + try + { + var proxy = new Uri(cfg); + + return proxy.Scheme; + } + catch (Exception ex) + { + Logger.LogWriteLine($"[CollapseSentryExtension::GetCollapseProxyType] Failure when parsing proxy URL scheme! returning empty string..." + + $"{ex}", LogType.Error, true); + + return string.Empty; + } + } } \ No newline at end of file