Commit a62c6bc1 authored by Esmael El-Moslimany's avatar Esmael El-Moslimany Committed by Commit Bot

WebUI NTP: add task module UMA for item/search display counts

Bug: 1147287
Change-Id: I6dba473b3648615cf877dbd23186b3176d9fd891
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532996
Commit-Queue: Esmael Elmoslimany <aee@chromium.org>
Auto-Submit: Esmael Elmoslimany <aee@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827092}
parent e0e6cc3c
......@@ -4,6 +4,7 @@
#include "chrome/browser/search/task_module/task_module_service.h"
#include "base/metrics/histogram_functions.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/profiles/profile.h"
......@@ -27,10 +28,7 @@ const char* GetPath(task_module::mojom::TaskModuleType task_module_type) {
return "/async/newtab_recipe_tasks";
case task_module::mojom::TaskModuleType::kShopping:
return "/async/newtab_shopping_tasks";
default:
NOTREACHED();
}
return nullptr;
}
GURL GetApiUrl(task_module::mojom::TaskModuleType task_module_type,
......@@ -50,10 +48,7 @@ const char* GetTasksKey(task_module::mojom::TaskModuleType task_module_type) {
return "recipe_tasks";
case task_module::mojom::TaskModuleType::kShopping:
return "shopping_tasks";
default:
NOTREACHED();
}
return nullptr;
}
const char* GetTaskItemsKey(
......@@ -63,10 +58,17 @@ const char* GetTaskItemsKey(
return "recipes";
case task_module::mojom::TaskModuleType::kShopping:
return "products";
default:
NOTREACHED();
}
return nullptr;
}
const char* GetTaskItemsName(
task_module::mojom::TaskModuleType task_module_type) {
switch (task_module_type) {
case task_module::mojom::TaskModuleType::kRecipe:
return "Recipes";
case task_module::mojom::TaskModuleType::kShopping:
return "Products";
}
}
const char* GetDismissedTasksPrefName(
......@@ -76,10 +78,16 @@ const char* GetDismissedTasksPrefName(
return "NewTabPage.DismissedRecipeTasks";
case task_module::mojom::TaskModuleType::kShopping:
return "NewTabPage.DismissedShoppingTasks";
default:
NOTREACHED();
}
return nullptr;
}
const char* GetModuleName(task_module::mojom::TaskModuleType task_module_type) {
switch (task_module_type) {
case task_module::mojom::TaskModuleType::kRecipe:
return "RecipeTasks";
case task_module::mojom::TaskModuleType::kShopping:
return "ShoppingTasks";
}
}
} // namespace
......@@ -221,6 +229,7 @@ void TaskModuleService::OnJsonParsed(
std::move(callback).Run(nullptr);
return;
}
for (const auto& task : tasks->GetList()) {
auto* title = task.FindStringPath("title");
auto* task_name = task.FindStringPath("task_name");
......@@ -272,8 +281,18 @@ void TaskModuleService::OnJsonParsed(
auto mojo_task = task_module::mojom::Task::New();
mojo_task->title = *title;
mojo_task->name = *task_name;
base::UmaHistogramCounts100(
base::StringPrintf("NewTabPage.%s.%sDownloadCount",
GetModuleName(task_module_type),
GetTaskItemsName(task_module_type)),
mojo_task_items.size());
mojo_task->task_items = std::move(mojo_task_items);
base::UmaHistogramCounts100(
base::StringPrintf("NewTabPage.%s.RelatedSearchDownloadCount",
GetModuleName(task_module_type)),
mojo_related_searches.size());
mojo_task->related_searches = std::move(mojo_related_searches);
std::move(callback).Run(std::move(mojo_task));
return;
}
......
......@@ -1062,6 +1062,19 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="NewTabPage.RecipeTasks.RecipeDownloadCount" units="recipes"
expires_after="2021-03-01">
<owner>tiborg@chromium.org</owner>
<owner>yyushkina@chromium.org</owner>
<owner>chrome-desktop-ntp@google.com</owner>
<summary>
The number of recipe search links in the primary shopping task (top-ranked,
recipe, search journey). The recipe search links are rendered with a name,
image and URL. This metric is logged after the recipe tasks are successfuly
retrieved.
</summary>
</histogram>
<histogram name="NewTabPage.RecipeTasks.RelatedSearchClick" units="index"
expires_after="2021-01-01">
<owner>tiborg@chromium.org</owner>
......@@ -1073,6 +1086,19 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="NewTabPage.RecipeTasks.RelatedSearchDownloadCount"
units="count" expires_after="2021-03-01">
<owner>tiborg@chromium.org</owner>
<owner>yyushkina@chromium.org</owner>
<owner>chrome-desktop-ntp@google.com</owner>
<summary>
The number of related search links in the primary recipe task (top-ranked,
recipe, search journey). The related search links are rendered with a name
and URL. This metric is logged after the recipe tasks are successfuly
retrieved.
</summary>
</histogram>
<histogram name="NewTabPage.RepeatableQueries.ExtractedCount" units="count"
expires_after="M90">
<owner>mahmadi@chromium.org</owner>
......@@ -1217,6 +1243,19 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="NewTabPage.ShoppingTasks.ProductDownloadCount"
units="products" expires_after="2021-03-01">
<owner>tiborg@chromium.org</owner>
<owner>yyushkina@chromium.org</owner>
<owner>chrome-desktop-ntp@google.com</owner>
<summary>
The number of product search links in the primary shopping task (top-ranked,
shopping, search journey). The product search links are rendered with a
name, price, image and URL. This metric is logged after the shopping tasks
are successfuly retrieved.
</summary>
</histogram>
<histogram name="NewTabPage.ShoppingTasks.RelatedSearchClick" units="index"
expires_after="2021-01-01">
<owner>tiborg@chromium.org</owner>
......@@ -1228,6 +1267,19 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="NewTabPage.ShoppingTasks.RelatedSearchDownloadCount"
units="count" expires_after="2021-03-01">
<owner>tiborg@chromium.org</owner>
<owner>yyushkina@chromium.org</owner>
<owner>chrome-desktop-ntp@google.com</owner>
<summary>
The number of related search links in the primary shopping task (top-ranked,
shopping, search journey). The related search links are rendered with a name
and URL. This metric is logged after the shopping tasks are successfuly
retrieved.
</summary>
</histogram>
<histogram name="NewTabPage.Snippets.DatabaseLoadTime" units="ms"
expires_after="M85">
<obsolete>
......
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