summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/welcome/onboarding_welcome/landing_view_proxy.js
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/chrome/browser/resources/welcome/onboarding_welcome/landing_view_proxy.js')
-rw-r--r--chromium/chrome/browser/resources/welcome/onboarding_welcome/landing_view_proxy.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/chromium/chrome/browser/resources/welcome/onboarding_welcome/landing_view_proxy.js b/chromium/chrome/browser/resources/welcome/onboarding_welcome/landing_view_proxy.js
new file mode 100644
index 00000000000..50d9fc06073
--- /dev/null
+++ b/chromium/chrome/browser/resources/welcome/onboarding_welcome/landing_view_proxy.js
@@ -0,0 +1,75 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('nux', function() {
+ const NUX_LANDING_PAGE_INTERACTION_METRIC_NAME =
+ 'FirstRun.NewUserExperience.LandingPageInteraction';
+
+ /**
+ * NuxLandingPageInteractions enum.
+ * These values are persisted to logs and should not be renumbered or re-used.
+ * See tools/metrics/histograms/enums.xml.
+ * @enum {number}
+ */
+ const NuxLandingPageInteractions = {
+ PageShown: 0,
+ NavigatedAway: 1,
+ NewUser: 2,
+ ExistingUser: 3,
+ };
+
+ const NUX_LANDING_PAGE_INTERACTIONS_COUNT =
+ Object.keys(NuxLandingPageInteractions).length;
+
+ /** @interface */
+ class LandingViewProxy {
+ recordPageShown() {}
+
+ recordNavigatedAway() {}
+
+ recordNewUser() {}
+
+ recordExistingUser() {}
+ }
+
+ /** @implements {nux.LandingViewProxy} */
+ class LandingViewProxyImpl {
+ /** @override */
+ recordPageShown() {
+ this.recordInteraction_(NuxLandingPageInteractions.PageShown);
+ }
+
+ /** @override */
+ recordNavigatedAway() {
+ this.recordInteraction_(NuxLandingPageInteractions.NavigatedAway);
+ }
+
+ /** @override */
+ recordNewUser() {
+ this.recordInteraction_(NuxLandingPageInteractions.NewUser);
+ }
+
+ /** @override */
+ recordExistingUser() {
+ this.recordInteraction_(NuxLandingPageInteractions.ExistingUser);
+ }
+
+ /**
+ * @param {number} interaction
+ * @private
+ */
+ recordInteraction_(interaction) {
+ chrome.metricsPrivate.recordEnumerationValue(
+ NUX_LANDING_PAGE_INTERACTION_METRIC_NAME, interaction,
+ NUX_LANDING_PAGE_INTERACTIONS_COUNT);
+ }
+ }
+
+ cr.addSingletonGetter(LandingViewProxyImpl);
+
+ return {
+ LandingViewProxy: LandingViewProxy,
+ LandingViewProxyImpl: LandingViewProxyImpl,
+ };
+});