feat: new events for newtab ai query analytics (#196)

* feat: new events for newtab ai query analytics

* fix: no need suggestion tracking
This commit is contained in:
Nikhil
2026-01-09 13:17:58 -08:00
committed by GitHub
parent 4f0ff4ff49
commit 1b5eb2e83b
3 changed files with 31 additions and 0 deletions

View File

@@ -21,7 +21,12 @@ import {
createAITabAction,
createBrowserOSAction,
} from '@/lib/chat-actions/types'
import {
NEWTAB_AI_TRIGGERED_EVENT,
NEWTAB_SEARCH_EXECUTED_EVENT,
} from '@/lib/constants/analyticsEvents'
import { openSidePanelWithSearch } from '@/lib/messaging/sidepanel/openSidepanelWithSearch'
import { track } from '@/lib/metrics/track'
import { cn } from '@/lib/utils'
import { FooterLinks } from './FooterLinks'
import type { SuggestionItem } from './lib/suggestions/types'
@@ -121,12 +126,17 @@ export const NewTab = () => {
switch (item.type) {
case 'search':
track(NEWTAB_SEARCH_EXECUTED_EVENT, { search_engine: 'google' })
window.open(
`https://www.google.com/search?q=${encodeURIComponent(item.query)}`,
'_self',
)
break
case 'ai-tab': {
track(NEWTAB_AI_TRIGGERED_EVENT, {
mode: 'agent',
tabs_count: selectedTabs.length,
})
const action = createAITabAction({
name: item.name,
description: item.description,
@@ -141,6 +151,10 @@ export const NewTab = () => {
break
}
case 'browseros': {
track(NEWTAB_AI_TRIGGERED_EVENT, {
mode: item.mode,
tabs_count: selectedTabs.length,
})
const action = createBrowserOSAction({
mode: item.mode,
message: item.message,

View File

@@ -1,5 +1,7 @@
import { useEffect, useRef, useState } from 'react'
import { createBrowserOSAction } from '@/lib/chat-actions/types'
import { SIDEPANEL_AI_TRIGGERED_EVENT } from '@/lib/constants/analyticsEvents'
import { track } from '@/lib/metrics/track'
import { ChatEmptyState } from './ChatEmptyState'
import { ChatError } from './ChatError'
import { ChatFooter } from './ChatFooter'
@@ -95,6 +97,12 @@ export const Chat = () => {
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault()
if (messages.length === 0) {
track(SIDEPANEL_AI_TRIGGERED_EVENT, {
mode,
tabs_count: attachedTabs.length,
})
}
executeMessage()
}

View File

@@ -57,3 +57,12 @@ export const SCHEDULED_TASK_VIEW_RESULTS_IN_NEWTAB_EVENT =
/** @public */
export const SCHEDULED_TASK_VIEW_MORE_IN_NEWTAB_EVENT =
'newtab.scheduled_task.view_more'
/** @public */
export const NEWTAB_AI_TRIGGERED_EVENT = 'newtab.ai.triggered'
/** @public */
export const NEWTAB_SEARCH_EXECUTED_EVENT = 'newtab.search.executed'
/** @public */
export const SIDEPANEL_AI_TRIGGERED_EVENT = 'sidepanel.ai.triggered'