mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
NEW: add track events for debugging network
Change-Id: I671f91b4af00277236ca71014f8d667109756d00 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
bd75af4a43
commit
6827b41eb3
13 changed files with 187 additions and 12 deletions
|
@ -262,6 +262,11 @@ namespace GUI {
|
|||
//check dev_id
|
||||
if (m_machine_info->dev_id.empty()) return;
|
||||
|
||||
// update ota version
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (agent)
|
||||
agent->track_update_property("dev_ota_version", m_machine_info->get_ota_version());
|
||||
|
||||
m_simplebook->SetSelection(0);
|
||||
m_bind_job = std::make_shared<BindJob>(m_status_bar, wxGetApp().plater(), m_machine_info->dev_id, m_machine_info->dev_ip);
|
||||
m_bind_job->set_event_handle(this);
|
||||
|
|
|
@ -3451,6 +3451,7 @@ int MachineObject::parse_json(std::string payload)
|
|||
module_vers.emplace(ver_info.name, ver_info);
|
||||
}
|
||||
parse_version_func();
|
||||
|
||||
bool get_version_result = true;
|
||||
if (j["info"].contains("result"))
|
||||
if (j["info"]["result"].get<std::string>() == "fail")
|
||||
|
|
|
@ -1127,9 +1127,11 @@ void GUI_App::post_init()
|
|||
//BBS: check new version
|
||||
this->check_new_version();
|
||||
//BBS: check privacy version
|
||||
if (is_user_login())
|
||||
if (is_user_login()) {
|
||||
this->check_privacy_version(0);
|
||||
|
||||
this->check_track_enable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3809,12 +3811,29 @@ void GUI_App::on_user_login_handle(wxCommandEvent &evt)
|
|||
}
|
||||
}
|
||||
|
||||
void GUI_App::check_track_enable()
|
||||
{
|
||||
if (app_config && app_config->get("firstguide", "privacyuse") == "true") {
|
||||
//enable track event
|
||||
json header_json;
|
||||
header_json["ver"] = SLIC3R_VERSION;
|
||||
wxString os_desc = wxGetOsDescription();
|
||||
int major = 0, minor = 0, micro = 0;
|
||||
header_json["os"] = std::string(os_desc.ToUTF8());
|
||||
if (m_agent) {
|
||||
m_agent->track_header(header_json.dump());
|
||||
m_agent->track_enable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_App::on_user_login(wxCommandEvent &evt)
|
||||
{
|
||||
if (!m_agent) { return; }
|
||||
int online_login = evt.GetInt();
|
||||
// check privacy before handle
|
||||
check_privacy_version(online_login);
|
||||
check_track_enable();
|
||||
}
|
||||
|
||||
bool GUI_App::is_studio_active()
|
||||
|
|
|
@ -442,6 +442,7 @@ public:
|
|||
void on_check_privacy_update(wxCommandEvent &evt);
|
||||
bool check_privacy_update();
|
||||
void check_privacy_version(int online_login = 0);
|
||||
void check_track_enable();
|
||||
|
||||
static bool catch_error(std::function<void()> cb, const std::string& err);
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void BindJob::process()
|
|||
long offset = tz.GetOffset();
|
||||
std::string timezone = get_timezone_utc_hm(offset);
|
||||
|
||||
int result = m_agent->bind(m_dev_ip, timezone,
|
||||
int result = m_agent->bind(m_dev_ip, m_dev_id, timezone,
|
||||
[this, &curr_percent, &msg](int stage, int code, std::string info) {
|
||||
if (stage == BBL::BindJobStage::LoginStageConnect) {
|
||||
curr_percent = 15;
|
||||
|
|
|
@ -806,6 +806,11 @@ void MainFrame::shutdown()
|
|||
m_plater->get_mouse3d_controller().save_config(*wxGetApp().app_config);
|
||||
}
|
||||
|
||||
// stop agent
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (agent)
|
||||
agent->track_enable(false);
|
||||
|
||||
// Stop the background thread of the removable drive manager, so that no new updates will be sent to the Plater.
|
||||
//wxGetApp().removable_drive_manager()->shutdown();
|
||||
//stop listening for messages from other instances
|
||||
|
|
|
@ -228,14 +228,15 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
m_button_download->Enable(e.GetInt() > 0);
|
||||
});
|
||||
fs->Bind(EVT_MODE_CHANGED, &MediaFilePanel::modeChanged, this);
|
||||
fs->Bind(EVT_STATUS_CHANGED, [this, wfs = boost::weak_ptr(fs)](auto &e) {
|
||||
fs->Bind(EVT_STATUS_CHANGED, [this, wfs = boost::weak_ptr(fs)](auto& e) {
|
||||
e.Skip();
|
||||
boost::shared_ptr fs(wfs.lock());
|
||||
if (m_image_grid->GetFileSystem() != fs) // canceled
|
||||
return;
|
||||
ScalableBitmap icon;
|
||||
wxString msg;
|
||||
switch (e.GetInt()) {
|
||||
int status = e.GetInt();
|
||||
switch (status) {
|
||||
case PrinterFileSystem::Initializing: icon = m_bmp_loading; msg = _L("Initializing..."); break;
|
||||
case PrinterFileSystem::Connecting: icon = m_bmp_loading; msg = _L("Connecting..."); break;
|
||||
case PrinterFileSystem::Failed: icon = m_bmp_failed; msg = _L("Connect failed [%d]!"); break;
|
||||
|
@ -246,6 +247,53 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
m_image_grid->SetStatus(icon, msg);
|
||||
if (e.GetInt() == PrinterFileSystem::Initializing)
|
||||
fetchUrl(boost::weak_ptr(fs));
|
||||
|
||||
if (status == PrinterFileSystem::Failed
|
||||
|| status == PrinterFileSystem::ListReady) {
|
||||
json j;
|
||||
j["code"] = fs->GetLastError();
|
||||
j["dev_id"] = m_machine;
|
||||
j["dev_ip"] = m_lan_ip;
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (status == PrinterFileSystem::Failed) {
|
||||
j["result"] = "failed";
|
||||
if (agent)
|
||||
agent->track_event("download_video_conn", j.dump());
|
||||
} else if (status == PrinterFileSystem::ListReady) {
|
||||
j["result"] = "success";
|
||||
if (agent)
|
||||
agent->track_event("download_video_conn", j.dump());
|
||||
}
|
||||
}
|
||||
});
|
||||
fs->Bind(EVT_DOWNLOAD, [this, wfs = boost::weak_ptr(fs)](auto& e) {
|
||||
e.Skip();
|
||||
boost::shared_ptr fs(wfs.lock());
|
||||
if (m_image_grid->GetFileSystem() != fs) // canceled
|
||||
return;
|
||||
|
||||
int result = e.GetExtraLong();
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (result > 1 || result == 0) {
|
||||
json j;
|
||||
j["code"] = result;
|
||||
j["dev_id"] = m_machine;
|
||||
j["dev_ip"] = m_lan_ip;
|
||||
if (result > 1) {
|
||||
// download failed
|
||||
j["result"] = "failed";
|
||||
if (agent) {
|
||||
agent->track_event("download_video", j.dump());
|
||||
}
|
||||
} else if (result == 0) {
|
||||
// download success
|
||||
j["result"] = "success";
|
||||
if (agent) {
|
||||
agent->track_event("download_video", j.dump());
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
});
|
||||
if (IsShown()) fs->Start();
|
||||
}
|
||||
|
|
|
@ -233,6 +233,19 @@ void MediaPlayCtrl::Stop(wxString const &msg)
|
|||
} else if (!msg.IsEmpty()) {
|
||||
SetStatus(msg, false);
|
||||
}
|
||||
|
||||
if (m_failed_code != 0) {
|
||||
json j;
|
||||
j["stage"] = std::to_string(m_last_state);
|
||||
j["dev_id"] = m_machine;
|
||||
j["dev_ip"] = m_lan_ip;
|
||||
j["result"] = "failed";
|
||||
j["code"] = m_failed_code;
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (agent)
|
||||
agent->track_event("start_liveview", j.dump());
|
||||
}
|
||||
|
||||
++m_failed_retry;
|
||||
if (m_failed_code != 0 && !m_tutk_support && (m_failed_retry > 1 || m_user_triggered)) {
|
||||
m_next_retry = wxDateTime(); // stop retry
|
||||
|
@ -369,6 +382,18 @@ void MediaPlayCtrl::onStateChanged(wxMediaEvent &event)
|
|||
if (size.GetWidth() > 1000) {
|
||||
m_last_state = state;
|
||||
SetStatus(_L("Playing..."), false);
|
||||
|
||||
// track event
|
||||
json j;
|
||||
j["stage"] = std::to_string(m_last_state);
|
||||
j["dev_id"] = m_machine;
|
||||
j["dev_ip"] = m_lan_ip;
|
||||
j["result"] = "success";
|
||||
j["code"] = 0;
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (agent)
|
||||
agent->track_event("start_liveview", j.dump());
|
||||
|
||||
m_failed_retry = 0;
|
||||
m_failed_code = 0;
|
||||
boost::unique_lock lock(m_mutex);
|
||||
|
|
|
@ -481,14 +481,12 @@ void PrinterFileSystem::DownloadNextFile()
|
|||
download->index = FindFile(download->index, download->name);
|
||||
if (download->index != size_t(-1)) {
|
||||
int progress = data.size * 100 / data.total;
|
||||
if (result > CONTINUE)
|
||||
progress = -2;
|
||||
auto & file = m_file_list[download->index];
|
||||
if (result == ERROR_CANCEL)
|
||||
file.flags &= ~FF_DOWNLOAD;
|
||||
else if (file.progress != progress) {
|
||||
file.progress = progress;
|
||||
SendChangedEvent(EVT_DOWNLOAD, download->index, file.path, data.size);
|
||||
SendChangedEvent(EVT_DOWNLOAD, download->index, file.path, result);
|
||||
}
|
||||
}
|
||||
if (result != CONTINUE) DownloadNextFile();
|
||||
|
|
|
@ -2228,6 +2228,11 @@ void SelectMachineDialog::on_ok()
|
|||
wxGetApp().show_ip_address_enter_dialog();
|
||||
});
|
||||
|
||||
// update ota version
|
||||
NetworkAgent* agent = wxGetApp().getAgent();
|
||||
if (agent)
|
||||
agent->track_update_property("dev_ota_version", obj_->get_ota_version());
|
||||
|
||||
m_print_job->start();
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: start print job";
|
||||
}
|
||||
|
|
|
@ -97,6 +97,10 @@ func_get_profile_3mf NetworkAgent::get_profile_3mf_ptr = nullptr;
|
|||
func_get_model_publish_url NetworkAgent::get_model_publish_url_ptr = nullptr;
|
||||
func_get_model_mall_home_url NetworkAgent::get_model_mall_home_url_ptr = nullptr;
|
||||
func_get_my_profile NetworkAgent::get_my_profile_ptr = nullptr;
|
||||
func_track_enable NetworkAgent::track_enable_ptr = nullptr;
|
||||
func_track_event NetworkAgent::track_event_ptr = nullptr;
|
||||
func_track_header NetworkAgent::track_header_ptr = nullptr;
|
||||
func_track_update_property NetworkAgent::track_update_property_ptr = nullptr;
|
||||
|
||||
|
||||
NetworkAgent::NetworkAgent()
|
||||
|
@ -240,6 +244,10 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
|||
get_model_publish_url_ptr = reinterpret_cast<func_get_model_publish_url>(get_network_function("bambu_network_get_model_publish_url"));
|
||||
get_model_mall_home_url_ptr = reinterpret_cast<func_get_model_mall_home_url>(get_network_function("bambu_network_get_model_mall_home_url"));
|
||||
get_my_profile_ptr = reinterpret_cast<func_get_my_profile>(get_network_function("bambu_network_get_my_profile"));
|
||||
track_enable_ptr = reinterpret_cast<func_track_enable>(get_network_function("bambu_network_track_enable"));
|
||||
track_event_ptr = reinterpret_cast<func_track_event>(get_network_function("bambu_network_track_event"));
|
||||
track_header_ptr = reinterpret_cast<func_track_header>(get_network_function("bambu_network_track_header"));
|
||||
track_update_property_ptr = reinterpret_cast<func_track_update_property>(get_network_function("bambu_network_track_update_property"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -336,6 +344,10 @@ int NetworkAgent::unload_network_module()
|
|||
get_model_publish_url_ptr = nullptr;
|
||||
get_model_mall_home_url_ptr = nullptr;
|
||||
get_my_profile_ptr = nullptr;
|
||||
track_enable_ptr = nullptr;
|
||||
track_event_ptr = nullptr;
|
||||
track_header_ptr = nullptr;
|
||||
track_update_property_ptr = nullptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -787,11 +799,11 @@ std::string NetworkAgent::build_login_info()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::bind(std::string dev_ip, std::string timezone, OnUpdateStatusFn update_fn)
|
||||
int NetworkAgent::bind(std::string dev_ip, std::string dev_id, std::string timezone, OnUpdateStatusFn update_fn)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && bind_ptr) {
|
||||
ret = bind_ptr(network_agent, dev_ip, timezone, update_fn);
|
||||
ret = bind_ptr(network_agent, dev_ip, dev_id, timezone, update_fn);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_ip=%3%, timezone=%4%")
|
||||
%network_agent %ret %dev_ip %timezone;
|
||||
|
@ -1130,4 +1142,48 @@ int NetworkAgent::get_my_profile(std::string token, unsigned int *http_code, std
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::track_enable(bool enable)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && track_enable_ptr) {
|
||||
ret = track_enable_ptr(network_agent, enable);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("error network_agnet=%1%, ret = %2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::track_event(std::string evt_key, std::string content)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && track_event_ptr) {
|
||||
ret = track_event_ptr(network_agent, evt_key, content);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("error network_agnet=%1%, ret = %2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::track_header(std::string header)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && track_header_ptr) {
|
||||
ret = track_header_ptr(network_agent, header);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("error network_agnet=%1%, ret = %2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::track_update_property(std::string name, std::string value, std::string type)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && track_update_property_ptr) {
|
||||
ret = track_update_property_ptr(network_agent, name, value, type);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("error network_agnet=%1%, ret = %2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} //namespace
|
||||
|
|
|
@ -45,7 +45,7 @@ typedef std::string (*func_get_user_nickanme)(void *agent);
|
|||
typedef std::string (*func_build_login_cmd)(void *agent);
|
||||
typedef std::string (*func_build_logout_cmd)(void *agent);
|
||||
typedef std::string (*func_build_login_info)(void *agent);
|
||||
typedef int (*func_bind)(void *agent, std::string dev_ip, std::string timezone, OnUpdateStatusFn update_fn);
|
||||
typedef int (*func_bind)(void *agent, std::string dev_ip, std::string dev_id, std::string timezone, OnUpdateStatusFn update_fn);
|
||||
typedef int (*func_unbind)(void *agent, std::string dev_id);
|
||||
typedef std::string (*func_get_bambulab_host)(void *agent);
|
||||
typedef std::string (*func_get_user_selected_machine)(void *agent);
|
||||
|
@ -77,6 +77,10 @@ typedef int (*func_get_profile_3mf)(void *agent, BBLProfile* profile);
|
|||
typedef int (*func_get_model_publish_url)(void *agent, std::string* url);
|
||||
typedef int (*func_get_model_mall_home_url)(void *agent, std::string* url);
|
||||
typedef int (*func_get_my_profile)(void *agent, std::string token, unsigned int *http_code, std::string *http_body);
|
||||
typedef int (*func_track_enable)(void *agent, bool enable);
|
||||
typedef int (*func_track_event)(void *agent, std::string evt_key, std::string content);
|
||||
typedef int (*func_track_header)(void *agent, std::string header);
|
||||
typedef int (*func_track_update_property)(void *agent, std::string name, std::string value, std::string type);
|
||||
|
||||
|
||||
//the NetworkAgent class
|
||||
|
@ -130,7 +134,7 @@ public:
|
|||
std::string build_login_cmd();
|
||||
std::string build_logout_cmd();
|
||||
std::string build_login_info();
|
||||
int bind(std::string dev_ip, std::string timezone, OnUpdateStatusFn update_fn);
|
||||
int bind(std::string dev_ip, std::string dev_id, std::string timezone, OnUpdateStatusFn update_fn);
|
||||
int unbind(std::string dev_id);
|
||||
std::string get_bambulab_host();
|
||||
std::string get_user_selected_machine();
|
||||
|
@ -162,6 +166,10 @@ public:
|
|||
int get_model_publish_url(std::string* url);
|
||||
int get_model_mall_home_url(std::string* url);
|
||||
int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body);
|
||||
int track_enable(bool enable);
|
||||
int track_event(std::string evt_key, std::string content);
|
||||
int track_header(std::string header);
|
||||
int track_update_property(std::string name, std::string value, std::string type = "string");
|
||||
|
||||
private:
|
||||
|
||||
|
@ -237,6 +245,10 @@ private:
|
|||
static func_get_model_publish_url get_model_publish_url_ptr;
|
||||
static func_get_model_mall_home_url get_model_mall_home_url_ptr;
|
||||
static func_get_my_profile get_my_profile_ptr;
|
||||
static func_track_enable track_enable_ptr;
|
||||
static func_track_event track_event_ptr;
|
||||
static func_track_header track_header_ptr;
|
||||
static func_track_update_property track_update_property_ptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue