metrics_utils.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. // Copyright (c) 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_SYSTEM_MESSAGE_CENTER_METRICS_UTILS_H_
  5. #define ASH_SYSTEM_MESSAGE_CENTER_METRICS_UTILS_H_
  6. #include "ash/ash_export.h"
  7. #include "third_party/abseil-cpp/absl/types/optional.h"
  8. #include "ui/message_center/public/cpp/notification.h"
  9. #include "ui/message_center/views/message_popup_view.h"
  10. namespace ash {
  11. namespace metrics_utils {
  12. // Keep in sync with enum in tools/metrics/histograms/enums.xml.
  13. enum NotificationTypeDetailed : int {
  14. CHROME_APP_PRIORITY_MINUS_TWO = 0,
  15. CHROME_APP_PRIORITY_MINUS_TWO_REQUIRE_INTERACTION = 1,
  16. CHROME_APP_PRIORITY_MINUS_ONE = 2,
  17. CHROME_APP_PRIORITY_MINUS_ONE_REQUIRE_INTERACTION = 3,
  18. CHROME_APP_PRIORITY_ZERO = 4,
  19. CHROME_APP_PRIORITY_ZERO_REQUIRE_INTERACTION = 5,
  20. CHROME_APP_PRIORITY_ONE = 6,
  21. CHROME_APP_PRIORITY_ONE_REQUIRE_INTERACTION = 7,
  22. CHROME_APP_PRIORITY_TWO = 8,
  23. CHROME_APP_PRIORITY_TWO_REQUIRE_INTERACTION = 9,
  24. ARC_PRIORITY_MINUS_TWO = 10,
  25. ARC_PRIORITY_MINUS_TWO_PINNED = 11,
  26. ARC_PRIORITY_MINUS_ONE = 12,
  27. ARC_PRIORITY_MINUS_ONE_PINNED = 13,
  28. ARC_PRIORITY_ZERO = 14,
  29. ARC_PRIORITY_ZERO_PINNED = 15,
  30. ARC_PRIORITY_ONE = 16,
  31. ARC_PRIORITY_ONE_PINNED = 17,
  32. ARC_PRIORITY_TWO = 18,
  33. ARC_PRIORITY_TWO_PINNED = 19,
  34. WEB = 20,
  35. WEB_REQUIRE_INTERACTION = 21,
  36. CROS_PRIORITY_MINUS_TWO = 22,
  37. CROS_PRIORITY_MINUS_TWO_PINNED = 23,
  38. CROS_PRIORITY_MINUS_ONE = 24,
  39. CROS_PRIORITY_MINUS_ONE_PINNED = 25,
  40. CROS_PRIORITY_ZERO = 26,
  41. CROS_PRIORITY_ZERO_PINNED = 27,
  42. CROS_PRIORITY_ONE = 28,
  43. CROS_PRIORITY_ONE_PINNED = 29,
  44. CROS_PRIORITY_TWO = 30,
  45. CROS_PRIORITY_TWO_PINNED = 31,
  46. CROS_SYSTEM_PRIORITY = 32,
  47. CROS_SYSTEM_PRIORITY_PINNED = 33,
  48. CROS_SYSTEM_PRIORITY_WARNING = 34,
  49. CROS_SYSTEM_PRIORITY_WARNING_PINNED = 35,
  50. CROS_SYSTEM_PRIORITY_CRITICAL_WARNING = 36,
  51. CROS_SYSTEM_PRIORITY_CRITICAL_WARNING_PINNED = 37,
  52. OTHER = 38,
  53. PHONEHUB_PRIORITY_MINUS_TWO = 39,
  54. PHONEHUB_PRIORITY_MINUS_ONE = 40,
  55. PHONEHUB_PRIORITY_ZERO = 41,
  56. PHONEHUB_PRIORITY_ONE = 42,
  57. PHONEHUB_PRIORITY_TWO = 43,
  58. kMaxValue = PHONEHUB_PRIORITY_TWO,
  59. };
  60. // These are the types of notification view that we are interested in recording
  61. // metrics. A notification view might contain an image, a set of action buttons,
  62. // and some of those buttons might enable inline reply. This enum covers all the
  63. // possible variations for a notification view with image, action buttons and
  64. // inline reply, and whether it is part of a group notification or not.
  65. // Note to keep in sync with enum in tools/metrics/histograms/enums.xml.
  66. enum class NotificationViewType {
  67. SIMPLE = 0, // no image, action buttons and inline reply.
  68. GROUPED_SIMPLE = 1,
  69. HAS_IMAGE = 2, // has image, no action buttons and inline reply.
  70. GROUPED_HAS_IMAGE = 3,
  71. HAS_ACTION = 4, // has action buttons, no image and inline reply.
  72. GROUPED_HAS_ACTION = 5,
  73. HAS_INLINE_REPLY = 6, // has inline reply, no image.
  74. GROUPED_HAS_INLINE_REPLY = 7,
  75. HAS_IMAGE_AND_ACTION = 8, // has image and action button, no inline reply.
  76. GROUPED_HAS_IMAGE_AND_ACTION = 9,
  77. HAS_IMAGE_AND_INLINE_REPLY = 10, // has image and inline reply.
  78. GROUPED_HAS_IMAGE_AND_INLINE_REPLY = 11,
  79. kMaxValue = GROUPED_HAS_IMAGE_AND_INLINE_REPLY,
  80. };
  81. // The actions that was performed after an expand button is clicked. These are
  82. // used in histograms, do not remove/renumber entries. If you're adding to this
  83. // enum with the intention that it will be logged, update the
  84. // ExpandButtonClickAction token variant in enums.xml.
  85. enum class ExpandButtonClickAction {
  86. EXPAND_INDIVIDUAL = 0,
  87. COLLAPSE_INDIVIDUAL = 1,
  88. EXPAND_GROUP = 2,
  89. COLLAPSE_GROUP = 3,
  90. kMaxValue = COLLAPSE_GROUP,
  91. };
  92. // The types of group notification. These are used in histograms, do not
  93. // remove/renumber entries. If you're adding to this enum with the intention
  94. // that it will be logged, update the ExpandButtonClickAction token variant in
  95. // enums.xml.
  96. enum class GroupNotificationType {
  97. GROUP_PARENT = 0,
  98. GROUP_CHILD = 1,
  99. kMaxValue = GROUP_CHILD,
  100. };
  101. // Returns the detailed notification type enum for a notification.
  102. NotificationTypeDetailed GetNotificationType(
  103. const message_center::Notification& notification);
  104. // Returns the detailed notification type enum for a notification id.
  105. absl::optional<NotificationTypeDetailed> GetNotificationType(
  106. const std::string& notification_id);
  107. // Logs a Hover event on a notification.
  108. void LogHover(const std::string& notification_id, bool is_popup);
  109. // Logs a ClickedBody event.
  110. void LogClickedBody(const std::string& notification_id, bool is_popup);
  111. // Logs a ClickedActionButton event.
  112. void LogClickedActionButton(const std::string& notification_id, bool is_popup);
  113. // Logs an InlineReplySent event.
  114. ASH_EXPORT void LogInlineReplySent(const std::string& notification_id,
  115. bool is_popup);
  116. // Logs a ExpireToTray event for a pop-up notification.
  117. void LogPopupExpiredToTray(const std::string& notification_id);
  118. // Logs a ClosedByUser event.
  119. void LogClosedByUser(const std::string& notification_id,
  120. bool is_swipe,
  121. bool is_popup);
  122. // Logs a SettingsShown event.
  123. void LogSettingsShown(const std::string& notification_id,
  124. bool is_slide_controls,
  125. bool is_popup);
  126. // Logs a Snoozed event.
  127. void LogSnoozed(const std::string& notification_id,
  128. bool is_slide_controls,
  129. bool is_popup);
  130. // Logs a popup Shown event.
  131. void LogPopupShown(const std::string& notification_id);
  132. // Logs a popup Closed event.
  133. void LogPopupClosed(message_center::MessagePopupView* popup);
  134. // Logs a tray ClosedByClearAll event.
  135. void LogClosedByClearAll(const std::string& notification_id);
  136. // Logs a notification added event.
  137. void LogNotificationAdded(const std::string& notification_id);
  138. // Logs a system notification added event.
  139. void LogSystemNotificationAdded(const std::string& notification_id);
  140. // Logs the count of notifications displayed during the first minute after a
  141. // user logs in.
  142. void LogNotificationsShownInFirstMinute(int notifications_count);
  143. // Logs the number of notifications contained in a group.
  144. void LogCountOfNotificationsInOneGroup(int notification_count);
  145. // Logs the action that was performed after an expand button is clicked,
  146. void LogExpandButtonClickAction(ExpandButtonClickAction action);
  147. // Logs the type of group notification added to the system.
  148. void LogGroupNotificationAddedType(GroupNotificationType type);
  149. } // namespace metrics_utils
  150. } // namespace ash
  151. #endif // ASH_SYSTEM_MESSAGE_CENTER_METRICS_UTILS_H_