diff --git a/src/bury_cfg/bury_point.hpp b/src/bury_cfg/bury_point.hpp index 9089fae41a..e4e477c4da 100644 --- a/src/bury_cfg/bury_point.hpp +++ b/src/bury_cfg/bury_point.hpp @@ -17,21 +17,21 @@ #define BURY_POINT "bury_point" #define BP_START_SOFT "bury_point_start_soft" -#define BP_SOFT_WORKS_TIME "soft_works_time" +#define BP_SOFT_WORKS_TIME "bury_point_soft_works_time" #define BP_DEIVCE_CONNECT "bury_point_device_connect" -#define BP_CONNECT_DEVICE_ID "device_id" -#define BP_CONNECT_NET_TYPE "net_type" +#define BP_CONNECT_DEVICE_ID "bury_point_device_id" +#define BP_CONNECT_NET_TYPE "bury_point_net_type" #define BP_LOGIN "bury_point_login" -#define BP_LOGIN_USER_ID "user_id" -#define BP_LOGIN_HTTP_CODE "http_code" +#define BP_LOGIN_USER_ID "bury_point_user_id" +#define BP_LOGIN_HTTP_CODE "bury_point_http_code" #define BP_VIDEO_START "bury_point_video_start" -#define BP_VIDEO_STATUS "video_status" +#define BP_VIDEO_STATUS "bury_point_video_status" #define BP_DEVICE_ERROR "bury_point_device_error" -#define BP_DEVICE_ERROR_STATUS "error_status" +#define BP_DEVICE_ERROR_STATUS "bury_point_error_status" #define BP_UPLOAD "bury_point_upload" @@ -42,7 +42,7 @@ #define BP_VIDEO_ABNORMAL "bury_point_video_abnormal" #define BP_SLICE_DURATION "bury_point_slice_duration" -#define BP_SLICE_DURATION_TIME "slice_duration_time" +#define BP_SLICE_DURATION_TIME "bury_point_slice_duration_time" #define BP_WEB_VIEW "bury_point_webview" @@ -51,7 +51,7 @@ #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" +#define BP_LOCAL_SERVER_ERR_CODE "bury_point_local_server_err_code" diff --git a/src/common_func/common_func.cpp b/src/common_func/common_func.cpp index c2c7060fb4..eb0ba2a203 100644 --- a/src/common_func/common_func.cpp +++ b/src/common_func/common_func.cpp @@ -4,7 +4,8 @@ #ifdef _WIN32 #include #include - +#include +#pragma comment(lib, "iphlpapi.lib") #elif __APPLE__ #include #endif @@ -19,6 +20,124 @@ namespace common return boost::asio::ip::host_name(); } + std::string getMachineId() + { + std::string machineId = std::string(); +#ifdef _WIN32 + + auto wstringTostring = [](std::wstring wTmpStr) -> std::string { + std::string resStr = std::string(); + int len = WideCharToMultiByte(CP_UTF8, 0, wTmpStr.c_str(), -1, nullptr, 0, nullptr, nullptr); + + if (len <= 0) + return std::string(); + std::string desStr(len, 0); + + WideCharToMultiByte(CP_UTF8, 0, wTmpStr.c_str(), -1, &desStr[0], len, nullptr, nullptr); + + resStr = desStr; + + return resStr; + }; + + HKEY key = NULL; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ | KEY_WOW64_64KEY, &key) == ERROR_SUCCESS) { + wchar_t buffer[1024]; + memset(buffer, 0, sizeof(wchar_t) * 1024); + DWORD size = sizeof(buffer); + bool ok = (RegQueryValueEx(key, L"MachineGuid", NULL, NULL, (LPBYTE) buffer, &size) == ERROR_SUCCESS); + RegCloseKey(key); + if (ok) { + machineId = wstringTostring(buffer); + } + } + +#elif __APPLE__ + FILE* fp = NULL; + char buffer[1024]; + + memset(buffer, 0, 1024); + io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); + CFStringRef strRef = (CFStringRef) IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); + CFStringGetCString(strRef, buffer, 1024, kCFStringEncodingMacRoman); + machineId = buffer; + +#endif // _WIN32 + return machineId; + } + + std::string getMacAddress() + { + std::string macAddress = std::string(); + +#ifndef __APPLE__ + ULONG ulBufferSize = 0; + DWORD dwResult = ::GetAdaptersInfo(NULL, &ulBufferSize); + if (ERROR_BUFFER_OVERFLOW != dwResult) { + return std::string(); + } + + PIP_ADAPTER_INFO pAdapterInfo = (PIP_ADAPTER_INFO) new BYTE[ulBufferSize]; + if (!pAdapterInfo) { + return std::string(); + } + + dwResult = ::GetAdaptersInfo(pAdapterInfo, &ulBufferSize); + if (ERROR_SUCCESS != dwResult) { + delete[] pAdapterInfo; + return std::string(); + } + + BYTE pMac[MAX_ADAPTER_ADDRESS_LENGTH] = {0}; + int nLen = MAX_ADAPTER_ADDRESS_LENGTH; + + if (NULL != pAdapterInfo) { + PIP_ADDR_STRING pAddTemp = &(pAdapterInfo->IpAddressList); + + if (NULL != pAddTemp) { + for (int i = 0; i < (int) pAdapterInfo->AddressLength; ++i) { + pMac[i] = pAdapterInfo->Address[i]; + } + nLen = pAdapterInfo->AddressLength; + } + } + delete[] pAdapterInfo; + + auto Encode16 = [](const BYTE* buf, int len) -> std::wstring { + const WCHAR strHex[] = L"0123456789ABCDEF"; + std::wstring wstr; + wstr.resize(len * 2); + for (int i = 0; i < len; ++i) { + wstr[i * 2 + 0] = strHex[buf[i] >> 4]; + wstr[i * 2 + 1] = strHex[buf[i] & 0xf]; + } + return wstr; + }; + + auto wstringTostring = [](std::wstring wTmpStr) -> std::string { + std::string resStr = std::string(); + int len = WideCharToMultiByte(CP_UTF8, 0, wTmpStr.c_str(), -1, nullptr, 0, nullptr, nullptr); + + if (len <= 0) + return std::string(); + std::string desStr(len, 0); + + WideCharToMultiByte(CP_UTF8, 0, wTmpStr.c_str(), -1, &desStr[0], len, nullptr, nullptr); + + resStr = desStr; + + return resStr; + }; + + std::wstring strMac = Encode16(pMac, nLen); + macAddress = wstringTostring(strMac); +#else + // todo get mac macaddress +#endif + return macAddress; + } + + std::string get_flutter_version() { diff --git a/src/common_func/common_func.hpp b/src/common_func/common_func.hpp index 0a0d007703..32838ed652 100644 --- a/src/common_func/common_func.hpp +++ b/src/common_func/common_func.hpp @@ -22,6 +22,10 @@ namespace common std::string get_pc_name(); std::string get_flutter_version(); -} // namespace common + + std::string getMachineId(); + + std::string getMacAddress(); + } // namespace common #endif \ No newline at end of file diff --git a/src/sentry_wrapper/SentryWrapper.cpp b/src/sentry_wrapper/SentryWrapper.cpp index bbcb05545e..a7d7595754 100644 --- a/src/sentry_wrapper/SentryWrapper.cpp +++ b/src/sentry_wrapper/SentryWrapper.cpp @@ -190,9 +190,6 @@ void initSentryEx() if (!dataBaseDir.empty()) sentry_options_set_database_path(options, dataBaseDir.c_str()); - std::string softVersion = "snapmaker_orca_2.2.0_beta2"; - sentry_options_set_release(options, softVersion.c_str()); - #if defined(_DEBUG) || !defined(NDEBUG) sentry_options_set_debug(options, 1); #else @@ -219,7 +216,17 @@ void initSentryEx() if (!flutterVersion.empty()) sentry_set_tag("flutter_version", flutterVersion.c_str()); - //sentryReportLog(SENTRY_LOG_ERROR, "init sentry error", "initSentry module"); + std::string machineID = common::getMachineId(); + if (!machineID.empty()) + sentry_set_tag("machine_id", machineID.c_str()); + + std::string macAdress = common::getMacAddress(); + if (!macAdress.empty()) + sentry_set_tag("macaddress", macAdress.c_str()); + + std::string pcName = common::get_pc_name(); + if (!pcName.empty()) + sentry_set_tag("pc_name", pcName.c_str()); } } diff --git a/src/slic3r/GUI/HttpServer.cpp b/src/slic3r/GUI/HttpServer.cpp index b9085a0a29..f2a01268af 100644 --- a/src/slic3r/GUI/HttpServer.cpp +++ b/src/slic3r/GUI/HttpServer.cpp @@ -293,7 +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); + Slic3r::sentryReportLog(Slic3r::SENTRY_LOG_FATAL,std::string("bury_point_HttpServer::start ") + e.what(), BP_LOCAL_SERVER); start_http_server = false; } }); @@ -315,7 +315,7 @@ 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(); + std::string error_msg = "bury_point_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; @@ -464,7 +464,7 @@ 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(); + std::string error_msg = "bury_point_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) { @@ -662,7 +662,7 @@ std::shared_ptr HttpServer::bbl_auth_handle_request(const user_account = user_j["account"].get(); } 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()); + std::string error_msg = "bury_point_User profile JSON parse error: " + std::string(e.what()); Slic3r::sentryReportLog(Slic3r::SENTRY_LOG_ERROR, error_msg.c_str(), BP_LOCAL_SERVER); } json j; diff --git a/src/slic3r/GUI/Widgets/WebView.cpp b/src/slic3r/GUI/Widgets/WebView.cpp index e9ba1a16f1..c388f39ed4 100644 --- a/src/slic3r/GUI/Widgets/WebView.cpp +++ b/src/slic3r/GUI/Widgets/WebView.cpp @@ -314,7 +314,7 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url) webView->EnableContextMenu(true); } else { 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); + Slic3r::sentryReportLog(Slic3r::SENTRY_LOG_FATAL, "bury_point_create webview fail and use fakewebview", BP_WEB_VIEW); webView = new FakeWebView; } webView->SetRefData(new WebViewRef(webView)); diff --git a/src/slic3r/Utils/MoonRaker.cpp b/src/slic3r/Utils/MoonRaker.cpp index 9c9be94399..af92115ec9 100644 --- a/src/slic3r/Utils/MoonRaker.cpp +++ b/src/slic3r/Utils/MoonRaker.cpp @@ -2288,7 +2288,7 @@ void Moonraker_Mqtt::async_camera_start(const std::string& domain, int interval, callback) { BOOST_LOG_TRIVIAL(error) << "[Moonraker_Mqtt] 发送启动摄像头监控请求失败"; wcp_loger.add_log("发送启动摄像头监控请求失败", false, "", "Moonraker_Mqtt", "error"); - sentryReportLog(SENTRY_LOG_TRACE, "open video cmd error", BP_VIDEO_ABNORMAL); + sentryReportLog(SENTRY_LOG_TRACE, "bury_point_open video cmd error", BP_VIDEO_ABNORMAL); callback(json::value_t::null); } } @@ -2338,7 +2338,7 @@ void Moonraker_Mqtt::async_canmera_stop(const std::string& domain, std::function callback) { BOOST_LOG_TRIVIAL(error) << "[Moonraker_Mqtt] 发送停止摄像头监控请求失败"; wcp_loger.add_log("发送停止摄像头监控请求失败", false, "", "Moonraker_Mqtt", "error"); - sentryReportLog(SENTRY_LOG_TRACE, "stop video cmd error", BP_VIDEO_ABNORMAL); + sentryReportLog(SENTRY_LOG_TRACE, "bury_point_stop video cmd error", BP_VIDEO_ABNORMAL); callback(json::value_t::null); } }