1 // Copyright 2023 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "components/metrics/debug/structured/structured_metrics_utils.h" 6 7 #include "base/i18n/number_formatting.h" 8 #include "components/metrics/structured/structured_metrics_service.h" 9 10 namespace metrics::structured { 11 GetStructuredMetricsSummary(StructuredMetricsService * service)12base::Value GetStructuredMetricsSummary(StructuredMetricsService* service) { 13 base::Value::Dict result = base::Value::Dict().Set("enabled", false); 14 15 #if BUILDFLAG(IS_CHROMEOS_ASH) 16 result.Set("crosDeviceId", "-"); 17 #endif 18 19 if (service && service->recording_enabled()) { 20 result.Set("enabled", true); 21 #if BUILDFLAG(IS_CHROMEOS_ASH) 22 auto id = 23 service->recorder()->key_data_provider()->GetSecondaryId("CrOSEvents"); 24 if (id.has_value()) { 25 result.Set("crosDeviceId", base::NumberToString(id.value())); 26 } 27 #endif 28 } 29 30 return base::Value(std::move(result)); 31 } 32 33 } // namespace metrics::structured 34