feat: 集成导航上报
This commit is contained in:
@@ -51,6 +51,7 @@ import SubscriptionButton from '../Subscription/SubscriptionButton';
|
|||||||
import SubscriptionModal from '../Subscription/SubscriptionModal';
|
import SubscriptionModal from '../Subscription/SubscriptionModal';
|
||||||
import { CrownIcon, TooltipContent } from '../Subscription/CrownTooltip';
|
import { CrownIcon, TooltipContent } from '../Subscription/CrownTooltip';
|
||||||
import InvestmentCalendar from '../../views/Community/components/InvestmentCalendar';
|
import InvestmentCalendar from '../../views/Community/components/InvestmentCalendar';
|
||||||
|
import { useNavigationEvents } from '../../hooks/useNavigationEvents';
|
||||||
|
|
||||||
/** 二级导航栏组件 - 显示当前一级菜单下的所有二级菜单项 */
|
/** 二级导航栏组件 - 显示当前一级菜单下的所有二级菜单项 */
|
||||||
const SecondaryNav = ({ showCompletenessAlert }) => {
|
const SecondaryNav = ({ showCompletenessAlert }) => {
|
||||||
@@ -61,6 +62,9 @@ const SecondaryNav = ({ showCompletenessAlert }) => {
|
|||||||
// ⚠️ 必须在组件顶层调用所有Hooks(不能在JSX中调用)
|
// ⚠️ 必须在组件顶层调用所有Hooks(不能在JSX中调用)
|
||||||
const borderColorValue = useColorModeValue('gray.200', 'gray.600');
|
const borderColorValue = useColorModeValue('gray.200', 'gray.600');
|
||||||
|
|
||||||
|
// 🎯 初始化导航埋点Hook
|
||||||
|
const navEvents = useNavigationEvents({ component: 'secondary_nav' });
|
||||||
|
|
||||||
// 定义二级导航结构
|
// 定义二级导航结构
|
||||||
const secondaryNavConfig = {
|
const secondaryNavConfig = {
|
||||||
'/community': {
|
'/community': {
|
||||||
@@ -162,7 +166,11 @@ const SecondaryNav = ({ showCompletenessAlert }) => {
|
|||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
key={index}
|
key={index}
|
||||||
onClick={() => navigate(item.path)}
|
onClick={() => {
|
||||||
|
// 🎯 追踪侧边栏菜单点击
|
||||||
|
navEvents.trackSidebarMenuClicked(item.label, item.path, 2, false);
|
||||||
|
navigate(item.path);
|
||||||
|
}}
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
bg={isActive ? 'blue.50' : 'transparent'}
|
bg={isActive ? 'blue.50' : 'transparent'}
|
||||||
@@ -313,6 +321,9 @@ const NavItems = ({ isAuthenticated, user }) => {
|
|||||||
// ⚠️ 必须在组件顶层调用所有Hooks(不能在JSX中调用)
|
// ⚠️ 必须在组件顶层调用所有Hooks(不能在JSX中调用)
|
||||||
const contactTextColor = useColorModeValue('gray.500', 'gray.300');
|
const contactTextColor = useColorModeValue('gray.500', 'gray.300');
|
||||||
|
|
||||||
|
// 🎯 初始化导航埋点Hook
|
||||||
|
const navEvents = useNavigationEvents({ component: 'top_nav' });
|
||||||
|
|
||||||
// 辅助函数:判断导航项是否激活
|
// 辅助函数:判断导航项是否激活
|
||||||
const isActive = useCallback((paths) => {
|
const isActive = useCallback((paths) => {
|
||||||
return paths.some(path => location.pathname.includes(path));
|
return paths.some(path => location.pathname.includes(path));
|
||||||
@@ -337,7 +348,11 @@ const NavItems = ({ isAuthenticated, user }) => {
|
|||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuList minW="260px" p={2}>
|
<MenuList minW="260px" p={2}>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={() => navigate('/community')}
|
onClick={() => {
|
||||||
|
// 🎯 追踪菜单项点击
|
||||||
|
navEvents.trackMenuItemClicked('事件中心', 'dropdown', '/community');
|
||||||
|
navigate('/community');
|
||||||
|
}}
|
||||||
borderRadius="md"
|
borderRadius="md"
|
||||||
bg={location.pathname.includes('/community') ? 'blue.50' : 'transparent'}
|
bg={location.pathname.includes('/community') ? 'blue.50' : 'transparent'}
|
||||||
borderLeft={location.pathname.includes('/community') ? '3px solid' : 'none'}
|
borderLeft={location.pathname.includes('/community') ? '3px solid' : 'none'}
|
||||||
@@ -353,7 +368,11 @@ const NavItems = ({ isAuthenticated, user }) => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={() => navigate('/concepts')}
|
onClick={() => {
|
||||||
|
// 🎯 追踪菜单项点击
|
||||||
|
navEvents.trackMenuItemClicked('概念中心', 'dropdown', '/concepts');
|
||||||
|
navigate('/concepts');
|
||||||
|
}}
|
||||||
borderRadius="md"
|
borderRadius="md"
|
||||||
bg={location.pathname.includes('/concepts') ? 'blue.50' : 'transparent'}
|
bg={location.pathname.includes('/concepts') ? 'blue.50' : 'transparent'}
|
||||||
borderLeft={location.pathname.includes('/concepts') ? '3px solid' : 'none'}
|
borderLeft={location.pathname.includes('/concepts') ? '3px solid' : 'none'}
|
||||||
@@ -489,6 +508,9 @@ export default function HomeNavbar() {
|
|||||||
const brandHover = useColorModeValue('blue.600', 'blue.300');
|
const brandHover = useColorModeValue('blue.600', 'blue.300');
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
|
// 🎯 初始化导航埋点Hook
|
||||||
|
const navEvents = useNavigationEvents({ component: 'main_navbar' });
|
||||||
|
|
||||||
// ⚡ 提取 userId 为独立变量,避免 user 对象引用变化导致无限循环
|
// ⚡ 提取 userId 为独立变量,避免 user 对象引用变化导致无限循环
|
||||||
const userId = user?.id;
|
const userId = user?.id;
|
||||||
const prevUserIdRef = React.useRef(userId);
|
const prevUserIdRef = React.useRef(userId);
|
||||||
@@ -882,7 +904,11 @@ export default function HomeNavbar() {
|
|||||||
color={brandText}
|
color={brandText}
|
||||||
cursor="pointer"
|
cursor="pointer"
|
||||||
_hover={{ color: brandHover }}
|
_hover={{ color: brandHover }}
|
||||||
onClick={() => navigate('/home')}
|
onClick={() => {
|
||||||
|
// 🎯 追踪Logo点击
|
||||||
|
navEvents.trackLogoClicked();
|
||||||
|
navigate('/home');
|
||||||
|
}}
|
||||||
style={{ minWidth: isMobile ? '100px' : '140px' }}
|
style={{ minWidth: isMobile ? '100px' : '140px' }}
|
||||||
noOfLines={1}
|
noOfLines={1}
|
||||||
>
|
>
|
||||||
@@ -912,7 +938,13 @@ export default function HomeNavbar() {
|
|||||||
<IconButton
|
<IconButton
|
||||||
aria-label="切换主题"
|
aria-label="切换主题"
|
||||||
icon={colorMode === 'light' ? <MoonIcon /> : <SunIcon />}
|
icon={colorMode === 'light' ? <MoonIcon /> : <SunIcon />}
|
||||||
onClick={toggleColorMode}
|
onClick={() => {
|
||||||
|
// 🎯 追踪主题切换
|
||||||
|
const fromTheme = colorMode;
|
||||||
|
const toTheme = colorMode === 'light' ? 'dark' : 'light';
|
||||||
|
navEvents.trackThemeChanged(fromTheme, toTheme);
|
||||||
|
toggleColorMode();
|
||||||
|
}}
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
minW={{ base: '36px', md: '40px' }}
|
minW={{ base: '36px', md: '40px' }}
|
||||||
|
|||||||
Reference in New Issue
Block a user