forked from organicmaps/organicmaps
Added statistics for traffic
This commit is contained in:
parent
2d14212f00
commit
63d27b071b
5 changed files with 62 additions and 1 deletions
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
#include "3party/Alohalytics/src/alohalytics.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
auto constexpr kUpdateInterval = minutes(1);
|
||||
|
@ -101,9 +103,17 @@ void TrafficManager::SetEnabled(bool enabled)
|
|||
m_drapeEngine->EnableTraffic(enabled);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
Invalidate();
|
||||
GetPlatform().GetMarketingService().SendPushWooshTag(marketing::kTrafficDiscovered);
|
||||
alohalytics::LogEvent(
|
||||
"$TrafficEnabled",
|
||||
alohalytics::TStringMap({{"dataVersion", strings::to_string(m_currentDataVersion.load())}}));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_observer.OnTrafficInfoClear();
|
||||
}
|
||||
}
|
||||
|
||||
void TrafficManager::Clear()
|
||||
|
@ -474,6 +484,9 @@ void TrafficManager::ChangeState(TrafficState newState)
|
|||
return;
|
||||
|
||||
m_state = newState;
|
||||
alohalytics::LogEvent(
|
||||
"$TrafficChangeState",
|
||||
alohalytics::TStringMap({{"state", DebugPrint(m_state.load())}}));
|
||||
|
||||
GetPlatform().RunOnGuiThread([this, newState]()
|
||||
{
|
||||
|
@ -481,3 +494,29 @@ void TrafficManager::ChangeState(TrafficState newState)
|
|||
m_onStateChangedFn(newState);
|
||||
});
|
||||
}
|
||||
|
||||
string DebugPrint(TrafficManager::TrafficState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case TrafficManager::TrafficState::Disabled:
|
||||
return "Disabled";
|
||||
case TrafficManager::TrafficState::Enabled:
|
||||
return "Enabled";
|
||||
case TrafficManager::TrafficState::WaitingData:
|
||||
return "WaitingData";
|
||||
case TrafficManager::TrafficState::Outdated:
|
||||
return "Outdated";
|
||||
case TrafficManager::TrafficState::NoData:
|
||||
return "NoData";
|
||||
case TrafficManager::TrafficState::NetworkError:
|
||||
return "NetworkError";
|
||||
case TrafficManager::TrafficState::ExpiredData:
|
||||
return "ExpiredData";
|
||||
case TrafficManager::TrafficState::ExpiredApp:
|
||||
return "ExpiredApp";
|
||||
default:
|
||||
ASSERT(false, ("Unknown state"));
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
|
|
@ -146,3 +146,5 @@ private:
|
|||
mutex m_mutex;
|
||||
threads::SimpleThread m_thread;
|
||||
};
|
||||
|
||||
extern string DebugPrint(TrafficManager::TrafficState state);
|
||||
|
|
|
@ -17,6 +17,7 @@ char const * const kRoutingBicycleDiscovered = "routing_bicycle_discovered";
|
|||
char const * const kRoutingTaxiDiscovered = "routing_taxi_discovered";
|
||||
char const * const kEditorAddDiscovered = "editor_add_discovered";
|
||||
char const * const kEditorEditDiscovered = "editor_edit_discovered";
|
||||
char const * const kTrafficDiscovered = "traffic_discovered";
|
||||
|
||||
// Events.
|
||||
char const * const kDownloaderMapActionFinished = "Downloader_Map_action_finished";
|
||||
|
@ -42,7 +43,9 @@ void MarketingService::ProcessFirstLaunch()
|
|||
kRoutingVehicleDiscovered, kRoutingPedestrianDiscovered,
|
||||
kRoutingBicycleDiscovered, kRoutingTaxiDiscovered,
|
||||
|
||||
kEditorAddDiscovered, kEditorEditDiscovered
|
||||
kEditorAddDiscovered, kEditorEditDiscovered,
|
||||
|
||||
kTrafficDiscovered
|
||||
};
|
||||
|
||||
for (auto const & tag : tags)
|
||||
|
|
|
@ -22,6 +22,7 @@ extern char const * const kRoutingBicycleDiscovered;
|
|||
extern char const * const kRoutingTaxiDiscovered;
|
||||
extern char const * const kEditorAddDiscovered;
|
||||
extern char const * const kEditorEditDiscovered;
|
||||
extern char const * const kTrafficDiscovered;
|
||||
|
||||
// Events.
|
||||
extern char const * const kDownloaderMapActionFinished;
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
#include "private.h"
|
||||
|
||||
#include "3party/Alohalytics/src/alohalytics.h"
|
||||
|
||||
namespace traffic
|
||||
{
|
||||
namespace
|
||||
|
@ -426,6 +428,10 @@ bool TrafficInfo::ReceiveTrafficValues(vector<SpeedGroup> & values)
|
|||
else
|
||||
{
|
||||
m_availability = Availability::Unknown;
|
||||
|
||||
alohalytics::LogEvent(
|
||||
"$TrafficNetworkError",
|
||||
alohalytics::TStringMap({{"code", strings::to_string(errorCode)}}));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -439,6 +445,12 @@ bool TrafficInfo::ReceiveTrafficValues(vector<SpeedGroup> & values)
|
|||
m_availability = Availability::NoData;
|
||||
LOG(LWARNING, ("Could not read traffic values received from server. MWM:",
|
||||
info->GetCountryName(), "Version:", info->GetVersion()));
|
||||
|
||||
alohalytics::LogEvent(
|
||||
"$TrafficReadError",
|
||||
alohalytics::TStringMap({{"mwm", info->GetCountryName()},
|
||||
{"version", strings::to_string(info->GetVersion())}}));
|
||||
|
||||
return false;
|
||||
}
|
||||
m_availability = Availability::IsAvailable;
|
||||
|
@ -454,6 +466,10 @@ bool TrafficInfo::UpdateTrafficData(vector<SpeedGroup> const & values)
|
|||
LOG(LWARNING,
|
||||
("The number of received traffic values does not correspond to the number of keys:",
|
||||
m_keys.size(), "keys", values.size(), "values."));
|
||||
alohalytics::LogEvent(
|
||||
"$TrafficUpdateError",
|
||||
alohalytics::TStringMap({{"keysCount", strings::to_string(m_keys.size())},
|
||||
{"valuesCount", strings::to_string(values.size())}}));
|
||||
m_availability = Availability::NoData;
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue