-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Login: Introduce MetricsReporter to centralize UMA tracking
In the current login flow, reporting metrics are sparsely located. We would like to centralize the metrics reporting to make changes in metrics implementation simpler in the future. Bug: 1306417 Change-Id: I1a491108f0795b32b6ceae34b96b2355f93352c1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3528787 Reviewed-by: Denis Kuznetsov <antrim@chromium.org> Reviewed-by: Ben Franz <bfranz@chromium.org> Commit-Queue: Sherri Lin <sherrilin@google.com> Cr-Commit-Position: refs/heads/main@{#988418}
- Loading branch information
1 parent
9b067ff
commit a593268
Showing
12 changed files
with
124 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ash/components/login/auth/metrics_recorder.h" | ||
|
||
#include "ash/components/login/auth/auth_status_consumer.h" | ||
#include "base/metrics/histogram_macros.h" | ||
#include "base/metrics/user_metrics.h" | ||
#include "base/metrics/user_metrics_action.h" | ||
|
||
namespace ash { | ||
namespace { | ||
|
||
// Histogram for tracking the reason of auth failure | ||
constexpr char kFailureReasonHistogramName[] = "Login.FailureReason"; | ||
|
||
// Histogram for tracking the reason of login success | ||
constexpr char kSuccessReasonHistogramName[] = "Login.SuccessReason"; | ||
|
||
} // namespace | ||
|
||
MetricsRecorder::MetricsRecorder() {} | ||
|
||
MetricsRecorder::~MetricsRecorder() = default; | ||
|
||
void MetricsRecorder::OnAuthFailure(const AuthFailure::FailureReason& reason) { | ||
base::RecordAction(base::UserMetricsAction("Login_Failure")); | ||
UMA_HISTOGRAM_ENUMERATION(kFailureReasonHistogramName, reason, | ||
AuthFailure::NUM_FAILURE_REASONS); | ||
} | ||
|
||
void MetricsRecorder::OnLoginSuccess(const SuccessReason& reason) { | ||
base::RecordAction(base::UserMetricsAction("Login_Success")); | ||
UMA_HISTOGRAM_ENUMERATION(kSuccessReasonHistogramName, reason, | ||
SuccessReason::NUM_SUCCESS_REASONS); | ||
} | ||
|
||
void MetricsRecorder::OnGuestLoignSuccess() { | ||
base::RecordAction(base::UserMetricsAction("Login_GuestLoginSuccess")); | ||
} | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ASH_COMPONENTS_LOGIN_AUTH_METRICS_RECORDER_H_ | ||
#define ASH_COMPONENTS_LOGIN_AUTH_METRICS_RECORDER_H_ | ||
|
||
#include "ash/components/login/auth/auth_status_consumer.h" | ||
|
||
namespace ash { | ||
|
||
// This class encapsulates metrics reporting. User actions and behaviors are | ||
// reported in multiple stages of the login flow. This metrics reporter would | ||
// centralize the tracking and reporting. | ||
class COMPONENT_EXPORT(ASH_LOGIN_AUTH) MetricsRecorder { | ||
public: | ||
// Reports various metrics during the login flow. | ||
MetricsRecorder(); | ||
MetricsRecorder(const MetricsRecorder&) = delete; | ||
MetricsRecorder& operator=(const MetricsRecorder&) = delete; | ||
MetricsRecorder(MetricsRecorder&&) = delete; | ||
MetricsRecorder& operator=(MetricsRecorder&&) = delete; | ||
~MetricsRecorder(); | ||
|
||
// Logs the auth failure action and reason. | ||
void OnAuthFailure(const AuthFailure::FailureReason& failure_reason); | ||
|
||
// Logs the login success action and reason. | ||
void OnLoginSuccess(const SuccessReason& reason); | ||
|
||
// Logs the guest login success action. | ||
void OnGuestLoignSuccess(); | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // ASH_COMPONENTS_LOGIN_AUTH_METRICS_RECORDER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters