Add search event analytics (#9949)
Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -38,6 +38,7 @@ import {Button, ButtonText} from '#/components/Button'
|
||||
import {SearchInput} from '#/components/forms/SearchInput'
|
||||
import * as Layout from '#/components/Layout'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {IS_WEB} from '#/env'
|
||||
import {account, useStorage} from '#/storage'
|
||||
import type * as bsky from '#/types/bsky'
|
||||
@@ -79,6 +80,7 @@ export function SearchScreenShell({
|
||||
inputPlaceholder?: string
|
||||
isExplore?: boolean
|
||||
}) {
|
||||
const ax = useAnalytics()
|
||||
const t = useTheme()
|
||||
const {gtMobile} = useBreakpoints()
|
||||
const navigation = useNavigation<NavigationProp>()
|
||||
@@ -225,9 +227,15 @@ export function SearchScreenShell({
|
||||
}
|
||||
}, [setShowAutocomplete, setSearchText, navigation, route.params, route.name])
|
||||
|
||||
const onSubmit = useCallback(() => {
|
||||
navigateToItem(searchText)
|
||||
}, [navigateToItem, searchText])
|
||||
const onSubmit = useCallback(
|
||||
(source: 'typed' | 'autocomplete') => () => {
|
||||
ax.metric('search:query', {
|
||||
source,
|
||||
})
|
||||
navigateToItem(searchText)
|
||||
},
|
||||
[ax, navigateToItem, searchText],
|
||||
)
|
||||
|
||||
const onAutocompleteResultPress = useCallback(() => {
|
||||
if (IS_WEB) {
|
||||
@@ -367,7 +375,7 @@ export function SearchScreenShell({
|
||||
onFocus={onSearchInputFocus}
|
||||
onChangeText={onChangeText}
|
||||
onClearText={onPressClearQuery}
|
||||
onSubmitEditing={onSubmit}
|
||||
onSubmitEditing={onSubmit('typed')}
|
||||
placeholder={
|
||||
inputPlaceholder ?? l`Search for posts, users, or feeds`
|
||||
}
|
||||
@@ -420,7 +428,7 @@ export function SearchScreenShell({
|
||||
isAutocompleteFetching={isAutocompleteFetching}
|
||||
autocompleteData={autocompleteData}
|
||||
searchText={searchText}
|
||||
onSubmit={onSubmit}
|
||||
onSubmit={onSubmit('autocomplete')}
|
||||
onResultPress={onAutocompleteResultPress}
|
||||
onProfileClick={handleProfileClick}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user