Commit be044933 authored by tby's avatar tby Committed by Commit Bot

[Structured metrics] Re-enable launcher collection.

This re-enables the launcher collection that we disabled while moving
from the hashed logging prototype to the structured metrics framework.

All logging is the same, with one exception: we previously had two
metrics aimed at recording which provider a search result comes from,
with each determining about half of the providers. I've simplified this
by combining them into one metric, which records the value of
RankingItemType, the enum we use for type identification for all
on-device models.

To do this I've cleaned up the RankingItemType enum, removing item
types that we no longer use and adding a "don't change this" header.

Bug: 1016655
Change-Id: Id04156a4818f842af6489aea23d4048d7aeb4824
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2038292Reviewed-by: default avatarCharles . <charleszhao@chromium.org>
Reviewed-by: default avatarJenny Zhang <jennyz@chromium.org>
Commit-Queue: Tony Yeoman <tby@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739241}
parent 66501e94
......@@ -3930,6 +3930,7 @@ jumbo_static_library("ui") {
"//chromeos/services/network_config/public/mojom",
"//components/assist_ranker",
"//components/assist_ranker/proto",
"//components/metrics/structured:structured_events",
"//components/services/app_service/public/cpp:app_file_handling",
"//services/audio/public/mojom",
"//services/device/public/mojom",
......
......@@ -30,9 +30,7 @@
#include "chrome/browser/ui/app_list/search/search_result_ranker/histogram_util.h"
#include "chrome/browser/ui/app_list/search/search_result_ranker/ranking_item_util.h"
#include "chrome/browser/ui/app_list/search/search_result_ranker/search_result_ranker.h"
#include "third_party/metrics_proto/chrome_os_app_list_launch_event.pb.h"
using metrics::ChromeOSAppListLaunchEventProto;
#include "components/metrics/structured/structured_events.h"
namespace app_list {
......@@ -216,7 +214,19 @@ int SearchController::GetLastQueryLength() const {
void SearchController::Train(AppLaunchData&& app_launch_data) {
if (app_list_features::IsAppListLaunchRecordingEnabled()) {
// TODO(crbug.com/951287): Add hashed logging once framework is done.
// Record a structured metrics event.
const base::Time now = base::Time::Now();
base::Time::Exploded now_exploded;
now.LocalExplode(&now_exploded);
metrics::structured::events::LauncherUsage()
.SetTarget(NormalizeId(app_launch_data.id))
.SetApp(last_launched_app_id_)
.SetSearchQuery(base::UTF16ToUTF8(last_query_))
.SetSearchQueryLength(last_query_.size())
.SetProviderType(static_cast<int>(app_launch_data.ranking_item_type))
.SetHour(now_exploded.hour)
.Record();
// Only record the last launched app if the hashed logging feature flag is
// enabled, because it is only used by hashed logging.
......
......@@ -23,16 +23,8 @@ ZeroStateResultType ZeroStateTypeFromRankingType(
case RankingItemType::kFile:
case RankingItemType::kApp:
case RankingItemType::kArcAppShortcut:
case RankingItemType::kOmniboxBookmark:
case RankingItemType::kOmniboxDeprecated:
case RankingItemType::kOmniboxDocument:
case RankingItemType::kOmniboxHistory:
case RankingItemType::kOmniboxNavSuggest:
return ZeroStateResultType::kUnanticipated;
// Omnibox search results could be classified as either of these two cases,
// depending on whether Omnibox results were expanded.
case RankingItemType::kOmniboxGeneric:
case RankingItemType::kOmniboxSearch:
return ZeroStateResultType::kOmniboxSearch;
case RankingItemType::kZeroStateFile:
return ZeroStateResultType::kZeroStateFile;
......
......@@ -12,23 +12,18 @@ class ChromeSearchResult;
namespace app_list {
// Warning: this enum may change, should not be serialised, and should not
// persist to logs.
// A simplified value describing what kind a search result should be treated as
// for the purposes of ranking. These values are persisted to logs. Entries
// should not be renumbered and numeric values should never be reused.
enum class RankingItemType {
kUnknown,
kIgnored,
kFile,
kApp,
kOmniboxGeneric,
kArcAppShortcut,
kOmniboxBookmark,
kOmniboxDeprecated,
kOmniboxDocument,
kOmniboxHistory,
kOmniboxNavSuggest,
kOmniboxSearch,
kZeroStateFile,
kDriveQuickAccess
kUnknown = 0,
kIgnored = 1,
kFile = 2,
kApp = 3,
kOmniboxGeneric = 4,
kArcAppShortcut = 5,
kZeroStateFile = 6,
kDriveQuickAccess = 7,
};
// Convert a |ChromeSearchResult| into its |RankingItemType|.
......
......@@ -78,10 +78,6 @@ Model ModelForType(RankingItemType type) {
switch (type) {
case RankingItemType::kFile:
case RankingItemType::kOmniboxGeneric:
case RankingItemType::kOmniboxBookmark:
case RankingItemType::kOmniboxDocument:
case RankingItemType::kOmniboxHistory:
case RankingItemType::kOmniboxSearch:
case RankingItemType::kZeroStateFile:
case RankingItemType::kDriveQuickAccess:
return Model::MIXED_TYPES;
......@@ -127,10 +123,6 @@ std::string NormalizeId(const std::string& id, RankingItemType type) {
// Put any further normalizations here.
switch (type) {
case RankingItemType::kOmniboxGeneric:
case RankingItemType::kOmniboxBookmark:
case RankingItemType::kOmniboxDocument:
case RankingItemType::kOmniboxHistory:
case RankingItemType::kOmniboxSearch:
// Heuristically check if the URL points to a Drive file. If so, strip
// some extra information from it.
if (GURL(id).host() == "docs.google.com")
......@@ -663,8 +655,7 @@ void SearchResultRanker::SaveQueryMixedRankerAfterDelete() {
void SearchResultRanker::LogZeroStateResultScore(RankingItemType type,
float score) {
const auto& now = Time::Now();
if (type == RankingItemType::kOmniboxGeneric ||
type == RankingItemType::kOmniboxSearch) {
if (type == RankingItemType::kOmniboxGeneric) {
if (now - time_of_last_omnibox_log_ < kMinTimeBetweenLogs)
return;
time_of_last_omnibox_log_ = now;
......
......@@ -387,11 +387,11 @@ TEST_F(SearchResultRankerTest, QueryMixedModelNormalizesUrlIds) {
AppLaunchData app_launch_data_1;
app_launch_data_1.id = url_1;
app_launch_data_1.ranking_item_type = RankingItemType::kOmniboxHistory;
app_launch_data_1.ranking_item_type = RankingItemType::kOmniboxGeneric;
app_launch_data_1.query = "query";
AppLaunchData app_launch_data_3;
app_launch_data_3.id = url_3;
app_launch_data_3.ranking_item_type = RankingItemType::kOmniboxHistory;
app_launch_data_3.ranking_item_type = RankingItemType::kOmniboxGeneric;
app_launch_data_3.query = "query";
for (int i = 0; i < 5; ++i) {
......@@ -477,7 +477,7 @@ TEST_F(SearchResultRankerTest, QueryMixedModelDeletesURLCorrectly) {
const std::string url_1 = "http://www.google.com/testing";
AppLaunchData url_1_data;
url_1_data.id = url_1;
url_1_data.ranking_item_type = RankingItemType::kOmniboxHistory;
url_1_data.ranking_item_type = RankingItemType::kOmniboxGeneric;
url_1_data.query = "query";
ranker->Train(url_1_data);
ranker->Train(url_1_data);
......@@ -485,7 +485,7 @@ TEST_F(SearchResultRankerTest, QueryMixedModelDeletesURLCorrectly) {
const std::string url_2 = "http://www.other.com";
AppLaunchData url_2_data;
url_2_data.id = url_2;
url_2_data.ranking_item_type = RankingItemType::kOmniboxHistory;
url_2_data.ranking_item_type = RankingItemType::kOmniboxGeneric;
url_2_data.query = "query";
ranker->Train(url_2_data);
......
<!-- Structured metrics is under development and isn't available for use yet. -->
<structured-metrics-configuration>
<!-- Structured metrics is under development and isn't available for use yet. -->
<event name="LauncherUsage">
<owner>tby@chromium.org</owner>
<summary>
Records information about the launch of an item (such as an app or a file)
from the ChromeOS launcher. One event is recorded for every launch
originating from any launcher UI component, and this is the only
circumstance that records events.
</summary>
<metric name="App" kind="hashed-string">
<summary>
App ID of the most-recently-opened app when this launch occured. This can
be an app ID of a Chrome app, Arc++ app, or PWA.
</summary>
</metric>
<metric name="Domain" kind="hashed-string">
<summary>
The most-recently-visited domain when this launch ocurred.
</summary>
</metric>
<metric name="Hour" kind="int">
<summary>
The hour of launch. This is the user's local time rounded to the nearest
hour, 0 to 23 inclusive.
</summary>
</metric>
<metric name="ProviderType" kind="int">
<summary>
Which kind of search provider the launched result was created by. This
comes from the RankingItemType enum.
</summary>
</metric>
<metric name="SearchQuery" kind="hashed-string">
<summary>
The search query associated with this launch. Before hashing, the query is
the empty string if there was no search query.
</summary>
</metric>
<metric name="SearchQueryLength" kind="int">
<summary>
String length of the search query associated with this launch. If there
was no query, this is zero.
</summary>
</metric>
<metric name="Target" kind="hashed-string">
<summary>
The target item of this launch, eg. an app ID, filepath, or omnibox URL.
</summary>
</metric>
</event>
<event name="TestEventOne">
<owner>tby@chromium.org</owner>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment