growth: Record error metrics.

Bug: b:344673533
Change-Id: I27a9294062fe42a056f630dbe348d65f8e97acfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6013079
Reviewed-by: Li Lin <llin@chromium.org>
Commit-Queue: Thu Huong Vu <thv@chromium.org>
Reviewed-by: Tao Wu <wutao@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1381970}
diff --git a/chromeos/ash/components/growth/campaigns_model.cc b/chromeos/ash/components/growth/campaigns_model.cc
index 135ddb97..babf175e 100644
--- a/chromeos/ash/components/growth/campaigns_model.cc
+++ b/chromeos/ash/components/growth/campaigns_model.cc
@@ -275,7 +275,7 @@
                                           int size,
                                           int index) {
   if (index < 0 || index >= size) {
-    // TODO: b/344673533 - Record error metrics.
+    RecordCampaignsManagerError(CampaignsManagerError::kFeatureIndexOutOfRange);
     return nullptr;
   }
 
@@ -707,7 +707,7 @@
   }
   for (const auto& active_url_regex_value : *active_url_regexes_value) {
     if (!active_url_regex_value.is_string()) {
-      // TODO(b/329124927): Record error.
+      RecordCampaignsManagerError(CampaignsManagerError::kInvalidUrlRegrex);
       CAMPAIGNS_LOG(ERROR) << "Invalid active url regex: "
                            << active_url_regex_value.DebugString();
       continue;
@@ -850,7 +850,7 @@
   }
 #endif  // BUILDFLAG(GOOGLE_CHROME_BRANDING)
 
-  // TODO: b/340895798 - record error metric.
+  RecordCampaignsManagerError(CampaignsManagerError::kUnrecognizedBuiltInImage);
   CAMPAIGNS_LOG(ERROR) << "Unrecognized built in image.";
 
   return nullptr;
@@ -873,7 +873,8 @@
 const gfx::VectorIcon* VectorIcon::GetBuiltInVectorIcon() const {
   const auto icon = GetBuiltInVectorIconType(vector_icon_dict_);
   if (!icon) {
-    // TODO: b/376659798 - record error metric.
+    RecordCampaignsManagerError(
+        CampaignsManagerError::kMissingBuiltInVectorIcon);
     CAMPAIGNS_LOG(ERROR) << "Missing built in vector icon.";
 
     return nullptr;
@@ -886,7 +887,7 @@
       return &ash::kNotificationHelpAppIcon;
   }
 
-  // TODO: b/376659798 - record error metric.
+  RecordCampaignsManagerError(CampaignsManagerError::kMissingBuiltInVectorIcon);
   CAMPAIGNS_LOG(ERROR) << "Unrecognized built in vector icon.";
 }
 
diff --git a/chromeos/ash/components/growth/growth_metrics.h b/chromeos/ash/components/growth/growth_metrics.h
index 6a8cb53b..a06b701 100644
--- a/chromeos/ash/components/growth/growth_metrics.h
+++ b/chromeos/ash/components/growth/growth_metrics.h
@@ -72,8 +72,12 @@
       kRecordEventBeforeCampaignsLoaded = 49,
       kNudgeSheflIconAnchorViewNotFound = 50,
       kNoBoardInfo = 51,
+      kFeatureIndexOutOfRange = 52,
+      kInvalidUrlRegrex = 53,
+      kUnrecognizedBuiltInImage = 54,
+      kMissingBuiltInVectorIcon = 55,
 
-      kMaxValue = kNoBoardInfo,
+      kMaxValue = kMissingBuiltInVectorIcon,
     };
 
 // Records errors encountered during the campaigns loading and matching flow.
diff --git a/tools/metrics/histograms/metadata/ash_growth/enums.xml b/tools/metrics/histograms/metadata/ash_growth/enums.xml
index 85890b88..f79b182 100644
--- a/tools/metrics/histograms/metadata/ash_growth/enums.xml
+++ b/tools/metrics/histograms/metadata/ash_growth/enums.xml
@@ -87,6 +87,10 @@
   <int value="49" label="Record events before campaigns loaded"/>
   <int value="50" label="Shelf icon not found for anchoring nudge"/>
   <int value="51" label="No board info is available"/>
+  <int value="52" label="Feature index out of range"/>
+  <int value="53" label="Invalid URL regrex"/>
+  <int value="54" label="Unrecognized built-in image"/>
+  <int value="55" label="Missing built-in vector icon"/>
 </enum>
 
 </enums>