@@ -17,6 +17,8 @@ import {
1717import { useTailwind } from '@metamask/design-system-twrnc-preset' ;
1818import { Pressable } from 'react-native' ;
1919import { SECTIONS_CONFIG , type SectionId } from '../../sections.config' ;
20+ import { MetaMetricsEvents } from '../../../../../core/Analytics/MetaMetrics.events' ;
21+ import { TapView , trackExploreEvent } from '../../utils/exploreSearch' ;
2022import { useExploreSearch } from '../../hooks/useExploreSearch' ;
2123import { selectBasicFunctionalityEnabled } from '../../../../../selectors/settings' ;
2224import SitesSearchFooter from '../../../../UI/Sites/components/SitesSearchFooter/SitesSearchFooter' ;
@@ -64,8 +66,14 @@ const ExploreSearchResults: React.FC<ExploreSearchResultsProps> = ({
6466 selectBasicFunctionalityEnabled ,
6567 ) ;
6668
69+ const hasScrollTracked = useRef ( false ) ;
70+
6771 const handleViewMore = useCallback (
6872 ( sectionId : SectionId , title : string ) => {
73+ trackExploreEvent ( MetaMetricsEvents . EXPLORE_SEARCH_VIEW_ALL_CLICKED , {
74+ searchQuery,
75+ sectionName : title ,
76+ } ) ;
6977 (
7078 navigation as never as {
7179 navigate : (
@@ -86,6 +94,18 @@ const ExploreSearchResults: React.FC<ExploreSearchResultsProps> = ({
8694 [ navigation , searchQuery ] ,
8795 ) ;
8896
97+ const handleScroll = useCallback ( ( ) => {
98+ if ( hasScrollTracked . current ) return ;
99+ hasScrollTracked . current = true ;
100+ trackExploreEvent ( MetaMetricsEvents . EXPLORE_SEARCH_SCROLLED , {
101+ searchQuery,
102+ } ) ;
103+ } , [ searchQuery ] ) ;
104+
105+ useEffect ( ( ) => {
106+ hasScrollTracked . current = false ;
107+ } , [ searchQuery ] ) ;
108+
89109 const renderSectionHeader = useCallback (
90110 ( item : ListItemHeader ) => (
91111 < Box
@@ -213,25 +233,29 @@ const ExploreSearchResults: React.FC<ExploreSearchResultsProps> = ({
213233 return < section . Skeleton /> ;
214234 }
215235
216- if ( section . OverrideRowItemSearch ) {
217- return (
218- < section . OverrideRowItemSearch
236+ const RowComponent = section . OverrideRowItemSearch ?? section . RowItem ;
237+ const { getItemIdentifier } = section ;
238+ const handleItemTouch = getItemIdentifier
239+ ? ( ) => {
240+ trackExploreEvent ( MetaMetricsEvents . EXPLORE_SEARCH_RESULT_CLICKED , {
241+ searchQuery,
242+ sectionName : section . title ,
243+ itemClicked : getItemIdentifier ( item . data ) ,
244+ } ) ;
245+ }
246+ : undefined ;
247+
248+ return (
249+ < TapView onTap = { handleItemTouch } >
250+ < RowComponent
219251 item = { item . data }
220252 index = { index }
221253 navigation = { navigation }
222254 />
223- ) ;
224- }
225-
226- return (
227- < section . RowItem
228- item = { item . data }
229- index = { index }
230- navigation = { navigation }
231- />
255+ </ TapView >
232256 ) ;
233257 } ,
234- [ navigation , renderSectionHeader ] ,
258+ [ navigation , renderSectionHeader , searchQuery ] ,
235259 ) ;
236260
237261 const keyExtractor = useCallback ( ( item : FlatListItem , index : number ) => {
@@ -256,6 +280,8 @@ const ExploreSearchResults: React.FC<ExploreSearchResultsProps> = ({
256280 keyboardShouldPersistTaps = "handled"
257281 testID = "trending-search-results-list"
258282 ListFooterComponent = { renderFooter }
283+ onScroll = { handleScroll }
284+ scrollEventThrottle = { 400 }
259285 />
260286 </ Box >
261287 ) ;
0 commit comments