@@ -55,11 +55,14 @@ import useHomeViewedEvent, {
5555} from '../../hooks/useHomeViewedEvent' ;
5656import { useSectionPerformance } from '../../hooks/useSectionPerformance' ;
5757import type { PerpsSectionProps } from './PerpsSectionWithProvider' ;
58+ import { HOMEPAGE_PERPS_PILLS_AB_EXPOSED_ANALYTICS_PROPERTY } from '../../abTestConfig' ;
5859import HomepageSectionUnrealizedPnlRow , {
5960 type HomepageUnrealizedPnlTone ,
6061} from '../../components/HomepageSectionUnrealizedPnlRow' ;
6162import { useHomepageTrendingTransactionActiveAbTests } from '../../hooks/useHomepageTrendingTransactionActiveAbTests' ;
63+ import { useHomepagePerpsPillsEmptyTransactionActiveAbTests } from '../../hooks/useHomepagePerpsPillsEmptyTransactionActiveAbTests' ;
6264import type { TransactionActiveAbTestEntry } from '../../../../../util/transactions/transaction-active-ab-test-attribution-registry' ;
65+ import { mergeActiveAbTestAssignmentLists } from '../../../../../util/analytics/activeABTestAssignments' ;
6366
6467const MAX_ITEMS = 5 ;
6568const MAX_TRENDING_MARKETS = 5 ;
@@ -70,17 +73,26 @@ interface UsePerpsTrendingCarouselDataArgs {
7073}
7174
7275interface UsePerpsNavigationHandlersArgs {
73- isDedicatedTrendingSection ?: boolean ;
7476 trendingTransactionActiveAbTests ?: TransactionActiveAbTestEntry [ ] ;
77+ extraTransactionActiveAbTests ?: TransactionActiveAbTestEntry [ ] ;
7578}
7679
7780const usePerpsNavigationHandlers = ( {
78- isDedicatedTrendingSection = false ,
7981 trendingTransactionActiveAbTests,
82+ extraTransactionActiveAbTests,
8083} : UsePerpsNavigationHandlersArgs = { } ) => {
8184 const navigation = useNavigation < NavigationProp < PerpsNavigationParamList > > ( ) ;
8285 const isFirstTimePerpsUser = useSelector ( selectIsFirstTimePerpsUser ) ;
8386
87+ const marketDetailsTransactionActiveAbTests = useMemo (
88+ ( ) =>
89+ mergeActiveAbTestAssignmentLists (
90+ trendingTransactionActiveAbTests ,
91+ extraTransactionActiveAbTests ,
92+ ) ,
93+ [ trendingTransactionActiveAbTests , extraTransactionActiveAbTests ] ,
94+ ) ;
95+
8496 const navigateToTutorialOrScreen = useCallback (
8597 ( screen : string , params : Record < string , unknown > ) => {
8698 if ( isFirstTimePerpsUser ) {
@@ -113,19 +125,14 @@ const usePerpsNavigationHandlers = ({
113125 navigateToTutorialOrScreen ( Routes . PERPS . MARKET_DETAILS , {
114126 market,
115127 source : PERPS_EVENT_VALUE . SOURCE . HOME_SECTION ,
116- ...( isDedicatedTrendingSection &&
117- trendingTransactionActiveAbTests ?. length
128+ ...( marketDetailsTransactionActiveAbTests ?. length
118129 ? {
119- transactionActiveAbTests : trendingTransactionActiveAbTests ,
130+ transactionActiveAbTests : marketDetailsTransactionActiveAbTests ,
120131 }
121132 : { } ) ,
122133 } ) ;
123134 } ,
124- [
125- isDedicatedTrendingSection ,
126- navigateToTutorialOrScreen ,
127- trendingTransactionActiveAbTests ,
128- ] ,
135+ [ navigateToTutorialOrScreen , marketDetailsTransactionActiveAbTests ] ,
129136 ) ;
130137
131138 return {
@@ -263,12 +270,6 @@ const PerpsSectionMain = forwardRef<SectionRefreshHandle, PerpsSectionProps>(
263270 usePerpsConnection ( ) ;
264271 const { track } = usePerpsEventTracking ( ) ;
265272 const privacyMode = useSelector ( selectPrivacyMode ) ;
266- const {
267- navigateToTutorialOrScreen,
268- handleViewAllPerps,
269- handleViewMorePerps,
270- handleTilePress,
271- } = usePerpsNavigationHandlers ( ) ;
272273
273274 const { positions, isInitialLoading : positionsLoading } =
274275 usePerpsLivePositions ( {
@@ -316,6 +317,37 @@ const PerpsSectionMain = forwardRef<SectionRefreshHandle, PerpsSectionProps>(
316317 ) ;
317318
318319 const hasItems = displayPositions . length > 0 || displayOrders . length > 0 ;
320+
321+ const trendingTransactionActiveAbTests =
322+ useHomepageTrendingTransactionActiveAbTests ( ) ;
323+ const perpsPillsEmptyTransactionActiveAbTests =
324+ useHomepagePerpsPillsEmptyTransactionActiveAbTests ( ! hasItems ) ;
325+ const {
326+ navigateToTutorialOrScreen,
327+ handleViewAllPerps,
328+ handleViewMorePerps,
329+ handleTilePress,
330+ } = usePerpsNavigationHandlers ( {
331+ trendingTransactionActiveAbTests,
332+ extraTransactionActiveAbTests : perpsPillsEmptyTransactionActiveAbTests ,
333+ } ) ;
334+
335+ const handleTrendingMarketPress = useCallback (
336+ ( market : PerpsMarketData ) => {
337+ track ( MetaMetricsEvents . PERPS_UI_INTERACTION , {
338+ [ PERPS_EVENT_PROPERTY . INTERACTION_TYPE ] :
339+ PERPS_EVENT_VALUE . INTERACTION_TYPE . BUTTON_CLICKED ,
340+ [ PERPS_EVENT_PROPERTY . BUTTON_CLICKED ] :
341+ PERPS_EVENT_VALUE . BUTTON_CLICKED . OPEN_POSITION ,
342+ [ PERPS_EVENT_PROPERTY . BUTTON_LOCATION ] :
343+ PERPS_EVENT_VALUE . BUTTON_LOCATION . WALLET_HOME ,
344+ [ HOMEPAGE_PERPS_PILLS_AB_EXPOSED_ANALYTICS_PROPERTY ] : true ,
345+ } ) ;
346+ handleTilePress ( market ) ;
347+ } ,
348+ [ handleTilePress , track ] ,
349+ ) ;
350+
319351 const hasFilledPositions = positions . length > 0 ;
320352
321353 // When user has no positions/orders, keep skeleton visible until markets load.
@@ -409,6 +441,10 @@ const PerpsSectionMain = forwardRef<SectionRefreshHandle, PerpsSectionProps>(
409441 totalSectionsLoaded,
410442 isEmpty,
411443 itemCount,
444+ additionalProperties :
445+ analyticsName === HomeSectionNames . PERPS && ! hasItems
446+ ? { [ HOMEPAGE_PERPS_PILLS_AB_EXPOSED_ANALYTICS_PROPERTY ] : true }
447+ : undefined ,
412448 } ) ;
413449
414450 useSectionPerformance ( {
@@ -484,7 +520,7 @@ const PerpsSectionMain = forwardRef<SectionRefreshHandle, PerpsSectionProps>(
484520 markets = { allCarouselMarkets }
485521 watchlistSymbolSet = { watchlistSymbolSet }
486522 sparklines = { sparklines }
487- onPressMarket = { handleTilePress }
523+ onPressMarket = { handleTrendingMarketPress }
488524 onPressViewMore = { handleViewMorePerps }
489525 />
490526 ) }
@@ -514,7 +550,6 @@ const PerpsSectionTrendingOnly = forwardRef<
514550 useHomepageTrendingTransactionActiveAbTests ( ) ;
515551 const { handleViewAllPerps, handleViewMorePerps, handleTilePress } =
516552 usePerpsNavigationHandlers ( {
517- isDedicatedTrendingSection : true ,
518553 trendingTransactionActiveAbTests,
519554 } ) ;
520555 const { marketsLoading, allCarouselMarkets, watchlistSymbolSet } =
0 commit comments