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

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

Issue 2301263004: Add WebAPK installation metrics. (Closed)
Patch Set: domnickn@'s comments. 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..ab44f3d1302e33e9d8db3d1e3e28f4fb89fccd8a 100644
--- a/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
+++ b/chrome/browser/android/banners/app_banner_infobar_delegate_android.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/android/shortcut_info.h"
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/android/webapk/webapk_installer.h"
+#include "chrome/browser/android/webapk/webapk_metrics.h"
#include "chrome/browser/banners/app_banner_manager.h"
#include "chrome/browser/banners/app_banner_metrics.h"
#include "chrome/browser/banners/app_banner_settings_helper.h"
@@ -43,8 +44,17 @@ bool IsInfoEmpty(const ShortcutInfo* info) {
return !info || info->url.is_empty();
}
+void TrackWebApkInstallationDismissEvents(banners::InstallState install_state) {
dominickn 2016/09/19 01:38:39 As per comment in the .h file, consider making thi
Xi Han 2016/09/20 18:25:18 Done.
+ if (install_state == banners::WAIT_FOR_START)
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_ADD_TO_HOME_SCREEN_DISMISS);
dominickn 2016/09/19 01:38:39 Won't you be in the WAIT_FOR_START state if you tr
Xi Han 2016/09/20 18:25:18 Rename it to DISMISS_BEFORE_INSTALLATION.
+ else if (install_state == banners::INSTALLING)
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_ADDING_DISMISS);
+ else if (install_state == banners::INSTALLED)
+ webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN_DISMISS);
}
+} // namespace
+
namespace banners {
// static
@@ -69,8 +79,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);
dominickn 2016/09/19 01:38:39 See comment in webapk_metrics.h
Xi Han 2016/09/20 18:25:18 Done.
+ }
+ }
return true;
}
@@ -96,10 +112,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 +195,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;
dominickn 2016/09/19 01:38:39 If a user already has the WebAPK installed, it see
Xi Han 2016/09/20 18:25:18 This is a good point. I add "has_user_interaction_
dominickn 2016/09/21 06:54:27 This seems reasonable to me.
}
// Request install the WebAPK.
+ install_state_ = INSTALLING;
TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
AppBannerSettingsHelper::RecordBannerInstallEvent(
web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
@@ -216,6 +236,7 @@ AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
event_request_id_(event_request_id),
has_user_interaction_(false),
is_webapk_(is_webapk),
+ install_state_(WAIT_FOR_START),
weak_ptr_factory_(this) {
DCHECK(!IsInfoEmpty(shortcut_info_.get()));
CreateJavaDelegate();
@@ -281,6 +302,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 +331,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);
return AcceptWebApk(web_contents);
+ }
return AcceptWebApp(web_contents);
}
@@ -368,6 +393,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 +405,8 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName(
env, java_delegate_, java_webapk_package_name);
UpdateInstallState(env, nullptr);
+ install_state_ = INSTALLED;
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_COMPLETED);
}
bool AppBannerInfoBarDelegateAndroid::LinkClicked(

Powered by Google App Engine
This is Rietveld 408576698