From 89867a92873e61d661eafdff1a7f5219a34f3fa3 Mon Sep 17 00:00:00 2001 From: Angela Xiao Date: Thu, 3 Aug 2023 17:09:58 +0000 Subject: [PATCH] Scalable Notifiers: add help app event logging Add event logging for help app actions (i.e. clicking CTA links). All the help app logging is done in the newly added `PerformActionForHelpApp` function. Bug: b/293951619 Change-Id: Ibf8bc967881863d97c055a9bf497df098884981a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4742902 Reviewed-by: Yuki Awano Reviewed-by: Callistus Tan Commit-Queue: Angela Xiao Cr-Commit-Position: refs/heads/main@{#1179103} --- .../apps/help_app/help_app_ui_delegate.cc | 2 +- .../components/scalable_iph/scalable_iph.cc | 41 +++++++++++++++++++ .../components/scalable_iph/scalable_iph.h | 4 ++ .../scalable_iph/scalable_iph_constants.h | 22 ++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) diff --git a/chrome/browser/ash/system_web_apps/apps/help_app/help_app_ui_delegate.cc b/chrome/browser/ash/system_web_apps/apps/help_app/help_app_ui_delegate.cc index d5dde7c249f80..e4d39915fa494 100644 --- a/chrome/browser/ash/system_web_apps/apps/help_app/help_app_ui_delegate.cc +++ b/chrome/browser/ash/system_web_apps/apps/help_app/help_app_ui_delegate.cc @@ -99,7 +99,7 @@ void ChromeHelpAppUIDelegate::TriggerWelcomeTipCallToAction( return; } - scalable_iph->PerformAction( + scalable_iph->PerformActionForHelpApp( static_cast(action_type_id)); } diff --git a/chromeos/ash/components/scalable_iph/scalable_iph.cc b/chromeos/ash/components/scalable_iph/scalable_iph.cc index 98b60e92b9adb..684051c3b83a9 100644 --- a/chromeos/ash/components/scalable_iph/scalable_iph.cc +++ b/chromeos/ash/components/scalable_iph/scalable_iph.cc @@ -48,6 +48,34 @@ const base::flat_map& GetEventNamesMap() { return *event_names_map; } +std::string GetHelpAppIphEventName(ActionType action_type) { + switch (action_type) { + case ActionType::kOpenChrome: + return kEventNameHelpAppActionTypeOpenChrome; + case ActionType::kOpenLauncher: + return kEventNameHelpAppActionTypeOpenLauncher; + case ActionType::kOpenPersonalizationApp: + return kEventNameHelpAppActionTypeOpenPersonalizationApp; + case ActionType::kOpenPlayStore: + return kEventNameHelpAppActionTypeOpenPlayStore; + case ActionType::kOpenGoogleDocs: + return kEventNameHelpAppActionTypeOpenGoogleDocs; + case ActionType::kOpenGooglePhotos: + return kEventNameHelpAppActionTypeOpenGooglePhotos; + case ActionType::kOpenSettingsPrinter: + return kEventNameHelpAppActionTypeOpenSettingsPrinter; + case ActionType::kOpenPhoneHub: + return kEventNameHelpAppActionTypeOpenPhoneHub; + case ActionType::kOpenYouTube: + return kEventNameHelpAppActionTypeOpenYouTube; + case ActionType::kOpenFileManager: + return kEventNameHelpAppActionTypeOpenFileManager; + case ActionType::kInvalid: + default: + return ""; + } +} + // The list of IPH features `SclableIph` supports. `ScalableIph` checks trigger // conditions of all events listed in this list when it receives an `Event`. const std::vector& GetFeatureListConstant() { @@ -367,6 +395,19 @@ void ScalableIph::OverrideTaskRunnerForTesting( EnsureTimerStarted(); } +void ScalableIph::PerformActionForHelpApp(ActionType action_type) { + std::string iph_event_name = GetHelpAppIphEventName(action_type); + + // ActionType enum is defined on the client side. We can use CHECK as this is + // a client side constraint. + CHECK(!iph_event_name.empty()) << "Unable to resolve the IPH event name to " + "an action type for the help app"; + + tracker_->NotifyEvent(iph_event_name); + + PerformAction(action_type); +} + void ScalableIph::PerformAction(ActionType action_type) { delegate_->PerformActionForScalableIph(action_type); } diff --git a/chromeos/ash/components/scalable_iph/scalable_iph.h b/chromeos/ash/components/scalable_iph/scalable_iph.h index 92d4065c9d2de..d4d0dcb8d122a 100644 --- a/chromeos/ash/components/scalable_iph/scalable_iph.h +++ b/chromeos/ash/components/scalable_iph/scalable_iph.h @@ -105,6 +105,10 @@ class ScalableIph : public KeyedService, void OverrideTaskRunnerForTesting( scoped_refptr task_runner); + // Called for a user action in the help app. All the logging related to + // help app action events will be done here before calling `PerformAction`. + void PerformActionForHelpApp(ActionType action_type); + // Perform `action_type` as a result of a user action, e.g. A link click in a // help app, etc. This notifies a corresponding IPH event to the feature // engagement framework. diff --git a/chromeos/ash/components/scalable_iph/scalable_iph_constants.h b/chromeos/ash/components/scalable_iph/scalable_iph_constants.h index 49fd1d0bf829a..23568d94c862b 100644 --- a/chromeos/ash/components/scalable_iph/scalable_iph_constants.h +++ b/chromeos/ash/components/scalable_iph/scalable_iph_constants.h @@ -42,6 +42,28 @@ constexpr char kActionTypeOpenFileManager[] = "OpenFileManager"; // Scalable Iph event names must start with `ScalableIph` as Iph event names // live in a global namespace. +// Constants for help app events, has 1 to 1 mapping with the ActionType. +constexpr char kEventNameHelpAppActionTypeOpenChrome[] = + "ScalableIphHelpAppActionOpenChrome"; +constexpr char kEventNameHelpAppActionTypeOpenLauncher[] = + "ScalableIphHelpAppActionOpenLauncher"; +constexpr char kEventNameHelpAppActionTypeOpenPersonalizationApp[] = + "ScalableIphHelpAppActionOpenPersonalizationApp"; +constexpr char kEventNameHelpAppActionTypeOpenPlayStore[] = + "ScalableIphHelpAppActionOpenPlayStore"; +constexpr char kEventNameHelpAppActionTypeOpenGoogleDocs[] = + "ScalableIphHelpAppActionOpenGoogleDocs"; +constexpr char kEventNameHelpAppActionTypeOpenGooglePhotos[] = + "ScalableIphHelpAppActionOpenGooglePhotos"; +constexpr char kEventNameHelpAppActionTypeOpenSettingsPrinter[] = + "ScalableIphHelpAppActionOpenSettingsPrinter"; +constexpr char kEventNameHelpAppActionTypeOpenPhoneHub[] = + "ScalableIphHelpAppActionOpenPhoneHub"; +constexpr char kEventNameHelpAppActionTypeOpenYouTube[] = + "ScalableIphHelpAppActionOpenYouTube"; +constexpr char kEventNameHelpAppActionTypeOpenFileManager[] = + "ScalableIphHelpAppActionOpenFileManager"; + // `FiveMinTick` event is recorded every five minutes after OOBE completion. constexpr char kEventNameFiveMinTick[] = "ScalableIphFiveMinTick";