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

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

Issue 2301263004: Add WebAPK installation metrics. (Closed)
Patch Set: Rebase. 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 24b1523948bec8f5c58a8083c549c6c793d37c5c..e9fe2be1ee8cfda6284fca862f48283c9d33ced6 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
@@ -43,8 +43,17 @@ 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);
+ else if (install_state == webapk::INSTALLED)
+ webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN_DISMISS);
}
+} // namespace
+
namespace banners {
// static
@@ -69,8 +78,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;
}
@@ -96,10 +111,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);
@@ -176,12 +194,13 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
base::android::ConvertUTF8ToJavaString(env, webapk_package_name_);
Java_AppBannerInfoBarDelegateAndroid_openWebApk(env, java_delegate_,
java_webapk_package_name);
-
+ webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN);
SendBannerAccepted(web_contents, "web");
return true;
}
// Request install the WebAPK.
+ install_state_ = webapk::INSTALLING;
TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
AppBannerSettingsHelper::RecordBannerInstallEvent(
web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
@@ -281,6 +300,8 @@ void AppBannerInfoBarDelegateAndroid::InfoBarDismissed() {
AppBannerSettingsHelper::RecordBannerDismissEvent(
web_contents, native_app_package_, AppBannerSettingsHelper::NATIVE);
} else {
+ if (is_webapk_)
+ TrackWebApkInstallationDismissEvents(install_state_);
TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED);
AppBannerSettingsHelper::RecordBannerDismissEvent(
web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
@@ -308,8 +329,10 @@ bool AppBannerInfoBarDelegateAndroid::Accept() {
if (!native_app_data_.is_null())
return AcceptNativeApp(web_contents);
- if (is_webapk_)
+ if (is_webapk_) {
+ webapk::TrackStartType(webapk::STARTED_FROM_BANNER);
dominickn 2016/09/09 08:14:11 Won't this metric be hit at least twice when the u
Xi Han 2016/09/09 15:37:32 No, it is only hit here, not by AppBannerInfoBarDe
return AcceptWebApk(web_contents);
+ }
return AcceptWebApp(web_contents);
}
@@ -368,6 +391,7 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
infobar()->RemoveSelf();
Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env);
DVLOG(1) << "The WebAPK installation failed.";
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_FAILED);
return;
}
@@ -379,6 +403,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(

Powered by Google App Engine
This is Rietveld 408576698