From c11a79f76f17643e40591740a44b84dc00228a6a Mon Sep 17 00:00:00 2001 From: Natsumi Date: Fri, 14 Nov 2025 17:45:36 +1100 Subject: [PATCH] Clean up, handle sentry init fail --- Dotnet/Cef/MainForm.Designer.cs | 95 ++++++++++++++++++--------------- src/components/NavMenu.vue | 10 ++-- src/plugin/sentry.js | 52 +++++++++--------- 3 files changed, 85 insertions(+), 72 deletions(-) diff --git a/Dotnet/Cef/MainForm.Designer.cs b/Dotnet/Cef/MainForm.Designer.cs index 18cee64c..f580da52 100644 --- a/Dotnet/Cef/MainForm.Designer.cs +++ b/Dotnet/Cef/MainForm.Designer.cs @@ -3,17 +3,22 @@ // This work is licensed under the terms of the MIT license. // For a copy, see . +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + namespace VRCX { partial class MainForm { /// - /// 필수 디자이너 변수입니다. + /// 필수 디자이너 변수입니다. /// - private System.ComponentModel.IContainer components = null; + private IContainer components = null; /// - /// 사용 중인 모든 리소스를 정리합니다. + /// 사용 중인 모든 리소스를 정리합니다. /// /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. protected override void Dispose(bool disposing) @@ -22,96 +27,100 @@ namespace VRCX { components.Dispose(); } + base.Dispose(disposing); } #region Windows Form 디자이너에서 생성한 코드 /// - /// 디자이너 지원에 필요한 메서드입니다. - /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.TrayMenu = new System.Windows.Forms.ContextMenuStrip(this.components); - this.TrayMenu_Open = new System.Windows.Forms.ToolStripMenuItem(); - this.TrayMenu_DevTools = new System.Windows.Forms.ToolStripMenuItem(); - this.TrayMenu_Separator = new System.Windows.Forms.ToolStripSeparator(); - this.TrayMenu_Quit = new System.Windows.Forms.ToolStripMenuItem(); - this.TrayIcon = new System.Windows.Forms.NotifyIcon(this.components); + this.components = new Container(); + this.TrayMenu = new ContextMenuStrip(this.components); + this.TrayMenu_Open = new ToolStripMenuItem(); + this.TrayMenu_DevTools = new ToolStripMenuItem(); + this.TrayMenu_Separator = new ToolStripSeparator(); + this.TrayMenu_Quit = new ToolStripMenuItem(); + this.TrayIcon = new NotifyIcon(this.components); + this.TrayMenu.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); + this.TrayMenu.SuspendLayout(); this.SuspendLayout(); // // TrayMenu // - this.TrayMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.TrayMenu_Open, - this.TrayMenu_DevTools, - this.TrayMenu_Separator, - this.TrayMenu_Quit}); + this.TrayMenu.Items.AddRange(new ToolStripItem[] + { + this.TrayMenu_Open, + this.TrayMenu_DevTools, + this.TrayMenu_Separator, + this.TrayMenu_Quit + }); this.TrayMenu.Name = "TrayMenu"; - this.TrayMenu.Size = new System.Drawing.Size(132, 54); + this.TrayMenu.Size = new Size(132, 54); // // TrayMenu_Open // this.TrayMenu_Open.Name = "TrayMenu_Open"; - this.TrayMenu_Open.Size = new System.Drawing.Size(131, 22); + this.TrayMenu_Open.Size = new Size(131, 22); this.TrayMenu_Open.Text = "Open"; - this.TrayMenu_Open.Click += new System.EventHandler(this.TrayMenu_Open_Click); + this.TrayMenu_Open.Click += new EventHandler(this.TrayMenu_Open_Click); // // TrayMenu_DevTools // this.TrayMenu_DevTools.Name = "TrayMenu_DevTools"; - this.TrayMenu_DevTools.Size = new System.Drawing.Size(131, 22); + this.TrayMenu_DevTools.Size = new Size(131, 22); this.TrayMenu_DevTools.Text = "DevTools"; - this.TrayMenu_DevTools.Click += new System.EventHandler(this.TrayMenu_DevTools_Click); + this.TrayMenu_DevTools.Click += new EventHandler(this.TrayMenu_DevTools_Click); // // TrayMenu_Separator // this.TrayMenu_Separator.Name = "TrayMenu_Separator"; - this.TrayMenu_Separator.Size = new System.Drawing.Size(128, 6); + this.TrayMenu_Separator.Size = new Size(128, 6); // // TrayMenu_Quit // this.TrayMenu_Quit.Name = "TrayMenu_Quit"; - this.TrayMenu_Quit.Size = new System.Drawing.Size(131, 22); + this.TrayMenu_Quit.Size = new Size(131, 22); this.TrayMenu_Quit.Text = "Quit VRCX"; - this.TrayMenu_Quit.Click += new System.EventHandler(this.TrayMenu_Quit_Click); + this.TrayMenu_Quit.Click += new EventHandler(this.TrayMenu_Quit_Click); // // TrayIcon // this.TrayIcon.ContextMenuStrip = this.TrayMenu; this.TrayIcon.Text = "VRCX"; this.TrayIcon.Visible = true; - this.TrayIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(this.TrayIcon_MouseClick); + this.TrayIcon.MouseClick += new MouseEventHandler(this.TrayIcon_MouseClick); // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ClientSize = new System.Drawing.Size(842, 561); - this.MinimumSize = new System.Drawing.Size(320, 240); + this.AutoScaleDimensions = new SizeF(96F, 96F); + this.AutoScaleMode = AutoScaleMode.Dpi; + this.ClientSize = new Size(842, 561); + this.MinimumSize = new Size(320, 240); this.Name = "MainForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.StartPosition = FormStartPosition.CenterScreen; this.Text = Program.Version; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); - this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed); - this.Load += new System.EventHandler(this.MainForm_Load); - this.Move += new System.EventHandler(this.MainForm_Move); - this.Resize += new System.EventHandler(this.MainForm_Resize); + this.FormClosing += new FormClosingEventHandler(this.MainForm_FormClosing); + this.FormClosed += new FormClosedEventHandler(this.MainForm_FormClosed); + this.Load += new EventHandler(this.MainForm_Load); + this.Move += new EventHandler(this.MainForm_Move); + this.Resize += new EventHandler(this.MainForm_Resize); this.TrayMenu.ResumeLayout(false); this.ResumeLayout(false); - } #endregion - private System.Windows.Forms.ContextMenuStrip TrayMenu; - private System.Windows.Forms.ToolStripMenuItem TrayMenu_Open; - private System.Windows.Forms.ToolStripMenuItem TrayMenu_DevTools; - private System.Windows.Forms.ToolStripSeparator TrayMenu_Separator; - private System.Windows.Forms.ToolStripMenuItem TrayMenu_Quit; - private System.Windows.Forms.NotifyIcon TrayIcon; + private ContextMenuStrip TrayMenu; + private ToolStripMenuItem TrayMenu_Open; + private ToolStripMenuItem TrayMenu_DevTools; + private ToolStripSeparator TrayMenu_Separator; + private ToolStripMenuItem TrayMenu_Quit; + private NotifyIcon TrayIcon; } } \ No newline at end of file diff --git a/src/components/NavMenu.vue b/src/components/NavMenu.vue index bf7d645c..96589454 100644 --- a/src/components/NavMenu.vue +++ b/src/components/NavMenu.vue @@ -456,9 +456,13 @@ onMounted(() => { if (!sentryErrorReporting.value) return; - const feedback = Sentry.getFeedback(); - feedback?.attachTo(document.getElementById('feedback')); - window.addEventListener('keydown', handleKeydown); + try { + const feedback = Sentry.getFeedback(); + feedback?.attachTo(document.getElementById('feedback')); + window.addEventListener('keydown', handleKeydown); + } catch (error) { + console.error('Error setting up Sentry feedback:', error); + } }); onUnmounted(() => { diff --git a/src/plugin/sentry.js b/src/plugin/sentry.js index ef31a3d8..84f68945 100644 --- a/src/plugin/sentry.js +++ b/src/plugin/sentry.js @@ -5,33 +5,33 @@ import configRepository from '../service/config'; import * as Sentry from '@sentry/vue'; export async function initSentry(app) { - const enabled = await configRepository.getString( - 'VRCX_SentryEnabled', - 'false' - ); - const version = await AppApi.GetVersion(); - const isNightly = version.includes('Nightly'); - if (enabled !== 'true' || !isNightly) { - return; - } - const vrcxId = await configRepository.getString('VRCX_id', ''); - const response = await webApiService.execute({ - url: 'https://api0.vrcx.app/errorreporting/getdsn', - method: 'GET', - headers: { - Referer: 'https://vrcx.app', - 'VRCX-ID': vrcxId - } - }); - if (response.status !== 200) { - console.error( - 'Failed to get Sentry DSN:', - response.status, - response.data - ); - return; - } try { + const enabled = await configRepository.getString( + 'VRCX_SentryEnabled', + 'false' + ); + const version = await AppApi.GetVersion(); + const isNightly = version.includes('Nightly'); + if (enabled !== 'true' || !isNightly) { + return; + } + const vrcxId = await configRepository.getString('VRCX_id', ''); + const response = await webApiService.execute({ + url: 'https://api0.vrcx.app/errorreporting/getdsn', + method: 'GET', + headers: { + Referer: 'https://vrcx.app', + 'VRCX-ID': vrcxId + } + }); + if (response.status !== 200) { + console.error( + 'Failed to get Sentry DSN:', + response.status, + response.data + ); + return; + } const dsn = atob(response.data); Sentry.init({ app,