From f950694e9386228c7cd04bd6149cfc73c633d134 Mon Sep 17 00:00:00 2001 From: Darnell Andries Date: Wed, 15 Jan 2025 13:30:25 -0800 Subject: [PATCH] Add date of install P3A attribute, change format of "day zero" metric --- browser/brave_browser_process_impl.cc | 3 +- .../ntp_p3a_helper_impl_unittest.cc | 4 +- .../misc_metrics/general_browser_usage.cc | 21 +++++++--- .../misc_metrics/general_browser_usage.h | 3 +- .../general_browser_usage_unittest.cc | 42 +++++++------------ components/misc_metrics/pref_names.h | 2 + .../p3a/constellation_helper_unittest.cc | 16 +++---- components/p3a/message_manager.cc | 4 +- components/p3a/message_manager.h | 2 +- components/p3a/message_manager_unittest.cc | 4 +- components/p3a/metric_config.h | 3 +- components/p3a/metric_names.h | 9 +--- components/p3a/p3a_message.cc | 18 ++++---- components/p3a/p3a_message.h | 2 +- components/p3a/p3a_service.cc | 7 +++- components/p3a/p3a_service.h | 2 +- components/p3a/p3a_service_unittest.cc | 4 +- 17 files changed, 78 insertions(+), 68 deletions(-) diff --git a/browser/brave_browser_process_impl.cc b/browser/brave_browser_process_impl.cc index 44eea71dc3b7..ed11d0942f47 100644 --- a/browser/brave_browser_process_impl.cc +++ b/browser/brave_browser_process_impl.cc @@ -16,6 +16,7 @@ #include "brave/browser/brave_referrals/referrals_service_delegate.h" #include "brave/browser/brave_shields/ad_block_subscription_download_manager_getter.h" #include "brave/browser/brave_stats/brave_stats_updater.h" +#include "brave/browser/brave_stats/first_run_util.h" #include "brave/browser/brave_wallet/wallet_data_files_installer_delegate_impl.h" #include "brave/browser/component_updater/brave_component_updater_configurator.h" #include "brave/browser/misc_metrics/process_misc_metrics.h" @@ -406,7 +407,7 @@ p3a::P3AService* BraveBrowserProcessImpl::p3a_service() { } p3a_service_ = base::MakeRefCounted( *local_state(), brave::GetChannelName(), - local_state()->GetString(kWeekOfInstallation), + brave_stats::GetFirstRunTime(local_state()), p3a::P3AConfig::LoadFromCommandLine()); p3a_service()->InitCallbacks(); return p3a_service_.get(); diff --git a/browser/ntp_background/ntp_p3a_helper_impl_unittest.cc b/browser/ntp_background/ntp_p3a_helper_impl_unittest.cc index 914f6e3fa25f..cb5742f73170 100644 --- a/browser/ntp_background/ntp_p3a_helper_impl_unittest.cc +++ b/browser/ntp_background/ntp_p3a_helper_impl_unittest.cc @@ -71,8 +71,10 @@ class NTPP3AHelperImplTest : public testing::Test { config.p3a_json_upload_url = GURL(kTestP3AJsonHost); config.p2a_json_upload_url = GURL(kTestP2AJsonHost); config.p3a_creative_upload_url = GURL(kTestP3ACreativeHost); + base::Time install_time; + ASSERT_TRUE(base::Time::FromString("2049-01-01", &install_time)); p3a_service_ = scoped_refptr(new p3a::P3AService( - local_state_, "release", "2049-01-01", std::move(config))); + local_state_, "release", install_time, std::move(config))); ntp_p3a_helper_ = std::make_unique( &local_state_, p3a_service_.get(), diff --git a/components/misc_metrics/general_browser_usage.cc b/components/misc_metrics/general_browser_usage.cc index 78f69ce00907..75e143fe651e 100644 --- a/components/misc_metrics/general_browser_usage.cc +++ b/components/misc_metrics/general_browser_usage.cc @@ -6,7 +6,6 @@ #include "brave/components/misc_metrics/general_browser_usage.h" #include "base/metrics/histogram_macros.h" -#include "base/strings/strcat.h" #include "base/strings/string_util.h" #include "base/time/time.h" #include "brave/components/misc_metrics/pref_names.h" @@ -54,6 +53,7 @@ GeneralBrowserUsage::~GeneralBrowserUsage() = default; void GeneralBrowserUsage::RegisterPrefs(PrefRegistrySimple* registry) { registry->RegisterListPref(kMiscMetricsBrowserUsageList); registry->RegisterStringPref(kMiscMetricsDayZeroVariantAtInstall, {}); + registry->RegisterTimePref(kMiscMetricsLastDayZeroReport, {}); } void GeneralBrowserUsage::ReportWeeklyUse() { @@ -68,19 +68,28 @@ void GeneralBrowserUsage::ReportWeeklyUse() { #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) void GeneralBrowserUsage::ReportInstallTime() { - int days_since_install = (base::Time::Now() - first_run_time_).InDays(); + int days_since_install = + (base::Time::Now() - first_run_time_).InDaysFloored(); if (days_since_install < 0 || days_since_install > 30) { return; } + auto start_of_report_day = first_run_time_ + base::Days(days_since_install); + auto last_report = local_state_->GetTime(kMiscMetricsLastDayZeroReport); + if (last_report >= start_of_report_day) { + return; + } std::string day_zero_variant = local_state_->GetString(kMiscMetricsDayZeroVariantAtInstall); if (day_zero_variant.empty()) { return; } - std::string histogram_name = base::StrCat( - {kDayZeroInstallTimePrefix, base::ToUpperASCII(day_zero_variant), - kDayZeroInstallTimeSuffix}); - base::UmaHistogramExactLinear(histogram_name, days_since_install, 31); + // Get index of first char (0-25 for a-z) + int variant_index = base::ToLowerASCII(day_zero_variant[0]) - 'a'; + if (variant_index < 0) { + return; + } + local_state_->SetTime(kMiscMetricsLastDayZeroReport, base::Time::Now()); + UMA_HISTOGRAM_EXACT_LINEAR(kDayZeroVariantHistogramName, variant_index, 31); } #endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) diff --git a/components/misc_metrics/general_browser_usage.h b/components/misc_metrics/general_browser_usage.h index 73e15c754dca..0aae9117c4c0 100644 --- a/components/misc_metrics/general_browser_usage.h +++ b/components/misc_metrics/general_browser_usage.h @@ -23,8 +23,7 @@ inline constexpr char kWeeklyUseHistogramName[] = "Brave.Core.WeeklyUsage"; inline constexpr char kProfileCountHistogramName[] = "Brave.Core.ProfileCount"; #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) -inline constexpr char kDayZeroInstallTimePrefix[] = "Brave.DayZero."; -inline constexpr char kDayZeroInstallTimeSuffix[] = ".InstallTime"; +inline constexpr char kDayZeroVariantHistogramName[] = "Brave.DayZero.Variant"; #endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) // TODO(djandries): remove this metric when Nebula experiment is over diff --git a/components/misc_metrics/general_browser_usage_unittest.cc b/components/misc_metrics/general_browser_usage_unittest.cc index ef973f2e861a..21f9a6e8d396 100644 --- a/components/misc_metrics/general_browser_usage_unittest.cc +++ b/components/misc_metrics/general_browser_usage_unittest.cc @@ -16,11 +16,6 @@ namespace misc_metrics { -#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) -constexpr char kDayZeroAInstallTime[] = "Brave.DayZero.A.InstallTime"; -constexpr char kDayZeroBInstallTime[] = "Brave.DayZero.B.InstallTime"; -#endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) - class GeneralBrowserUsageUnitTest : public testing::Test { public: GeneralBrowserUsageUnitTest() @@ -98,55 +93,48 @@ TEST_F(GeneralBrowserUsageUnitTest, ProfileCount) { #endif // !BUILDFLAG(IS_ANDROID) #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) -TEST_F(GeneralBrowserUsageUnitTest, InstallTimeB) { +TEST_F(GeneralBrowserUsageUnitTest, InstallTimeVariantSwitch) { base::Time install_time = base::Time::Now(); SetUpUsage("B", true, install_time); - histogram_tester_->ExpectUniqueSample(kDayZeroBInstallTime, 0, 1); + histogram_tester_->ExpectUniqueSample(kDayZeroVariantHistogramName, 1, 1); task_environment_.FastForwardBy(base::Days(15)); - int last_bucket_count = - histogram_tester_->GetBucketCount(kDayZeroBInstallTime, 15); - EXPECT_GE(last_bucket_count, 1); - histogram_tester_->ExpectTotalCount(kDayZeroAInstallTime, 0); + histogram_tester_->ExpectUniqueSample(kDayZeroVariantHistogramName, 1, 16); SetUpUsage("A", false, install_time); // Ensure histogram name does not change if "day zero" is enabled // after install; we only want to report the "day zero on" metric // if it was enabled at install time. - EXPECT_GT(histogram_tester_->GetBucketCount(kDayZeroBInstallTime, 15), - last_bucket_count); - histogram_tester_->ExpectTotalCount(kDayZeroAInstallTime, 0); + histogram_tester_->ExpectUniqueSample(kDayZeroVariantHistogramName, 1, 16); task_environment_.FastForwardBy(base::Days(16)); - EXPECT_GE(histogram_tester_->GetBucketCount(kDayZeroBInstallTime, 30), 1); + histogram_tester_->ExpectUniqueSample(kDayZeroVariantHistogramName, 1, 31); ResetHistogramTester(); // Ensure there are no more reports past 30 days task_environment_.FastForwardBy(base::Days(5)); - histogram_tester_->ExpectTotalCount(kDayZeroBInstallTime, 0); - histogram_tester_->ExpectTotalCount(kDayZeroAInstallTime, 0); + histogram_tester_->ExpectTotalCount(kDayZeroVariantHistogramName, 0); + histogram_tester_->ExpectTotalCount(kDayZeroVariantHistogramName, 0); } -TEST_F(GeneralBrowserUsageUnitTest, InstallTimeA) { +TEST_F(GeneralBrowserUsageUnitTest, InstallTimeBasic) { base::Time install_time = base::Time::Now(); SetUpUsage("A", true, install_time); - histogram_tester_->ExpectUniqueSample(kDayZeroAInstallTime, 0, 1); + histogram_tester_->ExpectUniqueSample(kDayZeroVariantHistogramName, 0, 1); task_environment_.FastForwardBy(base::Days(15)); - int last_bucket_count = - histogram_tester_->GetBucketCount(kDayZeroAInstallTime, 15); - EXPECT_GE(last_bucket_count, 1); - histogram_tester_->ExpectTotalCount(kDayZeroBInstallTime, 0); + histogram_tester_->ExpectUniqueSample(kDayZeroVariantHistogramName, 0, 16); - SetUpUsage("B", false, install_time); - EXPECT_GT(histogram_tester_->GetBucketCount(kDayZeroAInstallTime, 15), - last_bucket_count); - histogram_tester_->ExpectTotalCount(kDayZeroBInstallTime, 0); + task_environment_.FastForwardBy(base::Days(15)); + histogram_tester_->ExpectUniqueSample(kDayZeroVariantHistogramName, 0, 31); + + task_environment_.FastForwardBy(base::Days(15)); + histogram_tester_->ExpectUniqueSample(kDayZeroVariantHistogramName, 0, 31); } #endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) diff --git a/components/misc_metrics/pref_names.h b/components/misc_metrics/pref_names.h index de1a6cbf62c4..c4981b3f9b6a 100644 --- a/components/misc_metrics/pref_names.h +++ b/components/misc_metrics/pref_names.h @@ -64,6 +64,8 @@ inline constexpr char kMiscMetricsTotalLocationBarEntriesStorage[] = inline constexpr char kMiscMetricsDayZeroVariantAtInstall[] = "brave.misc_metrics.day_zero_variant_at_install"; +inline constexpr char kMiscMetricsLastDayZeroReport[] = + "brave.misc_metrics.last_day_zero_report"; inline constexpr char kMiscMetricsNTPWidgetUsageStorage[] = "brave.misc_metrics.ntp_widget_usage"; diff --git a/components/p3a/constellation_helper_unittest.cc b/components/p3a/constellation_helper_unittest.cc index 08b2766d6366..a8d6219ac712 100644 --- a/components/p3a/constellation_helper_unittest.cc +++ b/components/p3a/constellation_helper_unittest.cc @@ -60,6 +60,7 @@ class P3AConstellationHelperTest : public testing::Test { protected: void SetUp() override { + ASSERT_TRUE(base::Time::FromString("2022-01-01", &install_time_)); p3a_config_.disable_star_attestation = true; p3a_config_.star_randomness_host = kTestHost; @@ -175,6 +176,7 @@ class P3AConstellationHelperTest : public testing::Test { std::string histogram_name_from_callback_; uint8_t epoch_from_callback_; + base::Time install_time_; base::flat_map info_request_made_; base::flat_map points_request_made_; @@ -251,7 +253,7 @@ TEST_F(P3AConstellationHelperTest, GenerateBasicMessage) { task_environment_.RunUntilIdle(); MessageMetainfo meta_info; - meta_info.Init(&local_state_, "release", "2022-01-01"); + meta_info.Init(&local_state_, "release", install_time_); helper_->StartMessagePreparation( kTestHistogramName, log_type, @@ -274,7 +276,7 @@ TEST_F(P3AConstellationHelperTest, GenerateBasicMessage) { TEST_F(P3AConstellationHelperTest, IncludeRefcode) { MessageMetainfo meta_info; - meta_info.Init(&local_state_, "release", "2022-01-01"); + meta_info.Init(&local_state_, "release", install_time_); std::string message_with_no_refcode = GenerateP3AConstellationMessage( kTestHistogramName, 0, meta_info, kP3AUploadType, std::nullopt); @@ -299,7 +301,7 @@ TEST_F(P3AConstellationHelperTest, IncludeRefcode) { #if !BUILDFLAG(IS_IOS) local_state_.SetString(kReferralPromoCode, "BRV003"); - meta_info.Init(&local_state_, "release", "2022-01-01"); + meta_info.Init(&local_state_, "release", install_time_); message_with_refcode = GenerateP3AConstellationMessage( kTestHistogramName, 0, meta_info, kP3AUploadType, @@ -313,7 +315,7 @@ TEST_F(P3AConstellationHelperTest, IncludeRefcode) { EXPECT_EQ(refcode_layers.at(8), "ref|BRV003"); local_state_.SetString(kReferralPromoCode, "ZRK009"); - meta_info.Init(&local_state_, "release", "2022-01-01"); + meta_info.Init(&local_state_, "release", install_time_); message_with_refcode = GenerateP3AConstellationMessage( kTestHistogramName, 0, meta_info, kP3AUploadType, @@ -330,7 +332,7 @@ TEST_F(P3AConstellationHelperTest, IncludeRefcode) { TEST_F(P3AConstellationHelperTest, CustomAttributes) { MessageMetainfo meta_info; - meta_info.Init(&local_state_, "release", "2022-01-01"); + meta_info.Init(&local_state_, "release", install_time_); // Test with custom attributes list MetricConfig config{.attributes = MetricAttributes{ @@ -370,7 +372,7 @@ TEST_F(P3AConstellationHelperTest, CustomAttributes) { TEST_F(P3AConstellationHelperTest, NebulaMessage) { MessageMetainfo meta_info; - meta_info.Init(&local_state_, "release", "2022-01-01"); + meta_info.Init(&local_state_, "release", install_time_); std::string message = GenerateP3AConstellationMessage( kTestHistogramName, 3, meta_info, kP3AUploadType, @@ -394,7 +396,7 @@ TEST_F(P3AConstellationHelperTest, NebulaSample) { task_environment_.RunUntilIdle(); MessageMetainfo meta_info; - meta_info.Init(&local_state_, "release", "2022-01-01"); + meta_info.Init(&local_state_, "release", install_time_); helper_->StartMessagePreparation( kTestNebulaHistogramName, MetricLogType::kTypical, diff --git a/components/p3a/message_manager.cc b/components/p3a/message_manager.cc index cf95058e4d0c..5a32a5ebf1ac 100644 --- a/components/p3a/message_manager.cc +++ b/components/p3a/message_manager.cc @@ -40,9 +40,9 @@ MessageManager::MessageManager(PrefService& local_state, const P3AConfig* config, Delegate& delegate, std::string channel, - std::string week_of_install) + base::Time first_run_time) : local_state_(local_state), config_(config), delegate_(delegate) { - message_meta_.Init(&local_state, channel, week_of_install); + message_meta_.Init(&local_state, channel, first_run_time); // Init log stores. for (MetricLogType log_type : kAllMetricLogTypes) { diff --git a/components/p3a/message_manager.h b/components/p3a/message_manager.h index 48ded4faf72b..a6000d5601a2 100644 --- a/components/p3a/message_manager.h +++ b/components/p3a/message_manager.h @@ -66,7 +66,7 @@ class MessageManager : public MetricLogStore::Delegate { const P3AConfig* config, Delegate& delegate, std::string channel, - std::string week_of_install); + base::Time first_run_time); ~MessageManager() override; MessageManager(const MessageManager&) = delete; diff --git a/components/p3a/message_manager_unittest.cc b/components/p3a/message_manager_unittest.cc index 086c29b0fbc5..6dd63b91e324 100644 --- a/components/p3a/message_manager_unittest.cc +++ b/components/p3a/message_manager_unittest.cc @@ -158,8 +158,10 @@ class P3AMessageManagerTest : public testing::Test, url_loader_factory_.AddResponse(request.url.spec(), response); })); + base::Time install_time; + ASSERT_TRUE(base::Time::FromString("2099-01-01", &install_time)); message_manager_ = std::make_unique( - *local_state_, &p3a_config_, *this, "release", "2099-01-01"); + *local_state_, &p3a_config_, *this, "release", install_time); message_manager_->Start(shared_url_loader_factory_); diff --git a/components/p3a/metric_config.h b/components/p3a/metric_config.h index d755216bf359..845ad4a85728 100644 --- a/components/p3a/metric_config.h +++ b/components/p3a/metric_config.h @@ -25,7 +25,8 @@ enum class MetricAttribute { kRegion, kSubregion, kRef, - kMaxValue = kRef, + kDateOfInstall, + kMaxValue = kDateOfInstall, }; inline constexpr MetricAttribute kDefaultMetricAttributes[] = { diff --git a/components/p3a/metric_names.h b/components/p3a/metric_names.h index c52743103a2c..79ec094aaf1c 100644 --- a/components/p3a/metric_names.h +++ b/components/p3a/metric_names.h @@ -237,15 +237,10 @@ inline constexpr auto kCollectedExpressHistograms = {"Brave.AIChat.UsageDaily.2", MetricConfig{.ephemeral = true}}, {"Brave.AIChat.UsageDaily.SidebarEnabledA", MetricConfig{.ephemeral = true}}, {"Brave.Core.UsageDaily", {}}, - {"Brave.DayZero.A.InstallTime", MetricConfig{ + {"Brave.DayZero.Variant", MetricConfig{ .ephemeral = true, .constellation_only = true, - .append_attributes = MetricAttributesToAppend{MetricAttribute::kRef} - }}, - {"Brave.DayZero.B.InstallTime", MetricConfig{ - .ephemeral = true, - .constellation_only = true, - .append_attributes = MetricAttributesToAppend{MetricAttribute::kRef} + .attributes = MetricAttributes{MetricAttribute::kAnswerIndex, MetricAttribute::kDateOfInstall, MetricAttribute::kVersion, MetricAttribute::kChannel, MetricAttribute::kPlatform, MetricAttribute::kCountryCode, MetricAttribute::kRef} }}, {"Brave.Rewards.EnabledInstallationTime", MetricConfig{.ephemeral = true}}, {"Brave.Search.BraveDaily", MetricConfig{.ephemeral = true}}, diff --git a/components/p3a/p3a_message.cc b/components/p3a/p3a_message.cc index ae7fead336b0..7b0b7e958b31 100644 --- a/components/p3a/p3a_message.cc +++ b/components/p3a/p3a_message.cc @@ -17,6 +17,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" +#include "base/strings/stringprintf.h" #include "brave/components/brave_stats/browser/brave_stats_updater_util.h" #include "brave/components/l10n/common/locale_util.h" #include "brave/components/p3a/metric_config.h" @@ -44,6 +45,7 @@ constexpr char kWosAttributeName[] = "wos"; constexpr char kMosAttributeName[] = "mos"; constexpr char kWoiAttributeName[] = "woi"; constexpr char kYoiAttributeName[] = "yoi"; +constexpr char kDateOfInstallAttributeName[] = "dtoi"; constexpr char kCountryCodeAttributeName[] = "country_code"; constexpr char kVersionAttributeName[] = "version"; constexpr char kRegionAttributeName[] = "region"; @@ -75,7 +77,7 @@ std::vector> PopulateConstellationAttributes( const std::vector& attributes_to_load, bool is_creative) { base::Time::Exploded exploded; - meta.date_of_install().LocalExplode(&exploded); + meta.date_of_install().UTCExplode(&exploded); DCHECK_GE(exploded.year, 999); std::vector> attributes; @@ -88,6 +90,7 @@ std::vector> PopulateConstellationAttributes( attributes = {{kMetricNameAttributeName, std::string(metric_name)}}; } std::string country_code; + std::string dtoi; for (const auto& attribute : attributes_to_load) { switch (attribute) { case MetricAttribute::kAnswerIndex: @@ -132,6 +135,11 @@ std::vector> PopulateConstellationAttributes( attributes.push_back( {kWoiAttributeName, base::NumberToString(meta.woi())}); break; + case MetricAttribute::kDateOfInstall: + dtoi = base::StringPrintf("%d-%02d-%02d", exploded.year, exploded.month, + exploded.day_of_month); + attributes.push_back({kDateOfInstallAttributeName, dtoi}); + break; case MetricAttribute::kGeneralPlatform: attributes.push_back( {kGeneralPlatformAttributeName, meta.general_platform()}); @@ -273,7 +281,7 @@ std::string GenerateP3AConstellationMessage( void MessageMetainfo::Init(PrefService* local_state, std::string brave_channel, - std::string week_of_install) { + base::Time first_run_time) { local_state_ = local_state; platform_ = brave_stats::GetPlatformIdentifier(); general_platform_ = brave_stats::GetGeneralPlatformIdentifier(); @@ -281,11 +289,7 @@ void MessageMetainfo::Init(PrefService* local_state, InitVersion(); InitRef(); - if (!week_of_install.empty()) { - date_of_install_ = brave_stats::GetYMDAsDate(week_of_install); - } else { - date_of_install_ = base::Time::Now(); - } + date_of_install_ = first_run_time; woi_ = brave_stats::GetIsoWeekNumber(date_of_install_); country_code_from_timezone_raw_ = diff --git a/components/p3a/p3a_message.h b/components/p3a/p3a_message.h index 16eba10dfa9a..2e880851a37f 100644 --- a/components/p3a/p3a_message.h +++ b/components/p3a/p3a_message.h @@ -31,7 +31,7 @@ class MessageMetainfo { void Init(PrefService* local_state, std::string brave_channel, - std::string week_of_install); + base::Time first_run_time); void Update(); diff --git a/components/p3a/p3a_service.cc b/components/p3a/p3a_service.cc index ddca9d736e2b..94f26a4a5763 100644 --- a/components/p3a/p3a_service.cc +++ b/components/p3a/p3a_service.cc @@ -76,12 +76,15 @@ inline void DCheckCurrentlyOnUIThread() { P3AService::P3AService(PrefService& local_state, std::string channel, - std::string week_of_install, + base::Time first_run_time, P3AConfig config) : local_state_(local_state), config_(std::move(config)) { LoadDynamicMetrics(); + if (first_run_time.is_null()) { + first_run_time = base::Time::Now(); + } message_manager_ = std::make_unique( - local_state, &config_, *this, channel, week_of_install); + local_state, &config_, *this, channel, first_run_time); pref_change_registrar_.Init(&local_state); pref_change_registrar_.Add( kP3AEnabled, base::BindRepeating(&P3AService::OnP3AEnabledChanged, diff --git a/components/p3a/p3a_service.h b/components/p3a/p3a_service.h index 52dde2309978..96cc2333e920 100644 --- a/components/p3a/p3a_service.h +++ b/components/p3a/p3a_service.h @@ -45,7 +45,7 @@ class P3AService : public base::RefCountedThreadSafe, public: P3AService(PrefService& local_state, std::string channel, - std::string week_of_install, + base::Time first_run_time, P3AConfig config); P3AService(const P3AService&) = delete; diff --git a/components/p3a/p3a_service_unittest.cc b/components/p3a/p3a_service_unittest.cc index 637811c2b0fb..5e2b450ece30 100644 --- a/components/p3a/p3a_service_unittest.cc +++ b/components/p3a/p3a_service_unittest.cc @@ -85,8 +85,10 @@ class P3AServiceTest : public testing::Test { void TearDown() override { p3a_service_ = nullptr; } void SetUpP3AService() { + base::Time install_time; + ASSERT_TRUE(base::Time::FromString("2049-01-01", &install_time)); p3a_service_ = scoped_refptr(new P3AService( - local_state_, "release", "2049-01-01", P3AConfig(config_))); + local_state_, "release", install_time, P3AConfig(config_))); p3a_service_->DisableStarAttestationForTesting(); p3a_service_->Init(shared_url_loader_factory_);