Commit 41b76929 authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

[ntp][modules] Add NewTabPage.ShoppingTasks.[Product|RelatedSearch]Click

These histograms let us analyze usage of the shopping task module in
more granularity than what NewTabPage.Modules.Usage.shopping_tasks
allows.

Bug: 1133904
Change-Id: Id7470f6b2f0cbb7553dba406e57d5f62afd788c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2443392Reviewed-by: default avatarEmily Stark <estark@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Auto-Submit: Tibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814394}
parent b0ea6fb9
......@@ -134,8 +134,8 @@
<div id="products">
<template is="dom-repeat" id="productsRepeat"
items="[[shoppingTask.products]]" on-dom-change="onDomChange_">
<a class="product" href="[[item.targetUrl.url]]" on-click="onClick_"
on-auxclick="onClick_">
<a class="product" href="[[item.targetUrl.url]]" on-click="onProductClick_"
on-auxclick="onProductClick_">
<div class="image">
<img is="ntp-img" auto-src="[[item.imageUrl.url]]"></img>
</div>
......@@ -148,8 +148,8 @@
<div id="relatedSearches">
<template is="dom-repeat" id="relatedSearchesRepeat"
items="[[shoppingTask.relatedSearches]]" on-dom-change="onDomChange_">
<a class="pill" href="[[item.targetUrl.url]]" on-click="onClick_"
on-auxclick="onClick_">
<a class="pill" href="[[item.targetUrl.url]]" on-click="onPillClick_"
on-auxclick="onPillClick_">
<div class="loupe"></div>
<div class="search-text">[[item.text]]</div>
</a>
......
......@@ -41,8 +41,24 @@ class ShoppingTasksModuleElement extends PolymerElement {
this.intersectionObserver_ = null;
}
/** @private */
onClick_() {
/**
* @param {!Event} e
* @private
*/
onProductClick_(e) {
const index = this.$.productsRepeat.indexForElement(e.target);
ShoppingTasksHandlerProxy.getInstance().handler.onProductClicked(index);
this.dispatchEvent(new Event('usage', {bubbles: true, composed: true}));
}
/**
* @param {!Event} e
* @private
*/
onPillClick_(e) {
const index = this.$.relatedSearchesRepeat.indexForElement(e.target);
ShoppingTasksHandlerProxy.getInstance().handler.onRelatedSearchClicked(
index);
this.dispatchEvent(new Event('usage', {bubbles: true, composed: true}));
}
......
......@@ -49,4 +49,8 @@ interface ShoppingTasksHandler {
DismissShoppingTask(string task_name);
// Restores the task with the given name and remembers that setting.
RestoreShoppingTask(string task_name);
// Logs that the product at position |index| has been clicked.
OnProductClicked(uint32 index);
// Logs that the related search pill at position |index| has been clicked.
OnRelatedSearchClicked(uint32 index);
};
......@@ -4,6 +4,7 @@
#include "chrome/browser/search/shopping_tasks/shopping_tasks_handler.h"
#include "base/metrics/histogram_functions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/shopping_tasks/shopping_tasks_service.h"
#include "chrome/browser/search/shopping_tasks/shopping_tasks_service_factory.h"
......@@ -31,3 +32,12 @@ void ShoppingTasksHandler::RestoreShoppingTask(const std::string& task_name) {
ShoppingTasksServiceFactory::GetForProfile(profile_)->RestoreShoppingTask(
task_name);
}
void ShoppingTasksHandler::OnProductClicked(uint32_t index) {
base::UmaHistogramCounts100("NewTabPage.ShoppingTasks.ProductClick", index);
}
void ShoppingTasksHandler::OnRelatedSearchClicked(uint32_t index) {
base::UmaHistogramCounts100("NewTabPage.ShoppingTasks.RelatedSearchClick",
index);
}
......@@ -27,6 +27,8 @@ class ShoppingTasksHandler
void GetPrimaryShoppingTask(GetPrimaryShoppingTaskCallback callback) override;
void DismissShoppingTask(const std::string& task_name) override;
void RestoreShoppingTask(const std::string& task_name) override;
void OnProductClicked(uint32_t index) override;
void OnRelatedSearchClicked(uint32_t index) override;
private:
mojo::Receiver<shopping_tasks::mojom::ShoppingTasksHandler> receiver_;
......
......@@ -1135,6 +1135,28 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="NewTabPage.ShoppingTasks.ProductClick" units="index"
expires_after="2021-01-01">
<owner>tiborg@chromium.org</owner>
<owner>yyushkina@chromium.org</owner>
<owner>chrome-desktop-ntp@google.com</owner>
<summary>
Logged when a user clicked on a product in the shopping tasks module. The
value is equal to the index of the product.
</summary>
</histogram>
<histogram name="NewTabPage.ShoppingTasks.RelatedSearchClick" units="index"
expires_after="2021-01-01">
<owner>tiborg@chromium.org</owner>
<owner>yyushkina@chromium.org</owner>
<owner>chrome-desktop-ntp@google.com</owner>
<summary>
Logged when a user clicked on a related search pill in the shopping tasks
module. The value is equal to the index of the pill.
</summary>
</histogram>
<histogram name="NewTabPage.Snippets.DatabaseLoadTime" units="ms"
expires_after="M85">
<owner>treib@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