Task/Issue URL:
https://app.asana.com/1/137249556945/project/488551667048375/task/1215444384395011?focus=true
Tech Design URL (if applicable): N/A
### Description
See attached task description
### Steps to test this PR
Filter in your logcat: "Pixel sent: m_aichat_contextual_"
_contextualSheetImprovements OFF(No regression check)_
- [x] Disable contextualSheetImprovements
- [x] Open an article on a new tab
- [x] Open the contextual sheet
- [x] Verify `m_aichat_contextual_sheet_opened_count` is emitted
- [x] Verify `m_aichat_contextual_page_context_placeholder_shown_count`
is emitted
- [x] Click on “Summarize this page”
- [x] Verify `m_aichat_contextual_quick_action_summarize_selected_count`
is emitted
- [x] Submit prompt
- [x] Verify
`m_aichat_contextual_prompt_submitted_with_context_native_count` is
emitted
- [x] Click on the X icon
- [x] Verify `m_aichat_contextual_sheet_dismissed_count` is emitted
- [x] Open the contextual sheet again
- [x] Verify `m_aichat_contextual_session_restored_count` is emitted
- [x] Click on the new chat icon on the upper left next to the
fullscreen
- [x] Verify `m_aichat_contextual_new_chat_button_tapped_count` is
emitted
- [x] Click on the X icon
- [x] Open the contextual sheet again
- [x] Verify `m_aichat_contextual_session_restored_count` is NOT emitted
- [x] Remove the attached context
- [x] Verify `m_aichat_contextual_page_context_removed_native_count` is
emitted
- [x] Verify `m_aichat_contextual_page_context_placeholder_shown_count`
is emitted
- [x] Type anything on the input and submit
- [x] Verify
`m_aichat_contextual_prompt_submitted_without_context_native_count` is
emitted
_contextualSheetImprovements ON, clear all chats_
- [x] ENABLE contextualSheetImprovements
- [x] Open an article on a new tab
- [x] Open the contextual sheet
- [x] Verify `m_aichat_contextual_sheet_opened_count` is emitted
- [x] Click on “Ask about this page”
- [x] Verify
`m_aichat_contextual_quick_action_ask_about_page_selected_count` is
emitted
- [x] Verify
`m_aichat_contextual_page_context_manually_attached_native_count` is
emitted
- [x] Click on “Summarize this page”
- [x] Verify `m_aichat_contextual_quick_action_summarize_selected_count`
is emitted
- [x] Verify
`m_aichat_contextual_prompt_submitted_with_context_native_count` is
emitted
- [x] Click on the X icon
- [x] Verify `m_aichat_contextual_sheet_dismissed_count` is emitted
- [x] Open the contextual sheet again
- [x] Verify `m_aichat_contextual_session_restored_count` is emitted
- [x] Click on the chats icon on the upper left next to the fullscreen
- [x] Verify `m_aichat_contextual_chats_button_tapped_count` is emitted
- [x] Verify `m_aichat_contextual_sheet_dismissed_count` is emitted
- [x] Start a new duck ai chat in a new tab
- [x] Go back to the previous tab and open the contextual sheet again
- [x] Click on the chats icon again
- [x] Verify `m_aichat_contextual_chats_button_tapped_count` is emitted
- [x] Verify `m_aichat_contextual_recent_chats_popup_displayed_count` is
emitted
- [x] Click on one of the recent chats
- [x] Verify `m_aichat_contextual_recent_chat_selected_count` is emitted
- [x] Go back to the contextual sheet again
- [x] Click on the chats icon again and select View All Chats from the
popup menu
- [x] Verify `m_aichat_contextual_view_all_chats_tapped_count` is
emitted
- [x] Click on the chats icon again and select New chat
- [x] Verify `m_aichat_contextual_new_chat_menu_tapped_count` is emitted
- [x] Click on the X icon
- [x] Open the contextual sheet again
- [x] Verify `m_aichat_contextual_session_restored_count` is NOT emitted
- [x] Click on the Chats icon
- [x] Verify `m_aichat_contextual_chats_button_tapped_count` is emitted
- [x] Type anything on the input and submit
- [x] Verify
`m_aichat_contextual_prompt_submitted_without_context_native_count ` is
emitted [BUG FIX INCLUDED IN THIS PR]
- [x] Verify prompt submitted with NO context attached
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes prompt submit semantics (context reset on new chat) and widens
default exposure of contextualSheetImprovements via INTERNAL; otherwise
limited to analytics and UI event paths.
>
> **Overview**
> Adds **count/daily pixel definitions** and native firing for
contextual sheet improvements: recent-chats popup flows (chats icon,
popup shown, recent chat pick, view all, new chat from menu), **Ask
about this page** quick action, and wiring in `DuckChatPixels`.
>
> **Analytics behavior** is tightened so events match what the user
actually sees: placeholder-shown only when the attach-context
placeholder would be visible (`showsAttachContextPlaceholder`),
placeholder-tapped only on explicit placeholder taps
(`fromPlaceholderTap`), summarize-selected on quick-action paths (not
`replacePrompt`), and separate pixels for header new chat vs popup new
chat. Chats icon with no recents opens history without counting a “view
all” tap.
>
> **Product fix:** starting a new chat clears `showContext` /
`userRemovedContext` so prompts are not submitted with hidden page
context (fixes wrong “with context” vs “without context” submit pixels).
>
> `contextualSheetImprovements()` remote default changes from **false**
to **internal** so the improved sheet can roll out via internal builds
by default.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
db4e357ae046c341f93c1d63b9fa58482c2d61d6. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>