Skip to content

Commit

Permalink
[M110] Cherrypick: Adding default segmentIds for reporting metrics
Browse files Browse the repository at this point in the history
When SegmentationStructuredMetrics flags becomes enabled by default
through finch, we lost all the param values sent by that flag. As
a result, we are no longer getting the segment IDs that need to
report metrics.
This CL will hard code those values from the finch params. So that
the metrics will be properly reported.

BUG=1406404

(cherry picked from commit aaf6dd9)

Change-Id: Ia07beabc1dbb75db8fcac948c52086a248efb0a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4153335
Reviewed-by: Shakti Sahu <shaktisahu@chromium.org>
Commit-Queue: Min Qin <qinmin@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1091191}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4163258
Cr-Commit-Position: refs/branch-heads/5481@{#244}
Cr-Branched-From: 130f3e4-refs/heads/main@{#1084008}
  • Loading branch information
Min Qin authored and Chromium LUCI CQ committed Jan 12, 2023
1 parent 852e086 commit 5c45a02
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ const UkmMemberFn kSegmentationUkmOutputMethods[] = {
&Segmentation_ModelExecution::SetActualResult6};

base::flat_set<SegmentId> GetSegmentIdsAllowedForReporting() {
// TODO(crbug.com/1406404): Get allowed segment Ids from database.
if (base::FeatureList::IsEnabled(segmentation_platform::features::
kSegmentationDefaultReportingSegments)) {
return std::vector<SegmentId>{
SegmentId::OPTIMIZATION_TARGET_SEGMENTATION_NEW_TAB,
SegmentId::OPTIMIZATION_TARGET_SEGMENTATION_SHARE,
SegmentId::OPTIMIZATION_TARGET_SEGMENTATION_VOICE,
SegmentId::OPTIMIZATION_TARGET_SEGMENTATION_DUMMY,
SegmentId::OPTIMIZATION_TARGET_SEGMENTATION_CHROME_START_ANDROID,
SegmentId::OPTIMIZATION_TARGET_SEGMENTATION_QUERY_TILES,
SegmentId::OPTIMIZATION_TARGET_SEGMENTATION_CHROME_LOW_USER_ENGAGEMENT};
}
std::vector<std::string> segment_ids = base::SplitString(
base::GetFieldTrialParamValueByFeature(
segmentation_platform::features::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ class SegmentationUkmHelperTest : public testing::Test {
}

void InitializeAllowedSegmentIds(const std::string& allowed_ids) {
std::map<std::string, std::string> params = {
{kSegmentIdsAllowedForReportingKey, allowed_ids}};
feature_list_.InitAndEnableFeatureWithParameters(
features::kSegmentationStructuredMetricsFeature, params);
feature_list_.InitWithFeaturesAndParameters(
{{features::kSegmentationStructuredMetricsFeature,
{{kSegmentIdsAllowedForReportingKey, allowed_ids}}}},
{features::kSegmentationDefaultReportingSegments});
SegmentationUkmHelper::GetInstance()->Initialize();
}

Expand Down
4 changes: 4 additions & 0 deletions components/segmentation_platform/public/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ BASE_FEATURE(kSegmentationPlatformSegmentInfoCache,
"SegmentationPlatformSegmentInfoCache",
base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kSegmentationDefaultReportingSegments,
"SegmentationDefaultReportingSegments",
base::FEATURE_ENABLED_BY_DEFAULT);

} // namespace segmentation_platform::features
3 changes: 3 additions & 0 deletions components/segmentation_platform/public/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ BASE_DECLARE_FEATURE(kShoppingUserSegmentFeature);
// Feature flag for enabling `SegmentInfoCache` for `SegmentInfoDatabase`.
BASE_DECLARE_FEATURE(kSegmentationPlatformSegmentInfoCache);

// Feature flag for enabling default reporting segments.
BASE_DECLARE_FEATURE(kSegmentationDefaultReportingSegments);

} // namespace segmentation_platform::features

#endif // COMPONENTS_SEGMENTATION_PLATFORM_PUBLIC_FEATURES_H_

0 comments on commit 5c45a02

Please sign in to comment.