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

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

Issue 2301263004: Add WebAPK installation metrics. (Closed)
Patch Set: Another round of 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 c0b16e13fa8254362d3c237cd8218891e8845e9b..60318c0e22e147728ed04a535dcb65c790b261ee 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,7 +44,7 @@ bool IsInfoEmpty(const std::unique_ptr<ShortcutInfo>& info) {
return !info || info->url.is_empty();
}
-}
+} // namespace
namespace banners {
@@ -69,8 +70,17 @@ 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::TrackInstallTriggeredType(
+ webapk::TRIGGERED_FROM_ADD_TO_HOME_SCREEN_MENU);
+ webapk::TrackInstallStartType(
+ webapk::STARTED_FROM_ADD_TO_HOME_SCREEN_MENU);
+ } else {
+ webapk::TrackInstallTriggeredType(webapk::TRIGGERED_FROM_BANNER);
+ }
+ }
return true;
}
@@ -96,10 +106,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_))
+ } else {
TrackUserResponse(USER_RESPONSE_WEB_APP_IGNORED);
+ if (is_webapk_)
+ webapk::TrackInstallEvent(webapk::BANNER_IGNORED);
+ }
}
TrackDismissEvent(DISMISS_EVENT_DISMISSED);
@@ -162,6 +175,7 @@ void AppBannerInfoBarDelegateAndroid::OnInstallFinished(
bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
content::WebContents* web_contents) {
+ has_user_interaction_ = true;
if (IsInfoEmpty(shortcut_info_))
return true;
@@ -176,12 +190,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_ = INSTALLING;
TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
AppBannerSettingsHelper::RecordBannerInstallEvent(
web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
@@ -216,6 +231,7 @@ AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
event_request_id_(event_request_id),
has_user_interaction_(false),
is_webapk_(is_webapk),
+ install_state_(INSTALL_NOT_STARTED),
weak_ptr_factory_(this) {
DCHECK(!IsInfoEmpty(shortcut_info_));
CreateJavaDelegate();
@@ -277,6 +293,8 @@ void AppBannerInfoBarDelegateAndroid::InfoBarDismissed() {
event_request_id_));
if (native_app_data_.is_null()) {
+ if (is_webapk_)
+ TrackWebApkInstallationDismissEvents(install_state_);
TrackUserResponse(USER_RESPONSE_WEB_APP_DISMISSED);
AppBannerSettingsHelper::RecordBannerDismissEvent(
web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
@@ -308,8 +326,10 @@ bool AppBannerInfoBarDelegateAndroid::Accept() {
if (!native_app_data_.is_null())
return AcceptNativeApp(web_contents);
- if (is_webapk_)
+ if (is_webapk_) {
+ webapk::TrackInstallStartType(webapk::STARTED_FROM_BANNER);
return AcceptWebApk(web_contents);
+ }
return AcceptWebApp(web_contents);
}
@@ -365,6 +385,7 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
if (!success) {
DVLOG(1) << "The WebAPK installation failed.";
Java_AppBannerInfoBarDelegateAndroid_showWebApkInstallFailureToast(env);
+ webapk::TrackInstallEvent(webapk::INSTALL_FAILED);
if (infobar())
infobar()->RemoveSelf();
return;
@@ -378,6 +399,18 @@ void AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished(
Java_AppBannerInfoBarDelegateAndroid_setWebApkPackageName(
env, java_delegate_, java_webapk_package_name);
UpdateInstallState(env, nullptr);
+ install_state_ = INSTALLED;
+ webapk::TrackInstallEvent(webapk::INSTALL_COMPLETED);
+}
+
+void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents(
+ InstallState install_state) {
+ if (install_state == INSTALL_NOT_STARTED)
+ webapk::TrackInstallEvent(webapk::BANNER_DISMISSED_BEFORE_INSTALLATION);
+ else if (install_state == INSTALLING)
+ webapk::TrackInstallEvent(webapk::BANNER_DISMISSED_DURING_INSTALLATION);
+ else if (install_state == INSTALLED)
dominickn 2016/09/21 06:54:27 Minor nit: add an explicit comment saying that whe
Xi Han 2016/09/21 14:22:08 Done.
+ webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN_DISMISS);
}
bool AppBannerInfoBarDelegateAndroid::LinkClicked(

Powered by Google App Engine
This is Rietveld 408576698