diff --git a/map/framework.cpp b/map/framework.cpp index 2e4ebbf799..7cc6fa9fe3 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1314,7 +1314,14 @@ void Framework::InitUGC() { ASSERT(!m_ugcApi.get(), ("InitUGC() must be called only once.")); - m_ugcApi = make_unique(m_model.GetIndex()); + m_ugcApi = make_unique(m_model.GetIndex(), [this](size_t numberOfUnsynchronized) { + if (numberOfUnsynchronized == 0) + return; + + alohalytics::Stats::Instance().LogEvent( + "UGC_unsent", {{"num", strings::to_string(numberOfUnsynchronized)}, + {"is_authenticated", strings::to_string(m_user.IsAuthenticated())}}); + }); } void Framework::InitSearchAPI() diff --git a/ugc/api.cpp b/ugc/api.cpp index e11d07380b..efa8f07dd0 100644 --- a/ugc/api.cpp +++ b/ugc/api.cpp @@ -9,9 +9,13 @@ using namespace ugc; namespace ugc { -Api::Api(Index const & index) : m_storage(index), m_loader(index) +Api::Api(Index const & index, NumberOfUnsynchronizedCallback const & callback) + : m_storage(index), m_loader(index) { - m_thread.Push([this] { m_storage.Load(); }); + m_thread.Push([this, callback] { + m_storage.Load(); + callback(m_storage.GetNumberOfUnsynchronized()); + }); } void Api::GetUGC(FeatureID const & id, UGCCallbackUnsafe const & callback) diff --git a/ugc/api.hpp b/ugc/api.hpp index 60dd7a7e12..786e0c65d8 100644 --- a/ugc/api.hpp +++ b/ugc/api.hpp @@ -22,8 +22,9 @@ public: using UGCCallbackUnsafe = std::function; using UGCJsonToSendCallback = std::function; using OnResultCallback = platform::SafeCallback; + using NumberOfUnsynchronizedCallback = std::function; - explicit Api(Index const & index); + Api(Index const & index, NumberOfUnsynchronizedCallback const & callback); void GetUGC(FeatureID const & id, UGCCallbackUnsafe const & callback); void SetUGCUpdate(FeatureID const & id, UGCUpdate const & ugc, diff --git a/ugc/storage.cpp b/ugc/storage.cpp index 25289571c0..cffc49af28 100644 --- a/ugc/storage.cpp +++ b/ugc/storage.cpp @@ -18,7 +18,6 @@ #include #include -#include "3party/Alohalytics/src/alohalytics.h" #include "3party/jansson/myjansson.hpp" namespace ugc @@ -204,20 +203,11 @@ void Storage::Load() return; } - size_t numberOfUnsynchronized = 0; DeserializeUGCIndex(data, m_UGCIndexes); for (auto const & i : m_UGCIndexes) { if (i.m_deleted) ++m_numberOfDeleted; - else if (!i.m_synchronized) - ++numberOfUnsynchronized; - } - - if (numberOfUnsynchronized > 1) - { - alohalytics::Stats::Instance().LogEvent("UGC_unsent", - {{"num", strings::to_string(numberOfUnsynchronized)}}); } }