capture_mode_metrics.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. // Copyright 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_CAPTURE_MODE_CAPTURE_MODE_METRICS_H_
  5. #define ASH_CAPTURE_MODE_CAPTURE_MODE_METRICS_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include "ash/ash_export.h"
  9. #include "ash/capture_mode/capture_mode_types.h"
  10. namespace ash {
  11. // Enumeration of the reasons that lead to ending the screen recording.
  12. // Note that these values are persisted to histograms so existing values should
  13. // remain unchanged and new values should be added to the end.
  14. enum class EndRecordingReason {
  15. kStopRecordingButton,
  16. kDisplayOrWindowClosing,
  17. kActiveUserChange,
  18. kSessionBlocked,
  19. kShuttingDown,
  20. kImminentSuspend,
  21. kRecordingServiceDisconnected,
  22. kFileIoError,
  23. kDlpInterruption,
  24. kLowDiskSpace,
  25. kHdcpInterruption,
  26. kServiceClosing,
  27. kVizVideoCaptureDisconnected,
  28. kAudioEncoderInitializationFailure,
  29. kVideoEncoderInitializationFailure,
  30. kAudioEncodingError,
  31. kVideoEncodingError,
  32. kProjectorTranscriptionError,
  33. kLowDriveFsQuota,
  34. kMaxValue = kLowDriveFsQuota,
  35. };
  36. // Enumeration of capture bar buttons that can be pressed while in capture mode.
  37. // Note that these values are persisted to histograms so existing values should
  38. // remain unchanged and new values should be added to the end.
  39. enum class CaptureModeBarButtonType {
  40. kScreenCapture,
  41. kScreenRecord,
  42. kFull,
  43. kRegion,
  44. kWindow,
  45. kExit,
  46. kMaxValue = kExit,
  47. };
  48. // Enumeration of the various configurations a user can have while in capture
  49. // mode. Note that these values are persisted to histograms so existing values
  50. // should remain unchanged and new values should be added to the end.
  51. enum class CaptureModeConfiguration {
  52. kFullscreenScreenshot,
  53. kRegionScreenshot,
  54. kWindowScreenshot,
  55. kFullscreenRecording,
  56. kRegionRecording,
  57. kWindowRecording,
  58. kMaxValue = kWindowRecording,
  59. };
  60. // Enumeration of actions that can be taken to enter capture mode. Note that
  61. // these values are persisted to histograms so existing values should remain
  62. // unchanged and new values should be added to the end.
  63. enum class CaptureModeEntryType {
  64. kAccelTakePartialScreenshot,
  65. kAccelTakeWindowScreenshot,
  66. kQuickSettings,
  67. kStylusPalette,
  68. kPowerMenu,
  69. kSnipKey,
  70. kCaptureAllDisplays,
  71. kProjector,
  72. kMaxValue = kProjector,
  73. };
  74. // Enumeration of quick actions on screenshot notification. Note that these
  75. // values are persisted to histograms so existing values should remain
  76. // unchanged and new values should be added to the end.
  77. enum class CaptureQuickAction {
  78. kBacklight,
  79. kFiles,
  80. kDelete,
  81. kMaxValue = kDelete,
  82. };
  83. // Enumeration of user's selection on save-to locations. Note that these values
  84. // are persisted to histograms so existing values should remain unchanged and
  85. // new values should be added to the end.
  86. enum class CaptureModeSaveToLocation {
  87. kDefault,
  88. kDrive,
  89. kDriveFolder,
  90. kCustomizedFolder,
  91. kMaxValue = kCustomizedFolder,
  92. };
  93. // Enumeration of reasons for which the capture folder is switched to default
  94. // downloads folder. Note that these values are persisted to histograms so
  95. // existing values should remain unchanged and new values should be added to the
  96. // end.
  97. enum class CaptureModeSwitchToDefaultReason {
  98. kFolderUnavailable,
  99. kUserSelectedFromFolderSelectionDialog,
  100. kUserSelectedFromSettingsMenu,
  101. kMaxValue = kUserSelectedFromSettingsMenu,
  102. };
  103. // Enumeration of the camera preview size. Note that these values are persisted
  104. // to histograms so existing values should remain unchanged and new values
  105. // should be added to the end.
  106. enum class CaptureModeCameraSize {
  107. kExpanded,
  108. kCollapsed,
  109. kMaxValue = kCollapsed,
  110. };
  111. // Records the `reason` for which screen recording was ended.
  112. void RecordEndRecordingReason(EndRecordingReason reason);
  113. // Records capture mode bar button presses given by `button_type`.
  114. void RecordCaptureModeBarButtonType(CaptureModeBarButtonType button_type);
  115. // Records a user's configuration when they perform a capture.
  116. void RecordCaptureModeConfiguration(CaptureModeType type,
  117. CaptureModeSource source,
  118. bool audio_on,
  119. bool is_in_projector_mode);
  120. // Records the method the user enters capture mode given by |entry_type|.
  121. void RecordCaptureModeEntryType(CaptureModeEntryType entry_type);
  122. // Records the length in seconds of a recording taken by capture mode.
  123. void RecordCaptureModeRecordTime(int64_t length_in_seconds,
  124. bool is_in_projector_mode);
  125. // Records if the user has switched modes during a capture session.
  126. void RecordCaptureModeSwitchesFromInitialMode(bool switched);
  127. // Records the number of times a user adjusts a capture region. This includes
  128. // moving and resizing. The count is started when a user sets the capture source
  129. // as a region. The count is recorded and reset when a user performs a capture.
  130. // The count is just reset when a user selects a new region or the user switches
  131. // capture sources.
  132. void RecordNumberOfCaptureRegionAdjustments(int num_adjustments,
  133. bool is_in_projector_mode);
  134. // Records the number of times a user consecutively screenshots. Only records a
  135. // sample if `num_consecutive_screenshots` is greater than 1.
  136. void RecordNumberOfConsecutiveScreenshots(int num_consecutive_screenshots);
  137. // Records the number of screenshots taken. This metric is meant to be a rough
  138. // approximation so its counts are not persisted across crashes, restarts or
  139. // sessions.
  140. void RecordNumberOfScreenshotsTakenInLastDay(
  141. int num_screenshots_taken_in_last_day);
  142. void RecordNumberOfScreenshotsTakenInLastWeek(
  143. int num_screenshots_taken_in_last_week);
  144. // Records the action taken on screen notification.
  145. void RecordScreenshotNotificationQuickAction(CaptureQuickAction action);
  146. // Records the location where screen capture is saved.
  147. void RecordSaveToLocation(CaptureModeSaveToLocation save_location);
  148. // Records the `reason` for which the capture folder is switched to default
  149. // downloads folder.
  150. void RecordSwitchToDefaultFolderReason(CaptureModeSwitchToDefaultReason reason);
  151. // Maps given `type` and `source` to CaptureModeConfiguration enum.
  152. ASH_EXPORT CaptureModeConfiguration GetConfiguration(CaptureModeType type,
  153. CaptureModeSource source);
  154. // Records how often recording starts with a camera on.
  155. void RecordRecordingStartsWithCamera(bool starts_with_camera,
  156. bool is_in_projector_mode);
  157. // Records the number of camera disconnections during recording.
  158. void RecordCameraDisconnectionsDuringRecordings(int num_camera_disconnections);
  159. // Records the given `num_camera_connected`.
  160. void RecordNumberOfConnectedCameras(int num_camera_connected);
  161. // Records the duration of camera becoming available again after camera
  162. // disconnection.
  163. void RecordCameraReconnectDuration(int length_in_seconds,
  164. int grace_period_in_seconds);
  165. // Records the camera size when recording starts.
  166. void RecordCameraSizeOnStart(CaptureModeCameraSize camera_size);
  167. // Records the camera position when recording starts.
  168. void RecordCameraPositionOnStart(CameraPreviewSnapPosition camera_position);
  169. // Appends the proper suffix to `prefix` based on whether the user is in tablet
  170. // mode or not.
  171. ASH_EXPORT std::string GetCaptureModeHistogramName(std::string prefix);
  172. } // namespace ash
  173. #endif // ASH_CAPTURE_MODE_CAPTURE_MODE_METRICS_H_