1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_FEEDBACK_REDACTION_TOOL_REDACTION_TOOL_METRICS_RECORDER_H_
#define COMPONENTS_FEEDBACK_REDACTION_TOOL_REDACTION_TOOL_METRICS_RECORDER_H_
#include <memory>
#include <string_view>
#include "base/time/time.h"
#include "components/feedback/redaction_tool/pii_types.h"
namespace redaction {
// These values are logged to UMA. Entries should not be renumbered and
// numeric values should never be reused. Please keep in sync with
// "CreditCardDetection" in //tools/metrics/histograms/enums.xml.
enum class CreditCardDetection {
kRegexMatch = 1,
kTimestamp = 2,
kRepeatedChars = 3,
kDoesntValidate = 4,
kValidated = 5,
kMaxValue = kValidated,
};
// These values are logged to UMA. Entries should not be renumbered and
// numeric values should never be reused. Please keep in sync with
// "RedactionToolCaller" in //tools/metrics/histograms/enums.xml.
enum class RedactionToolCaller {
kSysLogUploader = 1,
kSysLogFetcher = 2,
kSupportTool = 3,
kErrorReporting = 4,
// Feedback Tool is deprecated and split into it's components.
// kFeedbackTool = 5,
// Browser system logs is deprecated since it's being called only
// by the feedback tool.
// kBrowserSystemLogs = 6,
kUnitTest = 7,
kUndetermined = 8,
kUnknown = 9,
kCrashTool = 10,
kCrashToolJSErrors = 11,
kFeedbackToolHotRod = 12,
kFeedbackToolUserDescriptions = 13,
kFeedbackToolLogs = 14,
kMaxValue = kFeedbackToolLogs,
};
inline constexpr char kPIIRedactedHistogram[] = "Feedback.RedactionTool";
inline constexpr char kCreditCardRedactionHistogram[] =
"Feedback.RedactionTool.CreditCardMatch";
inline constexpr char kRedactionToolCallerHistogram[] =
"Feedback.RedactionTool.Caller";
// This class is the platform independent interface to record histograms using
// the platform specific libraries.
class RedactionToolMetricsRecorder {
public:
// Create a new instance of the platform default implementation.
static std::unique_ptr<RedactionToolMetricsRecorder> Create();
RedactionToolMetricsRecorder() = default;
RedactionToolMetricsRecorder(const RedactionToolMetricsRecorder&) = delete;
RedactionToolMetricsRecorder& operator=(const RedactionToolMetricsRecorder&) =
delete;
virtual ~RedactionToolMetricsRecorder() = default;
// Record when a bit of PII of the type `pii_type` was redacted by the
// redaction tool.
virtual void RecordPIIRedactedHistogram(PIIType pii_type) = 0;
// Records the `step` that was reached when validating a series of numbers
// against credit card checks.
virtual void RecordCreditCardRedactionHistogram(CreditCardDetection step) = 0;
// Records the caller who initiated the call to the Redaction Tool.
virtual void RecordRedactionToolCallerHistogram(RedactionToolCaller step) = 0;
// Records the `time_spent` in milliseconds for redacting an input text.
virtual void RecordTimeSpentRedactingHistogram(
base::TimeDelta time_spent) = 0;
// Returns the platform specific metric name used to measure how long it took
// to redact the input.
static std::string_view GetTimeSpentRedactingHistogramNameForTesting();
};
} // namespace redaction
#endif // COMPONENTS_FEEDBACK_REDACTION_TOOL_REDACTION_TOOL_METRICS_RECORDER_H_
|