Commit 085bbd72 authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] All messages to the server now contain the active field...

[Autofill Assistant] All messages to the server now contain the active field trials of the client as part of the ClientContextProto.

This will allow the server to log the field trial state, which in turn will allow us to analyze how user behavior changes with respect to the active field trials. Serializing all active field trials makes this easier to maintain at the cost of some additional message overhead and log storage. For each active field trial, the trial name and the name of the randomly selected trial group are sent.

Bug: 806868
Change-Id: I0417b3d548f36ca8c98c80182ec314e8bb20eba0
Reviewed-on: https://chromium-review.googlesource.com/c/1326014Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#606801}
parent 43d0eed3
......@@ -6,7 +6,9 @@
#include <utility>
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "components/autofill_assistant/browser/actions/autofill_action.h"
#include "components/autofill_assistant/browser/actions/click_action.h"
#include "components/autofill_assistant/browser/actions/focus_element_action.h"
......@@ -44,6 +46,21 @@ void AddScriptParametersToProto(
}
}
// Fills the destination ClientContextProto fields.
void FillClientContext(ClientContextProto* destination) {
destination->mutable_chrome()->set_chrome_version(
version_info::GetProductNameAndVersionForUserAgent());
base::FieldTrial::ActiveGroups active_groups;
base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups);
for (const auto& group : active_groups) {
FieldTrialProto* field_trial =
destination->mutable_chrome()->add_active_field_trials();
field_trial->set_trial_name(group.trial_name);
field_trial->set_group_name(group.group_name);
}
}
} // namespace
// static
......@@ -54,8 +71,7 @@ std::string ProtocolUtils::CreateGetScriptsRequest(
SupportsScriptRequestProto script_proto;
script_proto.set_url(url.spec());
script_proto.mutable_client_context()->mutable_chrome()->set_chrome_version(
version_info::GetProductNameAndVersionForUserAgent());
FillClientContext(script_proto.mutable_client_context());
AddScriptParametersToProto(parameters,
script_proto.mutable_script_parameters());
std::string serialized_script_proto;
......@@ -118,8 +134,7 @@ std::string ProtocolUtils::CreateInitialScriptActionsRequest(
query->set_policy(PolicyType::SCRIPT);
AddScriptParametersToProto(
parameters, initial_request_proto->mutable_script_parameters());
request_proto.mutable_client_context()->mutable_chrome()->set_chrome_version(
version_info::GetProductNameAndVersionForUserAgent());
FillClientContext(request_proto.mutable_client_context());
if (!server_payload.empty()) {
request_proto.set_server_payload(server_payload);
......@@ -143,6 +158,7 @@ std::string ProtocolUtils::CreateNextScriptActionsRequest(
for (const auto& processed_action : processed_actions) {
next_request->add_processed_actions()->MergeFrom(processed_action);
}
FillClientContext(request_proto.mutable_client_context());
std::string serialized_request_proto;
bool success = request_proto.SerializeToString(&serialized_request_proto);
DCHECK(success);
......
......@@ -8,9 +8,19 @@ option optimize_for = LITE_RUNTIME;
package autofill_assistant;
// A field trial containing the name of the trial and the name of the
// randomly selected trial group.
message FieldTrialProto {
optional string trial_name = 1;
optional string group_name = 2;
}
// Context contains client environment details.
message ClientContextProto {
message Chrome { optional string chrome_version = 1; }
message Chrome {
optional string chrome_version = 1;
repeated FieldTrialProto active_field_trials = 2;
}
oneof client { Chrome chrome = 1; }
}
......
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