Commit 54c59407 authored by David Black's avatar David Black Committed by Commit Bot

Record number of screenshots taken per day/week.

We would like to understand approximately how many screenshots users are
taking per day and per week. This will inform how may screenshots we
choose to show in the holding space feature currently under development.

Note that we are also adding similar histograms to ScreenshotController
so these metrics may also be useful to measure impact of capture mode.

Bug: 1131266
Change-Id: Iddab5573aba57402f21ab270f8467c710d9affec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438679
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812051}
parent f720ade6
......@@ -26,6 +26,7 @@
#include "base/files/file_util.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "base/task/current_thread.h"
#include "base/task/task_traits.h"
......@@ -206,6 +207,20 @@ CaptureModeController::CaptureModeController(
: delegate_(std::move(delegate)) {
DCHECK_EQ(g_instance, nullptr);
g_instance = this;
// Schedule recording of the number of screenshots taken per day.
num_screenshots_taken_in_last_day_scheduler_.Start(
FROM_HERE, base::TimeDelta::FromDays(1),
base::BindRepeating(
&CaptureModeController::RecordNumberOfScreenshotsTakenInLastDay,
weak_ptr_factory_.GetWeakPtr()));
// Schedule recording of the number of screenshots taken per week.
num_screenshots_taken_in_last_week_scheduler_.Start(
FROM_HERE, base::TimeDelta::FromDays(7),
base::BindRepeating(
&CaptureModeController::RecordNumberOfScreenshotsTakenInLastWeek,
weak_ptr_factory_.GetWeakPtr()));
}
CaptureModeController::~CaptureModeController() {
......@@ -354,6 +369,9 @@ void CaptureModeController::CaptureImage() {
capture_params->window, capture_params->bounds,
base::BindOnce(&CaptureModeController::OnImageCaptured,
weak_ptr_factory_.GetWeakPtr(), base::Time::Now()));
++num_screenshots_taken_in_last_day_;
++num_screenshots_taken_in_last_week_;
}
void CaptureModeController::CaptureVideo() {
......@@ -489,4 +507,16 @@ base::FilePath CaptureModeController::BuildPath(const char* const format_string,
GetTimeStr(exploded_time, delegate_->Uses24HourFormat()).c_str()));
}
void CaptureModeController::RecordNumberOfScreenshotsTakenInLastDay() {
base::UmaHistogramCounts100("Ash.CaptureModeController.ScreenshotsPerDay",
num_screenshots_taken_in_last_day_);
num_screenshots_taken_in_last_day_ = 0;
}
void CaptureModeController::RecordNumberOfScreenshotsTakenInLastWeek() {
base::UmaHistogramCounts1000("Ash.CaptureModeController.ScreenshotsPerWeek",
num_screenshots_taken_in_last_week_);
num_screenshots_taken_in_last_week_ = 0;
}
} // namespace ash
......@@ -13,6 +13,7 @@
#include "base/memory/ref_counted_memory.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/timer/timer.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image.h"
......@@ -131,6 +132,10 @@ class ASH_EXPORT CaptureModeController {
base::FilePath BuildPath(const char* const format_string,
base::Time timestamp) const;
// Records the number of screenshots taken.
void RecordNumberOfScreenshotsTakenInLastDay();
void RecordNumberOfScreenshotsTakenInLastWeek();
std::unique_ptr<CaptureModeDelegate> delegate_;
CaptureModeType type_ = CaptureModeType::kImage;
......@@ -146,6 +151,14 @@ class ASH_EXPORT CaptureModeController {
// True when video recording is in progress.
bool is_recording_in_progress_ = false;
// Timers used to schedule recording of the number of screenshots taken.
base::RepeatingTimer num_screenshots_taken_in_last_day_scheduler_;
base::RepeatingTimer num_screenshots_taken_in_last_week_scheduler_;
// Counters used to track the number of screenshots taken.
int num_screenshots_taken_in_last_day_ = 0;
int num_screenshots_taken_in_last_week_ = 0;
base::WeakPtrFactory<CaptureModeController> weak_ptr_factory_{this};
};
......
......@@ -184,6 +184,31 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="Ash.CaptureModeController.ScreenshotsPerDay" units="int"
expires_after="2021-09-29">
<owner>afakhry@chromium.org</owner>
<owner>gzadina@google.com</owner>
<summary>
Records the number of screenshots that have been taken via the
CaptureModeController every 24 hours. Note that counts are not persisted
across crashes, restarts, or sessions so this is only intended to give a
rough approximation.
</summary>
</histogram>
<histogram name="Ash.CaptureModeController.ScreenshotsPerWeek" units="int"
expires_after="2021-09-29">
<owner>afakhry@chromium.org</owner>
<owner>gzadina@google.com</owner>
<summary>
Records the number of screenshots that have been taken via the
CaptureModeController every 7 days. Note that counts are not persisted
across crashes, restarts, or sessions so this is only intended to give a
rough approximation. This means that this metric will only be recorded in
sessions spanning at least 7 days.
</summary>
</histogram>
<histogram name="Ash.ClipboardHistory.ContextMenu.NumberOfItemsShown"
units="Items Shown" expires_after="2021-09-01">
<owner>andrewxu@chromium.org</owner>
......
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