diff --git a/deps_src/nlohmann/CMakeLists.txt b/deps_src/nlohmann/CMakeLists.txt index 5fb42165a3..c30ac1e4ca 100644 --- a/deps_src/nlohmann/CMakeLists.txt +++ b/deps_src/nlohmann/CMakeLists.txt @@ -6,7 +6,7 @@ add_library(nlohmann_json INTERFACE) target_include_directories(nlohmann_json SYSTEM INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/.. ) target_sources(nlohmann_json INTERFACE diff --git a/resources/web/guide/11/11.js b/resources/web/guide/11/11.js index 5cbc330192..74a201f338 100644 --- a/resources/web/guide/11/11.js +++ b/resources/web/guide/11/11.js @@ -62,7 +62,8 @@ function GotoPolicyPage() SendWXMessage( JSON.stringify(tSend) ); - window.location.href="../21/index.html"; + + window.location.href="../3/index.html"; } diff --git a/resources/web/guide/21/index.html b/resources/web/guide/21/index.html index 5122ccec49..c0694faffc 100644 --- a/resources/web/guide/21/index.html +++ b/resources/web/guide/21/index.html @@ -104,7 +104,7 @@
-
Back
+
Back
Next
diff --git a/resources/web/guide/3/3.css b/resources/web/guide/3/3.css index bd7d413337..f3044a5792 100644 --- a/resources/web/guide/3/3.css +++ b/resources/web/guide/3/3.css @@ -1,3 +1,25 @@ + +#Title { + height: auto; + min-height: 60px; + padding: 12px 25px; + box-sizing: border-box; +} + +#Title div { + font-size: 16px; + line-height: 24px; + word-wrap: break-word; + white-space: normal; + text-align: center; +} + + +#Content { + flex: 1; + height: auto; +} + .PolicyArea { background-color: #4A4A51; diff --git a/resources/web/guide/3/3.js b/resources/web/guide/3/3.js index 1418d50dda..379cd39441 100644 --- a/resources/web/guide/3/3.js +++ b/resources/web/guide/3/3.js @@ -1,31 +1,12 @@ +var m_Region = ''; + function OnInit() { TranslatePage(); - SendPrivacySelect(); -} - - -function SendPrivacySelect() -{ - let nVal="refuse"; - if( $('#ChoosePrivacy').is(':checked') ) - nVal="agree"; - var tSend={}; - tSend['sequence_id']=Math.round(new Date() / 1000); - tSend['command']="user_private_choice"; - tSend['data']={}; - tSend['data']['action']=nVal; - - SendWXMessage( JSON.stringify(tSend) ); -} - - -function GotoNextPage() -{ - RequestProfile(); + RequestProfile(); } function RequestProfile() @@ -40,41 +21,72 @@ function RequestProfile() function HandleStudio( pVal ) { let strCmd=pVal['command']; - //alert(strCmd); if(strCmd=='response_userguide_profile') { - HandleModelInfo(pVal['response']); + + if(pVal['response'] && pVal['response']['region']) { + m_Region = pVal['response']['region']; + } } } -function HandleModelInfo( pVal ) -{ - let Modellist=pVal["model"]; - let nModel=Modellist.length; - - if(nModel==1) - { -// let pModel=Modellist[0]; -// -// var tSend={}; -// tSend['sequence_id']=Math.round(new Date() / 1000); -// tSend['command']="save_userguide_models"; -// tSend['data']={}; -// -// let ModelName=pModel['model']; -// -// tSend['data'][ModelName]={}; -// tSend['data'][ModelName]['model']=pModel['model']; -// tSend['data'][ModelName]['nozzle_diameter']=pModel['nozzle_diameter']; -// tSend['data'][ModelName]['vendor']=pModel['vendor']; -// -// SendWXMessage( JSON.stringify(tSend) ); - - window.location.href="../22/index.html"; - - return; - } - window.location.href="../21/index.html"; -} \ No newline at end of file +function GotoBackPage() +{ + window.location.href="../11/index.html"; +} + + +function GotoNextPage() +{ + + SendPrivacyChoice("agree"); + + + window.location.href="../21/index.html"; +} + + +function GotoSkipPage() +{ + + SendPrivacyChoice("refuse"); + + + window.location.href="../21/index.html"; +} + + +function SendPrivacyChoice(action) +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="user_private_choice"; + tSend['data']={}; + tSend['data']['action']=action; // "agree" 或 "refuse" + + SendWXMessage( JSON.stringify(tSend) ); +} + + +function OpenPrivacyPolicy() +{ + var privacyUrl = ""; + + + if(m_Region === "China") { + privacyUrl = "https://www.snapmaker.cn/privacy-policy.html"; + } else { + privacyUrl = "https://www.snapmaker.com/privacy-policy"; + } + + + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="common_openurl"; + tSend['url']=privacyUrl; + tSend['local']=m_Region + + SendWXMessage( JSON.stringify(tSend) ); +} diff --git a/resources/web/guide/3/index.html b/resources/web/guide/3/index.html index 836811bf84..daef8b263b 100644 --- a/resources/web/guide/3/index.html +++ b/resources/web/guide/3/index.html @@ -16,24 +16,21 @@
-
We kindly request your help to improve
everyone's printing
+
We kindly request your help to improve everyone's printing.
Come and Join our Customer Experience Improvement Program
-In the 3D Printing community, we learn from each other’s successes and failures to adjust our own slicing parameters and settings. Orca Slicer follows the same principle and uses machine learning to improve its performance from the successes and failures of the vast number of prints by our users. We are training Orca Slicer to be smarter by feeding them the real-world data. If you are willing, this service will access information from your error logs and usage logs, which may include information described in Privacy Policy +In the 3D Printing community, we learn from each other’s successes and failures to adjust our own slicing parameters and settings. Bambu Studio follows the same principle and uses machine learning to improve its performance from the successes and failures of the vast number of prints by our users. We are training Bambu Studio to be smarter by feeding them the real-world data. If you are willing, this service will access information from your error logs and usage logs, which may include information described in Privacy Policy . We will not collect any Personal Data by which an individual can be identified directly or indirectly, including without limitation names, addresses, payment information, or phone numbers. By enabling this service, you agree to these terms and the statement about Privacy Policy. +

You may change your choice in preference anytime.


- -
-
Back
-
Next
+
Back
+
Skip
+
Join the Program
diff --git a/resources/web/guide/31/index.html b/resources/web/guide/31/index.html index 65b81fd420..3a68b05338 100644 --- a/resources/web/guide/31/index.html +++ b/resources/web/guide/31/index.html @@ -19,7 +19,7 @@
-In the 3D Printing community, we learn from each other’s successes and failures to adjust our own slicing parameters and settings. Orca Slicer follows the same principle and uses machine learning to improve its performance from the successes and failures of the vast number of prints by our users. We are training Orca Slicer to be smarter by feeding them the real-world data. If you are willing, this service will access information from your error logs and usage logs, which may include information described in Privacy Policy +In the 3D Printing community, we learn from each other’s successes and failures to adjust our own slicing parameters and settings. Orca Slicer follows the same principle and uses machine learning to improve its performance from the successes and failures of the vast number of prints by our users. We are training Orca Slicer to be smarter by feeding them the real-world data. If you are willing, this service will access information from your error logs and usage logs, which may include information described in Privacy Policy . We will not collect any Personal Data by which an individual can be identified directly or indirectly, including without limitation names, addresses, payment information, or phone numbers. By enabling this service, you agree to these terms and the statement about Privacy Policy.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee5c2e7cf4..c060c480c7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -115,9 +115,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev-utils/platform/msw/Snapmaker_Orca configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev-utils/platform/msw/Snapmaker_Orca.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/Snapmaker_Orca.manifest @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev-utils/platform/osx/Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist @ONLY) if (WIN32) - add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp dev-utils/BaseException.cpp dev-utils/BaseException.h dev-utils/StackWalker.cpp dev-utils/StackWalker.h sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp) + add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp dev-utils/BaseException.cpp dev-utils/BaseException.h dev-utils/StackWalker.cpp dev-utils/StackWalker.h sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.hpp bury_cfg/bury_point.cpp common_func/common_func.hpp common_func/common_func.cpp) + target_compile_definitions(Snapmaker_Orca PRIVATE BURY_EXPORTS) else () - add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp) + add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.hpp bury_cfg/bury_point.cpp common_func/common_func.hpp common_func/common_func.cpp) endif () if (MINGW) @@ -181,7 +182,8 @@ if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode") endif() - add_executable(Snapmaker_Orca_app_gui WIN32 Snapmaker_Orca_app_msvc.cpp sentry_wrapper/SentryWrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/Snapmaker_Orca.rc) + + add_executable(Snapmaker_Orca_app_gui WIN32 Snapmaker_Orca_app_msvc.cpp sentry_wrapper/SentryWrapper.cpp common_func/common_func.cpp ${CMAKE_CURRENT_BINARY_DIR}/Snapmaker_Orca.rc) # Generate debug symbols even in release mode. if(MSVC) target_link_options(Snapmaker_Orca_app_gui PUBLIC "$<$:/DEBUG>") @@ -189,10 +191,11 @@ if (WIN32) target_compile_definitions(Snapmaker_Orca_app_gui PRIVATE -DSLIC3R_WRAPPER_NOCONSOLE) add_dependencies(Snapmaker_Orca_app_gui Snapmaker_Orca) set_target_properties(Snapmaker_Orca_app_gui PROPERTIES OUTPUT_NAME "snapmaker-orca") + if (SLIC3R_SENTRY) - target_link_libraries(Snapmaker_Orca_app_gui PRIVATE boost_headeronly sentry::sentry) + target_link_libraries(Snapmaker_Orca_app_gui PRIVATE boost_headeronly sentry::sentry nlohmann_json Snapmaker_Orca) else() - target_link_libraries(Snapmaker_Orca_app_gui PRIVATE boost_headeronly) + target_link_libraries(Snapmaker_Orca_app_gui PRIVATE boost_headeronly nlohmann_json Snapmaker_Orca) endif() if (SLIC3R_SENTRY) target_compile_definitions(Snapmaker_Orca_app_gui PRIVATE SLIC3R_SENTRY) diff --git a/src/Snapmaker_Orca.cpp b/src/Snapmaker_Orca.cpp index 5f50d8aca3..f340215897 100644 --- a/src/Snapmaker_Orca.cpp +++ b/src/Snapmaker_Orca.cpp @@ -6296,9 +6296,12 @@ extern "C" { int main(int argc, char **argv) { initSentry(); - + auto soft_start_time = get_time_timestamp(); auto res = CLI().run(argc, argv); + auto soft_end_time = get_time_timestamp(); + std::string softEndTime = BP_SOFT_WORKS_TIME + std::string(":") + get_works_time(soft_end_time - soft_start_time); + sentryReportLog(SENTRY_LOG_TRACE, softEndTime, BP_START_SOFT); exitSentry(); return res; diff --git a/src/Snapmaker_Orca_app_msvc.cpp b/src/Snapmaker_Orca_app_msvc.cpp index fe77bf37ea..2d47aefb15 100644 --- a/src/Snapmaker_Orca_app_msvc.cpp +++ b/src/Snapmaker_Orca_app_msvc.cpp @@ -227,6 +227,7 @@ int wmain(int argc, wchar_t** argv) _set_error_mode(_OUT_TO_MSGBOX); initSentry(); + auto soft_start_time = get_time_timestamp(); std::vector argv_extended; argv_extended.emplace_back(argv[0]); @@ -292,6 +293,10 @@ int wmain(int argc, wchar_t** argv) HINSTANCE hInstance_Slic3r = LoadLibraryExW(path_to_slic3r, nullptr, 0); if (hInstance_Slic3r == nullptr) { printf("Snapmaker_Orca.dll was not loaded, error=%d\n", GetLastError()); + + auto soft_end_time = get_time_timestamp(); + std::string softEndTime = BP_SOFT_WORKS_TIME + std::string(":") + get_works_time(soft_end_time - soft_start_time); + sentryReportLog(SENTRY_LOG_TRACE, softEndTime, BP_START_SOFT); exitSentry(); return -1; } @@ -308,12 +313,18 @@ int wmain(int argc, wchar_t** argv) ); if (Snapmaker_Orca_main == nullptr) { printf("could not locate the function Snapmaker_Orca_main in Snapmaker_Orca.dll\n"); + auto soft_end_time = get_time_timestamp(); + std::string softEndTime = BP_SOFT_WORKS_TIME + std::string(":") + get_works_time(soft_end_time - soft_start_time); + sentryReportLog(SENTRY_LOG_TRACE, softEndTime, BP_START_SOFT); exitSentry(); return -1; } // argc minus the trailing nullptr of the argv auto res = Snapmaker_Orca_main((int) argv_extended.size() - 1, argv_extended.data()); + auto soft_end_time = get_time_timestamp(); + std::string softEndTime = BP_SOFT_WORKS_TIME + std::string(":") + get_works_time(soft_end_time - soft_start_time); + sentryReportLog(SENTRY_LOG_TRACE, softEndTime, BP_START_SOFT); exitSentry(); return res; } diff --git a/src/bury_cfg/bury_point.cpp b/src/bury_cfg/bury_point.cpp new file mode 100644 index 0000000000..8c16dc5a0b --- /dev/null +++ b/src/bury_cfg/bury_point.cpp @@ -0,0 +1,57 @@ +#include "bury_point.hpp" +#include +#include +#include +#include + +static std::atomic isAgreeSlice(true); +bool get_privacy_policy() +{ + return isAgreeSlice; +} + +void set_privacy_policy(bool isAgree) { + isAgreeSlice = isAgree; +} + +std::string get_timestamp_seconds() +{ + auto now = std::chrono::system_clock::now(); + + auto timestamp = std::chrono::duration_cast(now.time_since_epoch()).count(); + + std::ostringstream oss; + oss << timestamp; + auto strTime = oss.str(); + + return strTime; +} + +long long get_time_timestamp() +{ + auto now = std::chrono::system_clock::now(); + + auto timestamp = std::chrono::duration_cast(now.time_since_epoch()).count(); + + return timestamp; +} + +std::string get_works_time(const long long& timestamp) +{ + long long hours = timestamp / 3600000; + long long remaining_ms = timestamp % 3600000; + + long long minutes = remaining_ms / 60000; + remaining_ms = remaining_ms % 60000; + + long long seconds = remaining_ms / 1000; + long long ms = remaining_ms % 1000; + + char buffer[32] = {0}; + std::snprintf(buffer, sizeof(buffer), "%02llu:%02llu:%02llu.%03llu", hours, minutes, seconds, ms); + + + std::string works_time = std::string(buffer); + + return works_time; +} \ No newline at end of file diff --git a/src/bury_cfg/bury_point.hpp b/src/bury_cfg/bury_point.hpp new file mode 100644 index 0000000000..9fb3f2bc20 --- /dev/null +++ b/src/bury_cfg/bury_point.hpp @@ -0,0 +1,55 @@ +#ifndef _BURY_POINT_hpp_ +#define _BURY_POINT_hpp_ +#include +#include +#include + +#ifdef _WIN32 + #ifdef BURY_EXPORTS + #define BURY_API __declspec(dllexport) + #else + #define BURY_API __declspec(dllimport) + #endif +#else + #define BURY_API extern +#endif + +#define BURY_POINT "bury_point" + +#define BP_START_SOFT "bury_point_start_soft" +#define BP_SOFT_WORKS_TIME "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_LOGIN "bury_point_login" +#define BP_LOGIN_USER_ID "user_id" +#define BP_LOGIN_HTTP_CODE "http_code" + +#define BP_VIDEO_START "bury_point_video_start" +#define BP_VIDEO_STATUS "video_status" + +#define BP_DEVICE_ERROR "bury_point_device_error" +#define BP_DEVICE_ERROR_STATUS "error_status" + +#define BP_UPLOAD "bury_point_upload" + +#define BP_UPLOAD_AND_PRINT "bury_point_upload_and_print" + +#define BP_COLOR_PAINTING "bury_point_color_painting" + +#define BP_VIDEO_ABNORMAL "bury_point_video_abnormal" + +#define BP_SLICE_DURATION "bury_point_slice_duration" +#define BP_SLICE_DURATION_TIME "slice_duration_time" + +//webview bury point + + BURY_API bool get_privacy_policy(); + BURY_API void set_privacy_policy(bool isAgree); + BURY_API std::string get_timestamp_seconds(); + BURY_API long long get_time_timestamp(); + BURY_API std::string get_works_time(const long long& timestamp); + +#endif \ No newline at end of file diff --git a/src/common_func/common_func.cpp b/src/common_func/common_func.cpp new file mode 100644 index 0000000000..c2c7060fb4 --- /dev/null +++ b/src/common_func/common_func.cpp @@ -0,0 +1,59 @@ +#include "common_func.hpp" +#include + +#ifdef _WIN32 +#include +#include + +#elif __APPLE__ +#include +#endif + +#include +#include + +namespace common +{ + std::string get_pc_name() + { + return boost::asio::ip::host_name(); + } + + std::string get_flutter_version() + { + + std::string versionFilePath = ""; + +#ifdef _WIN32 + wchar_t appDataPath[MAX_PATH] = {0}; + auto hr = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath); + char* path = new char[MAX_PATH]; + size_t pathLength; + wcstombs_s(&pathLength, path, MAX_PATH, appDataPath, MAX_PATH); + std::string filePath = path; + versionFilePath = filePath + "\\" + std::string("Snapmaker_Orca\\web\\flutter_web\\version.json"); +#elif __APPLE__ + const char* home_env = getenv("HOME"); + versionFilePath = home_env; + versionFilePath = versionFilePath + "/Library/Application Support/Snapmaker_Orca/web/flutter_web/version.json"; +#else + +#endif + + std::ifstream json_file(versionFilePath); + if (!json_file.is_open()) { + std::ifstream json_file(versionFilePath); + return ""; + } + nlohmann::json json_data; + json_file >> json_data; + std::string str_version = json_data["version"]; + std::string str_build_number = json_data["build_number"]; + + std::string flutter_version = std::string("flutter_version: ") + str_version + std::string(" ") + std::string("build_number: ") + + str_build_number; + + return flutter_version; + } + +} \ No newline at end of file diff --git a/src/common_func/common_func.hpp b/src/common_func/common_func.hpp new file mode 100644 index 0000000000..919e234fee --- /dev/null +++ b/src/common_func/common_func.hpp @@ -0,0 +1,27 @@ +#ifndef _common_func_hppp_ +#define _common_func_hppp_ +#include + + +#define SLIC3R_APP_NAME "Snapmaker Orca" +#define SLIC3R_APP_KEY "Snapmaker_Orca" +#define SLIC3R_VERSION "01.10.01.50" +#define Snapmaker_VERSION "2.2.0" +#define MIN_FIRM_VER "0.8.4" +#ifndef GIT_COMMIT_HASH +#define GIT_COMMIT_HASH "0000000" // 0000000 means uninitialized +#endif +#define SLIC3R_BUILD_ID "" +// #define SLIC3R_RC_VERSION "01.10.01.50" +#define BBL_RELEASE_TO_PUBLIC 1 +#define BBL_INTERNAL_TESTING 0 +#define ORCA_CHECK_GCODE_PLACEHOLDERS 0 + +namespace common +{ + std::string get_pc_name(); + + std::string get_flutter_version(); +} // namespace common + +#endif \ No newline at end of file diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 79071cc061..407b6bf740 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -6,7 +6,7 @@ #include "Utils.hpp" #include "Model.hpp" #include "format.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/libslic3r/libslic3r.h b/src/libslic3r/libslic3r.h index 0364ac340e..8d0f779129 100644 --- a/src/libslic3r/libslic3r.h +++ b/src/libslic3r/libslic3r.h @@ -1,7 +1,7 @@ #ifndef _libslic3r_h_ #define _libslic3r_h_ -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #define SLIC3R_APP_FULL_NAME "Snapmaker Orca" #define GCODEVIEWER_APP_NAME "Snapmaker_Orca G-code Viewer" #define GCODEVIEWER_APP_KEY "Snapmaker_OrcaGcodeViewer" diff --git a/src/libslic3r/pchheader.hpp b/src/libslic3r/pchheader.hpp index 1bedfb482a..cc93b3b220 100644 --- a/src/libslic3r/pchheader.hpp +++ b/src/libslic3r/pchheader.hpp @@ -125,7 +125,7 @@ #include "SVG.hpp" #include "libslic3r.h" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include diff --git a/src/sentry_wrapper/SentryWrapper.cpp b/src/sentry_wrapper/SentryWrapper.cpp index 0b2224adb5..4774bff7a7 100644 --- a/src/sentry_wrapper/SentryWrapper.cpp +++ b/src/sentry_wrapper/SentryWrapper.cpp @@ -27,6 +27,7 @@ #include #include #include +#include "common_func/common_func.hpp" namespace Slic3r { @@ -56,15 +57,22 @@ static sentry_value_t on_crash_callback(const sentry_ucontext_t* uctx, sentry_va static sentry_value_t before_send(sentry_value_t event, void* hint, void* data) { + if (!get_privacy_policy()) + { + sentry_value_decref(event); + return sentry_value_new_null(); + } + sentry_value_t level_val = sentry_value_get_by_key(event, SENTRY_KEY_LEVEL); + std::string levelName = sentry_value_as_string(level_val); std::string eventLevel = sentry_value_as_string(sentry_value_get_by_key(event, SENTRY_KEY_LEVEL)); //module name - sentry_value_t logger_val = sentry_value_get_by_key(event, "logger"); - std::string logger = sentry_value_as_string(logger_val); + sentry_value_t moduleValue = sentry_value_get_by_key(event, "logger"); + std::string moduleName = sentry_value_as_string(moduleValue); - if (MACHINE_MODULE == logger) + if (MACHINE_MODULE == moduleName) { srand((unsigned int) time(0)); int random_num = rand() % 100; @@ -192,6 +200,7 @@ void initSentryEx() #endif sentry_options_set_environment(options, "develop"); + //sentry_options_set_environment(options, "Release"); sentry_options_set_auto_session_tracking(options, 0); sentry_options_set_symbolize_stacktraces(options, 1); @@ -201,6 +210,12 @@ 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); + + std::string flutterVersion = common::get_flutter_version(); + if (!flutterVersion.empty()) + set_sentry_tags("flutter_version", flutterVersion); + sentry_init(options); sentry_start_session(); @@ -255,6 +270,8 @@ void sentryReportLogEx(SENTRY_LOG_LEVEL logLevel, sentry_value_set_by_key(tags, "snapmaker_trace_id", sentry_value_new_string(logTraceId.c_str())); } + if (SENTRY_LEVEL_TRACE == sentry_msg_level) + sentry_set_tag(BURY_POINT, "snapmaker_bury_point"); if (!logTagKey.empty()) sentry_set_tag(logTagKey.c_str(), logTagValue.c_str()); @@ -293,5 +310,13 @@ void sentryReportLog(SENTRY_LOG_LEVEL logLevel, #endif } +void set_sentry_tags(const std::string& tag_key, const std::string& tag_value) +{ +#ifdef SLIC3R_SENTRY + if (!tag_key.empty()) + sentry_set_tag(tag_key.c_str(), tag_value.c_str()); +#endif +} + } // namespace Slic3r diff --git a/src/sentry_wrapper/SentryWrapper.hpp b/src/sentry_wrapper/SentryWrapper.hpp index 29de368b0e..2a902b583c 100644 --- a/src/sentry_wrapper/SentryWrapper.hpp +++ b/src/sentry_wrapper/SentryWrapper.hpp @@ -2,6 +2,7 @@ #define slic3r_SentryWrapper_hpp_ #include +#include "bury_cfg/bury_point.hpp" namespace Slic3r { @@ -24,6 +25,8 @@ namespace Slic3r { const std::string& logTagKey = "", const std::string& logTagValue = "", const std::string& logTraceId = ""); + + void set_sentry_tags(const std::string& tag_key,const std::string& tag_value); } // namespace Slic3r #endif // slic3r_SentryWrapper_hpp_ diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 44ae2d49a1..28596e3fb9 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -653,7 +653,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/GeneratedConfig.hpp.in @ONLY) add_library(libslic3r_gui STATIC ${SLIC3R_GUI_SOURCES}) -target_include_directories(libslic3r_gui PRIVATE Utils ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(libslic3r_gui PRIVATE Utils ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..) target_link_libraries(libslic3r_gui paho-mqttpp3-static) target_include_directories(libslic3r_gui PRIVATE ${PAHO_MQTT_CPP_PATH}/include) diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index 36d572e1b9..78e14f1bed 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -16,7 +16,7 @@ #include "FileHelp.hpp" #include "Tab.hpp" #include "MainFrame.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #define NAME_OPTION_COMBOBOX_SIZE wxSize(FromDIP(200), FromDIP(24)) #define FILAMENT_PRESET_COMBOBOX_SIZE wxSize(FromDIP(300), FromDIP(24)) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index ec857d3cec..21ea5be632 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -6,7 +6,7 @@ #include "slic3r/GUI/UserManager.hpp" #include "slic3r/GUI/TaskManager.hpp" #include "format.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include "Downloader.hpp" #include "slic3r/GUI/WebUrlDialog.hpp" @@ -120,7 +120,7 @@ #include "PrivacyUpdateDialog.hpp" #include "ModelMall.hpp" #include "HintNotification.hpp" - +#include "bury_cfg/bury_point.hpp" //#ifdef WIN32 //#include "BaseException.h" //#endif @@ -3756,6 +3756,9 @@ if (res) { } catch (std::exception &) { // wxMessageBox(e.what(), "", MB_OK); } + auto isAgree = wxGetApp().app_config->get("snapmaker_privacy_policy", "isagree"); + + set_privacy_policy(isAgree == "true"); } void GUI_App::ShowDownNetPluginDlg() { @@ -7061,6 +7064,9 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage mainframe->refresh_plugin_tips(); // BBS: remove SLA related message } + auto isAgree = wxGetApp().app_config->get("snapmaker_privacy_policy", "isagree"); + + set_privacy_policy(isAgree == "true"); return res; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 762b371778..1b2bb4bad7 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -34,6 +34,7 @@ #include +#include "sentry_wrapper/SentryWrapper.hpp" namespace Slic3r { namespace GUI { //BBS: GUI refactor: to support top layout @@ -350,6 +351,8 @@ bool GLGizmosManager::open_gizmo(EType type) #ifdef __WXOSX__ m_parent.post_event(SimpleEvent(wxEVT_PAINT)); #endif + if (EType::MmSegmentation == type) + sentryReportLog(SENTRY_LOG_TRACE, BP_COLOR_PAINTING, BP_COLOR_PAINTING); return true; } return false; diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 8a42c4747e..f6e67d1c0a 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -72,9 +72,9 @@ #include #include #include -#include "sentry_wrapper/SentryWrapper.hpp" #endif // _WIN32 #include +#include "sentry_wrapper/SentryWrapper.hpp" namespace Slic3r { @@ -1089,8 +1089,8 @@ void MainFrame::init_tabpanel() { }); m_tabpanel->AddPage(m_webview, "", "tab_home_active", "tab_home_active", false); m_param_panel = new ParamsPanel(m_tabpanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL); + } - m_plater = new Plater(this, this); m_plater->SetBackgroundColour(*wxWHITE); m_plater->Hide(); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 664f3dcd58..c9b4b06e5e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1,6 +1,6 @@ #include "Plater.hpp" #include "libslic3r/Config.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include @@ -156,6 +156,9 @@ #include "CloneDialog.hpp" #include "WebPreprintDialog.hpp" +#include "sentry_wrapper/SentryWrapper.hpp" +#include + using boost::optional; namespace fs = boost::filesystem; using Slic3r::_3DScene; @@ -3089,6 +3092,9 @@ struct Plater::priv bool show_wireframe{ false }; bool wireframe_enabled{ true }; + std::chrono::steady_clock::time_point m_slice_start_time; + bool m_slice_timing_active = false; + static const std::regex pattern_bundle; static const std::regex pattern_3mf; static const std::regex pattern_zip_amf; @@ -7649,6 +7655,9 @@ void Plater::priv::on_export_finished(wxCommandEvent& evt) void Plater::priv::on_slicing_began() { + if(!m_slice_timing_active) + m_slice_start_time = std::chrono::steady_clock::now(); + m_slice_timing_active = true; clear_warnings(); notification_manager->close_notification_of_type(NotificationType::SignDetected); notification_manager->close_notification_of_type(NotificationType::ExportFinished); @@ -7733,6 +7742,31 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt) //BBS: add project slice logic bool is_finished = !m_slice_all || (m_cur_slice_plate == (partplate_list.get_plate_count() - 1)); + { + if (m_slice_timing_active) { + auto end_time = std::chrono::steady_clock::now(); + auto duration_ms = std::chrono::duration_cast(end_time - m_slice_start_time).count(); + auto timess = duration_ms; + if (evt.cancelled()) { + BOOST_LOG_TRIVIAL(info) << "Slicing cancelled after " << duration_ms << " ms"; + m_slice_start_time = {}; + m_slice_timing_active = false; + } else if (evt.error()) + { + m_slice_start_time = {}; + m_slice_timing_active = false; + } + else if (is_finished && evt.finished()) + { + auto strTime = get_works_time(duration_ms); + auto slice_time = BP_SLICE_DURATION_TIME + std::string(":") + strTime; + sentryReportLog(SENTRY_LOG_TRACE, slice_time, BP_SLICE_DURATION); + + m_slice_start_time = {}; + m_slice_timing_active = false; + } + } + } //BBS: slice .gcode.3mf file related logic, assign is_finished again bool only_has_gcode_need_preview = false; auto plate_list = this->partplate_list.get_plate_list(); @@ -7751,6 +7785,13 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt) // At this point of time the thread should be either finished or canceled, // so the following call just confirms, that the produced data were consumed. this->background_process.stop(); + if (m_slice_timing_active && !this->background_process.running()) + { + if (evt.cancelled() || evt.error()) { + m_slice_start_time = {}; + m_slice_timing_active = false; + } + } notification_manager->set_slicing_progress_export_possible(); // Reset the "export G-code path" name, so that the automatic background processing will be enabled again. diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index deeb64cae0..e728d2b075 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -3,6 +3,7 @@ #include #include +#include "sentry_wrapper/SentryWrapper.hpp" #include #include #include @@ -152,6 +153,7 @@ void PrintHostSendDialog::init() auto* btn_ok = add_button(wxID_OK, true, _L("Upload")); btn_ok->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) { + sentryReportLog(SENTRY_LOG_TRACE, BP_UPLOAD, BP_UPLOAD); if (validate_path(txt_filename->GetValue())) { post_upload_action = PrintHostPostUploadAction::None; EndDialog(wxID_OK); @@ -172,6 +174,7 @@ void PrintHostSendDialog::init() if (post_actions.has(PrintHostPostUploadAction::StartPrint)) { auto* btn_print = add_button(wxID_YES, false, _L("Upload and Print")); btn_print->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) { + sentryReportLog(SENTRY_LOG_TRACE, BP_UPLOAD_AND_PRINT, BP_UPLOAD_AND_PRINT); if (validate_path(txt_filename->GetValue())) { post_upload_action = PrintHostPostUploadAction::StartPrint; EndDialog(wxID_OK); diff --git a/src/slic3r/GUI/PrinterWebView.cpp b/src/slic3r/GUI/PrinterWebView.cpp index 322eb642a6..4a8c42edc6 100644 --- a/src/slic3r/GUI/PrinterWebView.cpp +++ b/src/slic3r/GUI/PrinterWebView.cpp @@ -5,7 +5,7 @@ #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/MainFrame.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/slic3r/GUI/SSWCP.cpp b/src/slic3r/GUI/SSWCP.cpp index 88b53c8626..8deb7b0508 100644 --- a/src/slic3r/GUI/SSWCP.cpp +++ b/src/slic3r/GUI/SSWCP.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "NetworkTestDialog.hpp" @@ -91,6 +92,7 @@ bool WCP_Logger::set_level(wxString& level) } } + // Add a log message to the queue void WCP_Logger::add_log(const wxString& content, bool is_web = false, wxString time = "", wxString module = "Default", wxString level = "debug") { diff --git a/src/slic3r/GUI/WebDownPluginDlg.cpp b/src/slic3r/GUI/WebDownPluginDlg.cpp index 93a1a5959c..a1141ab48c 100644 --- a/src/slic3r/GUI/WebDownPluginDlg.cpp +++ b/src/slic3r/GUI/WebDownPluginDlg.cpp @@ -6,7 +6,7 @@ #include "libslic3r/AppConfig.hpp" #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 97fae75977..483508bdef 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -10,7 +10,7 @@ #include "libslic3r/PresetBundle.hpp" #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include @@ -492,6 +492,15 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt) this->Close(); } else if (strCmd == "save_region") { m_Region = j["region"]; + m_ProfileJson["region"] = m_Region; + } + else if (strCmd == "common_openurl") { + + std::string url = j["url"]; + std::string local = j["local"]; + if (!url.empty()) { + wxLaunchDefaultBrowser(url); + } } else if (strCmd == "network_plugin_install") { std::string sAction = j["data"]["action"]; @@ -617,7 +626,7 @@ int GuideFrame::SaveProfile() // m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "privacyuse", "1"); // } else // m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "privacyuse", "0"); - + m_MainPtr->app_config->set("snapmaker_privacy_policy", "isagree", PrivacyUse); m_MainPtr->app_config->set("region", m_Region); m_MainPtr->app_config->set_bool("stealth_mode", StealthMode); diff --git a/src/slic3r/GUI/WebPresetDialog.cpp b/src/slic3r/GUI/WebPresetDialog.cpp index 8bfacafbc9..95853e3cad 100644 --- a/src/slic3r/GUI/WebPresetDialog.cpp +++ b/src/slic3r/GUI/WebPresetDialog.cpp @@ -6,7 +6,7 @@ #include "libslic3r/AppConfig.hpp" #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include @@ -590,6 +590,14 @@ void WebPresetDialog::OnScriptMessage(wxWebViewEvent& evt) this->Close(); } else if (strCmd == "save_region") { m_Region = j["region"]; + m_ProfileJson["region"] = m_Region; + } + else if (strCmd == "common_openurl") { + + std::string url = j["url"]; + if (!url.empty()) { + wxLaunchDefaultBrowser(url); + } } else if (strCmd == "network_plugin_install") { std::string sAction = j["data"]["action"]; diff --git a/src/slic3r/GUI/WebSMUserLoginDialog.cpp b/src/slic3r/GUI/WebSMUserLoginDialog.cpp index d302285087..f152ad9e38 100644 --- a/src/slic3r/GUI/WebSMUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebSMUserLoginDialog.cpp @@ -5,7 +5,7 @@ #include "libslic3r/AppConfig.hpp" #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include @@ -25,6 +25,7 @@ #include #include +#include "sentry_wrapper/SentryWrapper.hpp" using namespace std; using namespace nlohmann; @@ -198,11 +199,13 @@ void SMUserLogin::OnNavigationRequest(wxWebViewEvent &evt) http.header("Authorization",token); http.on_complete([&](std::string body, unsigned status) { if (status == 200) { + std::string user_id = ""; json response = json::parse(body); if (response.count("data")) { json data = response["data"]; if (data.count("id")) { wxGetApp().sm_get_userinfo()->set_user_id(std::to_string(data["id"].get())); + user_id = std::to_string(data["id"].get()); } if (data.count("nickname")) { wxGetApp().sm_get_userinfo()->set_user_name(data["nickname"].get()); @@ -214,13 +217,15 @@ void SMUserLogin::OnNavigationRequest(wxWebViewEvent &evt) wxGetApp().sm_get_userinfo()->set_user_account(data["account"].get()); } } - + string userInfo = BP_LOGIN_USER_ID + std::string(":") + user_id; + sentryReportLog(SENTRY_LOG_TRACE, userInfo, BP_LOGIN); wxGetApp().sm_get_userinfo()->set_user_token(token); wxGetApp().sm_get_userinfo()->set_user_login(true); } }) .on_error([&](std::string body, std::string error, unsigned status) { - + std::string http_code = BP_LOGIN_HTTP_CODE + string(":") + std::to_string(status); + sentryReportLog(SENTRY_LOG_TRACE, http_code, BP_LOGIN); }) .perform_sync(); }); diff --git a/src/slic3r/GUI/WebUserLoginDialog.cpp b/src/slic3r/GUI/WebUserLoginDialog.cpp index 8bffe3e08b..5afc43568a 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebUserLoginDialog.cpp @@ -5,7 +5,7 @@ #include "libslic3r/AppConfig.hpp" #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include #include diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index a7f9b4801f..98aa42af2a 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -4,7 +4,7 @@ #include "slic3r/GUI/wxExtensions.hpp" #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/MainFrame.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include "../Utils/Http.hpp" #include "SSWCP.hpp" diff --git a/src/slic3r/Utils/Http.hpp b/src/slic3r/Utils/Http.hpp index ef31a1127e..7b2c05b908 100644 --- a/src/slic3r/Utils/Http.hpp +++ b/src/slic3r/Utils/Http.hpp @@ -9,7 +9,7 @@ #include #include "libslic3r/Exception.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #define MAX_SIZE_TO_FILE 3*1024 diff --git a/src/slic3r/Utils/MoonRaker.cpp b/src/slic3r/Utils/MoonRaker.cpp index 89c13b3de0..9c9be94399 100644 --- a/src/slic3r/Utils/MoonRaker.cpp +++ b/src/slic3r/Utils/MoonRaker.cpp @@ -28,6 +28,7 @@ #include "slic3r/GUI/WebPreprintDialog.hpp" #include "slic3r/GUI/SSWCP.hpp" +#include "sentry_wrapper/SentryWrapper.hpp" #ifdef _WIN32 #include #include @@ -2287,6 +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); callback(json::value_t::null); } } @@ -2336,6 +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); callback(json::value_t::null); } } diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index c9f2de7517..b1321a2689 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -25,7 +25,7 @@ #include "libslic3r/format.hpp" #include "libslic3r/Utils.hpp" #include "libslic3r/PresetBundle.hpp" -#include "libslic3r_version.h" +#include "common_func/common_func.hpp" #include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/I18N.hpp"