1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
|
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/app_list/app_list_metrics.h"
#include <algorithm>
#include <string>
#include "ash/app_list/app_list_controller_impl.h"
#include "ash/app_list/app_list_model_provider.h"
#include "ash/app_list/model/app_list_folder_item.h"
#include "ash/app_list/model/app_list_item.h"
#include "ash/app_list/model/app_list_item_list.h"
#include "ash/app_list/views/continue_section_view.h"
#include "ash/constants/ash_features.h"
#include "ash/public/cpp/app_list/app_list_types.h"
#include "ash/public/cpp/app_menu_constants.h"
#include "ash/shell.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "ui/compositor/compositor.h"
namespace ash {
// The number of files removed from the continue section during this session.
int g_continue_file_removals_in_session = 0;
// The UMA histogram that logs smoothness of pagination animation.
constexpr char kPaginationTransitionAnimationSmoothnessInTablet[] =
"Apps.PaginationTransition.AnimationSmoothness.TabletMode";
// The UMA histogram that logs smoothness of cardified animation.
constexpr char kCardifiedStateAnimationSmoothnessEnter[] =
"Apps.AppList.CardifiedStateAnimation.AnimationSmoothness."
"EnterCardifiedState";
constexpr char kCardifiedStateAnimationSmoothnessExit[] =
"Apps.AppList.CardifiedStateAnimation.AnimationSmoothness."
"ExitCardifiedState";
// The UMA histogram that logs user's decision (remove or cancel) for search
// result removal confirmation. Result removal is enabled outside zero state
// search.
constexpr char kSearchResultRemovalDialogDecisionHistogram[] =
"Apps.AppList.SearchResultRemovalDecision";
// The base UMA histogram that logs app launches within the HomeLauncher (tablet
// mode AppList) and the Shelf.
constexpr char kAppListAppLaunched[] = "Apps.AppListAppLaunchedV2";
// UMA histograms that log app launches within the app list, and the shelf.
// Split depending on whether tablet mode is active or not.
constexpr char kAppLaunchInTablet[] = "Apps.AppList.AppLaunched.TabletMode";
constexpr char kAppLaunchInClamshell[] =
"Apps.AppList.AppLaunched.ClamshellMode";
// UMA histograms that log launcher workflow actions (launching an app, search
// result, or a continue section task) in the app list UI. Split depending on
// whether tablet mode is active or not. Note that unlike `kAppListAppLaunched`
// histograms, these do not include actions from shelf, but do include non-app
// launch actions.
constexpr char kLauncherUserActionInTablet[] =
"Apps.AppList.UserAction.TabletMode";
constexpr char kLauncherUserActionInClamshell[] =
"Apps.AppList.UserAction.ClamshellMode";
// UMA histograms that log time elapsed from launcher getting shown at the time
// of an user taking a launcher workflow action (launching an app, search
// result, or a continue section task) in the app list UI. Split depending on
// whether tablet mode is active or not.
constexpr char kTimeToLauncherUserActionInTablet[] =
"Apps.AppList.TimeToUserAction.TabletMode";
constexpr char kTimeToLauncherUserActionInClamshell[] =
"Apps.AppList.TimeToUserAction.ClamshellMode";
// The UMA histograms that log app launches within the AppList, AppListBubble
// and Shelf. The app launches are divided by histogram for each of the the
// different AppList states.
constexpr char kAppListAppLaunchedBubbleAllApps[] =
"Apps.AppListAppLaunchedV2.BubbleAllApps";
constexpr char kAppListAppLaunchedClosed[] = "Apps.AppListAppLaunchedV2.Closed";
constexpr char kAppListAppLaunchedFullscreenAllApps[] =
"Apps.AppListAppLaunchedV2.FullscreenAllApps";
constexpr char kAppListAppLaunchedFullscreenSearch[] =
"Apps.AppListAppLaunchedV2.FullscreenSearch";
constexpr char kAppListAppLaunchedHomecherClosed[] =
"Apps.AppListAppLaunchedV2.HomecherClosed";
constexpr char kAppListAppLaunchedHomecherAllApps[] =
"Apps.AppListAppLaunchedV2.HomecherAllApps";
constexpr char kAppListAppLaunchedHomecherSearch[] =
"Apps.AppListAppLaunchedV2.HomecherSearch";
// UMA histograms for app list sort reorder.
constexpr char kClamshellReorderAnimationSmoothnessHistogram[] =
"Apps.Launcher.ProductivityReorderAnimationSmoothness.ClamshellMode";
constexpr char kTabletReorderAnimationSmoothnessHistogram[] =
"Apps.Launcher.ProductivityReorderAnimationSmoothness.TabletMode";
constexpr char kClamshellReorderActionHistogram[] =
"Apps.Launcher.ProductivityReorderAction.ClamshellMode";
constexpr char kTabletReorderActionHistogram[] =
"Apps.Launcher.ProductivityReorderAction.TabletMode";
// UMA histograms for app list drag reorder.
constexpr char kClamshellDragReorderAnimationSmoothnessHistogram[] =
"Apps.Launcher.DragReorderAnimationSmoothness.ClamshellMode";
constexpr char kTabletDragReorderAnimationSmoothnessHistogram[] =
"Apps.Launcher.DragReorderAnimationSmoothness.TabletMode";
// The prefix for all the variants that track how long the app list is kept
// open by open method. Suffix is decided in `GetAppListOpenMethod`
constexpr char kAppListOpenTimePrefix[] = "Apps.AppListOpenTime.";
constexpr char kContinueSectionFilesRemovedInSessionHistogram[] =
"Apps.AppList.Search.ContinueSectionFilesRemovedPerSession";
AppLaunchedMetricParams::AppLaunchedMetricParams() = default;
AppLaunchedMetricParams::AppLaunchedMetricParams(
const AppLaunchedMetricParams&) = default;
AppLaunchedMetricParams& AppLaunchedMetricParams::operator=(
const AppLaunchedMetricParams&) = default;
AppLaunchedMetricParams::AppLaunchedMetricParams(
AppListLaunchedFrom launched_from,
AppListLaunchType launch_type)
: launched_from(launched_from), launch_type(launch_type) {}
AppLaunchedMetricParams::~AppLaunchedMetricParams() = default;
void AppListRecordPageSwitcherSourceByEventType(ui::EventType type) {
AppListPageSwitcherSource source;
switch (type) {
case ui::ET_MOUSEWHEEL:
source = kMouseWheelScroll;
break;
case ui::ET_SCROLL:
source = kMousePadScroll;
break;
case ui::ET_GESTURE_SCROLL_END:
source = kSwipeAppGrid;
break;
case ui::ET_SCROLL_FLING_START:
source = kFlingAppGrid;
break;
case ui::ET_MOUSE_RELEASED:
source = kMouseDrag;
break;
default:
NOTREACHED();
return;
}
RecordPageSwitcherSource(source);
}
void RecordPageSwitcherSource(AppListPageSwitcherSource source) {
UMA_HISTOGRAM_ENUMERATION("Apps.AppListPageSwitcherSource", source,
kMaxAppListPageSwitcherSource);
}
void RecordSearchResultRemovalDialogDecision(
SearchResultRemovalConfirmation removal_decision) {
base::UmaHistogramEnumeration(kSearchResultRemovalDialogDecisionHistogram,
removal_decision);
}
std::string GetAppListOpenMethod(AppListShowSource source) {
// This switch determines which metric we submit for the Apps.AppListOpenTime
// metric. Adding a string requires you update the apps histogram.xml as well.
switch (source) {
case AppListShowSource::kSearchKey:
case AppListShowSource::kSearchKeyFullscreen_DEPRECATED:
return "SearchKey";
case AppListShowSource::kShelfButton:
case AppListShowSource::kShelfButtonFullscreen_DEPRECATED:
return "HomeButton";
case AppListShowSource::kSwipeFromShelf:
return "Swipe";
case AppListShowSource::kScrollFromShelf:
return "Scroll";
case AppListShowSource::kTabletMode:
case AppListShowSource::kAssistantEntryPoint:
case AppListShowSource::kBrowser:
case AppListShowSource::kWelcomeTour:
return "Others";
}
NOTREACHED();
}
void RecordAppListUserJourneyTime(AppListShowSource source,
base::TimeDelta time) {
base::UmaHistogramMediumTimes(
kAppListOpenTimePrefix + GetAppListOpenMethod(source), time);
}
void RecordPeriodicAppListMetrics() {
int number_of_apps_in_launcher = 0;
int number_of_root_level_items = 0;
int number_of_folders = 0;
int number_of_non_system_folders = 0;
int number_of_apps_in_non_system_folders = 0;
AppListModel* const model = AppListModelProvider::Get()->model();
AppListItemList* const item_list = model->top_level_item_list();
for (size_t i = 0; i < item_list->item_count(); ++i) {
AppListItem* item = item_list->item_at(i);
number_of_root_level_items++;
// Item is a folder.
if (item->GetItemType() == AppListFolderItem::kItemType) {
AppListFolderItem* folder = static_cast<AppListFolderItem*>(item);
number_of_apps_in_launcher += folder->item_list()->item_count();
number_of_folders++;
// Ignore the OEM folder and the "Linux apps" folder because those folders
// are automatically created. The following metrics are trying to measure
// how often users engage with folders that they created themselves.
if (folder->IsSystemFolder())
continue;
number_of_apps_in_non_system_folders += folder->item_list()->item_count();
number_of_non_system_folders++;
continue;
}
// Item is an app that isn't in a folder.
number_of_apps_in_launcher++;
}
UMA_HISTOGRAM_COUNTS_100("Apps.AppList.NumberOfApps",
number_of_apps_in_launcher);
UMA_HISTOGRAM_COUNTS_100("Apps.AppList.NumberOfRootLevelItems",
number_of_root_level_items);
UMA_HISTOGRAM_COUNTS_100("Apps.AppList.NumberOfFolders", number_of_folders);
UMA_HISTOGRAM_COUNTS_100("Apps.AppList.NumberOfNonSystemFolders",
number_of_non_system_folders);
UMA_HISTOGRAM_COUNTS_100("Apps.AppList.NumberOfAppsInNonSystemFolders",
number_of_apps_in_non_system_folders);
}
void RecordAppListAppLaunched(AppListLaunchedFrom launched_from,
AppListViewState app_list_state,
bool is_tablet_mode,
bool app_list_shown) {
UMA_HISTOGRAM_ENUMERATION(kAppListAppLaunched, launched_from);
if (is_tablet_mode) {
base::UmaHistogramEnumeration(kAppLaunchInTablet, launched_from);
} else {
base::UmaHistogramEnumeration(kAppLaunchInClamshell, launched_from);
}
if (!is_tablet_mode) {
if (!app_list_shown) {
UMA_HISTOGRAM_ENUMERATION(kAppListAppLaunchedClosed, launched_from);
} else {
// TODO(newcomer): Handle the case where search is open.
UMA_HISTOGRAM_ENUMERATION(kAppListAppLaunchedBubbleAllApps,
launched_from);
}
return;
}
switch (app_list_state) {
case AppListViewState::kClosed:
// The app list state may be set to closed while the device is animating
// to tablet mode. While this transition is running, a user may be able to
// launch an app.
DCHECK_EQ(launched_from, AppListLaunchedFrom::kLaunchedFromShelf);
UMA_HISTOGRAM_ENUMERATION(kAppListAppLaunchedClosed, launched_from);
break;
case AppListViewState::kFullscreenAllApps:
if (is_tablet_mode) {
if (app_list_shown) {
UMA_HISTOGRAM_ENUMERATION(kAppListAppLaunchedHomecherAllApps,
launched_from);
} else {
UMA_HISTOGRAM_ENUMERATION(kAppListAppLaunchedHomecherClosed,
launched_from);
}
} else {
UMA_HISTOGRAM_ENUMERATION(kAppListAppLaunchedFullscreenAllApps,
launched_from);
}
break;
case AppListViewState::kFullscreenSearch:
if (is_tablet_mode) {
if (app_list_shown) {
UMA_HISTOGRAM_ENUMERATION(kAppListAppLaunchedHomecherSearch,
launched_from);
} else {
// (http://crbug.com/947729) Search box still expanded when opening
// launcher in tablet mode
UMA_HISTOGRAM_ENUMERATION(kAppListAppLaunchedHomecherClosed,
launched_from);
}
} else {
UMA_HISTOGRAM_ENUMERATION(kAppListAppLaunchedFullscreenSearch,
launched_from);
}
break;
}
}
ASH_EXPORT void RecordLauncherWorkflowMetrics(
AppListUserAction action,
bool is_tablet_mode,
absl::optional<base::TimeTicks> launcher_show_time) {
if (is_tablet_mode) {
base::UmaHistogramEnumeration(kLauncherUserActionInTablet, action);
if (launcher_show_time) {
base::UmaHistogramMediumTimes(
kTimeToLauncherUserActionInTablet,
base::TimeTicks::Now() - *launcher_show_time);
}
} else {
base::UmaHistogramEnumeration(kLauncherUserActionInClamshell, action);
if (launcher_show_time) {
base::UmaHistogramMediumTimes(
kTimeToLauncherUserActionInClamshell,
base::TimeTicks::Now() - *launcher_show_time);
}
}
}
bool IsCommandIdAnAppLaunch(int command_id_number) {
CommandId command_id = static_cast<CommandId>(command_id_number);
// Consider all platform app menu options as launches.
if (command_id >= CommandId::EXTENSIONS_CONTEXT_CUSTOM_FIRST &&
command_id < CommandId::EXTENSIONS_CONTEXT_CUSTOM_LAST) {
return true;
}
// Consider all arc app shortcut options as launches.
if (command_id >= CommandId::LAUNCH_APP_SHORTCUT_FIRST &&
command_id < CommandId::LAUNCH_APP_SHORTCUT_LAST) {
return true;
}
// All app menu items in a ShelfApplicationMenuModel are not launches.
if (command_id >= CommandId::APP_MENU_ITEM_ID_FIRST &&
command_id < CommandId::APP_MENU_ITEM_ID_LAST) {
return false;
}
switch (command_id) {
// Used by AppContextMenu and/or ShelfContextMenu.
case CommandId::LAUNCH_NEW:
case CommandId::SHOW_APP_INFO:
case CommandId::OPTIONS:
case CommandId::APP_CONTEXT_MENU_NEW_WINDOW:
case CommandId::APP_CONTEXT_MENU_NEW_INCOGNITO_WINDOW:
case CommandId::SETTINGS:
// Used by both AppContextMenu and ShelfContextMenu for app shortcuts.
case CommandId::LAUNCH_APP_SHORTCUT_FIRST:
case CommandId::LAUNCH_APP_SHORTCUT_LAST:
return true;
// Used by ShelfContextMenu (shelf).
case CommandId::MENU_CLOSE:
case CommandId::SWAP_WITH_NEXT:
case CommandId::SWAP_WITH_PREVIOUS:
// Used by AppMenuModelAdapter
case CommandId::NOTIFICATION_CONTAINER:
// Used by CrostiniShelfContextMenu.
case CommandId::CROSTINI_USE_LOW_DENSITY:
case CommandId::CROSTINI_USE_HIGH_DENSITY:
// Used by AppContextMenu.
case CommandId::TOGGLE_PIN:
case CommandId::UNINSTALL:
case CommandId::REMOVE_FROM_FOLDER:
case CommandId::INSTALL:
case CommandId::USE_LAUNCH_TYPE_REGULAR:
case CommandId::USE_LAUNCH_TYPE_WINDOW:
case CommandId::USE_LAUNCH_TYPE_TABBED_WINDOW:
case CommandId::USE_LAUNCH_TYPE_COMMAND_END:
case CommandId::REORDER_SUBMENU:
case CommandId::REORDER_BY_NAME_ALPHABETICAL:
case CommandId::REORDER_BY_NAME_REVERSE_ALPHABETICAL:
case CommandId::REORDER_BY_COLOR:
case CommandId::SHUTDOWN_GUEST_OS:
case CommandId::EXTENSIONS_CONTEXT_CUSTOM_FIRST:
case CommandId::EXTENSIONS_CONTEXT_CUSTOM_LAST:
case CommandId::COMMAND_ID_COUNT:
// Used by ShelfApplicationMenuModel.
case CommandId::APP_MENU_ITEM_ID_FIRST:
case CommandId::APP_MENU_ITEM_ID_LAST:
return false;
case CommandId::DEPRECATED_MENU_OPEN_NEW:
case CommandId::DEPRECATED_MENU_PIN:
case CommandId::DEPRECATED_MENU_NEW_WINDOW:
case CommandId::DEPRECATED_MENU_NEW_INCOGNITO_WINDOW:
case CommandId::DEPRECATED_LAUNCH_TYPE_PINNED_TAB:
case CommandId::DEPRECATED_LAUNCH_TYPE_REGULAR_TAB:
case CommandId::DEPRECATED_LAUNCH_TYPE_WINDOW:
case CommandId::DEPRECATED_LAUNCH_TYPE_TABBED_WINDOW:
case CommandId::DEPRECATED_LAUNCH_TYPE_FULLSCREEN:
case CommandId::DEPRECATED_USE_LAUNCH_TYPE_PINNED:
case CommandId::DEPRECATED_USE_LAUNCH_TYPE_FULLSCREEN:
NOTREACHED();
return false;
}
NOTREACHED();
return false;
}
void ReportPaginationSmoothness(int smoothness) {
UMA_HISTOGRAM_PERCENTAGE(kPaginationTransitionAnimationSmoothnessInTablet,
smoothness);
}
void ReportCardifiedSmoothness(bool is_entering_cardified, int smoothness) {
if (is_entering_cardified) {
UMA_HISTOGRAM_PERCENTAGE(kCardifiedStateAnimationSmoothnessEnter,
smoothness);
} else {
UMA_HISTOGRAM_PERCENTAGE(kCardifiedStateAnimationSmoothnessExit,
smoothness);
}
}
// Reports reorder animation smoothness.
void ReportReorderAnimationSmoothness(bool in_tablet, int smoothness) {
if (in_tablet) {
base::UmaHistogramPercentage(kTabletReorderAnimationSmoothnessHistogram,
smoothness);
} else {
base::UmaHistogramPercentage(kClamshellReorderAnimationSmoothnessHistogram,
smoothness);
}
}
void RecordAppListSortAction(AppListSortOrder new_order, bool in_tablet) {
// NOTE: (1) kNameReverseAlphabetical is not used for now; (2) Resetting the
// sort order is not recorded here.
DCHECK(new_order != AppListSortOrder::kNameReverseAlphabetical &&
new_order != AppListSortOrder::kCustom);
if (in_tablet)
base::UmaHistogramEnumeration(kTabletReorderActionHistogram, new_order);
else
base::UmaHistogramEnumeration(kClamshellReorderActionHistogram, new_order);
}
void ReportItemDragReorderAnimationSmoothness(bool in_tablet, int smoothness) {
if (in_tablet) {
base::UmaHistogramPercentage(kTabletDragReorderAnimationSmoothnessHistogram,
smoothness);
} else {
base::UmaHistogramPercentage(
kClamshellDragReorderAnimationSmoothnessHistogram, smoothness);
}
}
void RecordMetricsOnSessionEnd() {
if (ContinueSectionView::EnableContinueSectionFileRemovalMetrics() &&
g_continue_file_removals_in_session == 0) {
base::UmaHistogramCounts100(kContinueSectionFilesRemovedInSessionHistogram,
0);
}
}
void RecordCumulativeContinueSectionResultRemovedNumber() {
base::UmaHistogramCounts100(kContinueSectionFilesRemovedInSessionHistogram,
++g_continue_file_removals_in_session);
}
void ResetContinueSectionFileRemovedCountForTest() {
g_continue_file_removals_in_session = 0;
}
void RecordHideContinueSectionMetric() {
const bool hide_continue_section =
Shell::Get()->app_list_controller()->ShouldHideContinueSection();
if (Shell::Get()->IsInTabletMode()) {
base::UmaHistogramBoolean(
"Apps.AppList.ContinueSectionHiddenByUser.TabletMode",
hide_continue_section);
} else {
base::UmaHistogramBoolean(
"Apps.AppList.ContinueSectionHiddenByUser.ClamshellMode",
hide_continue_section);
}
}
} // namespace ash
|