[PriceTracking] Add user action for price tracking native UI

This CL adds the following user actions:
  * Commerce.PriceTracking.BookmarkDialogPriceTrackViewTrackedPrice
  * Commerce.PriceTracking.BookmarkDialogPriceTrackViewUntrackedPrice
  * Commerce.PriceTracking.BookmarkDialogPriceTrackViewShown
  * Commerce.PriceTracking.ConfirmationShown
  * Commerce.PriceTracking.ConfirmationUntracked
  * Commerce.PriceTracking.EditedBookmarkFolderFromOmniboxBubble
  * Commerce.PriceTracking.FirstRunBubbleDismissed
  * Commerce.PriceTracking.FirstRunBubbleShown
  * Commerce.PriceTracking.FirstRunBubbleTrackedPrice
  * Commerce.PriceTracking.OmniboxChip.Tracked
  * Commerce.PriceTracking.OmniboxChipClicked
  * Commerce.PriceTracking.OmniboxChipShown

Bug: 1346612
Change-Id: Iebe3045573634521f282e9f98b391724ba9e0089
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3919784
Reviewed-by: Peter Boström <pbos@chromium.org>
Reviewed-by: Matthew Jones <mdjones@chromium.org>
Reviewed-by: Wei-Yin Chen <wychen@chromium.org>
Commit-Queue: Mei Liang <meiliang@chromium.org>
Reviewed-by: Emily Shack <emshack@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1054998}
diff --git a/chrome/browser/ui/views/commerce/price_tracking_bubble_dialog_view.cc b/chrome/browser/ui/views/commerce/price_tracking_bubble_dialog_view.cc
index 3125421..ff45ea2c 100644
--- a/chrome/browser/ui/views/commerce/price_tracking_bubble_dialog_view.cc
+++ b/chrome/browser/ui/views/commerce/price_tracking_bubble_dialog_view.cc
@@ -4,6 +4,8 @@
 
 #include "chrome/browser/ui/views/commerce/price_tracking_bubble_dialog_view.h"
 
+#include "base/functional/callback_helpers.h"
+#include "base/metrics/user_metrics.h"
 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/ui/bookmarks/bookmark_editor.h"
@@ -50,7 +52,6 @@
     : LocationBarBubbleDelegateView(anchor_view, web_contents),
       profile_(profile),
       url_(url),
-      action_callback_(std::move(on_track_price_callback)),
       type_(type) {
   SetShowCloseButton(true);
   SetLayoutManager(std::make_unique<views::FillLayout>());
@@ -58,10 +59,6 @@
   set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
       views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
 
-  auto run_callback = [](PriceTrackingBubbleDialogView* bubble, bool is_track) {
-    std::move(bubble->action_callback_).Run(is_track);
-  };
-
   auto folder_name = GetMostRecentlyModifiedUserBookmarkFolderName(profile_);
 
   if (type == PriceTrackingBubbleDialogView::Type::TYPE_FIRST_USE_EXPERIENCE) {
@@ -73,8 +70,12 @@
     SetButtonLabel(ui::DIALOG_BUTTON_CANCEL,
                    l10n_util::GetStringUTF16(
                        IDS_OMNIBOX_TRACK_PRICE_DIALOG_CANCEL_BUTTON));
-    SetAcceptCallback(
-        base::BindOnce(run_callback, base::Unretained(this), true));
+    SetAcceptCallback(base::BindOnce(&PriceTrackingBubbleDialogView::OnAccepted,
+                                     weak_factory_.GetWeakPtr(),
+                                     std::move(on_track_price_callback)));
+    SetCancelCallback(base::BindOnce(&PriceTrackingBubbleDialogView::OnCanceled,
+                                     weak_factory_.GetWeakPtr(),
+                                     base::DoNothing()));
     auto body_text = l10n_util::GetStringFUTF16(
         IDS_OMNIBOX_TRACK_PRICE_DIALOG_DESCRIPTION_FIRST_RUN, folder_name);
     body_label_ = AddChildView(CreateBodyLabel(body_text));
@@ -87,8 +88,12 @@
     SetButtonLabel(ui::DIALOG_BUTTON_CANCEL,
                    l10n_util::GetStringUTF16(
                        IDS_OMNIBOX_TRACKING_PRICE_DIALOG_UNTRACK_BUTTON));
-    SetCancelCallback(
-        base::BindOnce(run_callback, base::Unretained(this), false));
+    SetAcceptCallback(base::BindOnce(&PriceTrackingBubbleDialogView::OnAccepted,
+                                     weak_factory_.GetWeakPtr(),
+                                     base::DoNothing()));
+    SetCancelCallback(base::BindOnce(&PriceTrackingBubbleDialogView::OnCanceled,
+                                     weak_factory_.GetWeakPtr(),
+                                     std::move(on_track_price_callback)));
 
     auto body_text = l10n_util::GetStringFUTF16(
         IDS_OMNIBOX_TRACKING_PRICE_DIALOG_DESCRIPTION, folder_name);
@@ -120,12 +125,37 @@
           ->GetMostRecentlyAddedUserNodeForURL(url_);
 
   if (node && native_parent) {
+    base::RecordAction(base::UserMetricsAction(
+        "Commerce.PriceTracking.EditedBookmarkFolderFromOmniboxBubble"));
+
     BookmarkEditor::Show(native_parent, profile_,
                          BookmarkEditor::EditDetails::EditNode(node),
                          BookmarkEditor::SHOW_TREE);
   }
 }
 
+void PriceTrackingBubbleDialogView::OnAccepted(
+    OnTrackPriceCallback on_track_price_callback) {
+  if (type_ == PriceTrackingBubbleDialogView::Type::TYPE_FIRST_USE_EXPERIENCE) {
+    base::RecordAction(base::UserMetricsAction(
+        "Commerce.PriceTracking.FirstRunBubbleTrackedPrice"));
+  }
+
+  std::move(on_track_price_callback).Run(true);
+}
+
+void PriceTrackingBubbleDialogView::OnCanceled(
+    OnTrackPriceCallback on_track_price_callback) {
+  if (type_ == PriceTrackingBubbleDialogView::Type::TYPE_FIRST_USE_EXPERIENCE) {
+    base::RecordAction(base::UserMetricsAction(
+        "Commerce.PriceTracking.FirstRunBubbleDismissed"));
+  } else if (type_ == PriceTrackingBubbleDialogView::Type::TYPE_NORMAL) {
+    base::RecordAction(
+        base::UserMetricsAction("Commerce.PriceTracking.Confirmation.Untrack"));
+  }
+  std::move(on_track_price_callback).Run(false);
+}
+
 // PriceTrackingBubbleCoordinator
 PriceTrackingBubbleCoordinator::PriceTrackingBubbleCoordinator(
     views::View* anchor_view)
@@ -142,6 +172,14 @@
     PriceTrackingBubbleDialogView::Type type) {
   DCHECK(!tracker_.view());
 
+  if (type == PriceTrackingBubbleDialogView::Type::TYPE_FIRST_USE_EXPERIENCE) {
+    base::RecordAction(
+        base::UserMetricsAction("Commerce.PriceTracking.FirstRunBubbleShown"));
+  } else if (type == PriceTrackingBubbleDialogView::Type::TYPE_NORMAL) {
+    base::RecordAction(
+        base::UserMetricsAction("Commerce.PriceTracking.ConfirmationShown"));
+  }
+
   auto bubble = std::make_unique<PriceTrackingBubbleDialogView>(
       anchor_view_, web_contents, profile, url, std::move(image_model),
       std::move(callback), type);
diff --git a/chrome/browser/ui/views/commerce/price_tracking_bubble_dialog_view.h b/chrome/browser/ui/views/commerce/price_tracking_bubble_dialog_view.h
index df5e198e..8420620 100644
--- a/chrome/browser/ui/views/commerce/price_tracking_bubble_dialog_view.h
+++ b/chrome/browser/ui/views/commerce/price_tracking_bubble_dialog_view.h
@@ -47,10 +47,11 @@
 
  private:
   void ShowBookmarkEditor();
+  void OnAccepted(OnTrackPriceCallback on_track_price_callback);
+  void OnCanceled(OnTrackPriceCallback on_track_price_callback);
 
   const raw_ptr<Profile> profile_;
   const GURL url_;
-  OnTrackPriceCallback action_callback_;
   const Type type_;
   raw_ptr<views::StyledLabel> body_label_;
 
diff --git a/chrome/browser/ui/views/commerce/price_tracking_icon_view.cc b/chrome/browser/ui/views/commerce/price_tracking_icon_view.cc
index 813af45..3cb8717 100644
--- a/chrome/browser/ui/views/commerce/price_tracking_icon_view.cc
+++ b/chrome/browser/ui/views/commerce/price_tracking_icon_view.cc
@@ -4,6 +4,7 @@
 
 #include "chrome/browser/ui/views/commerce/price_tracking_icon_view.h"
 
+#include "base/metrics/user_metrics.h"
 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
 #include "chrome/browser/commerce/shopping_service_factory.h"
 #include "chrome/browser/profiles/profile.h"
@@ -63,12 +64,15 @@
   const gfx::Image& product_image = tab_helper->GetProductImage();
   DCHECK(!product_image.IsEmpty());
 
+  base::RecordAction(
+      base::UserMetricsAction("Commerce.PriceTracking.OmniboxChipClicked"));
+
   if (ShouldShowFirstUseExperienceBubble()) {
     bubble_coordinator_.Show(
         GetWebContents(), profile_, GetWebContents()->GetLastCommittedURL(),
         ui::ImageModel::FromImage(product_image),
         base::BindOnce(&PriceTrackingIconView::EnablePriceTracking,
-                       base::Unretained(this)),
+                       weak_ptr_factory_.GetWeakPtr()),
         PriceTrackingBubbleDialogView::Type::TYPE_FIRST_USE_EXPERIENCE);
   } else {
     EnablePriceTracking(/*enable=*/true);
@@ -76,7 +80,7 @@
         GetWebContents(), profile_, GetWebContents()->GetLastCommittedURL(),
         ui::ImageModel::FromImage(product_image),
         base::BindOnce(&PriceTrackingIconView::EnablePriceTracking,
-                       base::Unretained(this)),
+                       weak_ptr_factory_.GetWeakPtr()),
         PriceTrackingBubbleDialogView::Type::TYPE_NORMAL);
   }
 }
@@ -104,8 +108,13 @@
 
 void PriceTrackingIconView::UpdateImpl() {
   bool should_show = ShouldShow();
+
   if (should_show) {
     SetVisualState(IsPriceTracking());
+    if (!GetVisible()) {
+      base::RecordAction(
+          base::UserMetricsAction("Commerce.PriceTracking.OmniboxChipShown"));
+    }
   }
   SetVisible(should_show);
 }
@@ -137,6 +146,8 @@
     if (chrome::GetURLAndTitleToBookmark(GetWebContents(), &url, &title)) {
       bookmarks::AddIfNotBookmarked(model, url, title);
     }
+    base::RecordAction(
+        base::UserMetricsAction("Commerce.PriceTracking.OmniboxChip.Tracked"));
   }
 
   const bookmarks::BookmarkNode* node =
diff --git a/chrome/browser/ui/views/commerce/price_tracking_icon_view_interactive_uitest.cc b/chrome/browser/ui/views/commerce/price_tracking_icon_view_interactive_uitest.cc
index c75802a..e8f5e1ef 100644
--- a/chrome/browser/ui/views/commerce/price_tracking_icon_view_interactive_uitest.cc
+++ b/chrome/browser/ui/views/commerce/price_tracking_icon_view_interactive_uitest.cc
@@ -4,6 +4,7 @@
 
 #include "chrome/browser/ui/views/commerce/price_tracking_icon_view.h"
 
+#include "base/test/metrics/user_action_tester.h"
 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
 #include "chrome/browser/commerce/shopping_service_factory.h"
 #include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
@@ -30,6 +31,7 @@
 #include "ui/base/interaction/element_tracker.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/events/base_event_utils.h"
+#include "ui/views/controls/styled_label.h"
 #include "ui/views/interaction/element_tracker_views.h"
 #include "ui/views/test/button_test_api.h"
 #include "ui/views/test/widget_test.h"
@@ -104,6 +106,7 @@
   }
 
  protected:
+  base::UserActionTester user_action_tester_;
   raw_ptr<MockShoppingListUiTabHelper> mock_tab_helper_;
 
  private:
@@ -203,6 +206,65 @@
             l10n_util::GetStringUTF16(IDS_OMNIBOX_TRACKING_PRICE));
 }
 
+IN_PROC_BROWSER_TEST_F(PriceTrackingIconViewInteractiveTest,
+                       RecordOmniboxChipClicked) {
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.OmniboxChipClicked"),
+            0);
+  auto* icon_view = GetChip();
+  icon_view->ForceVisibleForTesting(/*is_tracking_price=*/false);
+  ClickPriceTrackingIconView();
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.OmniboxChipClicked"),
+            1);
+}
+
+IN_PROC_BROWSER_TEST_F(PriceTrackingIconViewInteractiveTest,
+                       RecordOmniboxChipTracked) {
+  browser()->profile()->GetPrefs()->SetBoolean(
+      prefs::kShouldShowPriceTrackFUEBubble, false);
+
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.OmniboxChip.Tracked"),
+            0);
+  auto* icon_view = GetChip();
+  icon_view->ForceVisibleForTesting(/*is_tracking_price=*/false);
+  ClickPriceTrackingIconView();
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.OmniboxChip.Tracked"),
+            1);
+}
+
+IN_PROC_BROWSER_TEST_F(PriceTrackingIconViewInteractiveTest,
+                       NoRecordOmniboxChipTracked_ForTrackedProduct) {
+  browser()->profile()->GetPrefs()->SetBoolean(
+      prefs::kShouldShowPriceTrackFUEBubble, false);
+
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.OmniboxChip.Tracked"),
+            0);
+  auto* icon_view = GetChip();
+  SimulateServerPriceTrackStateUpdated(/*is_price_tracked=*/true);
+  icon_view->ForceVisibleForTesting(/*is_tracking_price=*/true);
+  ClickPriceTrackingIconView();
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.OmniboxChip.Tracked"),
+            0);
+}
+
+IN_PROC_BROWSER_TEST_F(PriceTrackingIconViewInteractiveTest,
+                       NoRecordOmniboxChipTracked_ForFUEFlow) {
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.OmniboxChip.Tracked"),
+            0);
+  auto* icon_view = GetChip();
+  icon_view->ForceVisibleForTesting(/*is_tracking_price=*/false);
+  ClickPriceTrackingIconView();
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.OmniboxChip.Tracked"),
+            0);
+}
+
 class PriceTrackingBubbleInteractiveTest
     : public PriceTrackingIconViewInteractiveTest {
  public:
@@ -302,3 +364,119 @@
   EXPECT_EQ(icon_view->GetTextForTooltipAndAccessibleName(),
             l10n_util::GetStringUTF16(IDS_OMNIBOX_TRACK_PRICE));
 }
+
+IN_PROC_BROWSER_TEST_F(PriceTrackingBubbleInteractiveTest,
+                       RecordFirstRunBubbleShown) {
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.FirstRunBubbleShown"),
+            0);
+
+  auto* icon_view = GetChip();
+  icon_view->ForceVisibleForTesting(/*is_tracking_price=*/false);
+
+  ClickPriceTrackingIconView();
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.FirstRunBubbleShown"),
+            1);
+}
+
+IN_PROC_BROWSER_TEST_F(PriceTrackingBubbleInteractiveTest,
+                       RecordFirstRunBubblTrackedPrice) {
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.FirstRunBubbleTrackedPrice"),
+            0);
+
+  auto* icon_view = GetChip();
+  icon_view->ForceVisibleForTesting(/*is_tracking_price=*/false);
+
+  ClickPriceTrackingIconView();
+  auto* bubble =
+      static_cast<PriceTrackingBubbleDialogView*>(icon_view->GetBubble());
+  EXPECT_TRUE(bubble);
+  bubble->Accept();
+
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.FirstRunBubbleTrackedPrice"),
+            1);
+}
+
+IN_PROC_BROWSER_TEST_F(PriceTrackingBubbleInteractiveTest,
+                       RecordFirstRunBubbleDismissed) {
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.FirstRunBubbleDismissed"),
+            0);
+
+  auto* icon_view = GetChip();
+  icon_view->ForceVisibleForTesting(/*is_tracking_price=*/false);
+
+  ClickPriceTrackingIconView();
+  auto* bubble =
+      static_cast<PriceTrackingBubbleDialogView*>(icon_view->GetBubble());
+  EXPECT_TRUE(bubble);
+  bubble->Cancel();
+
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.FirstRunBubbleDismissed"),
+            1);
+}
+
+IN_PROC_BROWSER_TEST_F(PriceTrackingBubbleInteractiveTest,
+                       RecordConfirmationShown) {
+  browser()->profile()->GetPrefs()->SetBoolean(
+      prefs::kShouldShowPriceTrackFUEBubble, false);
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.ConfirmationShown"),
+            0);
+
+  auto* icon_view = GetChip();
+  icon_view->ForceVisibleForTesting(/*is_tracking_price=*/false);
+
+  ClickPriceTrackingIconView();
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.ConfirmationShown"),
+            1);
+}
+
+IN_PROC_BROWSER_TEST_F(PriceTrackingBubbleInteractiveTest,
+                       RecordConfirmationUntracked) {
+  browser()->profile()->GetPrefs()->SetBoolean(
+      prefs::kShouldShowPriceTrackFUEBubble, false);
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.Confirmation.Untrack"),
+            0);
+
+  auto* icon_view = GetChip();
+  icon_view->ForceVisibleForTesting(/*is_tracking_price=*/false);
+
+  ClickPriceTrackingIconView();
+  auto* bubble =
+      static_cast<PriceTrackingBubbleDialogView*>(icon_view->GetBubble());
+  EXPECT_TRUE(bubble);
+  bubble->Cancel();
+
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.Confirmation.Untrack"),
+            1);
+}
+
+IN_PROC_BROWSER_TEST_F(PriceTrackingBubbleInteractiveTest,
+                       RecordEditedBookmarkFolderFromOmniboxBubble) {
+  browser()->profile()->GetPrefs()->SetBoolean(
+      prefs::kShouldShowPriceTrackFUEBubble, false);
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.EditedBookmarkFolderFromOmniboxBubble"),
+            0);
+
+  auto* icon_view = GetChip();
+  icon_view->ForceVisibleForTesting(/*is_tracking_price=*/false);
+
+  ClickPriceTrackingIconView();
+  auto* bubble =
+      static_cast<PriceTrackingBubbleDialogView*>(icon_view->GetBubble());
+  EXPECT_TRUE(bubble);
+  bubble->GetBodyLabelForTesting()->ClickFirstLinkForTesting();
+
+  EXPECT_EQ(user_action_tester_.GetActionCount(
+                "Commerce.PriceTracking.EditedBookmarkFolderFromOmniboxBubble"),
+            1);
+}
diff --git a/chrome/browser/ui/views/commerce/price_tracking_view.cc b/chrome/browser/ui/views/commerce/price_tracking_view.cc
index 19e6436..80e88d57 100644
--- a/chrome/browser/ui/views/commerce/price_tracking_view.cc
+++ b/chrome/browser/ui/views/commerce/price_tracking_view.cc
@@ -3,6 +3,8 @@
 // found in the LICENSE file.
 
 #include "chrome/browser/ui/views/commerce/price_tracking_view.h"
+
+#include "base/metrics/user_metrics.h"
 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
 #include "chrome/browser/commerce/shopping_service_factory.h"
 #include "chrome/browser/profiles/profile.h"
@@ -89,6 +91,9 @@
                           kProductImageSize -
                           toggle_button_->GetPreferredSize().width();
   body_label_->SizeToFit(label_width);
+
+  base::RecordAction(base::UserMetricsAction(
+      "Commerce.PriceTracking.BookmarkDialogPriceTrackViewShown"));
 }
 
 PriceTrackingView::~PriceTrackingView() = default;
@@ -105,6 +110,14 @@
 
 void PriceTrackingView::OnToggleButtonPressed(const GURL url) {
   is_price_track_enabled_ = !is_price_track_enabled_;
+  if (is_price_track_enabled_) {
+    base::RecordAction(base::UserMetricsAction(
+        "Commerce.PriceTracking.BookmarkDialogPriceTrackViewTrackedPrice"));
+  } else {
+    base::RecordAction(base::UserMetricsAction(
+        "Commerce.PriceTracking.BookmarkDialogPriceTrackViewUntrackedPrice"));
+  }
+
   toggle_button_->SetAccessibleName(GetToggleAccessibleName());
   UpdatePriceTrackingState(url);
 }
diff --git a/chrome/browser/ui/views/commerce/price_tracking_view_unittest.cc b/chrome/browser/ui/views/commerce/price_tracking_view_unittest.cc
index 6d5e04f..41607cca 100644
--- a/chrome/browser/ui/views/commerce/price_tracking_view_unittest.cc
+++ b/chrome/browser/ui/views/commerce/price_tracking_view_unittest.cc
@@ -4,6 +4,7 @@
 
 #include "chrome/browser/ui/views/commerce/price_tracking_view.h"
 
+#include "base/test/metrics/user_action_tester.h"
 #include "base/test/task_environment.h"
 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
 #include "chrome/browser/commerce/shopping_service_factory.h"
@@ -125,6 +126,9 @@
     EXPECT_EQ(price_tracking_View_->body_label_->GetText(), expected_message);
   }
 
+ protected:
+  base::UserActionTester user_action_tester_;
+
  private:
   views::UniqueWidgetPtr anchor_widget_;
   raw_ptr<PriceTrackingView> price_tracking_View_;
@@ -183,3 +187,37 @@
   VerifyBodyMessage(l10n_util::GetStringUTF16(
       IDS_OMNIBOX_TRACK_PRICE_DIALOG_ERROR_DESCRIPTION));
 }
+
+TEST_F(PriceTrackingViewTest, ToggleRecordTracked) {
+  SetUpDependencies();
+
+  const bool initial_enabled = false;
+  CreateViewAndShow(initial_enabled);
+  EXPECT_EQ(
+      user_action_tester_.GetActionCount(
+          "Commerce.PriceTracking.BookmarkDialogPriceTrackViewTrackedPrice"),
+      0);
+  ClickToggle();
+
+  EXPECT_EQ(
+      user_action_tester_.GetActionCount(
+          "Commerce.PriceTracking.BookmarkDialogPriceTrackViewTrackedPrice"),
+      1);
+}
+
+TEST_F(PriceTrackingViewTest, ToggleRecordUntracked) {
+  SetUpDependencies();
+
+  const bool initial_enabled = true;
+  CreateViewAndShow(initial_enabled);
+  EXPECT_EQ(
+      user_action_tester_.GetActionCount(
+          "Commerce.PriceTracking.BookmarkDialogPriceTrackViewUntrackedPrice"),
+      0);
+  ClickToggle();
+
+  EXPECT_EQ(
+      user_action_tester_.GetActionCount(
+          "Commerce.PriceTracking.BookmarkDialogPriceTrackViewUntrackedPrice"),
+      1);
+}
diff --git a/tools/metrics/actions/actions.xml b/tools/metrics/actions/actions.xml
index 4536ef3..585326a 100644
--- a/tools/metrics/actions/actions.xml
+++ b/tools/metrics/actions/actions.xml
@@ -5964,6 +5964,114 @@
   </description>
 </action>
 
