[search] Added an event that identifies which search result was chosen.
This commit introduces a new Alohalytics event key: "searchShowResult".
This commit is contained in:
parent
6d52e521bc
commit
110919fc04
4 changed files with 40 additions and 22 deletions
|
@ -1082,6 +1082,10 @@ void Framework::ShowSearchResult(search::Result const & res)
|
|||
using namespace search;
|
||||
using namespace feature;
|
||||
|
||||
alohalytics::TStringMap stats = {{"pos", strings::to_string(res.GetPositionInResults())},
|
||||
{"result", DebugPrint(res)}};
|
||||
alohalytics::LogEvent("searchShowResult", stats);
|
||||
|
||||
switch (res.GetResultType())
|
||||
{
|
||||
case Result::RESULT_FEATURE:
|
||||
|
|
|
@ -14,19 +14,41 @@ Result::Result(FeatureID const & id, m2::PointD const & pt, string const & str,
|
|||
, m_type(type)
|
||||
, m_featureType(featureType)
|
||||
, m_metadata(meta)
|
||||
, m_positionInResults(-1)
|
||||
{
|
||||
Init(true /* metadataInitialized */);
|
||||
}
|
||||
|
||||
Result::Result(FeatureID const & id, m2::PointD const & pt, string const & str, string const & type)
|
||||
: m_id(id)
|
||||
, m_center(pt)
|
||||
, m_str(str)
|
||||
, m_type(type)
|
||||
: m_id(id), m_center(pt), m_str(str), m_type(type), m_positionInResults(-1)
|
||||
{
|
||||
Init(false /* metadataInitialized */);
|
||||
}
|
||||
|
||||
Result::Result(m2::PointD const & pt, string const & str, string const & region,
|
||||
string const & type)
|
||||
: m_center(pt), m_str(str), m_region(region), m_type(type), m_positionInResults(-1)
|
||||
{
|
||||
}
|
||||
|
||||
Result::Result(string const & str, string const & suggest)
|
||||
: m_str(str), m_suggestionStr(suggest), m_positionInResults(-1)
|
||||
{
|
||||
}
|
||||
|
||||
Result::Result(Result const & res, string const & suggest)
|
||||
: m_id(res.m_id)
|
||||
, m_center(res.m_center)
|
||||
, m_str(res.m_str)
|
||||
, m_region(res.m_region)
|
||||
, m_type(res.m_type)
|
||||
, m_featureType(res.m_featureType)
|
||||
, m_suggestionStr(suggest)
|
||||
, m_hightlightRanges(res.m_hightlightRanges)
|
||||
, m_positionInResults(-1)
|
||||
{
|
||||
}
|
||||
|
||||
void Result::Init(bool metadataInitialized)
|
||||
{
|
||||
// Features with empty names can be found after suggestion.
|
||||
|
@ -36,24 +58,6 @@ void Result::Init(bool metadataInitialized)
|
|||
m_metadata.m_isInitialized = metadataInitialized;
|
||||
}
|
||||
|
||||
Result::Result(m2::PointD const & pt, string const & str,
|
||||
string const & region, string const & type)
|
||||
: m_center(pt), m_str(str), m_region(region), m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
Result::Result(string const & str, string const & suggest)
|
||||
: m_str(str), m_suggestionStr(suggest)
|
||||
{
|
||||
}
|
||||
|
||||
Result::Result(Result const & res, string const & suggest)
|
||||
: m_id(res.m_id), m_center(res.m_center), m_str(res.m_str),
|
||||
m_region(res.m_region), m_type(res.m_type), m_featureType(res.m_featureType),
|
||||
m_suggestionStr(suggest), m_hightlightRanges(res.m_hightlightRanges)
|
||||
{
|
||||
}
|
||||
|
||||
Result::ResultType Result::GetResultType() const
|
||||
{
|
||||
bool const idValid = m_id.IsValid();
|
||||
|
|
|
@ -91,6 +91,9 @@ public:
|
|||
|
||||
void AppendCity(string const & name);
|
||||
|
||||
int32_t GetPositionInResults() const { return m_positionInResults; }
|
||||
void SetPositionInResults(int32_t pos) { m_positionInResults = pos; }
|
||||
|
||||
private:
|
||||
void Init(bool metadataInitialized);
|
||||
|
||||
|
@ -101,6 +104,10 @@ private:
|
|||
string m_suggestionStr;
|
||||
buffer_vector<pair<uint16_t, uint16_t>, 4> m_hightlightRanges;
|
||||
|
||||
// The position that this result occupied in the vector returned
|
||||
// by a search query. -1 if undefined.
|
||||
int32_t m_positionInResults;
|
||||
|
||||
public:
|
||||
Metadata m_metadata;
|
||||
};
|
||||
|
|
|
@ -181,6 +181,9 @@ void Engine::EmitResults(SearchParams const & params, m2::RectD const & viewport
|
|||
};
|
||||
alohalytics::LogEvent("searchEmitResults", stats);
|
||||
|
||||
for (size_t i = 0; i < res.GetCount(); ++i)
|
||||
res.GetResult(i).SetPositionInResults(i);
|
||||
|
||||
params.m_callback(res);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue