From 793c4b3be7948dc84c8330058f445dbe78983dba Mon Sep 17 00:00:00 2001 From: xiaoyeliu <166936931+womendoushihaoyin@users.noreply.github.com> Date: Mon, 8 Dec 2025 11:29:39 +0800 Subject: [PATCH] Add: wcp_sentry_upload_api (#51) --- src/slic3r/GUI/SSWCP.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/slic3r/GUI/SSWCP.hpp | 3 +++ 2 files changed, 41 insertions(+) diff --git a/src/slic3r/GUI/SSWCP.cpp b/src/slic3r/GUI/SSWCP.cpp index d36ccff637..24e2ec8fec 100644 --- a/src/slic3r/GUI/SSWCP.cpp +++ b/src/slic3r/GUI/SSWCP.cpp @@ -4,6 +4,7 @@ #include "MainFrame.hpp" #include "nlohmann/json.hpp" #include "slic3r/GUI/Tab.hpp" +#include "sentry_wrapper/SentryWrapper.hpp" #include #include #include @@ -450,12 +451,49 @@ void SSWCP_Instance::process() { sw_SubscribeCacheKey(); } else if (m_cmd == "sw_UnsubscribeCacheKeys") { sw_UnsubscribeCacheKeys(); + } else if (m_cmd == "sw_UploadEvent"){ + sw_UploadEvent(); } else { handle_general_fail(); } } +void SSWCP_Instance::sw_UploadEvent() { + try { + if(!m_param_data.count("traceId")){ + handle_general_fail(-1, "param [traceId] required!"); + return; + } + + if(!m_param_data.count("level")){ + handle_general_fail(-1, "param [level] required!"); + return; + } + + if(!m_param_data.count("content")){ + handle_general_fail(-1, "param [content] required!"); + return; + } + + std::string traceId = m_param_data["traceId"].get(); + int level = m_param_data["level"].get(); + + std::string content = m_param_data["content"].get(); + + std::string funcModule = m_param_data.count("funcModule") ? m_param_data["funcModule"].get() : ""; + std::string tagKey = m_param_data.count("tagKey") ? m_param_data["tagKey"].get() : ""; + std::string tagValue = m_param_data.count("tagValue") ? m_param_data["tagValue"].get() : ""; + + + sentryReportLog(SENTRY_LOG_LEVEL(level), content, funcModule, tagKey, tagValue, traceId); + + } + catch (std::exception& e) { + handle_general_fail(); + } +} + void SSWCP_Instance::sw_FileLog() { try { std::string level = m_param_data.count("level") ? m_param_data["level"].get() : "debug"; diff --git a/src/slic3r/GUI/SSWCP.hpp b/src/slic3r/GUI/SSWCP.hpp index cbffebb53b..7fb328f284 100644 --- a/src/slic3r/GUI/SSWCP.hpp +++ b/src/slic3r/GUI/SSWCP.hpp @@ -169,6 +169,9 @@ private: // orca log void sw_FileLog(); + // Sentry + void sw_UploadEvent(); + public: // 抽象工具类函数