From 2495fc7b265055d2390dff66fedbcef90bdbbe2f Mon Sep 17 00:00:00 2001
From: CJKmkp <2564608840@qq.com>
Date: Fri, 6 Feb 2026 23:36:57 +0800
Subject: [PATCH] =?UTF-8?q?add:Dlass=E9=81=A5=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Ink Canvas/Helpers/DeviceIdentifier.cs | 37 ++++++++++++++
Ink Canvas/Helpers/TelemetryUploader.cs | 66 +++++++++----------------
Ink Canvas/MainWindow.xaml | 2 +-
Ink Canvas/MainWindow.xaml.cs | 1 -
Ink Canvas/MainWindow_cs/MW_Settings.cs | 1 +
5 files changed, 61 insertions(+), 46 deletions(-)
diff --git a/Ink Canvas/Helpers/DeviceIdentifier.cs b/Ink Canvas/Helpers/DeviceIdentifier.cs
index 9bb45e9f..8778457c 100644
--- a/Ink Canvas/Helpers/DeviceIdentifier.cs
+++ b/Ink Canvas/Helpers/DeviceIdentifier.cs
@@ -426,6 +426,9 @@ namespace Ink_Canvas.Helpers
[JsonProperty("lastModified")]
public DateTime LastModified { get; set; }
+ [JsonProperty("updateChannel")]
+ public Ink_Canvas.UpdateChannel UpdateChannel { get; set; } = Ink_Canvas.UpdateChannel.Release;
+
// 每周统计数据(秒级精度)
[JsonProperty("weeklyLaunchCount")]
public int WeeklyLaunchCount { get; set; }
@@ -1003,6 +1006,40 @@ namespace Ink_Canvas.Helpers
}
}
+ public static void UpdateUsageChannel(Ink_Canvas.UpdateChannel channel)
+ {
+ try
+ {
+ lock (fileLock)
+ {
+ var stats = LoadUsageStats();
+ if (stats == null)
+ {
+ stats = new UsageStats
+ {
+ DeviceId = DeviceId,
+ LastLaunchTime = DateTime.Now,
+ LaunchCount = 0,
+ TotalUsageSeconds = 0,
+ AverageSessionSeconds = 0,
+ LastUpdateCheck = DateTime.MinValue,
+ UpdatePriority = UpdatePriority.Medium,
+ UsageFrequency = UsageFrequency.Medium
+ };
+ }
+
+ stats.UpdateChannel = channel;
+ SaveUsageStats(stats);
+
+ LogHelper.WriteLogToFile($"DeviceIdentifier | 更新使用统计中的通道信息: {channel}");
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"DeviceIdentifier | 更新通道信息到使用统计失败: {ex.Message}", LogHelper.LogType.Error);
+ }
+ }
+
///
/// 记录更新检查时间
///
diff --git a/Ink Canvas/Helpers/TelemetryUploader.cs b/Ink Canvas/Helpers/TelemetryUploader.cs
index 393ea09b..da20c242 100644
--- a/Ink Canvas/Helpers/TelemetryUploader.cs
+++ b/Ink Canvas/Helpers/TelemetryUploader.cs
@@ -8,7 +8,7 @@ using Sentry;
namespace Ink_Canvas.Helpers
{
///
- /// 遥测上传辅助类:根据用户设置,通过 Sentry 上传 usage_stats.enc 和 Crashes 目录的摘要信息。
+ /// 遥测上传:根据用户设置,通过 Sentry 上传 usage_stats 和 Crashes 目录的摘要信息。
///
internal static class TelemetryUploader
{
@@ -42,24 +42,7 @@ namespace Ink_Canvas.Helpers
return;
}
- // 读取 usage_stats.enc 作为基础数据
- string usageStatsPath = Path.Combine(App.RootPath, "usage_stats.enc");
- string usageStatsContent = null;
- if (File.Exists(usageStatsPath))
- {
- try
- {
- usageStatsContent = File.ReadAllText(usageStatsPath);
- }
- catch (Exception ex)
- {
- LogHelper.WriteLogToFile(
- $"TelemetryUploader | 读取 usage_stats.enc 失败: {ex.Message}",
- LogHelper.LogType.Warning);
- }
- }
-
- // 可选:读取 Crashes 目录下的崩溃日志(仅在扩展模式时上传)
+ // 可选:Crashes 目录下的崩溃日志
List