+<action name="Commerce.PriceTracking.BookmarkDialogPriceTrackViewShown">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users click the bookmark star icon and the price track view is
+    shown inside the bookmark bubble.
+  </description>
+</action>
+
+<action name="Commerce.PriceTracking.BookmarkDialogPriceTrackViewTrackedPrice">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users clicks the toggle button in the bookmark bubble to track
+    the product.
+  </description>
+</action>
+
+<action
+    name="Commerce.PriceTracking.BookmarkDialogPriceTrackViewUntrackedPrice">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users clicks the toggle button in the bookmark bubble to
+    untrack the product.
+  </description>
+</action>
+
+<action name="Commerce.PriceTracking.Confirmation.Untrack">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users click the &quot;Untrack&quot; button to untrack the
+    product in the confirmation bubble.
+  </description>
+</action>
+
+<action name="Commerce.PriceTracking.ConfirmationShown">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users click the price tracking icon view and shows the
+    confirmation bubble.
+  </description>
+</action>
+
+<action name="Commerce.PriceTracking.EditedBookmarkFolderFromOmniboxBubble">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users click the bookmark folder name shown in the confirmation
+    bubble to launch the bookmark editor.
+  </description>
+</action>
+
+<action name="Commerce.PriceTracking.FirstRunBubbleDismissed">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users click the &quot;Cancel&quot; button to dismiss the
+    confirmation bubble.
+  </description>
+</action>
+
+<action name="Commerce.PriceTracking.FirstRunBubbleShown">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users click the price tracking icon view and shows the first
+    run experience bubble.
+  </description>
+</action>
+
+<action name="Commerce.PriceTracking.FirstRunBubbleTrackedPrice">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users click the &quot;Track price&quot; button to track the
+    product in the first run experience bubble.
+  </description>
+</action>
+
+<action name="Commerce.PriceTracking.OmniboxChip.Tracked">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users click the price tracking icon view to track the product.
+  </description>
+</action>
+
+<action name="Commerce.PriceTracking.OmniboxChipClicked">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when users click the price tracking icon view regarless of the icon
+    view state.
+  </description>
+</action>
+
+<action name="Commerce.PriceTracking.OmniboxChipShown">
+  <owner>meiliang@chromium.org</owner>
+  <owner>chrome-shopping@google.com</owner>
+  <description>
+    Records when price tracking icon view shown regarless of the icon view
+    state.
+  </description>
+</action>
+
 <action name="Commerce.PriceTracking.SidePanel.ClickedTrackedProduct">
   <owner>yuezhanggg@chromium.org</owner>
   <owner>chrome-shopping@google.com</owner>
@@ -5977,7 +6085,7 @@
   <owner>yuezhanggg@chromium.org</owner>
   <owner>chrome-shopping@google.com</owner>
   <description>
-    Triggered when users stop tracking price for a product from side panel via
+    Triggered when users start tracking price for a product from side panel via
     bell button.
   </description>
 </action>
@@ -5986,7 +6094,7 @@
   <owner>yuezhanggg@chromium.org</owner>
   <owner>chrome-shopping@google.com</owner>
   <description>
-    Triggered when users stop tracking price for a product from side panel via
+    Triggered when users start tracking price for a product from side panel via
     context menu.
   </description>
 </action>