Commit e6717228 authored by Yue Li's avatar Yue Li Committed by Chromium LUCI CQ

Quick Answers: Add UMA for context menu close duration

Add metrics to measure how long the context menu has shown before the
usre close it.

Bug: b/173809124
Test: None
Change-Id: Ieb28c43078ff7ea81f2d51823d84c0d5414eb38f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2567634
Commit-Queue: Yue Li <updowndota@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832592}
parent 0b953348
......@@ -69,6 +69,8 @@ QuickAnswersMenuObserver::~QuickAnswersMenuObserver() = default;
void QuickAnswersMenuObserver::OnContextMenuShown(
const content::ContextMenuParams& params,
const gfx::Rect& bounds_in_screen) {
menu_shown_time_ = base::TimeTicks::Now();
if (!quick_answers_controller_ || !is_eligible_)
return;
......@@ -112,6 +114,17 @@ void QuickAnswersMenuObserver::OnContextMenuViewBoundsChanged(
}
void QuickAnswersMenuObserver::OnMenuClosed() {
const base::TimeDelta time_since_request_sent =
base::TimeTicks::Now() - menu_shown_time_;
if (is_other_command_executed_) {
base::UmaHistogramTimes("QuickAnswers.ContextMenu.Close.DurationWithClick",
time_since_request_sent);
} else {
base::UmaHistogramTimes(
"QuickAnswers.ContextMenu.Close.DurationWithoutClick",
time_since_request_sent);
}
base::UmaHistogramBoolean("QuickAnswers.ContextMenu.Close",
is_other_command_executed_);
......
......@@ -8,6 +8,7 @@
#include <memory>
#include <string>
#include "base/time/time.h"
#include "chromeos/components/quick_answers/quick_answers_client.h"
#include "components/renderer_context_menu/render_view_context_menu_observer.h"
#include "ui/gfx/geometry/rect.h"
......@@ -68,6 +69,9 @@ class QuickAnswersMenuObserver
// Whether commands other than quick answers is executed.
bool is_other_command_executed_ = false;
// Time that the context menu is shown.
base::TimeTicks menu_shown_time_;
base::WeakPtrFactory<QuickAnswersMenuObserver> weak_factory_{this};
};
......
......@@ -304,6 +304,21 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="QuickAnswers.ContextMenu.Close.Duration{InteractionType}"
units="ms" expires_after="2021-02-14">
<owner>updowndota@chromium.org</owner>
<owner>croissant-eng@chromium.org</owner>
<summary>
Records the amount of time the context menu was shown before close if the
user {InteractionType} (via clicking) with the context menu. Recorded on
ChromeOS only.
</summary>
<token key="InteractionType">
<variant name="WithClick" summary="has interacted"/>
<variant name="WithoutClick" summary="has not interacted"/>
</token>
</histogram>
<histogram name="QuickAnswers.Intent" enum="QuickAnswersIntentType"
expires_after="2021-04-25">
<owner>llin@google.com</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