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
|
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/webapps/browser/installable/installable_metrics.h"
#include <atomic>
#include <ostream>
#include "base/check.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/time/time.h"
#include "components/webapps/browser/webapps_client.h"
#include "content/public/browser/service_worker_context.h"
namespace webapps {
std::ostream& operator<<(std::ostream& os, WebappInstallSource source) {
switch (source) {
case WebappInstallSource::MENU_BROWSER_TAB:
return os << "menu browser tab";
case WebappInstallSource::MENU_CUSTOM_TAB:
return os << "menu custom tab";
case WebappInstallSource::AUTOMATIC_PROMPT_BROWSER_TAB:
return os << "automatic prompt browser tab";
case WebappInstallSource::AUTOMATIC_PROMPT_CUSTOM_TAB:
return os << "automatic prompt custom tab";
case WebappInstallSource::API_BROWSER_TAB:
return os << "api browser tab";
case WebappInstallSource::API_CUSTOM_TAB:
return os << "api custom tab";
case WebappInstallSource::DEVTOOLS:
return os << "devtools";
case WebappInstallSource::MANAGEMENT_API:
return os << "management api";
case WebappInstallSource::AMBIENT_BADGE_BROWSER_TAB:
return os << "ambient badge browser tab";
case WebappInstallSource::AMBIENT_BADGE_CUSTOM_TAB:
return os << "ambient badge custom tab";
case WebappInstallSource::ARC:
return os << "arc";
case WebappInstallSource::INTERNAL_DEFAULT:
return os << "internal default";
case WebappInstallSource::EXTERNAL_DEFAULT:
return os << "external default";
case WebappInstallSource::EXTERNAL_POLICY:
return os << "external policy";
case WebappInstallSource::SYSTEM_DEFAULT:
return os << "system default";
case WebappInstallSource::OMNIBOX_INSTALL_ICON:
return os << "omnibox install icon";
case WebappInstallSource::SYNC:
return os << "sync";
case WebappInstallSource::MENU_CREATE_SHORTCUT:
return os << "menu create shortcut";
case WebappInstallSource::SUB_APP:
return os << "sub app";
case WebappInstallSource::CHROME_SERVICE:
return os << "chrome service";
case WebappInstallSource::RICH_INSTALL_UI_WEBLAYER:
return os << "rich install ui weblayer";
case WebappInstallSource::KIOSK:
return os << "kiosk";
case WebappInstallSource::ISOLATED_APP_DEV_INSTALL:
return os << "isolated app dev install";
case WebappInstallSource::EXTERNAL_LOCK_SCREEN:
return os << "external lock screen";
case WebappInstallSource::PRELOADED_OEM:
return os << "preloaded oem";
case WebappInstallSource::MICROSOFT_365_SETUP:
return os << "microsoft 365 setup";
case WebappInstallSource::PROFILE_MENU:
return os << "profile menu";
case WebappInstallSource::ML_PROMOTION:
return os << "ml promotion";
case WebappInstallSource::PRELOADED_DEFAULT:
return os << "preloaded default";
case WebappInstallSource::COUNT:
return os << "count";
}
}
// static
void InstallableMetrics::TrackInstallEvent(WebappInstallSource source) {
DCHECK(IsReportableInstallSource(source));
base::UmaHistogramEnumeration("Webapp.Install.InstallEvent", source,
WebappInstallSource::COUNT);
}
// static
bool InstallableMetrics::IsReportableInstallSource(WebappInstallSource source) {
switch (source) {
case WebappInstallSource::AMBIENT_BADGE_BROWSER_TAB:
case WebappInstallSource::AMBIENT_BADGE_CUSTOM_TAB:
case WebappInstallSource::API_BROWSER_TAB:
case WebappInstallSource::API_CUSTOM_TAB:
case WebappInstallSource::ARC:
case WebappInstallSource::AUTOMATIC_PROMPT_BROWSER_TAB:
case WebappInstallSource::AUTOMATIC_PROMPT_CUSTOM_TAB:
case WebappInstallSource::CHROME_SERVICE:
case WebappInstallSource::DEVTOOLS:
case WebappInstallSource::EXTERNAL_DEFAULT:
case WebappInstallSource::EXTERNAL_LOCK_SCREEN:
case WebappInstallSource::EXTERNAL_POLICY:
case WebappInstallSource::INTERNAL_DEFAULT:
case WebappInstallSource::KIOSK:
case WebappInstallSource::MENU_BROWSER_TAB:
case WebappInstallSource::MENU_CREATE_SHORTCUT:
case WebappInstallSource::MENU_CUSTOM_TAB:
case WebappInstallSource::MICROSOFT_365_SETUP:
case WebappInstallSource::ML_PROMOTION:
case WebappInstallSource::OMNIBOX_INSTALL_ICON:
case WebappInstallSource::PRELOADED_OEM:
case WebappInstallSource::PROFILE_MENU:
case WebappInstallSource::RICH_INSTALL_UI_WEBLAYER:
case WebappInstallSource::SYSTEM_DEFAULT:
case WebappInstallSource::PRELOADED_DEFAULT:
return true;
case WebappInstallSource::ISOLATED_APP_DEV_INSTALL:
case WebappInstallSource::MANAGEMENT_API:
case WebappInstallSource::SUB_APP:
case WebappInstallSource::SYNC:
return false;
case WebappInstallSource::COUNT:
NOTREACHED();
return false;
}
}
// static
WebappInstallSource InstallableMetrics::GetInstallSource(
content::WebContents* web_contents,
InstallTrigger trigger) {
return WebappsClient::Get()->GetInstallSource(web_contents, trigger);
}
// static
void InstallableMetrics::RecordCheckServiceWorkerTime(base::TimeDelta time) {
UMA_HISTOGRAM_MEDIUM_TIMES("Webapp.CheckServiceWorker.Time", time);
}
// static
void InstallableMetrics::RecordCheckServiceWorkerStatus(
ServiceWorkerOfflineCapability status) {
UMA_HISTOGRAM_ENUMERATION("Webapp.CheckServiceWorker.Status", status);
}
// static
ServiceWorkerOfflineCapability
InstallableMetrics::ConvertFromServiceWorkerCapability(
content::ServiceWorkerCapability capability) {
switch (capability) {
case content::ServiceWorkerCapability::SERVICE_WORKER_WITH_FETCH_HANDLER:
return ServiceWorkerOfflineCapability::kServiceWorkerWithOfflineSupport;
case content::ServiceWorkerCapability::SERVICE_WORKER_NO_FETCH_HANDLER:
return ServiceWorkerOfflineCapability::kServiceWorkerNoFetchHandler;
case content::ServiceWorkerCapability::NO_SERVICE_WORKER:
return ServiceWorkerOfflineCapability::kNoServiceWorker;
}
NOTREACHED();
}
// static
ServiceWorkerOfflineCapability InstallableMetrics::ConvertFromOfflineCapability(
content::OfflineCapability capability) {
switch (capability) {
case content::OfflineCapability::kSupported:
return ServiceWorkerOfflineCapability::kServiceWorkerWithOfflineSupport;
case content::OfflineCapability::kUnsupported:
return ServiceWorkerOfflineCapability::kServiceWorkerNoOfflineSupport;
}
NOTREACHED();
}
// static
void InstallableMetrics::TrackUninstallEvent(WebappUninstallSource source) {
base::UmaHistogramEnumeration("Webapp.Install.UninstallEvent", source);
}
// static
void InstallableMetrics::TrackInstallResult(bool result) {
base::UmaHistogramBoolean("WebApp.Install.Result", result);
}
} // namespace webapps
|