Commit 88bd0688 authored by apacible's avatar apacible Committed by Commit bot

Add P2 UMA metrics for Media Router navigations.

This change adds the following metrics:
- Count of times the help page is opened.
- Count of times the user explicitly navigates from the route details to sink list.
- Count of times the user explicitly navigates from the sink list to route details.
- Count of times the user explicitly navigates from the sink list to cast mode picker.

BUG=547977

Review URL: https://codereview.chromium.org/1548123002

Cr-Commit-Position: refs/heads/master@{#367203}
parent 7680f374
......@@ -821,6 +821,7 @@ Polymer({
var route = this.sinkToRouteMap_[sink.id];
if (route) {
this.showRouteDetails_(route);
this.fire('navigate-sink-list-to-details');
} else if (this.currentLaunchingSinkId_ == '') {
// Allow one launch at a time.
this.fire('create-route', {
......@@ -877,9 +878,11 @@ Polymer({
* @private
*/
toggleCastModeHidden_: function() {
if (this.currentView_ == media_router.MediaRouterView.CAST_MODE_LIST)
if (this.currentView_ == media_router.MediaRouterView.CAST_MODE_LIST) {
this.showSinkList_();
else
} else {
this.showCastModeList_();
this.fire('navigate-to-cast-mode-list');
}
},
});
......@@ -22,12 +22,17 @@ cr.define('media_router', function() {
container = $('media-router-container');
media_router.ui.setContainer(container);
container.addEventListener('back-click', onNavigateToSinkList);
container.addEventListener('cast-mode-selected', onCastModeSelected);
container.addEventListener('close-button-click', onCloseDialogEvent);
container.addEventListener('close-dialog', onCloseDialogEvent);
container.addEventListener('close-route-click', onCloseRouteClick);
container.addEventListener('create-route', onCreateRoute);
container.addEventListener('issue-action-click', onIssueActionClick);
container.addEventListener('navigate-sink-list-to-details',
onNavigateToDetails);
container.addEventListener('navigate-to-cast-mode-list',
onNavigateToCastMode);
container.addEventListener('report-sink-count', onSinkCountReported);
container.addEventListener('sink-click', onSinkClick);
}
......@@ -108,6 +113,36 @@ cr.define('media_router', function() {
media_router.browserApi.reportClickedSinkIndex(data.detail.index);
}
/**
* Reports the user navigation to the cast mode view.
* Called when the user clicks the drop arrow to navigate to the cast mode
* view on the dialog.
*/
function onNavigateToCastMode() {
media_router.browserApi.reportNavigateToView(
media_router.MediaRouterView.CAST_MODE_LIST);
}
/**
* Reports the user navigation the route details view.
* Called when the user clicks on a sink to navigate to the route details
* view.
*/
function onNavigateToDetails() {
media_router.browserApi.reportNavigateToView(
media_router.MediaRouterView.ROUTE_DETAILS);
}
/**
* Reports the user navigation the sink list view.
* Called when the user clicks on the back button from the route details view
* to the sink list view.
*/
function onNavigateToSinkList() {
media_router.browserApi.reportNavigateToView(
media_router.MediaRouterView.SINK_LIST);
}
/**
* Reports the current sink count.
* Called 3 seconds after the dialog is initially opened.
......
......@@ -157,6 +157,15 @@ cr.define('media_router.browserApi', function() {
chrome.send('reportClickedSinkIndex', [sinkIndex]);
}
/**
* Reports the navigation to the specified view.
*
* @param {string} view
*/
function reportNavigateToView(view) {
chrome.send('reportNavigateToView', [view]);
}
/**
* Reports the cast mode that the user selected.
*
......@@ -201,6 +210,7 @@ cr.define('media_router.browserApi', function() {
closeRoute: closeRoute,
onInitialDataReceived: onInitialDataReceived,
reportClickedSinkIndex: reportClickedSinkIndex,
reportNavigateToView: reportNavigateToView,
reportSelectedCastMode: reportSelectedCastMode,
reportSinkCount: reportSinkCount,
requestInitialData: requestInitialData,
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/logging.h"
#include "base/metrics/user_metrics.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/media/router/media_router_factory.h"
#include "chrome/browser/media/router/media_router_mojo_impl.h"
......@@ -86,6 +87,8 @@ void MediaRouterContextualMenu::ExecuteCommand(int command_id,
break;
case IDC_MEDIA_ROUTER_HELP:
chrome::ShowSingletonTab(browser_, GURL(kCastHelpCenterPageUrl));
base::RecordAction(base::UserMetricsAction(
"MediaRouter_Ui_Navigate_Help"));
break;
case IDC_MEDIA_ROUTER_LEARN_MORE:
chrome::ShowSingletonTab(browser_, GURL(kCastLearnMorePageUrl));
......
......@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/media/router/issue.h"
#include "chrome/browser/ui/webui/media_router/media_router_ui.h"
......@@ -30,6 +31,7 @@ const char kActOnIssue[] = "actOnIssue";
const char kCloseRoute[] = "closeRoute";
const char kCloseDialog[] = "closeDialog";
const char kReportClickedSinkIndex[] = "reportClickedSinkIndex";
const char kReportNavigateToView[] = "reportNavigateToView";
const char kReportSelectedCastMode[] = "reportSelectedCastMode";
const char kReportSinkCount[] = "reportSinkCount";
const char kOnInitialDataReceived[] = "onInitialDataReceived";
......@@ -259,6 +261,10 @@ void MediaRouterWebUIMessageHandler::RegisterMessages() {
kReportSelectedCastMode,
base::Bind(&MediaRouterWebUIMessageHandler::OnReportSelectedCastMode,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
kReportNavigateToView,
base::Bind(&MediaRouterWebUIMessageHandler::OnReportNavigateToView,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
kReportSinkCount,
base::Bind(&MediaRouterWebUIMessageHandler::OnReportSinkCount,
......@@ -408,6 +414,27 @@ void MediaRouterWebUIMessageHandler::OnReportClickedSinkIndex(
std::min(index, 100));
}
void MediaRouterWebUIMessageHandler::OnReportNavigateToView(
const base::ListValue* args) {
DVLOG(1) << "OnReportNavigateToView";
std::string view;
if (!args->GetString(0, &view)) {
DVLOG(1) << "Unable to extract args.";
return;
}
if (view == "cast-mode-list") {
base::RecordAction(base::UserMetricsAction(
"MediaRouter_Ui_Navigate_SinkListToSource"));
} else if (view == "route-details") {
base::RecordAction(base::UserMetricsAction(
"MediaRouter_Ui_Navigate_SinkListToRouteDetails"));
} else if (view == "sink-list") {
base::RecordAction(base::UserMetricsAction(
"MediaRouter_Ui_Navigate_RouteDetailsToSinkList"));
}
}
void MediaRouterWebUIMessageHandler::OnReportSelectedCastMode(
const base::ListValue* args) {
DVLOG(1) << "OnReportSelectedCastMode";
......
......@@ -59,6 +59,7 @@ class MediaRouterWebUIMessageHandler : public content::WebUIMessageHandler {
void OnCloseRoute(const base::ListValue* args);
void OnCloseDialog(const base::ListValue* args);
void OnReportClickedSinkIndex(const base::ListValue* args);
void OnReportNavigateToView(const base::ListValue* args);
void OnReportSelectedCastMode(const base::ListValue* args);
void OnReportSinkCount(const base::ListValue* args);
void OnInitialDataReceived(const base::ListValue* args);
......
......@@ -7770,6 +7770,38 @@ should be able to be added at any place in this file.
</description>
</action>
<action name="MediaRouter_Ui_Navigate_Help">
<owner>apacible@chromium.org</owner>
<description>
User clicked the Media Router help menu item, located on the Media Router
contextual menu, to open the Cast help page.
</description>
</action>
<action name="MediaRouter_Ui_Navigate_RouteDetailsToSinkList">
<owner>apacible@chromium.org</owner>
<description>
User explicitly clicked the back button from the route details view to
navigate to the sink list view.
</description>
</action>
<action name="MediaRouter_Ui_Navigate_SinkListToRouteDetails">
<owner>apacible@chromium.org</owner>
<description>
User explicitly clicked a sink to navigate to the route details view from
the sink list view.
</description>
</action>
<action name="MediaRouter_Ui_Navigate_SinkListToSource">
<owner>apacible@chromium.org</owner>
<description>
User explicitly clicked to navigate from the sink view to the cast mode
view.
</description>
</action>
<action name="Menu_Take_Screenshot">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<description>Please enter the description of this user action.</description>
......
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