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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
// Copyright 2022 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_AUTOFILL_CORE_BROWSER_METRICS_LOG_EVENT_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_METRICS_LOG_EVENT_H_
#include <variant>
#include "base/time/time.h"
#include "base/types/id_type.h"
#include "components/autofill/core/browser/filling/field_filling_skip_reason.h"
#include "components/autofill/core/browser/heuristic_source.h"
#include "components/autofill/core/browser/proto/api_v1.pb.h"
#include "components/autofill/core/browser/studies/autofill_ablation_study.h"
#include "components/autofill/core/common/is_required.h"
namespace autofill {
using FieldPrediction =
AutofillQueryResponse::FormSuggestion::FieldSuggestion::FieldPrediction;
// An identifier to connect the various sub-events of filling together.
using FillEventId = base::IdTypeU32<class FillEventIdClass>;
FillEventId GetNextFillEventId();
enum class OptionalBoolean : uint8_t {
kFalse = 0,
kTrue = 1,
kUndefined = 2,
};
OptionalBoolean& operator|=(OptionalBoolean& a, OptionalBoolean b);
OptionalBoolean ToOptionalBoolean(bool value);
bool OptionalBooleanToBool(OptionalBoolean value);
// Enum for different data types filled during autofill filling events,
// including those of the SingleFieldFiller.
enum class FillDataType : uint8_t {
kUndefined = 0,
kAutofillProfile = 1,
kCreditCard = 2,
kSingleFieldFillerAutocomplete = 3,
kSingleFieldFillerIban = 4,
kSingleFieldFillerPromoCode = 5,
kAutofillAi = 6,
kSingleFieldFillerLoyaltyCard = 7,
};
// AreCollapsible(..., ...) are a set of functions that checks whether two
// consecutive events in the event log of a form can be merged into one.
// This is a best effort mechanism to reduce the memory footprint caused by
// redundant events.
bool AreCollapsible(const std::monostate& event1, const std::monostate& event2);
// Log the field that shows a dropdown list of suggestions for autofill.
struct AskForValuesToFillFieldLogEvent {
OptionalBoolean has_suggestion = internal::IsRequired();
OptionalBoolean suggestion_is_shown = internal::IsRequired();
};
bool AreCollapsible(const AskForValuesToFillFieldLogEvent& event1,
const AskForValuesToFillFieldLogEvent& event2);
// Log the field that triggers the suggestion that the user selects to fill.
struct TriggerFillFieldLogEvent {
FillEventId fill_event_id = GetNextFillEventId();
// The type of filled data for the Autofill event.
FillDataType data_type = internal::IsRequired();
// The country_code associated with the information filled. Only present for
// autofill addresses (i.e. `AutofillEventType::kAutofillProfile`).
std::string associated_country_code = internal::IsRequired();
// The time at which the event occurred.
base::Time timestamp = internal::IsRequired();
};
bool AreCollapsible(const TriggerFillFieldLogEvent& event1,
const TriggerFillFieldLogEvent& event2);
// Log the fields on the form that are autofilled.
struct FillFieldLogEvent {
// This refers to `TriggleFillFieldLogEvent::fill_event_id`.
FillEventId fill_event_id = internal::IsRequired();
OptionalBoolean had_value_before_filling = internal::IsRequired();
FieldFillingSkipReason autofill_skipped_status = internal::IsRequired();
// The two attributes below are only valid if |autofill_skipped_status| has a
// value of "kNotSkipped".
// Whether the field was autofilled during this fill operation. If a fill
// operation did not change the value of a field because the old value
// matches the filled value, this is still recorded as a
// was_autofilled = true before checking the iframe security policy.
OptionalBoolean was_autofilled_before_security_policy =
internal::IsRequired();
// Whether the field had a value after this fill operation.
OptionalBoolean had_value_after_filling = internal::IsRequired();
// Records whether filling was ever prevented because of the cross c
// autofill security policy that applies to credit cards.
OptionalBoolean filling_prevented_by_iframe_security_policy =
OptionalBoolean::kUndefined;
// Indicates whether the filling was triggered due to a change in a dynamic
// form. (see FormFiller::TriggerRefill()).
OptionalBoolean was_refill = OptionalBoolean::kUndefined;
};
bool AreCollapsible(const FillFieldLogEvent& event1,
const FillFieldLogEvent& event2);
// Log the field that the user types in.
struct TypingFieldLogEvent {
OptionalBoolean has_value_after_typing = internal::IsRequired();
};
bool AreCollapsible(const TypingFieldLogEvent& event1,
const TypingFieldLogEvent& event2);
// Events recorded after local heuristic prediction happened.
struct HeuristicPredictionFieldLogEvent {
FieldType field_type = internal::IsRequired();
HeuristicSource heuristic_source = internal::IsRequired();
bool is_active_heuristic_source = internal::IsRequired();
size_t rank_in_field_signature_group = internal::IsRequired();
};
bool AreCollapsible(const HeuristicPredictionFieldLogEvent& event1,
const HeuristicPredictionFieldLogEvent& event2);
// Events recorded after parsing autocomplete attribute.
struct AutocompleteAttributeFieldLogEvent {
HtmlFieldType html_type = internal::IsRequired();
HtmlFieldMode html_mode = internal::IsRequired();
size_t rank_in_field_signature_group = internal::IsRequired();
};
bool AreCollapsible(const AutocompleteAttributeFieldLogEvent& event1,
const AutocompleteAttributeFieldLogEvent& event2);
// Events recorded after autofill server prediction happened.
struct ServerPredictionFieldLogEvent {
std::optional<FieldType> server_type1 =
static_cast<FieldType>(internal::IsRequired());
FieldPrediction::Source prediction_source1 = internal::IsRequired();
std::optional<FieldType> server_type2 =
static_cast<FieldType>(internal::IsRequired());
FieldPrediction::Source prediction_source2 = internal::IsRequired();
bool server_type_prediction_is_override = internal::IsRequired();
size_t rank_in_field_signature_group = internal::IsRequired();
};
bool AreCollapsible(const ServerPredictionFieldLogEvent& event1,
const ServerPredictionFieldLogEvent& event2);
// Events recorded after rationalization happened.
struct RationalizationFieldLogEvent {
FieldType field_type = internal::IsRequired();
size_t section_id = internal::IsRequired();
bool type_changed = internal::IsRequired();
};
bool AreCollapsible(const RationalizationFieldLogEvent& event1,
const RationalizationFieldLogEvent& event2);
struct AblationFieldLogEvent {
AblationGroup ablation_group = internal::IsRequired();
AblationGroup conditional_ablation_group = internal::IsRequired();
int day_in_ablation_window = internal::IsRequired();
};
bool AreCollapsible(const AblationFieldLogEvent& event1,
const AblationFieldLogEvent& event2);
} // namespace autofill
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_METRICS_LOG_EVENT_H_
|