Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Unified Diff: chrome/browser/android/banners/app_banner_infobar_delegate_android.cc

Issue 2301263004: Add WebAPK installation metrics. (Closed)
Patch Set: Update the metrics. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
diff --git a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
index 8c444f7b09c38655b8de3be43dfea1589e6e9dad..78eda1bf946c3f4d9cd10fd4199e731c5a3a0a8a 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
@@ -43,6 +43,15 @@ bool IsInfoEmpty(const ShortcutInfo* info) {
return !info || info->url.is_empty();
}
+void TrackWebApkInstallationDismissEvents(webapk::InstallState install_state) {
+ if (install_state == webapk::WAIT_FOR_START)
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_ADD_TO_HOME_SCREEN_DISMISS);
+ else if (install_state == webapk::INSTALLING)
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_ADDING_DISMISS);
dominickn 2016/09/09 08:14:11 Why is this method recording metrics in two differ
Xi Han 2016/09/09 15:37:32 Because the first two are recorded in the INSTALL_
+ else if (install_state == webapk::INSTALLED)
+ webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN_DISMISS);
+}
+
} // anonymous namespace
namespace banners {
@@ -71,8 +80,14 @@ bool AppBannerInfoBarDelegateAndroid::Create(
->AddInfoBar(std::move(infobar)))
return false;
- if (is_webapk && start_install_webapk)
- raw_delegate->AcceptWebApk(web_contents);
+ if (is_webapk) {
+ if (start_install_webapk) {
+ raw_delegate->AcceptWebApk(web_contents);
+ webapk::TrackStartType(webapk::STARTED_FROM_ADD_TO_HOME_SCREEN_MENU);
+ } else {
+ webapk::TrackStartType(webapk::TRIGGERED_FROM_BANNER);
+ }
+ }
return true;
}
@@ -99,10 +114,13 @@ AppBannerInfoBarDelegateAndroid::~AppBannerInfoBarDelegateAndroid() {
weak_ptr_factory_.InvalidateWeakPtrs();
if (!has_user_interaction_) {
- if (!native_app_data_.is_null())
+ if (!native_app_data_.is_null()) {
TrackUserResponse(USER_RESPONSE_NATIVE_APP_IGNORED);
- else if (!IsInfoEmpty(shortcut_info_.get()))
+ } else if (!IsInfoEmpty(shortcut_info_.get())) {
TrackUserResponse(USER_RESPONSE_WEB_APP_IGNORED);
+ if (is_webapk_)
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_BANNER_IGNORED);
+ }
}
TrackDismissEvent(DISMISS_EVENT_DISMISSED);
@@ -180,6 +198,7 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
// the "Open" button is pressed, then open the installed WebAPK.
if (webapk_package_name_.empty()) {
// Request install the WebAPK.
+ install_state_ = webapk::INSTALLING;
TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
AppBannerSettingsHelper::RecordBannerInstallEvent(
@@ -209,6 +228,7 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
java_webapk_package_name);
SendBannerAccepted(web_contents, "web");
+ webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN);
return true;
}
@@ -294,6 +314,8 @@ void AppBannerInfoBarDelegateAndroid::InfoBarDismissed() {
AppBannerSettingsHelper::RecordBannerDismissEvent(
web_contents, native_app_package_, AppBannerSettingsHelper::NATIVE);
} else if (!IsInfoEmpty(shortcut_info_.get())) {
+ if (is_webapk_)
+ TrackWebApkInstallationDismissEvents(install_state_);
TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED);
AppBannerSettingsHelper::RecordBannerDismissEvent(
web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
@@ -318,12 +340,14 @@ bool AppBannerInfoBarDelegateAndroid::Accept() {
return true;
}
- if (!native_app_data_.is_null())
+ if (!native_app_data_.is_null()) {
return AcceptNativeApp(web_contents);
- else if (is_webapk_)
+ } else if (is_webapk_) {
+ webapk::TrackStartType(webapk::STARTED_FROM_BANNER);
return AcceptWebApk(web_contents);
- else
+ } else {
return AcceptWebApp(web_contents);
+ }
}
bool AppBannerInfoBarDelegateAndroid::AcceptNativeApp(
@@ -383,6 +407,7 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
infobar()->RemoveSelf();
Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env);
DVLOG(1) << "The WebAPK installation failed.";
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_FAILED);
return;
}
@@ -394,6 +419,8 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName(
env, java_delegate_, java_webapk_package_name);
UpdateInstallState(env, nullptr);
+ install_state_ = webapk::INSTALLED;
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_COMPLETED);
}
bool AppBannerInfoBarDelegateAndroid::LinkClicked(
« no previous file with comments | « chrome/browser/android/banners/app_banner_infobar_delegate_android.h ('k') | chrome/browser/android/webapk/webapk_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698