From 4728c6ce54d7cf14bd788945060146c41d823561 Mon Sep 17 00:00:00 2001 From: alves Date: Fri, 19 Dec 2025 16:43:04 +0800 Subject: [PATCH 1/2] feature add bury point for local server and webview init. --- src/bury_cfg/bury_point.hpp | 11 +++++++++++ src/slic3r/GUI/HttpServer.cpp | 12 ++++++++++-- src/slic3r/GUI/Widgets/WebView.cpp | 4 +++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/bury_cfg/bury_point.hpp b/src/bury_cfg/bury_point.hpp index 9fb3f2bc20..9089fae41a 100644 --- a/src/bury_cfg/bury_point.hpp +++ b/src/bury_cfg/bury_point.hpp @@ -44,6 +44,17 @@ #define BP_SLICE_DURATION "bury_point_slice_duration" #define BP_SLICE_DURATION_TIME "slice_duration_time" +#define BP_WEB_VIEW "bury_point_webview" + +#define BP_LOCAL_SERVER "bury_point_local_server" +#define BP_LOCAL_SERVER_STATUS "bury_point_local_server_status" +#define BP_LOCAL_SERVER_ERROR_CODE "bury_point_local_server_error_code" + +#define BP_LOCAL_SERVER "bury_point_local_server" +#define BP_LOCAL_SERVER_ERR_CODE "bury_local_server_err_code" + + + //webview bury point BURY_API bool get_privacy_policy(); diff --git a/src/slic3r/GUI/HttpServer.cpp b/src/slic3r/GUI/HttpServer.cpp index ac6a9bc2d6..b9085a0a29 100644 --- a/src/slic3r/GUI/HttpServer.cpp +++ b/src/slic3r/GUI/HttpServer.cpp @@ -4,6 +4,7 @@ #include "GUI_App.hpp" #include "slic3r/Utils/Http.hpp" #include "slic3r/Utils/NetworkAgent.hpp" +#include "sentry_wrapper/SentryWrapper.hpp" #ifdef _WIN32 #include #include @@ -292,6 +293,7 @@ void HttpServer::start() server_->io_service.run(); } catch (const std::exception& e) { BOOST_LOG_TRIVIAL(error) << "HTTP server error: " << e.what(); + Slic3r::sentryReportLog(Slic3r::SENTRY_LOG_FATAL,std::string("HttpServer::start ") + e.what(), BP_LOCAL_SERVER); start_http_server = false; } }); @@ -313,6 +315,8 @@ void HttpServer::start() } catch (const std::exception& e) { BOOST_LOG_TRIVIAL(error) << "Failed to start HTTP server: " << e.what(); + std::string error_msg = "Failed to start HTTP server on port " + std::to_string(port) + ": " + e.what(); + Slic3r::sentryReportLog(Slic3r::SENTRY_LOG_FATAL, error_msg.c_str(), BP_LOCAL_SERVER); start_http_server = false; throw; } @@ -460,6 +464,8 @@ void HttpServer::start_health_check() BOOST_LOG_TRIVIAL(info) << "HTTP server restart completed by health check thread"; } catch (const std::exception& e) { BOOST_LOG_TRIVIAL(error) << "Failed to restart HTTP server: " << e.what(); + std::string error_msg = "HTTP server restart failed after health check on port " + std::to_string(port) + ": " + e.what(); + Slic3r::sentryReportLog(Slic3r::SENTRY_LOG_ERROR, error_msg.c_str(), BP_LOCAL_SERVER); } } else if (start_http_server) { BOOST_LOG_TRIVIAL(debug) << "HTTP server health check passed"; @@ -654,8 +660,10 @@ std::shared_ptr HttpServer::bbl_auth_handle_request(const user_avatar = user_j["avatar"].get(); if (user_j.contains("account")) user_account = user_j["account"].get(); - } catch (...) { - ; + } catch (const std::exception& e) { + BOOST_LOG_TRIVIAL(error) << "Failed to parse user profile JSON: " << e.what(); + std::string error_msg = "User profile JSON parse error: " + std::string(e.what()); + Slic3r::sentryReportLog(Slic3r::SENTRY_LOG_ERROR, error_msg.c_str(), BP_LOCAL_SERVER); } json j; j["data"]["refresh_token"] = refresh_token; diff --git a/src/slic3r/GUI/Widgets/WebView.cpp b/src/slic3r/GUI/Widgets/WebView.cpp index dfc825f8c5..e9ba1a16f1 100644 --- a/src/slic3r/GUI/Widgets/WebView.cpp +++ b/src/slic3r/GUI/Widgets/WebView.cpp @@ -16,6 +16,7 @@ #include "wx/private/jsscriptwrapper.h" #endif +#include "sentry_wrapper/SentryWrapper.hpp" #ifdef __WIN32__ #include #include @@ -312,7 +313,8 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url) #endif webView->EnableContextMenu(true); } else { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": failed. Use fake web view."; + BOOST_LOG_TRIVIAL(fatal) << __FUNCTION__ << ": failed. Use fake web view."; + Slic3r::sentryReportLog(Slic3r::SENTRY_LOG_FATAL, "create webview fail and use fakewebview", BP_WEB_VIEW); webView = new FakeWebView; } webView->SetRefData(new WebViewRef(webView)); From 7a2a1b9e84fbc8ea11c750a919468d87e6e63a9c Mon Sep 17 00:00:00 2001 From: alves Date: Tue, 23 Dec 2025 11:28:05 +0800 Subject: [PATCH 2/2] fix tags not work bug for sentry --- src/sentry_wrapper/SentryWrapper.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sentry_wrapper/SentryWrapper.cpp b/src/sentry_wrapper/SentryWrapper.cpp index ee4bd51f15..10471d2656 100644 --- a/src/sentry_wrapper/SentryWrapper.cpp +++ b/src/sentry_wrapper/SentryWrapper.cpp @@ -210,15 +210,15 @@ void initSentryEx() sentry_options_set_sample_rate(options, 1.0); sentry_options_set_traces_sample_rate(options, 1.0); - sentry_set_tag("version", Snapmaker_VERSION); + sentry_init(options); + sentry_start_session(); + + sentry_set_tag("snapmaker_version", Snapmaker_VERSION); std::string flutterVersion = common::get_flutter_version(); if (!flutterVersion.empty()) - set_sentry_tags("flutter_version", flutterVersion); + sentry_set_tag("flutter_version", flutterVersion.c_str()); - sentry_init(options); - sentry_start_session(); - //sentryReportLog(SENTRY_LOG_ERROR, "init sentry error", "initSentry module"); } }