2026-03-11 15:14:08 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2026-03-09 15:11:48 +08:00
|
|
|
using Avalonia;
|
2026-03-20 00:41:14 +08:00
|
|
|
using LanMountainDesktop.DesktopHost;
|
2026-03-13 09:10:00 +08:00
|
|
|
using LanMountainDesktop.Models;
|
2026-04-13 08:02:47 +08:00
|
|
|
using LanMountainDesktop.Plugins;
|
2026-03-09 15:11:48 +08:00
|
|
|
using LanMountainDesktop.Services;
|
2026-04-22 07:31:54 +08:00
|
|
|
using LanMountainDesktop.Services.Launcher;
|
2026-03-13 09:10:00 +08:00
|
|
|
using LanMountainDesktop.Services.Settings;
|
2026-04-21 20:59:52 +08:00
|
|
|
using LanMountainDesktop.Shared.Contracts.Launcher;
|
2026-02-26 23:08:19 +08:00
|
|
|
|
2026-03-04 15:22:52 +08:00
|
|
|
namespace LanMountainDesktop;
|
2026-02-26 23:08:19 +08:00
|
|
|
|
2026-03-22 02:53:31 +08:00
|
|
|
public sealed class Program
|
2026-02-26 23:08:19 +08:00
|
|
|
{
|
2026-03-13 22:20:12 +08:00
|
|
|
internal static string StartupRenderMode { get; private set; } = AppRenderingModeHelper.Default;
|
|
|
|
|
|
2026-02-26 23:08:19 +08:00
|
|
|
[STAThread]
|
2026-03-10 21:25:47 +08:00
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Initialize();
|
Launcher fix (#6)
* fix.hy3试图修复中
* Resolve dev paths and fix splash UI thread
Compute a solutionRoot and expand development search paths (LanMountainDesktop and dev-test) in DeploymentLocator, add logging when scanning/finding hosts, and return distinct full paths. Ensure backward-compatible path checks. Fix cross-thread UI calls: invoke splashWindow.DismissAsync on the UI thread in LauncherFlowCoordinator, and make SplashWindow.DismissAsync ensure it runs on the UI thread before closing (simplified Close call). These changes improve development host discovery and prevent UI-thread access issues during shutdown.
* Add configurable data location (portable/system)
Introduce support for choosing and resolving the application's data root (system user dir vs. portable app folder). Adds DataLocationConfig model, DataLocationResolver (load/save/resolve/migrate), a UI prompt (DataLocationPromptWindow) and an OOBE step (DataLocationOobeStep) to let users pick and optionally migrate existing data. Wire the chosen data root into the launcher flow and host launch plan (forwarded via --data-root and LMD_DATA_ROOT), and add AppDataPathProvider to let runtime services read the effective data root (initialized in Program.Main). Update various services (logging, settings, DB, plugin/market, startup registry, etc.) to use the new provider/resolver and register the config type in the JSON context. This enables portable installs, safe migration, and runtime overrides via CLI or environment variable.
* Add dev/debug startup flow and launch profiles
Handle design-time initialization and add a developer debug startup path: App now skips normal startup when in design mode and shows a DevDebugWindow when running in debug (unless a preview or apply-update command). CommandContext.IsDebugMode is extended to include DOTNET_ENVIRONMENT=Development via a new IsDevelopmentEnvironment helper. Program.Main and BuildAvaloniaApp are made public to aid tooling. Added multiple launchSettings profiles for debug and preview commands that set DOTNET_ENVIRONMENT=Development to simplify IDE debugging and UI previewing.
* Simplify splash to fade; add themed about banners
Simplify splash startup visuals by removing the multi-mode/slide behavior and always using a fade animation. Update App to create SplashWindow without a StartupVisualMode parameter and remove related fields, layout configuration, slide animation, and easing helpers from SplashWindow. Clean up unused using. Replace the single about_banner asset with theme-aware variants (about_banner_dark.png and about_banner_light.png), delete the old about_banner.png, and update AboutSettingsPage to use a DynamicResource ImageBrush (AboutBannerBrush) that selects the appropriate banner per theme.
* Use AppJsonContext for startup state serialization
Switch serialization to the source-generated System.Text.Json context: add JsonSerializable(typeof(StartupAttemptRecord)) to AppJsonContext and replace the previous JsonSerializerOptions-based Serialize/Deserialize calls with AppJsonContext.Default.StartupAttemptRecord. Also remove the now-unused SerializerOptions field. Additionally, update .gitignore to exclude /test-aot-publish.
* Add OOBE redesign, theme & data location support
Introduce a redesigned OOBE flow and data-location/theme support across the launcher. Adds a new ThemeService for applying light/dark and accent colors; integrates FluentIcons.Avalonia package for icons. Overhauls OobeWindow (UX animations, typing effect, multi-step theme and data-location pages, Monet options, and final welcome step) and its code-behind to handle step navigation, accent selection, and data-location resolution. Adds DataLocation UI and handlers (DataLocationPromptWindow changes, DataLocation resolver usage) and wires a DevDebug UI for toggling/opening the data-location page. UpdateEngineService now resolves the launcher root via DataLocationResolver. Misc: update various view models, localization entries and remove TrimmerRoots.xml.
* Refactor data location paths and add background service
Refactor DataLocationResolver to centralize data path resolution (ResolveLauncherDataPath, ResolveDesktopDataPath, ResolveConfigPath, ResolveLauncherLogsPath, ResolveLauncherStatePath) and replace usages of the previous ".launcher" layout with a "Launcher" folder. Update API: LoadConfig/SaveConfig reorganized and ApplyLocationChoice now accepts an optional custom path and migration flag; migration logic updated accordingly. Update dependent services and views (Logger, DeploymentLocator, UpdateEngineService, OobeStateService, StartupAttemptRegistry, LauncherDebugSettingsStore, OobeWindow) to use the new resolver APIs and paths. Add LauncherBackgroundService to load/validate/cache a custom splash background image and wire it into SplashWindow (AXAML/Axaml.cs) with UI placeholders and overlay. Misc: minor cleanup of Oobe/Splash XAML and related code adjustments and logging improvements.
2026-04-25 18:41:26 +08:00
|
|
|
AppDataPathProvider.Initialize(args);
|
2026-04-13 08:02:47 +08:00
|
|
|
DevPluginOptions.Parse(args);
|
2026-03-10 21:25:47 +08:00
|
|
|
RegisterGlobalExceptionLogging();
|
2026-04-23 00:27:01 +08:00
|
|
|
var restartParentProcessId = LauncherRuntimeMetadata.GetRestartParentProcessId(args);
|
2026-03-10 21:25:47 +08:00
|
|
|
|
2026-03-12 12:25:22 +08:00
|
|
|
using var singleInstance = AcquireSingleInstance(restartParentProcessId);
|
2026-03-11 09:40:36 +08:00
|
|
|
if (!singleInstance.IsPrimaryInstance)
|
|
|
|
|
{
|
2026-03-12 12:25:22 +08:00
|
|
|
if (restartParentProcessId is not null)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Warn(
|
|
|
|
|
"Startup",
|
|
|
|
|
$"Restart relaunch could not acquire the single-instance lock. pid={restartParentProcessId.Value}. Suppressing multi-open activation prompt.");
|
2026-04-22 07:31:54 +08:00
|
|
|
ReportLauncherStageBeforeExit(StartupStage.ActivationFailed, "Restart relaunch could not acquire the single-instance lock.");
|
2026-04-21 20:59:52 +08:00
|
|
|
Environment.ExitCode = HostExitCodes.RestartLockNotAcquired;
|
2026-03-12 12:25:22 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-21 20:59:52 +08:00
|
|
|
var activationAcknowledged = singleInstance.TryNotifyPrimaryInstance(TimeSpan.FromSeconds(2), out var failureReason);
|
|
|
|
|
if (activationAcknowledged)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Info(
|
|
|
|
|
"Startup",
|
|
|
|
|
$"Secondary launch forwarded to primary instance successfully. Acked={activationAcknowledged}; Pid={Environment.ProcessId}.");
|
2026-04-22 07:31:54 +08:00
|
|
|
ReportLauncherStageBeforeExit(StartupStage.ActivationRedirected, "Secondary launch forwarded to the primary instance.");
|
2026-04-21 20:59:52 +08:00
|
|
|
Environment.ExitCode = HostExitCodes.SecondaryActivationSucceeded;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Warn(
|
|
|
|
|
"Startup",
|
|
|
|
|
$"Secondary launch failed to activate the primary instance. Acked={activationAcknowledged}; Reason='{failureReason ?? "unknown"}'; Pid={Environment.ProcessId}.");
|
2026-04-22 07:31:54 +08:00
|
|
|
ReportLauncherStageBeforeExit(
|
|
|
|
|
StartupStage.ActivationFailed,
|
|
|
|
|
$"Secondary launch failed to activate the primary instance. Reason='{failureReason ?? "unknown"}'.");
|
2026-04-21 20:59:52 +08:00
|
|
|
Environment.ExitCode = HostExitCodes.SecondaryActivationFailed;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-11 09:40:36 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-21 16:16:02 +08:00
|
|
|
DesktopBootstrap.InitializeStartupServices(
|
|
|
|
|
InitializeTelemetryIdentity,
|
|
|
|
|
InitializeCrashTelemetry,
|
|
|
|
|
InitializeUsageTelemetry,
|
|
|
|
|
ScheduleWhiteboardNoteStartupCleanup);
|
|
|
|
|
|
2026-03-10 21:25:47 +08:00
|
|
|
var diagnostics = StartupDiagnosticsService.Run(args);
|
|
|
|
|
StartupDiagnosticsService.ShowLegacyExecutableWarningIfNeeded(diagnostics);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var renderMode = LoadConfiguredRenderMode();
|
2026-03-13 22:20:12 +08:00
|
|
|
StartupRenderMode = renderMode;
|
2026-03-10 21:25:47 +08:00
|
|
|
AppLogger.Info("Startup", $"Resolved render mode '{renderMode}'.");
|
2026-03-11 09:40:36 +08:00
|
|
|
App.CurrentSingleInstanceService = singleInstance;
|
2026-04-23 23:07:37 +08:00
|
|
|
singleInstance.StartActivationListener(() =>
|
|
|
|
|
{
|
|
|
|
|
if (Avalonia.Application.Current is App app)
|
|
|
|
|
{
|
|
|
|
|
app.ActivateMainWindow();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppLogger.Info("SingleInstance", "Activation acknowledged before Avalonia App was ready.");
|
|
|
|
|
});
|
2026-03-10 21:25:47 +08:00
|
|
|
BuildAvaloniaApp(renderMode).StartWithClassicDesktopLifetime(args);
|
|
|
|
|
AppLogger.Info("Startup", "Application exited normally.");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Critical("Startup", "Application terminated during startup.", ex);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2026-03-11 09:40:36 +08:00
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
App.CurrentSingleInstanceService = null;
|
|
|
|
|
}
|
2026-03-10 21:25:47 +08:00
|
|
|
}
|
2026-02-26 23:08:19 +08:00
|
|
|
|
2026-03-22 02:53:31 +08:00
|
|
|
public static AppBuilder BuildAvaloniaApp()
|
|
|
|
|
{
|
|
|
|
|
return BuildAvaloniaApp(AppRenderingModeHelper.Default);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static AppBuilder BuildAvaloniaApp(string renderMode)
|
2026-03-09 15:11:48 +08:00
|
|
|
{
|
|
|
|
|
var builder = AppBuilder.Configure<App>()
|
2026-02-26 23:08:19 +08:00
|
|
|
.UsePlatformDetect()
|
|
|
|
|
.WithInterFont()
|
|
|
|
|
.LogToTrace();
|
2026-03-09 15:11:48 +08:00
|
|
|
|
|
|
|
|
if (OperatingSystem.IsWindows())
|
|
|
|
|
{
|
|
|
|
|
var configuredModes = AppRenderingModeHelper.GetWin32RenderingModes(renderMode);
|
|
|
|
|
if (configuredModes is { Length: > 0 })
|
|
|
|
|
{
|
|
|
|
|
builder = builder.With(new Win32PlatformOptions
|
|
|
|
|
{
|
|
|
|
|
RenderingMode = configuredModes
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-19 16:27:16 +08:00
|
|
|
private static void ScheduleWhiteboardNoteStartupCleanup()
|
|
|
|
|
{
|
|
|
|
|
_ = Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var deletedCount = new WhiteboardNotePersistenceService().DeleteExpiredNotesBatch(batchSize: 512);
|
|
|
|
|
if (deletedCount > 0)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Info("Startup", $"Deleted {deletedCount} expired whiteboard notes during startup maintenance.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Warn("Startup", "Failed to run whiteboard note startup maintenance.", ex);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-12 12:25:22 +08:00
|
|
|
private static SingleInstanceService AcquireSingleInstance(int? restartParentProcessId)
|
2026-03-11 15:14:08 +08:00
|
|
|
{
|
|
|
|
|
var singleInstance = SingleInstanceService.CreateDefault();
|
|
|
|
|
if (singleInstance.IsPrimaryInstance || restartParentProcessId is null)
|
|
|
|
|
{
|
|
|
|
|
return singleInstance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppLogger.Info(
|
|
|
|
|
"Startup",
|
|
|
|
|
$"Restart relaunch detected. Waiting for previous instance pid={restartParentProcessId.Value} to exit before re-acquiring the single-instance lock.");
|
|
|
|
|
singleInstance.Dispose();
|
|
|
|
|
|
|
|
|
|
var deadline = DateTime.UtcNow + TimeSpan.FromSeconds(12);
|
|
|
|
|
WaitForRestartParentExit(restartParentProcessId.Value, deadline);
|
|
|
|
|
|
|
|
|
|
while (DateTime.UtcNow < deadline)
|
|
|
|
|
{
|
|
|
|
|
var retryInstance = SingleInstanceService.CreateDefault();
|
|
|
|
|
if (retryInstance.IsPrimaryInstance)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Info("Startup", "Restart relaunch acquired the single-instance lock.");
|
|
|
|
|
return retryInstance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retryInstance.Dispose();
|
|
|
|
|
Thread.Sleep(150);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppLogger.Warn(
|
|
|
|
|
"Startup",
|
|
|
|
|
$"Restart relaunch timed out while waiting for the single-instance lock. pid={restartParentProcessId.Value}.");
|
|
|
|
|
return SingleInstanceService.CreateDefault();
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-09 15:11:48 +08:00
|
|
|
private static string LoadConfiguredRenderMode()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2026-03-13 09:10:00 +08:00
|
|
|
var snapshot = HostSettingsFacadeProvider.GetOrCreate()
|
|
|
|
|
.Settings
|
|
|
|
|
.LoadSnapshot<AppSettingsSnapshot>(LanMountainDesktop.PluginSdk.SettingsScope.App);
|
|
|
|
|
return AppRenderingModeHelper.Normalize(snapshot.AppRenderMode);
|
2026-03-09 15:11:48 +08:00
|
|
|
}
|
2026-03-10 21:25:47 +08:00
|
|
|
catch (Exception ex)
|
2026-03-09 15:11:48 +08:00
|
|
|
{
|
2026-03-10 21:25:47 +08:00
|
|
|
AppLogger.Warn("Startup", "Failed to load configured render mode. Falling back to default.", ex);
|
2026-03-09 15:11:48 +08:00
|
|
|
return AppRenderingModeHelper.Default;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-10 21:25:47 +08:00
|
|
|
|
2026-03-11 15:14:08 +08:00
|
|
|
private static void WaitForRestartParentExit(int processId, DateTime deadlineUtc)
|
2026-03-11 09:40:36 +08:00
|
|
|
{
|
2026-03-11 15:14:08 +08:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using var process = Process.GetProcessById(processId);
|
|
|
|
|
var remaining = deadlineUtc - DateTime.UtcNow;
|
|
|
|
|
if (remaining > TimeSpan.Zero)
|
|
|
|
|
{
|
|
|
|
|
process.WaitForExit((int)Math.Ceiling(remaining.TotalMilliseconds));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (ArgumentException)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Warn("Startup", $"Failed while waiting for restart parent pid={processId} to exit.", ex);
|
|
|
|
|
}
|
2026-03-11 09:40:36 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-10 21:25:47 +08:00
|
|
|
private static void RegisterGlobalExceptionLogging()
|
|
|
|
|
{
|
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += (_, eventArgs) =>
|
|
|
|
|
{
|
2026-03-21 16:16:02 +08:00
|
|
|
var exception = eventArgs.ExceptionObject as Exception
|
|
|
|
|
?? new Exception(eventArgs.ExceptionObject?.ToString() ?? "Unhandled exception.");
|
|
|
|
|
|
2026-03-10 21:25:47 +08:00
|
|
|
AppLogger.Critical(
|
|
|
|
|
"UnhandledException",
|
|
|
|
|
$"Unhandled exception. IsTerminating={eventArgs.IsTerminating}",
|
2026-03-21 16:16:02 +08:00
|
|
|
exception);
|
2026-03-16 09:50:48 +08:00
|
|
|
|
2026-03-21 16:16:02 +08:00
|
|
|
try
|
2026-03-16 09:50:48 +08:00
|
|
|
{
|
2026-03-21 16:16:02 +08:00
|
|
|
TelemetryServices.Crash?.CaptureUnhandledException(
|
|
|
|
|
exception,
|
|
|
|
|
"AppDomain.UnhandledException",
|
|
|
|
|
eventArgs.IsTerminating);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception telemetryException)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Warn("UnhandledException", "Failed to forward unhandled exception to crash telemetry.", telemetryException);
|
2026-03-16 09:50:48 +08:00
|
|
|
}
|
2026-03-10 21:25:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TaskScheduler.UnobservedTaskException += (_, eventArgs) =>
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Error("TaskScheduler", "Unobserved task exception.", eventArgs.Exception);
|
2026-03-21 16:16:02 +08:00
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TelemetryServices.Crash?.CaptureTaskException(
|
|
|
|
|
eventArgs.Exception,
|
|
|
|
|
"TaskScheduler.UnobservedTaskException");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception telemetryException)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Warn("TaskScheduler", "Failed to forward task exception to crash telemetry.", telemetryException);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-12 12:25:22 +08:00
|
|
|
eventArgs.SetObserved();
|
2026-03-10 21:25:47 +08:00
|
|
|
};
|
|
|
|
|
}
|
2026-03-16 09:50:48 +08:00
|
|
|
|
2026-04-22 07:31:54 +08:00
|
|
|
private static void ReportLauncherStageBeforeExit(StartupStage stage, string message)
|
|
|
|
|
{
|
|
|
|
|
if (!LauncherIpcClient.IsLaunchedByLauncher())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using var launcherIpcClient = new LauncherIpcClient();
|
|
|
|
|
var connected = launcherIpcClient.ConnectAsync().GetAwaiter().GetResult();
|
|
|
|
|
if (!connected)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
launcherIpcClient.ReportProgressAsync(new StartupProgressMessage
|
|
|
|
|
{
|
|
|
|
|
Stage = stage,
|
|
|
|
|
ProgressPercent = 100,
|
|
|
|
|
Message = message
|
|
|
|
|
}).GetAwaiter().GetResult();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
AppLogger.Warn("LauncherIpc", $"Failed to report early launcher stage '{stage}'.", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-21 16:16:02 +08:00
|
|
|
private static void InitializeTelemetryIdentity()
|
2026-03-16 09:50:48 +08:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2026-03-21 16:16:02 +08:00
|
|
|
TelemetryIdentityService.Initialize(HostSettingsFacadeProvider.GetOrCreate());
|
|
|
|
|
AppLogger.Info(
|
|
|
|
|
"Startup",
|
|
|
|
|
$"Telemetry identity initialized. InstallId={TelemetryIdentityService.Instance.InstallId}; TelemetryId={TelemetryIdentityService.Instance.TelemetryId}.");
|
2026-03-16 09:50:48 +08:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2026-03-21 16:16:02 +08:00
|
|
|
AppLogger.Warn("Startup", "Failed to initialize telemetry identity service.", ex);
|
2026-03-16 09:50:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-21 16:16:02 +08:00
|
|
|
private static void InitializeCrashTelemetry()
|
2026-03-16 09:50:48 +08:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var settingsFacade = HostSettingsFacadeProvider.GetOrCreate();
|
2026-03-21 16:16:02 +08:00
|
|
|
var crashTelemetry = new SentryCrashTelemetryService(settingsFacade);
|
|
|
|
|
TelemetryServices.Crash = crashTelemetry;
|
|
|
|
|
crashTelemetry.Initialize();
|
|
|
|
|
AppLogger.Info("Startup", $"Crash telemetry initialized. Enabled={crashTelemetry.IsEnabled}.");
|
2026-03-16 09:50:48 +08:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2026-03-21 16:16:02 +08:00
|
|
|
AppLogger.Warn("Startup", "Failed to initialize crash telemetry service.", ex);
|
2026-03-16 09:50:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-21 16:16:02 +08:00
|
|
|
private static void InitializeUsageTelemetry()
|
2026-03-16 09:50:48 +08:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var settingsFacade = HostSettingsFacadeProvider.GetOrCreate();
|
2026-03-21 16:16:02 +08:00
|
|
|
var usageTelemetry = new PostHogUsageTelemetryService(settingsFacade);
|
|
|
|
|
TelemetryServices.Usage = usageTelemetry;
|
|
|
|
|
usageTelemetry.Initialize();
|
|
|
|
|
AppLogger.Info("Startup", $"Usage telemetry initialized. Enabled={usageTelemetry.IsUsageEnabled}.");
|
2026-03-16 09:50:48 +08:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2026-03-21 16:16:02 +08:00
|
|
|
AppLogger.Warn("Startup", "Failed to initialize usage telemetry service.", ex);
|
2026-03-16 09:50:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-02-26 23:08:19 +08:00
|
|
|
}
|