feat: add Google Analytics event tracking for filter selections in chart and workflow logs

This commit is contained in:
CodingOnStar 2025-10-16 10:18:13 +08:00
parent eb7e03b0ce
commit 81500b9b19
3 changed files with 18 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import type { Item } from '@/app/components/base/select'
import { SimpleSelect } from '@/app/components/base/select'
import { TIME_PERIOD_MAPPING } from '@/app/components/app/log/filter'
import { useStore as useAppStore } from '@/app/components/app/store'
import { sendGAEvent } from '@/utils/gtag'
dayjs.extend(quarterOfYear)
@ -56,6 +57,10 @@ export default function ChartView({ appId, headerRight }: IChartViewProps) {
className='mt-0 !w-40'
notClearable={true}
onSelect={(item) => {
sendGAEvent(isWorkflow ? 'filter_workflow_overview_period' : 'filter_chat_conversation_overview_period', {
period: item.value,
period_name: item.name,
})
const id = item.value
const value = TIME_PERIOD_MAPPING[id]?.value ?? '-1'
const name = item.name || t('appLog.filter.period.allTime')

View File

@ -11,6 +11,7 @@ import Chip from '@/app/components/base/chip'
import Input from '@/app/components/base/input'
import Sort from '@/app/components/base/sort'
import { fetchAnnotationsCount } from '@/service/log'
import { sendGAEvent } from '@/utils/gtag'
dayjs.extend(quarterOfYear)
const today = dayjs()
@ -47,6 +48,10 @@ const Filter: FC<IFilterProps> = ({ isChatMode, appId, queryParams, setQueryPara
leftIcon={<RiCalendarLine className='h-4 w-4 text-text-secondary' />}
value={queryParams.period}
onSelect={(item) => {
sendGAEvent('filter_chat_conversation_period', {
period: item.value,
period_name: item.name,
})
setQueryParams({ ...queryParams, period: item.value })
}}
onClear={() => setQueryParams({ ...queryParams, period: '9' })}
@ -58,6 +63,10 @@ const Filter: FC<IFilterProps> = ({ isChatMode, appId, queryParams, setQueryPara
showLeftIcon={false}
value={queryParams.annotation_status || 'all'}
onSelect={(item) => {
sendGAEvent('filter_chat_conversation_annotation_status', {
annotation_status: item.value,
annotation_status_name: item.name,
})
setQueryParams({ ...queryParams, annotation_status: item.value as string })
}}
onClear={() => setQueryParams({ ...queryParams, annotation_status: 'all' })}

View File

@ -57,6 +57,10 @@ const Filter: FC<IFilterProps> = ({ queryParams, setQueryParams }: IFilterProps)
leftIcon={<RiCalendarLine className='h-4 w-4 text-text-secondary' />}
value={queryParams.period}
onSelect={(item) => {
sendGAEvent('filter_workflow_period', {
period: item.value,
period_name: item.name,
})
setQueryParams({ ...queryParams, period: item.value })
}}
onClear={() => setQueryParams({ ...queryParams, period: '9' })}