diff --git a/src/app/check_update.cpp b/src/app/check_update.cpp index 2fe2d7714..6490cacf0 100644 --- a/src/app/check_update.cpp +++ b/src/app/check_update.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020 Igara Studio S.A. +// Copyright (C) 2020-2021 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -21,6 +21,10 @@ #include "base/version.h" #include "ver/info.h" +#if ENABLE_SENTRY + #include "app/sentry_wrapper.h" +#endif + #include #include @@ -113,6 +117,14 @@ CheckUpdateThreadLauncher::~CheckUpdateThreadLauncher() void CheckUpdateThreadLauncher::launch() { + if (m_uuid.empty()) + m_uuid = m_preferences.updater.uuid(); + +#if ENABLE_SENTRY + if (!m_uuid.empty()) + Sentry::setUserID(m_uuid); +#endif + // In this case we are in the "wait days" period, so we don't check // for updates. if (!m_doCheck) { @@ -120,9 +132,6 @@ void CheckUpdateThreadLauncher::launch() return; } - if (m_uuid.empty()) - m_uuid = m_preferences.updater.uuid(); - m_delegate->onCheckingUpdates(); m_bgJob.reset(new CheckUpdateBackgroundJob); @@ -168,6 +177,11 @@ void CheckUpdateThreadLauncher::onMonitoringTick() if (!m_response.getUuid().empty()) { m_uuid = m_response.getUuid(); m_preferences.updater.uuid(m_uuid); + +#if ENABLE_SENTRY + if (!m_uuid.empty()) + Sentry::setUserID(m_uuid); +#endif } // Set the date of the last "check for updates" and the "WaitDays" parameter. diff --git a/src/app/sentry_wrapper.cpp b/src/app/sentry_wrapper.cpp index 0dd6a8cf0..40e3427d6 100644 --- a/src/app/sentry_wrapper.cpp +++ b/src/app/sentry_wrapper.cpp @@ -50,6 +50,14 @@ Sentry::~Sentry() sentry_close(); } +// static +void Sentry::setUserID(const std::string& uuid) +{ + sentry_value_t user = sentry_value_new_object(); + sentry_value_set_by_key(user, "id", sentry_value_new_string(uuid.c_str())); + sentry_set_user(user); +} + // static bool Sentry::requireConsent() { diff --git a/src/app/sentry_wrapper.h b/src/app/sentry_wrapper.h index 97873016c..c833f9f9d 100644 --- a/src/app/sentry_wrapper.h +++ b/src/app/sentry_wrapper.h @@ -22,6 +22,8 @@ public: void init(); ~Sentry(); + static void setUserID(const std::string& uuid); + static bool requireConsent(); static bool consentGiven(); static void giveConsent();