|
1 | | -import React, { useCallback, useEffect } from 'react'; |
| 1 | +import React, { useCallback, useEffect, useRef } from 'react'; |
2 | 2 | import { TouchableOpacity } from 'react-native'; |
3 | 3 | import { SafeAreaView } from 'react-native-safe-area-context'; |
4 | 4 | import { useNavigation } from '@react-navigation/native'; |
@@ -33,6 +33,19 @@ import SportsTab from './tabs/SportsTab'; |
33 | 33 | import DappsTab from './tabs/DappsTab'; |
34 | 34 | import { TrendingViewSelectorsIDs } from './TrendingView.testIds'; |
35 | 35 | import ExplorePageV1 from './ExplorePageV1'; |
| 36 | +import { |
| 37 | + trackExploreInteracted, |
| 38 | + type ExploreTabName, |
| 39 | +} from './search/analytics'; |
| 40 | + |
| 41 | +const TAB_NAMES: ExploreTabName[] = [ |
| 42 | + 'Now', |
| 43 | + 'Macro', |
| 44 | + 'RWAs', |
| 45 | + 'Crypto', |
| 46 | + 'Sports', |
| 47 | + 'Sites', |
| 48 | +]; |
36 | 49 |
|
37 | 50 | export const ExploreFeed: React.FC = () => { |
38 | 51 | const tw = useTailwind(); |
@@ -89,6 +102,19 @@ export const ExploreFeed: React.FC = () => { |
89 | 102 | navigation.navigate(Routes.EXPLORE_SEARCH); |
90 | 103 | }, [navigation]); |
91 | 104 |
|
| 105 | + const previousTabRef = useRef<ExploreTabName>('Now'); |
| 106 | + |
| 107 | + const handleTabChange = useCallback(({ i }: { i: number }) => { |
| 108 | + const destinationTab = TAB_NAMES[i]; |
| 109 | + if (!destinationTab) return; |
| 110 | + trackExploreInteracted({ |
| 111 | + interaction_type: 'tab_switched', |
| 112 | + tab_name: destinationTab, |
| 113 | + previous_tab: previousTabRef.current, |
| 114 | + }); |
| 115 | + previousTabRef.current = destinationTab; |
| 116 | + }, []); |
| 117 | + |
92 | 118 | return ( |
93 | 119 | <SafeAreaView |
94 | 120 | edges={{ top: 'additive' }} |
@@ -123,7 +149,10 @@ export const ExploreFeed: React.FC = () => { |
123 | 149 | {!isBasicFunctionalityEnabled ? ( |
124 | 150 | <BasicFunctionalityEmptyState /> |
125 | 151 | ) : isExplorePageV2Enabled ? ( |
126 | | - <TabsList tabsListContentTwClassName="px-0 pb-3"> |
| 152 | + <TabsList |
| 153 | + tabsListContentTwClassName="px-0 pb-3" |
| 154 | + onChangeTab={handleTabChange} |
| 155 | + > |
127 | 156 | <Box |
128 | 157 | key="now" |
129 | 158 | twClassName="flex-1" |
|
0 commit comments