#include "components/compose/core/browser/compose_metrics.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/strcat.h"
#include "base/time/time.h"
#include "services/metrics/public/cpp/metrics_utils.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
namespace compose {
const char kComposeDialogInnerTextShortenedBy[] = …;
const char kComposeDialogInnerTextSize[] = …;
const char kComposeDialogOpenLatency[] = …;
const char kComposeDialogSelectionLength[] = …;
const char kComposeRequestReason[] = …;
const char kComposeRequestDurationOkSuffix[] = …;
const char kComposeRequestDurationErrorSuffix[] = …;
const char kComposeRequestStatus[] = …;
const char kComposeSessionComposeCount[] = …;
const char kComposeSessionCloseReason[] = …;
const char kComposeSessionDialogShownCount[] = …;
const char kComposeSessionEventCounts[] = …;
const char kComposeSessionDuration[] = …;
const char kComposeSessionOverOneDay[] = …;
const char kComposeSessionUndoCount[] = …;
const char kComposeSessionUpdateInputCount[] = …;
const char kComposeShowStatus[] = …;
const char kComposeMSBBSessionCloseReason[] = …;
const char kComposeMSBBSessionDialogShownCount[] = …;
const char kComposeFirstRunSessionCloseReason[] = …;
const char kComposeFirstRunSessionDialogShownCount[] = …;
const char kInnerTextNodeOffsetFound[] = …;
const char kComposeContextMenuCtr[] = …;
const char kComposeProactiveNudgeCtr[] = …;
const char kComposeProactiveNudgeShowStatus[] = …;
const char kOpenComposeDialogResult[] = …;
const char kComposeSelectAll[] = …;
const char kComposeStartSessionEntryPoint[] = …;
const char kComposeResumeSessionEntryPoint[] = …;
namespace {
std::string_view EvalLocationString(EvalLocation location) { … }
std::string_view LanguageSupportedString(bool page_language_supported) { … }
bool HasAckedFreOrAcceptedMsbb(ComposeFreOrMsbbSessionCloseReason reason) { … }
}
PageUkmTracker::PageUkmTracker(ukm::SourceId source_id)
: … { … }
PageUkmTracker::~PageUkmTracker() { … }
void PageUkmTracker::MenuItemShown() { … }
void PageUkmTracker::MenuItemClicked() { … }
void PageUkmTracker::ComposeTextInserted() { … }
void PageUkmTracker::ComposeProactiveNudgeShouldShow() { … }
void PageUkmTracker::ProactiveNudgeShown() { … }
void PageUkmTracker::ProactiveNudgeOpened() { … }
void PageUkmTracker::ProactiveNudgeDisabledGlobally() { … }
void PageUkmTracker::ProactiveNudgeDisabledForSite() { … }
void PageUkmTracker::ShowDialogAbortedDueToMissingFormData() { … }
void PageUkmTracker::ShowDialogAbortedDueToMissingFormFieldData() { … }
void PageUkmTracker::MaybeLogUkm() { … }
ComposeSessionEvents::ComposeSessionEvents() { … }
void LogComposeContextMenuCtr(ComposeContextMenuCtrEvent event) { … }
void LogComposeContextMenuShowStatus(ComposeShowStatus status) { … }
void LogComposeProactiveNudgeCtr(ComposeProactiveNudgeCtrEvent event) { … }
void LogComposeProactiveNudgeShowStatus(ComposeShowStatus status) { … }
void LogOpenComposeDialogResult(OpenComposeDialogResult result) { … }
void LogStartSessionEntryPoint(ComposeEntryPoint entry_point) { … }
void LogResumeSessionEntryPoint(ComposeEntryPoint entry_point) { … }
void LogComposeRequestReason(ComposeRequestReason reason) { … }
void LogComposeRequestReason(EvalLocation eval_location,
ComposeRequestReason reason) { … }
void LogComposeRequestStatus(bool page_language_supported,
compose::mojom::ComposeStatus status) { … }
void LogComposeRequestStatus(EvalLocation eval_location,
bool page_language_supported,
compose::mojom::ComposeStatus status) { … }
void LogComposeRequestDuration(base::TimeDelta duration,
EvalLocation eval_location,
bool is_ok) { … }
void LogComposeFirstRunSessionCloseReason(
ComposeFreOrMsbbSessionCloseReason reason) { … }
void LogComposeFirstRunSessionDialogShownCount(
ComposeFreOrMsbbSessionCloseReason reason,
int dialog_shown_count) { … }
void LogComposeMSBBSessionCloseReason(
ComposeFreOrMsbbSessionCloseReason reason) { … }
void LogComposeMSBBSessionDialogShownCount(
ComposeFreOrMsbbSessionCloseReason reason,
int dialog_shown_count) { … }
SessionEvalLocation GetSessionEvalLocationFromEvents(
const ComposeSessionEvents& session_events) { … }
std::optional<EvalLocation> GetEvalLocationFromEvents(
const ComposeSessionEvents& session_events) { … }
void LogComposeSessionCloseMetrics(ComposeSessionCloseReason reason,
const ComposeSessionEvents& session_events) { … }
void LogComposeSessionCloseUkmMetrics(
ukm::SourceId source_id,
const ComposeSessionEvents& session_events) { … }
void LogComposeDialogInnerTextShortenedBy(int shortened_by) { … }
void LogComposeDialogInnerTextSize(int size) { … }
void LogComposeDialogInnerTextOffsetFound(bool inner_offset_found) { … }
void LogComposeDialogOpenLatency(base::TimeDelta duration) { … }
void LogComposeDialogSelectionLength(int length) { … }
void LogComposeSessionDuration(base::TimeDelta session_duration,
std::string session_suffix,
std::optional<EvalLocation> eval_location) { … }
void LogComposeRequestFeedback(EvalLocation eval_location,
ComposeRequestFeedback feedback) { … }
void LogComposeSelectAllStatus(ComposeSelectAllStatus select_all_status) { … }
void LogComposeSessionEventCounts(std::optional<EvalLocation> eval_location,
const ComposeSessionEvents& session_events) { … }
}