|
14 | 14 | #include "base/functional/callback_forward.h" |
15 | 15 | #include "brave/browser/ai_chat/ai_chat_service_factory.h" |
16 | 16 | #include "brave/browser/ai_chat/ai_chat_urls.h" |
| 17 | +#include "brave/browser/brave_browser_process.h" |
| 18 | +#include "brave/browser/misc_metrics/process_misc_metrics.h" |
17 | 19 | #include "brave/browser/ui/side_panel/ai_chat/ai_chat_side_panel_utils.h" |
18 | 20 | #include "brave/components/ai_chat/core/browser/ai_chat_service.h" |
19 | 21 | #include "brave/components/ai_chat/core/browser/constants.h" |
@@ -137,13 +139,20 @@ AIChatUIPageHandler::AIChatUIPageHandler( |
137 | 139 | mojo::PendingReceiver<ai_chat::mojom::AIChatUIHandler> receiver) |
138 | 140 | : owner_web_contents_(owner_web_contents), |
139 | 141 | profile_(profile), |
| 142 | + ai_chat_metrics_( |
| 143 | + g_brave_browser_process->process_misc_metrics()->ai_chat_metrics()), |
140 | 144 | receiver_(this, std::move(receiver)) { |
141 | 145 | // Standalone mode means Chat is opened as its own tab in the tab strip and |
142 | 146 | // not a side panel. chat_context_web_contents is nullptr in that case |
143 | 147 | favicon_service_ = FaviconServiceFactory::GetForProfile( |
144 | 148 | profile_, ServiceAccessType::EXPLICIT_ACCESS); |
145 | 149 | const bool is_standalone = chat_context_web_contents == nullptr; |
146 | 150 | if (!is_standalone) { |
| 151 | +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) |
| 152 | + if (ai_chat_metrics_) { |
| 153 | + ai_chat_metrics_->RecordSidebarUsage(); |
| 154 | + } |
| 155 | +#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) |
147 | 156 | active_chat_tab_helper_ = |
148 | 157 | ai_chat::AIChatTabHelper::FromWebContents(chat_context_web_contents); |
149 | 158 | chat_tab_helper_observation_.Observe(active_chat_tab_helper_); |
@@ -190,6 +199,11 @@ void AIChatUIPageHandler::OpenConversationFullPage( |
190 | 199 | const std::string& conversation_uuid) { |
191 | 200 | CHECK(ai_chat::features::IsAIChatHistoryEnabled()); |
192 | 201 | CHECK(active_chat_tab_helper_); |
| 202 | +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) |
| 203 | + if (ai_chat_metrics_) { |
| 204 | + ai_chat_metrics_->RecordFullPageSwitch(); |
| 205 | + } |
| 206 | +#endif |
193 | 207 | active_chat_tab_helper_->web_contents()->OpenURL( |
194 | 208 | { |
195 | 209 | ConversationUrl(conversation_uuid), |
|
0 commit comments