Add nav:click event to all main nav items (#10540)
Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -60,6 +60,20 @@ export type Events = {
|
|||||||
'router:navigate': {
|
'router:navigate': {
|
||||||
from?: string
|
from?: string
|
||||||
}
|
}
|
||||||
|
'nav:click': {
|
||||||
|
item:
|
||||||
|
| 'home'
|
||||||
|
| 'search'
|
||||||
|
| 'chat'
|
||||||
|
| 'notifications'
|
||||||
|
| 'profile'
|
||||||
|
| 'feeds'
|
||||||
|
| 'lists'
|
||||||
|
| 'saved'
|
||||||
|
| 'settings'
|
||||||
|
| 'menu'
|
||||||
|
surface: 'bottomBar' | 'drawer' | 'drawerHeader' | 'topBar' | 'leftNav'
|
||||||
|
}
|
||||||
'deepLink:referrerReceived': {
|
'deepLink:referrerReceived': {
|
||||||
to: string
|
to: string
|
||||||
referrer: string
|
referrer: string
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import {
|
|||||||
} from '#/components/Layout/const'
|
} from '#/components/Layout/const'
|
||||||
import {ScrollbarOffsetContext} from '#/components/Layout/context'
|
import {ScrollbarOffsetContext} from '#/components/Layout/context'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_IOS} from '#/env'
|
import {IS_IOS} from '#/env'
|
||||||
|
|
||||||
export function Outer({
|
export function Outer({
|
||||||
@@ -150,13 +151,15 @@ export function BackButton({onPress, style, ...props}: Partial<ButtonProps>) {
|
|||||||
|
|
||||||
export function MenuButton() {
|
export function MenuButton() {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const ax = useAnalytics()
|
||||||
const setDrawerOpen = useSetDrawerOpen()
|
const setDrawerOpen = useSetDrawerOpen()
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
|
|
||||||
const onPress = useCallback(() => {
|
const onPress = useCallback(() => {
|
||||||
|
ax.metric('nav:click', {item: 'menu', surface: 'topBar'})
|
||||||
Keyboard.dismiss()
|
Keyboard.dismiss()
|
||||||
setDrawerOpen(true)
|
setDrawerOpen(true)
|
||||||
}, [setDrawerOpen])
|
}, [setDrawerOpen, ax])
|
||||||
|
|
||||||
return gtMobile ? null : (
|
return gtMobile ? null : (
|
||||||
<Slot>
|
<Slot>
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import {type Events} from '#/analytics/metrics/types'
|
||||||
|
|
||||||
|
export type SharedNavTab =
|
||||||
|
| 'Home'
|
||||||
|
| 'Search'
|
||||||
|
| 'Messages'
|
||||||
|
| 'Notifications'
|
||||||
|
| 'MyProfile'
|
||||||
|
|
||||||
|
export const TAB_TO_NAV_ITEM: Record<
|
||||||
|
SharedNavTab,
|
||||||
|
Events['nav:click']['item']
|
||||||
|
> = {
|
||||||
|
Home: 'home',
|
||||||
|
Search: 'search',
|
||||||
|
Messages: 'chat',
|
||||||
|
Notifications: 'notifications',
|
||||||
|
MyProfile: 'profile',
|
||||||
|
}
|
||||||
@@ -190,7 +190,7 @@ const GalleryItem = ({
|
|||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
ref={altBtnRef}
|
ref={altBtnRef}
|
||||||
style={imageStyle as ViewStyle}
|
style={imageStyle}
|
||||||
// Fixes ALT and icons appearing with half opacity when the post is inactive
|
// Fixes ALT and icons appearing with half opacity when the post is inactive
|
||||||
renderToHardwareTextureAndroid>
|
renderToHardwareTextureAndroid>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {ButtonIcon} from '#/components/Button'
|
|||||||
import {Hashtag_Stroke2_Corner0_Rounded as FeedsIcon} from '#/components/icons/Hashtag'
|
import {Hashtag_Stroke2_Corner0_Rounded as FeedsIcon} from '#/components/icons/Hashtag'
|
||||||
import * as Layout from '#/components/Layout'
|
import * as Layout from '#/components/Layout'
|
||||||
import {Link} from '#/components/Link'
|
import {Link} from '#/components/Link'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
|
|
||||||
export function HomeHeaderLayout(props: {
|
export function HomeHeaderLayout(props: {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
@@ -38,6 +39,7 @@ function HomeHeaderLayoutDesktopAndTablet({
|
|||||||
const {headerHeight} = useShellLayout()
|
const {headerHeight} = useShellLayout()
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const ax = useAnalytics()
|
||||||
const kawaii = useKawaiiMode()
|
const kawaii = useKawaiiMode()
|
||||||
const gutters = useGutters([0, 'base'])
|
const gutters = useGutters([0, 'base'])
|
||||||
|
|
||||||
@@ -59,6 +61,9 @@ function HomeHeaderLayoutDesktopAndTablet({
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
shape="square"
|
shape="square"
|
||||||
|
onPress={() => {
|
||||||
|
ax.metric('nav:click', {item: 'feeds', surface: 'topBar'})
|
||||||
|
}}
|
||||||
style={[a.justify_center]}>
|
style={[a.justify_center]}>
|
||||||
<ButtonIcon icon={FeedsIcon} size="lg" />
|
<ButtonIcon icon={FeedsIcon} size="lg" />
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {ButtonIcon} from '#/components/Button'
|
|||||||
import {Hashtag_Stroke2_Corner0_Rounded as FeedsIcon} from '#/components/icons/Hashtag'
|
import {Hashtag_Stroke2_Corner0_Rounded as FeedsIcon} from '#/components/icons/Hashtag'
|
||||||
import * as Layout from '#/components/Layout'
|
import * as Layout from '#/components/Layout'
|
||||||
import {Link} from '#/components/Link'
|
import {Link} from '#/components/Link'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_DEV, IS_LIQUID_GLASS} from '#/env'
|
import {IS_DEV, IS_LIQUID_GLASS} from '#/env'
|
||||||
|
|
||||||
export function HomeHeaderLayoutMobile({
|
export function HomeHeaderLayoutMobile({
|
||||||
@@ -29,6 +30,7 @@ export function HomeHeaderLayoutMobile({
|
|||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const ax = useAnalytics()
|
||||||
const {headerHeight} = useShellLayout()
|
const {headerHeight} = useShellLayout()
|
||||||
const insets = useSafeAreaInsets()
|
const insets = useSafeAreaInsets()
|
||||||
const headerMinimalShellTransform = useHomeHeaderTransform()
|
const headerMinimalShellTransform = useHomeHeaderTransform()
|
||||||
@@ -84,6 +86,9 @@ export function HomeHeaderLayoutMobile({
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
shape="square"
|
shape="square"
|
||||||
|
onPress={() => {
|
||||||
|
ax.metric('nav:click', {item: 'feeds', surface: 'topBar'})
|
||||||
|
}}
|
||||||
style={[
|
style={[
|
||||||
a.justify_center,
|
a.justify_center,
|
||||||
{marginRight: -Layout.BUTTON_VISUAL_ALIGNMENT_OFFSET},
|
{marginRight: -Layout.BUTTON_VISUAL_ALIGNMENT_OFFSET},
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {FEEDBACK_FORM_URL, HELP_DESK_URL} from '#/lib/constants'
|
|||||||
import {type PressableScale} from '#/lib/custom-animations/PressableScale'
|
import {type PressableScale} from '#/lib/custom-animations/PressableScale'
|
||||||
import {useNavigationTabState} from '#/lib/hooks/useNavigationTabState'
|
import {useNavigationTabState} from '#/lib/hooks/useNavigationTabState'
|
||||||
import {getTabState, TabState} from '#/lib/routes/helpers'
|
import {getTabState, TabState} from '#/lib/routes/helpers'
|
||||||
|
import {type SharedNavTab, TAB_TO_NAV_ITEM} from '#/lib/routes/tab-to-nav-item'
|
||||||
import {type NavigationProp} from '#/lib/routes/types'
|
import {type NavigationProp} from '#/lib/routes/types'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
import {colors} from '#/lib/styles'
|
import {colors} from '#/lib/styles'
|
||||||
@@ -55,6 +56,7 @@ import {
|
|||||||
import {InlineLinkText} from '#/components/Link'
|
import {InlineLinkText} from '#/components/Link'
|
||||||
import {ProfileBadges} from '#/components/ProfileBadges'
|
import {ProfileBadges} from '#/components/ProfileBadges'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
import {IS_WEB} from '#/env'
|
import {IS_WEB} from '#/env'
|
||||||
import {useActorStatus} from '#/features/liveNow'
|
import {useActorStatus} from '#/features/liveNow'
|
||||||
|
|
||||||
@@ -138,6 +140,7 @@ let DrawerContent = ({}: React.PropsWithoutRef<{}>): React.ReactNode => {
|
|||||||
const insets = useSafeAreaInsets()
|
const insets = useSafeAreaInsets()
|
||||||
const setDrawerOpen = useSetDrawerOpen()
|
const setDrawerOpen = useSetDrawerOpen()
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
|
const ax = useAnalytics()
|
||||||
const {
|
const {
|
||||||
isAtHome,
|
isAtHome,
|
||||||
isAtSearch,
|
isAtSearch,
|
||||||
@@ -153,7 +156,11 @@ let DrawerContent = ({}: React.PropsWithoutRef<{}>): React.ReactNode => {
|
|||||||
// =
|
// =
|
||||||
|
|
||||||
const onPressTab = useCallback(
|
const onPressTab = useCallback(
|
||||||
(tab: 'Home' | 'Search' | 'Messages' | 'Notifications' | 'MyProfile') => {
|
(tab: SharedNavTab, surface: 'drawer' | 'drawerHeader' = 'drawer') => {
|
||||||
|
ax.metric('nav:click', {
|
||||||
|
item: TAB_TO_NAV_ITEM[tab],
|
||||||
|
surface,
|
||||||
|
})
|
||||||
const state = navigation.getState()
|
const state = navigation.getState()
|
||||||
setDrawerOpen(false)
|
setDrawerOpen(false)
|
||||||
if (IS_WEB) {
|
if (IS_WEB) {
|
||||||
@@ -190,7 +197,7 @@ let DrawerContent = ({}: React.PropsWithoutRef<{}>): React.ReactNode => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[navigation, setDrawerOpen, currentAccount],
|
[navigation, setDrawerOpen, currentAccount, ax],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onPressHome = useCallback(() => onPressTab('Home'), [onPressTab])
|
const onPressHome = useCallback(() => onPressTab('Home'), [onPressTab])
|
||||||
@@ -211,25 +218,33 @@ let DrawerContent = ({}: React.PropsWithoutRef<{}>): React.ReactNode => {
|
|||||||
onPressTab('MyProfile')
|
onPressTab('MyProfile')
|
||||||
}, [onPressTab])
|
}, [onPressTab])
|
||||||
|
|
||||||
|
const onPressDrawerHeaderProfile = useCallback(() => {
|
||||||
|
onPressTab('MyProfile', 'drawerHeader')
|
||||||
|
}, [onPressTab])
|
||||||
|
|
||||||
const onPressMyFeeds = useCallback(() => {
|
const onPressMyFeeds = useCallback(() => {
|
||||||
|
ax.metric('nav:click', {item: 'feeds', surface: 'drawer'})
|
||||||
navigation.navigate('Feeds')
|
navigation.navigate('Feeds')
|
||||||
setDrawerOpen(false)
|
setDrawerOpen(false)
|
||||||
}, [navigation, setDrawerOpen])
|
}, [navigation, setDrawerOpen, ax])
|
||||||
|
|
||||||
const onPressLists = useCallback(() => {
|
const onPressLists = useCallback(() => {
|
||||||
|
ax.metric('nav:click', {item: 'lists', surface: 'drawer'})
|
||||||
navigation.navigate('Lists')
|
navigation.navigate('Lists')
|
||||||
setDrawerOpen(false)
|
setDrawerOpen(false)
|
||||||
}, [navigation, setDrawerOpen])
|
}, [navigation, setDrawerOpen, ax])
|
||||||
|
|
||||||
const onPressBookmarks = useCallback(() => {
|
const onPressBookmarks = useCallback(() => {
|
||||||
|
ax.metric('nav:click', {item: 'saved', surface: 'drawer'})
|
||||||
navigation.navigate('Bookmarks')
|
navigation.navigate('Bookmarks')
|
||||||
setDrawerOpen(false)
|
setDrawerOpen(false)
|
||||||
}, [navigation, setDrawerOpen])
|
}, [navigation, setDrawerOpen, ax])
|
||||||
|
|
||||||
const onPressSettings = useCallback(() => {
|
const onPressSettings = useCallback(() => {
|
||||||
|
ax.metric('nav:click', {item: 'settings', surface: 'drawer'})
|
||||||
navigation.navigate('Settings')
|
navigation.navigate('Settings')
|
||||||
setDrawerOpen(false)
|
setDrawerOpen(false)
|
||||||
}, [navigation, setDrawerOpen])
|
}, [navigation, setDrawerOpen, ax])
|
||||||
|
|
||||||
const onPressFeedback = useCallback(() => {
|
const onPressFeedback = useCallback(() => {
|
||||||
Linking.openURL(
|
Linking.openURL(
|
||||||
@@ -265,7 +280,7 @@ let DrawerContent = ({}: React.PropsWithoutRef<{}>): React.ReactNode => {
|
|||||||
{hasSession && currentAccount ? (
|
{hasSession && currentAccount ? (
|
||||||
<DrawerProfileCard
|
<DrawerProfileCard
|
||||||
account={currentAccount}
|
account={currentAccount}
|
||||||
onPressProfile={onPressProfile}
|
onPressProfile={onPressDrawerHeaderProfile}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<View style={[a.pr_xl]}>
|
<View style={[a.pr_xl]}>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {useMinimalShellFooterTransform} from '#/lib/hooks/useMinimalShellTransfo
|
|||||||
import {useNavigationTabState} from '#/lib/hooks/useNavigationTabState'
|
import {useNavigationTabState} from '#/lib/hooks/useNavigationTabState'
|
||||||
import {clamp} from '#/lib/numbers'
|
import {clamp} from '#/lib/numbers'
|
||||||
import {getTabState, TabState} from '#/lib/routes/helpers'
|
import {getTabState, TabState} from '#/lib/routes/helpers'
|
||||||
|
import {type SharedNavTab, TAB_TO_NAV_ITEM} from '#/lib/routes/tab-to-nav-item'
|
||||||
import {emitSoftReset} from '#/state/events'
|
import {emitSoftReset} from '#/state/events'
|
||||||
import {useUnreadMessageCount} from '#/state/queries/messages/list-conversations'
|
import {useUnreadMessageCount} from '#/state/queries/messages/list-conversations'
|
||||||
import {useUnreadNotifications} from '#/state/queries/notifications/unread'
|
import {useUnreadNotifications} from '#/state/queries/notifications/unread'
|
||||||
@@ -50,16 +51,16 @@ import {
|
|||||||
} from '#/components/icons/Message'
|
} from '#/components/icons/Message'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useAgeAssurance} from '#/ageAssurance'
|
import {useAgeAssurance} from '#/ageAssurance'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
import {useActorStatus} from '#/features/liveNow'
|
import {useActorStatus} from '#/features/liveNow'
|
||||||
import {useDemoMode} from '#/storage/hooks/demo-mode'
|
import {useDemoMode} from '#/storage/hooks/demo-mode'
|
||||||
import {styles} from './BottomBarStyles'
|
import {styles} from './BottomBarStyles'
|
||||||
|
|
||||||
type TabOptions = 'Home' | 'Search' | 'Messages' | 'Notifications' | 'MyProfile'
|
|
||||||
|
|
||||||
export function BottomBar({navigation}: BottomTabBarProps) {
|
export function BottomBar({navigation}: BottomTabBarProps) {
|
||||||
const {hasSession, currentAccount} = useSession()
|
const {hasSession, currentAccount} = useSession()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const ax = useAnalytics()
|
||||||
const safeAreaInsets = useSafeAreaInsets()
|
const safeAreaInsets = useSafeAreaInsets()
|
||||||
const {footerHeight} = useShellLayout()
|
const {footerHeight} = useShellLayout()
|
||||||
const {isAtHome, isAtSearch, isAtNotifications, isAtMyProfile, isAtMessages} =
|
const {isAtHome, isAtSearch, isAtNotifications, isAtMyProfile, isAtMessages} =
|
||||||
@@ -89,7 +90,11 @@ export function BottomBar({navigation}: BottomTabBarProps) {
|
|||||||
}, [requestSwitchToAccount, closeAllActiveElements])
|
}, [requestSwitchToAccount, closeAllActiveElements])
|
||||||
|
|
||||||
const onPressTab = useCallback(
|
const onPressTab = useCallback(
|
||||||
(tab: TabOptions) => {
|
(tab: SharedNavTab) => {
|
||||||
|
ax.metric('nav:click', {
|
||||||
|
item: TAB_TO_NAV_ITEM[tab],
|
||||||
|
surface: 'bottomBar',
|
||||||
|
})
|
||||||
const state = navigation.getState()
|
const state = navigation.getState()
|
||||||
const tabState = getTabState(state, tab)
|
const tabState = getTabState(state, tab)
|
||||||
if (tabState === TabState.InsideAtRoot) {
|
if (tabState === TabState.InsideAtRoot) {
|
||||||
@@ -117,7 +122,7 @@ export function BottomBar({navigation}: BottomTabBarProps) {
|
|||||||
dedupe(() => navigation.navigate(`${tab}Tab`))
|
dedupe(() => navigation.navigate(`${tab}Tab`))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[navigation, dedupe],
|
[navigation, dedupe, ax],
|
||||||
)
|
)
|
||||||
const onPressHome = useCallback(() => onPressTab('Home'), [onPressTab])
|
const onPressHome = useCallback(() => onPressTab('Home'), [onPressTab])
|
||||||
const onPressSearch = useCallback(() => onPressTab('Search'), [onPressTab])
|
const onPressSearch = useCallback(() => onPressTab('Search'), [onPressTab])
|
||||||
|
|||||||
@@ -44,8 +44,11 @@ import {
|
|||||||
} from '#/components/icons/Message'
|
} from '#/components/icons/Message'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useAgeAssurance} from '#/ageAssurance'
|
import {useAgeAssurance} from '#/ageAssurance'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
import {styles} from './BottomBarStyles'
|
import {styles} from './BottomBarStyles'
|
||||||
|
|
||||||
|
type NavItemValue = 'home' | 'search' | 'chat' | 'notifications' | 'profile'
|
||||||
|
|
||||||
export function BottomBarWeb() {
|
export function BottomBarWeb() {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {hasSession, currentAccount} = useSession()
|
const {hasSession, currentAccount} = useSession()
|
||||||
@@ -96,7 +99,7 @@ export function BottomBarWeb() {
|
|||||||
onLayout={event => footerHeight.set(event.nativeEvent.layout.height)}>
|
onLayout={event => footerHeight.set(event.nativeEvent.layout.height)}>
|
||||||
{hasSession ? (
|
{hasSession ? (
|
||||||
<>
|
<>
|
||||||
<NavItem routeName="Home" href="/">
|
<NavItem routeName="Home" href="/" navItem="home">
|
||||||
{({isActive}) => {
|
{({isActive}) => {
|
||||||
const Icon = isActive ? HomeFilled : Home
|
const Icon = isActive ? HomeFilled : Home
|
||||||
return (
|
return (
|
||||||
@@ -108,7 +111,7 @@ export function BottomBarWeb() {
|
|||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
</NavItem>
|
</NavItem>
|
||||||
<NavItem routeName="Search" href="/search">
|
<NavItem routeName="Search" href="/search" navItem="search">
|
||||||
{({isActive}) => {
|
{({isActive}) => {
|
||||||
const Icon = isActive ? MagnifyingGlassFilled : MagnifyingGlass
|
const Icon = isActive ? MagnifyingGlassFilled : MagnifyingGlass
|
||||||
return (
|
return (
|
||||||
@@ -126,6 +129,7 @@ export function BottomBarWeb() {
|
|||||||
<NavItem
|
<NavItem
|
||||||
routeName="Messages"
|
routeName="Messages"
|
||||||
href="/messages"
|
href="/messages"
|
||||||
|
navItem="chat"
|
||||||
notificationCount={
|
notificationCount={
|
||||||
aa.flags.chatDisabled
|
aa.flags.chatDisabled
|
||||||
? undefined
|
? undefined
|
||||||
@@ -152,6 +156,7 @@ export function BottomBarWeb() {
|
|||||||
<NavItem
|
<NavItem
|
||||||
routeName="Notifications"
|
routeName="Notifications"
|
||||||
href="/notifications"
|
href="/notifications"
|
||||||
|
navItem="notifications"
|
||||||
notificationCount={notificationCountStr}>
|
notificationCount={notificationCountStr}>
|
||||||
{({isActive}) => {
|
{({isActive}) => {
|
||||||
const Icon = isActive ? BellFilled : Bell
|
const Icon = isActive ? BellFilled : Bell
|
||||||
@@ -174,6 +179,7 @@ export function BottomBarWeb() {
|
|||||||
})
|
})
|
||||||
: '/'
|
: '/'
|
||||||
}
|
}
|
||||||
|
navItem="profile"
|
||||||
onLongPress={onLongPressProfile}>
|
onLongPress={onLongPressProfile}>
|
||||||
{({isActive}) => (
|
{({isActive}) => (
|
||||||
<View style={styles.ctrlIconSizingWrapper}>
|
<View style={styles.ctrlIconSizingWrapper}>
|
||||||
@@ -257,12 +263,22 @@ const NavItem: React.FC<{
|
|||||||
children: (props: {isActive: boolean}) => React.ReactNode
|
children: (props: {isActive: boolean}) => React.ReactNode
|
||||||
href: string
|
href: string
|
||||||
routeName: string
|
routeName: string
|
||||||
|
navItem: NavItemValue
|
||||||
hasNew?: boolean
|
hasNew?: boolean
|
||||||
notificationCount?: string
|
notificationCount?: string
|
||||||
onLongPress?: () => void
|
onLongPress?: () => void
|
||||||
}> = ({children, href, routeName, hasNew, notificationCount, onLongPress}) => {
|
}> = ({
|
||||||
|
children,
|
||||||
|
href,
|
||||||
|
routeName,
|
||||||
|
navItem,
|
||||||
|
hasNew,
|
||||||
|
notificationCount,
|
||||||
|
onLongPress,
|
||||||
|
}) => {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const ax = useAnalytics()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const currentRoute = useNavigationState(state => {
|
const currentRoute = useNavigationState(state => {
|
||||||
if (!state) {
|
if (!state) {
|
||||||
@@ -271,6 +287,10 @@ const NavItem: React.FC<{
|
|||||||
return getCurrentRoute(state)
|
return getCurrentRoute(state)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const onBeforePress = useCallback(() => {
|
||||||
|
ax.metric('nav:click', {item: navItem, surface: 'bottomBar'})
|
||||||
|
}, [ax, navItem])
|
||||||
|
|
||||||
// Checks whether we're on someone else's profile
|
// Checks whether we're on someone else's profile
|
||||||
const isOnDifferentProfile =
|
const isOnDifferentProfile =
|
||||||
currentRoute.name === 'Profile' &&
|
currentRoute.name === 'Profile' &&
|
||||||
@@ -295,6 +315,7 @@ const NavItem: React.FC<{
|
|||||||
aria-role="link"
|
aria-role="link"
|
||||||
aria-label={routeName}
|
aria-label={routeName}
|
||||||
accessible={true}
|
accessible={true}
|
||||||
|
onBeforePress={onBeforePress}
|
||||||
onLongPress={onLongPress}>
|
onLongPress={onLongPress}>
|
||||||
{children({isActive})}
|
{children({isActive})}
|
||||||
{notificationCount ? (
|
{notificationCount ? (
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ import * as Menu from '#/components/Menu'
|
|||||||
import * as Prompt from '#/components/Prompt'
|
import * as Prompt from '#/components/Prompt'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {useAgeAssurance} from '#/ageAssurance'
|
import {useAgeAssurance} from '#/ageAssurance'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
|
import {type Events} from '#/analytics/metrics/types'
|
||||||
import {useActorStatus} from '#/features/liveNow'
|
import {useActorStatus} from '#/features/liveNow'
|
||||||
import {router} from '#/routes'
|
import {router} from '#/routes'
|
||||||
import {PlatformInfo} from '../../../../modules/expo-bluesky-swiss-army'
|
import {PlatformInfo} from '../../../../modules/expo-bluesky-swiss-army'
|
||||||
@@ -389,10 +391,20 @@ interface NavItemProps {
|
|||||||
}
|
}
|
||||||
label: string
|
label: string
|
||||||
minimal: boolean
|
minimal: boolean
|
||||||
|
navItem: Events['nav:click']['item']
|
||||||
}
|
}
|
||||||
function NavItem({count, hasNew, href, icons, label, minimal}: NavItemProps) {
|
function NavItem({
|
||||||
|
count,
|
||||||
|
hasNew,
|
||||||
|
href,
|
||||||
|
icons,
|
||||||
|
label,
|
||||||
|
minimal,
|
||||||
|
navItem,
|
||||||
|
}: NavItemProps) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
|
const ax = useAnalytics()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
|
||||||
const [pathName] = useMemo(() => router.matchPath(href), [href])
|
const [pathName] = useMemo(() => router.matchPath(href), [href])
|
||||||
@@ -412,6 +424,7 @@ function NavItem({count, hasNew, href, icons, label, minimal}: NavItemProps) {
|
|||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
const onPressWrapped = useCallback(
|
const onPressWrapped = useCallback(
|
||||||
(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
||||||
|
ax.metric('nav:click', {item: navItem, surface: 'leftNav'})
|
||||||
if (e.ctrlKey || e.metaKey || e.altKey) {
|
if (e.ctrlKey || e.metaKey || e.altKey) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -424,7 +437,7 @@ function NavItem({count, hasNew, href, icons, label, minimal}: NavItemProps) {
|
|||||||
navigation.navigate(screen, params, {pop: true})
|
navigation.navigate(screen, params, {pop: true})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[navigation, href, isCurrent],
|
[navigation, href, isCurrent, ax, navItem],
|
||||||
)
|
)
|
||||||
|
|
||||||
const Icon = isCurrent || isRelated ? icons.active : icons.inactive
|
const Icon = isCurrent || isRelated ? icons.active : icons.inactive
|
||||||
@@ -652,6 +665,7 @@ export function DesktopLeftNav({routeName}: {routeName: string}) {
|
|||||||
<NavItem
|
<NavItem
|
||||||
label={l`Home`}
|
label={l`Home`}
|
||||||
href="/"
|
href="/"
|
||||||
|
navItem="home"
|
||||||
minimal={leftNavMinimal}
|
minimal={leftNavMinimal}
|
||||||
icons={{
|
icons={{
|
||||||
inactive: HomeIcon,
|
inactive: HomeIcon,
|
||||||
@@ -661,6 +675,7 @@ export function DesktopLeftNav({routeName}: {routeName: string}) {
|
|||||||
<NavItem
|
<NavItem
|
||||||
label={l`Explore`}
|
label={l`Explore`}
|
||||||
href="/search"
|
href="/search"
|
||||||
|
navItem="search"
|
||||||
minimal={leftNavMinimal}
|
minimal={leftNavMinimal}
|
||||||
icons={{
|
icons={{
|
||||||
inactive: MagnifyingGlassIcon,
|
inactive: MagnifyingGlassIcon,
|
||||||
@@ -670,6 +685,7 @@ export function DesktopLeftNav({routeName}: {routeName: string}) {
|
|||||||
<NavItem
|
<NavItem
|
||||||
label={l`Notifications`}
|
label={l`Notifications`}
|
||||||
href="/notifications"
|
href="/notifications"
|
||||||
|
navItem="notifications"
|
||||||
minimal={leftNavMinimal}
|
minimal={leftNavMinimal}
|
||||||
count={numUnreadNotifications}
|
count={numUnreadNotifications}
|
||||||
icons={{
|
icons={{
|
||||||
@@ -680,6 +696,7 @@ export function DesktopLeftNav({routeName}: {routeName: string}) {
|
|||||||
<NavItem
|
<NavItem
|
||||||
label={l`Chat`}
|
label={l`Chat`}
|
||||||
href="/messages"
|
href="/messages"
|
||||||
|
navItem="chat"
|
||||||
minimal={leftNavMinimal}
|
minimal={leftNavMinimal}
|
||||||
count={
|
count={
|
||||||
aa.flags.chatDisabled ? undefined : numUnreadMessages.numUnread
|
aa.flags.chatDisabled ? undefined : numUnreadMessages.numUnread
|
||||||
@@ -693,6 +710,7 @@ export function DesktopLeftNav({routeName}: {routeName: string}) {
|
|||||||
<NavItem
|
<NavItem
|
||||||
label={l`Feeds`}
|
label={l`Feeds`}
|
||||||
href="/feeds"
|
href="/feeds"
|
||||||
|
navItem="feeds"
|
||||||
minimal={leftNavMinimal}
|
minimal={leftNavMinimal}
|
||||||
icons={{
|
icons={{
|
||||||
inactive: HashtagIcon,
|
inactive: HashtagIcon,
|
||||||
@@ -702,6 +720,7 @@ export function DesktopLeftNav({routeName}: {routeName: string}) {
|
|||||||
<NavItem
|
<NavItem
|
||||||
label={l`Lists`}
|
label={l`Lists`}
|
||||||
href="/lists"
|
href="/lists"
|
||||||
|
navItem="lists"
|
||||||
minimal={leftNavMinimal}
|
minimal={leftNavMinimal}
|
||||||
icons={{
|
icons={{
|
||||||
inactive: ListIcon,
|
inactive: ListIcon,
|
||||||
@@ -714,6 +733,7 @@ export function DesktopLeftNav({routeName}: {routeName: string}) {
|
|||||||
context: 'link to bookmarks screen',
|
context: 'link to bookmarks screen',
|
||||||
})}
|
})}
|
||||||
href="/saved"
|
href="/saved"
|
||||||
|
navItem="saved"
|
||||||
minimal={leftNavMinimal}
|
minimal={leftNavMinimal}
|
||||||
icons={{
|
icons={{
|
||||||
inactive: BookmarkIcon,
|
inactive: BookmarkIcon,
|
||||||
@@ -723,6 +743,7 @@ export function DesktopLeftNav({routeName}: {routeName: string}) {
|
|||||||
<NavItem
|
<NavItem
|
||||||
label={l`Profile`}
|
label={l`Profile`}
|
||||||
href={makeProfileLink(currentAccount!)}
|
href={makeProfileLink(currentAccount!)}
|
||||||
|
navItem="profile"
|
||||||
minimal={leftNavMinimal}
|
minimal={leftNavMinimal}
|
||||||
icons={{
|
icons={{
|
||||||
inactive: UserCircleIcon,
|
inactive: UserCircleIcon,
|
||||||
@@ -732,6 +753,7 @@ export function DesktopLeftNav({routeName}: {routeName: string}) {
|
|||||||
<NavItem
|
<NavItem
|
||||||
label={l`Settings`}
|
label={l`Settings`}
|
||||||
href="/settings"
|
href="/settings"
|
||||||
|
navItem="settings"
|
||||||
minimal={leftNavMinimal}
|
minimal={leftNavMinimal}
|
||||||
icons={{
|
icons={{
|
||||||
inactive: SettingsIcon,
|
inactive: SettingsIcon,
|
||||||
|
|||||||
Reference in New Issue
Block a user