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

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

Issue 2301263004: Add WebAPK installation metrics. (Closed)
Patch Set: 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 9736a200bc5e7588687f4323c8a9658c57bc02a9..460798eaee81ace7b16bcb4d146d22b2506d3bc6 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,6 +44,15 @@ bool IsInfoEmpty(const ShortcutInfo* info) {
return !info || info->url.is_empty();
}
+void TrackWebApkDismissEvents(banners::InstallState install_state) {
+ if (install_state == banners::WAIT_FOR_START)
+ webapk::TrackDismissEvent(webapk::DISMISS_EVENT_ADD_TO_HOMESCREEN);
+ else if (install_state == banners::INSTALLING)
+ webapk::TrackDismissEvent(webapk::DISMISS_EVENT_ADDING);
+ else if (install_state == banners::INSTALLED)
+ webapk::TrackDismissEvent(webapk::DISMISS_EVENT_OPEN);
+}
+
} // anonymous namespace
namespace banners {
@@ -65,6 +75,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();
@@ -93,10 +104,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::TrackUserAction(webapk::USER_ACTION_BANNER_IGNORED);
+ }
}
TrackDismissEvent(DISMISS_EVENT_DISMISSED);
@@ -169,6 +183,9 @@ void AppBannerInfoBarDelegateAndroid::InstallWebApk(
<< "the associated WebContents is null.";
return;
}
+ install_state_ = INSTALLING;
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_ADD_FROM_MENU_STARTED);
+ webapk::TrackUserAction(webapk::USER_ACTION_ADD_FROM_MENU);
AcceptWebApk(web_contents);
}
@@ -216,6 +233,8 @@ void AppBannerInfoBarDelegateAndroid::InfoBarDismissed() {
AppBannerSettingsHelper::RecordBannerDismissEvent(
web_contents, native_app_package_, AppBannerSettingsHelper::NATIVE);
} else if (!IsInfoEmpty(shortcut_info_.get())) {
+ if (is_webapk_)
+ TrackWebApkDismissEvents(install_state_);
TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED);
AppBannerSettingsHelper::RecordBannerDismissEvent(
web_contents, shortcut_info_->url.spec(),
@@ -244,6 +263,8 @@ bool AppBannerInfoBarDelegateAndroid::Accept() {
if (!native_app_data_.is_null()) {
return AcceptNativeApp(web_contents);
} else if (is_webapk_) {
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_ADD_FROM_BANNER_STARTED);
+ webapk::TrackUserAction(webapk::USER_ACTION_ADD_FROM_BANNER_ACCEPTED);
return AcceptWebApk(web_contents);
}
return AcceptWebApp(web_contents);
@@ -309,6 +330,7 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
// button is pressed, so request WebAPK installation. Otherwise, it means
// the "Open" button is pressed, then open the installed WebAPK.
if (webapk_package_name_.empty()) {
+ install_state_ = INSTALLING;
// Request install the WebAPK.
TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
@@ -340,6 +362,7 @@ bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
env, java_delegate_, java_webapk_package_name);
SendBannerAccepted(web_contents, "web");
+ webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN);
return true;
}
@@ -352,7 +375,7 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
if (infobar())
infobar()->RemoveSelf();
Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env);
- DVLOG(1) << "The WebAPK installation failed.";
dominickn 2016/09/05 07:34:31 Not sure if you want to remove the DVLOG here - re
Xi Han 2016/09/07 20:58:52 Good point, add the LOG back.
+ webapk::TrackInstallEvent(webapk::INSTALL_EVENT_FAILED);
return;
}
@@ -364,6 +387,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