1
- import React , { useCallback , useContext , useEffect , useMemo } from 'react' ;
1
+ import React , { useCallback , useContext , useMemo } from 'react' ;
2
2
import { useHistory } from 'react-router-dom' ;
3
+ import { endTraces , trace , TraceName } from '../../../../shared/lib/trace' ;
3
4
import { useI18nContext } from '../../../hooks/useI18nContext' ;
4
5
import { ASSET_ROUTE } from '../../../helpers/constants/routes' ;
5
6
import {
@@ -37,7 +38,6 @@ import {
37
38
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
38
39
import InstitutionalHomeFooter from '../../../pages/home/institutional/institutional-home-footer' ;
39
40
///: END:ONLY_INCLUDE_IF
40
- import { endTrace , trace , TraceName } from '../../../../shared/lib/trace' ;
41
41
import { AccountOverviewCommonProps } from './common' ;
42
42
43
43
export type AccountOverviewTabsProps = AccountOverviewCommonProps & {
@@ -62,10 +62,6 @@ export const AccountOverviewTabs = ({
62
62
const t = useI18nContext ( ) ;
63
63
const trackEvent = useContext ( MetaMetricsContext ) ;
64
64
65
- useEffect ( ( ) => {
66
- endTrace ( { name : TraceName . AccountOverviewTab } ) ;
67
- } , [ ] ) ;
68
-
69
65
const tabProps = useMemo (
70
66
( ) => ( {
71
67
activeClassName : 'account-overview__tab--active' ,
@@ -85,13 +81,32 @@ export const AccountOverviewTabs = ({
85
81
}
86
82
} ;
87
83
84
+ const handleTraceFromTabName = ( tabName : string ) => {
85
+ endTraces (
86
+ { name : TraceName . AccountOverviewAssetListTab } ,
87
+ { name : TraceName . AccountOverviewNftsTab } ,
88
+ { name : TraceName . AccountOverviewActivityTab } ,
89
+ ) ;
90
+ switch ( tabName ) {
91
+ case 'nfts' :
92
+ trace ( { name : TraceName . AccountOverviewNftsTab } ) ;
93
+ break ;
94
+ case 'activity' :
95
+ trace ( { name : TraceName . AccountOverviewActivityTab } ) ;
96
+ break ;
97
+ default :
98
+ trace ( { name : TraceName . AccountOverviewAssetListTab } ) ;
99
+ }
100
+ } ;
101
+
88
102
const handleTabClick = useCallback (
89
103
( tabName : string ) => {
90
104
onTabClick ( tabName ) ;
91
105
trackEvent ( {
92
106
category : MetaMetricsEventCategory . Home ,
93
107
event : getEventFromTabName ( tabName ) ,
94
108
} ) ;
109
+ handleTraceFromTabName ( tabName ) ;
95
110
} ,
96
111
[ onTabClick ] ,
97
112
) ;
0 commit comments