diff --git a/android/jni/com/mapswithme/maps/StatsClient.cpp b/android/jni/com/mapswithme/maps/StatsClient.cpp index 283861d66d..59f8ac90d8 100644 --- a/android/jni/com/mapswithme/maps/StatsClient.cpp +++ b/android/jni/com/mapswithme/maps/StatsClient.cpp @@ -1,20 +1,20 @@ -#include "../../../../../stats/client/stats_client.hpp" +#include "../../../../../stats/client/event_tracker.hpp" #include "../core/jni_helper.hpp" extern "C" { - static stats::Client * g_client = 0; + static stats::EventTracker * g_nativeTracker = 0; - stats::Client * NativeStat() + stats::EventTracker * NativeTracker() { - if (!g_client) - g_client = new stats::Client(); - return g_client; + if (!g_nativeTracker) + g_nativeTracker = new stats::EventTracker(); + return g_nativeTracker; } JNIEXPORT jboolean JNICALL Java_com_mapswithme_util_StatsClient_trackSearchQuery(JNIEnv * env, jclass clazz, jstring query) { - return NativeStat()->Search(jni::ToNativeString(env, query)); + return NativeTracker()->TrackSearch(jni::ToNativeString(env, query)); } } diff --git a/iphone/Maps/Statistics/Statistics.h b/iphone/Maps/Statistics/Statistics.h index d72cc75c14..0d8b9abb34 100644 --- a/iphone/Maps/Statistics/Statistics.h +++ b/iphone/Maps/Statistics/Statistics.h @@ -1,10 +1,10 @@ #import -#include "../../stats/client/stats_client.hpp" +#include "../../stats/client/event_tracker.hpp" @interface Statistics : NSObject { - stats::Client m_client; + stats::EventTracker m_tracker; } - (void)startSession; diff --git a/iphone/Maps/Statistics/Statistics.mm b/iphone/Maps/Statistics/Statistics.mm index c0f9744923..a71a50b952 100644 --- a/iphone/Maps/Statistics/Statistics.mm +++ b/iphone/Maps/Statistics/Statistics.mm @@ -97,7 +97,7 @@ - (void)logSearchQuery:(NSString *)query { - m_client.Search([query UTF8String]); + m_tracker.TrackSearch([query UTF8String]); } @end \ No newline at end of file diff --git a/stats/client/client.pro b/stats/client/client.pro index c0910d46fe..6bc96e8a8e 100644 --- a/stats/client/client.pro +++ b/stats/client/client.pro @@ -11,13 +11,13 @@ INCLUDEPATH += $$ROOT_DIR/3party/protobuf/src DEPENDENCIES = base protobuf SOURCES += \ - stats_client.cpp \ - stats_writer.cpp \ ../common/wire.pb.cc \ + event_tracker.cpp \ + event_writer.cpp HEADERS += \ - stats_client.hpp \ - stats_writer.hpp \ ../common/wire.pb.h \ + event_tracker.hpp \ + event_writer.hpp OTHER_FILES += ../common/wire.proto diff --git a/stats/client/event_tracker.cpp b/stats/client/event_tracker.cpp new file mode 100644 index 0000000000..ae63626b07 --- /dev/null +++ b/stats/client/event_tracker.cpp @@ -0,0 +1,26 @@ +#include "event_tracker.hpp" +#include "event_writer.hpp" + +#include "../common/wire.pb.h" + +namespace stats +{ + +EventTracker::EventTracker() + : m_writer(new EventWriter(GetPlatform().UniqueClientId(), GetPlatform().WritableDir() + "stats")) +{ +} + +EventTracker::~EventTracker() +{ + delete m_writer; +} + +bool EventTracker::TrackSearch(string const & query) +{ + class Search s; + s.set_query(query); + return m_writer->Write(s); +} + +} // namespace stats diff --git a/stats/client/event_tracker.hpp b/stats/client/event_tracker.hpp new file mode 100644 index 0000000000..2d138774a1 --- /dev/null +++ b/stats/client/event_tracker.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "../../platform/platform.hpp" + +namespace stats +{ + +class EventWriter; + +class EventTracker +{ +public: + EventTracker(); + ~EventTracker(); + bool TrackSearch(string const & query); + +private: + EventWriter * m_writer; +}; + +} // namespace stats diff --git a/stats/client/stats_writer.cpp b/stats/client/event_writer.cpp similarity index 59% rename from stats/client/stats_writer.cpp rename to stats/client/event_writer.cpp index 94e4286b05..83d5ff8c83 100644 --- a/stats/client/stats_writer.cpp +++ b/stats/client/event_writer.cpp @@ -1,4 +1,4 @@ -#include "stats_writer.hpp" +#include "event_writer.hpp" #include "../../base/string_format.hpp" @@ -7,18 +7,18 @@ namespace stats { -StatsWriter::StatsWriter(string const & uniqueClientId, string const & dbPath) +EventWriter::EventWriter(string const & uniqueClientId, string const & dbPath) : m_cnt(0), m_db(0), m_path(dbPath), m_uid(0) { } -bool StatsWriter::Store(const Event & e) +bool EventWriter::Store(const Event & e) { // @todo add impl return false; } -bool StatsWriter::OpenDb(string const & path) +bool EventWriter::OpenDb(string const & path) { // @todo add impl return false; diff --git a/stats/client/stats_writer.hpp b/stats/client/event_writer.hpp similarity index 84% rename from stats/client/stats_writer.hpp rename to stats/client/event_writer.hpp index 388a6cfaf3..b0b192130c 100644 --- a/stats/client/stats_writer.hpp +++ b/stats/client/event_writer.hpp @@ -7,14 +7,14 @@ namespace stats { -class StatsWriter +class EventWriter { public: - StatsWriter(string const & uniqueClientId, string const & dbPath); + EventWriter(string const & uniqueClientId, string const & dbPath); bool Store(Event const & e); - ~StatsWriter() {} + ~EventWriter() {} template bool Write(T const & m) diff --git a/stats/client/stats_client.cpp b/stats/client/stats_client.cpp deleted file mode 100644 index d0858090aa..0000000000 --- a/stats/client/stats_client.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "stats_client.hpp" -#include "stats_writer.hpp" - -#include "../common/wire.pb.h" - -namespace stats -{ - -Client::Client() - : m_writer(new StatsWriter(GetPlatform().UniqueClientId(), GetPlatform().WritableDir() + "stats")) -{ -} - -Client::~Client() -{ - delete m_writer; -} - -bool Client::Search(string const & query) -{ - class Search s; - s.set_query(query); - return m_writer->Write(s); -} - -} // namespace stats diff --git a/stats/client/stats_client.hpp b/stats/client/stats_client.hpp deleted file mode 100644 index c313c78c5c..0000000000 --- a/stats/client/stats_client.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "../../platform/platform.hpp" - -namespace stats -{ - -class StatsWriter; - -class Client -{ -public: - Client(); - ~Client(); - bool Search(string const & query); - -private: - StatsWriter * m_writer; -}; - -} // namespace stats