blob: 7c177932ef89e23e2ea3deeea9a716fe4362ac7f [file] [log] [blame]
// Copyright 2021 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 "components/metrics/structured/neutrino_logging_util.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/metrics/structured/structured_events.h"
namespace metrics {
namespace structured {
void NeutrinoDevicesLogWithLocalState(PrefService* local_state,
NeutrinoDevicesLocation location) {
auto code_point = events::neutrino_devices::CodePoint();
if (local_state &&
local_state->HasPrefPath(metrics::prefs::kMetricsClientID)) {
const std::string client_id =
local_state->GetString(metrics::prefs::kMetricsClientID);
if (!client_id.empty())
code_point.SetClientId(client_id);
}
code_point.SetLocation(static_cast<int64_t>(location)).Record();
}
void NeutrinoDevicesLogEnrollmentWithLocalState(
PrefService* local_state,
bool is_managed,
NeutrinoDevicesLocation location) {
auto enrollment = events::neutrino_devices::Enrollment();
if (local_state &&
local_state->HasPrefPath(metrics::prefs::kMetricsClientID)) {
const std::string client_id =
local_state->GetString(metrics::prefs::kMetricsClientID);
if (!client_id.empty())
enrollment.SetClientId(client_id);
}
enrollment.SetIsManagedPolicy(is_managed)
.SetLocation(static_cast<int64_t>(location))
.Record();
}
} // namespace structured
} // namespace metrics