Commit f1ff8e90 authored by Glenn Hartmann's avatar Glenn Hartmann Committed by Commit Bot

Implement PWA.Visit.WebAPKableSiteVisit metric.

See http://go/webapk-retention-metrics,
http://go/webapk-retention-metrics-impl for details.

The eventual hope is to augment this metric so that it records
page-loads to installed experiences as well, and record a boolean value
along with the metric so we can distinguish between the scenarios. This
will give us a more direct way to see exactly what proportion of
installable page-loads per app are taking advantage of the benefits of
installation.

It seems like that might require some refactoring to do properly, so
I'm going to do the easy part first so we can start getting at least
some numbers ASAP, then we can look at improving the situation later.

Bug: 1044709
Change-Id: I472012cffe4d0860457a586b2b01a3e7c573a342
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2057108
Commit-Queue: Glenn Hartmann <hartmanng@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748204}
parent ee4361ac
......@@ -101,6 +101,17 @@ void WebApkUkmRecorder::RecordUninstall(const GURL& manifest_url,
.Record(ukm::UkmRecorder::Get());
}
// static
void WebApkUkmRecorder::RecordWebApkableVisit(const GURL& manifest_url) {
if (!manifest_url.is_valid())
return;
ukm::SourceId source_id =
ukm::UkmRecorder::GetSourceIdForWebApkManifestUrl(manifest_url);
ukm::builders::PWA_Visit(source_id).SetWebAPKableSiteVisit(1).Record(
ukm::UkmRecorder::Get());
}
// Called by the Java counterpart to record the Session Duration UKM metric.
void JNI_WebApkUkmRecorder_RecordSessionDuration(
JNIEnv* env,
......
......@@ -37,6 +37,15 @@ class WebApkUkmRecorder {
int64_t launch_count,
int64_t install_duration);
// RecordWebApkableVisit records a visit to an installable PWA from a
// non-installed surface on Android (ie, if an installable site is visited
// from within a regular browser tab).
//
// Note that the metric will be recorded whether or not the PWA is actually
// installed - all that matters is that it is being visited from a
// "non-installed experience" (ie, as a normal browser tab).
static void RecordWebApkableVisit(const GURL& manifest_url);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(WebApkUkmRecorder);
};
......
......@@ -15,6 +15,7 @@
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/android/tab_web_contents_delegate_android.h"
#include "chrome/browser/android/webapk/webapk_metrics.h"
#include "chrome/browser/android/webapk/webapk_ukm_recorder.h"
#include "chrome/browser/android/webapk/webapk_web_manifest_checker.h"
#include "chrome/browser/android/webapps/add_to_homescreen_coordinator.h"
#include "chrome/browser/android/webapps/add_to_homescreen_params.h"
......@@ -186,6 +187,14 @@ void AppBannerManagerAndroid::PerformInstallableWebAppCheck() {
AppBannerManager::PerformInstallableWebAppCheck();
}
void AppBannerManagerAndroid::OnDidPerformInstallableWebAppCheck(
const InstallableData& data) {
if (data.errors.empty())
WebApkUkmRecorder::RecordWebApkableVisit(data.manifest_url);
AppBannerManager::OnDidPerformInstallableWebAppCheck(data);
}
void AppBannerManagerAndroid::ResetCurrentPageData() {
AppBannerManager::ResetCurrentPageData();
native_app_data_.Reset();
......
......@@ -84,6 +84,8 @@ class AppBannerManagerAndroid
void PerformInstallableChecks() override;
InstallableParams ParamsToPerformInstallableWebAppCheck() override;
void PerformInstallableWebAppCheck() override;
void OnDidPerformInstallableWebAppCheck(
const InstallableData& result) override;
void ResetCurrentPageData() override;
void ShowBannerUi(WebappInstallSource install_source) override;
void MaybeShowAmbientBadge() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment