feat: 添加post postHog加上
This commit is contained in:
@@ -35,7 +35,7 @@ const CustomArrow = ({ className, style, onClick, direction }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const HotEvents = ({ events, onPageChange }) => {
|
const HotEvents = ({ events, onPageChange, onEventClick }) => {
|
||||||
const [currentSlide, setCurrentSlide] = useState(0);
|
const [currentSlide, setCurrentSlide] = useState(0);
|
||||||
const { isOpen: isModalOpen, onOpen: onModalOpen, onClose: onModalClose } = useDisclosure();
|
const { isOpen: isModalOpen, onOpen: onModalOpen, onClose: onModalClose } = useDisclosure();
|
||||||
const [modalEvent, setModalEvent] = useState(null);
|
const [modalEvent, setModalEvent] = useState(null);
|
||||||
@@ -67,6 +67,17 @@ const HotEvents = ({ events, onPageChange }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleCardClick = (event) => {
|
const handleCardClick = (event) => {
|
||||||
|
// 🎯 追踪热点事件点击
|
||||||
|
if (onEventClick) {
|
||||||
|
onEventClick({
|
||||||
|
eventId: event.id,
|
||||||
|
eventTitle: event.title,
|
||||||
|
importance: event.importance,
|
||||||
|
source: 'hot_events_section',
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setModalEvent(event);
|
setModalEvent(event);
|
||||||
onModalOpen();
|
onModalOpen();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ import HotEvents from './HotEvents';
|
|||||||
/**
|
/**
|
||||||
* 热点事件区域组件
|
* 热点事件区域组件
|
||||||
* @param {Array} events - 热点事件列表
|
* @param {Array} events - 热点事件列表
|
||||||
|
* @param {Function} onEventClick - 事件点击追踪回调
|
||||||
*/
|
*/
|
||||||
const HotEventsSection = ({ events }) => {
|
const HotEventsSection = ({ events, onEventClick }) => {
|
||||||
const cardBg = useColorModeValue('white', 'gray.800');
|
const cardBg = useColorModeValue('white', 'gray.800');
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
const [totalPages, setTotalPages] = useState(1);
|
const [totalPages, setTotalPages] = useState(1);
|
||||||
@@ -55,7 +56,11 @@ const HotEventsSection = ({ events }) => {
|
|||||||
)}
|
)}
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardBody py={0} px={4}>
|
<CardBody py={0} px={4}>
|
||||||
<HotEvents events={events} onPageChange={handlePageChange} />
|
<HotEvents
|
||||||
|
events={events}
|
||||||
|
onPageChange={handlePageChange}
|
||||||
|
onEventClick={onEventClick}
|
||||||
|
/>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ const UnifiedSearchBox = ({
|
|||||||
popularKeywords = [],
|
popularKeywords = [],
|
||||||
filters = {},
|
filters = {},
|
||||||
mode, // 显示模式(如:vertical, horizontal 等)
|
mode, // 显示模式(如:vertical, horizontal 等)
|
||||||
pageSize // 每页显示数量
|
pageSize, // 每页显示数量
|
||||||
|
trackingFunctions = {} // PostHog 追踪函数集合
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
// 其他状态
|
// 其他状态
|
||||||
@@ -259,6 +260,16 @@ const UnifiedSearchBox = ({
|
|||||||
name: stockInfo.name
|
name: stockInfo.name
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 🎯 追踪股票点击
|
||||||
|
if (trackingFunctions.trackRelatedStockClicked) {
|
||||||
|
trackingFunctions.trackRelatedStockClicked({
|
||||||
|
stockCode: stockInfo.code,
|
||||||
|
stockName: stockInfo.name,
|
||||||
|
source: 'search_box_autocomplete',
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 更新输入框显示
|
// 更新输入框显示
|
||||||
setInputValue(`${stockInfo.code} ${stockInfo.name}`);
|
setInputValue(`${stockInfo.code} ${stockInfo.name}`);
|
||||||
|
|
||||||
@@ -289,6 +300,15 @@ const UnifiedSearchBox = ({
|
|||||||
// 转换为逗号分隔字符串传给后端(空数组表示"全部")
|
// 转换为逗号分隔字符串传给后端(空数组表示"全部")
|
||||||
const importanceStr = value.length === 0 ? 'all' : value.join(',');
|
const importanceStr = value.length === 0 ? 'all' : value.join(',');
|
||||||
|
|
||||||
|
// 🎯 追踪筛选操作
|
||||||
|
if (trackingFunctions.trackNewsFilterApplied) {
|
||||||
|
trackingFunctions.trackNewsFilterApplied({
|
||||||
|
filterType: 'importance',
|
||||||
|
filterValue: importanceStr,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 立即触发搜索
|
// 立即触发搜索
|
||||||
const params = buildFilterParams({ importance: importanceStr });
|
const params = buildFilterParams({ importance: importanceStr });
|
||||||
logger.debug('UnifiedSearchBox', '重要性改变,立即触发搜索', params);
|
logger.debug('UnifiedSearchBox', '重要性改变,立即触发搜索', params);
|
||||||
@@ -309,6 +329,15 @@ const UnifiedSearchBox = ({
|
|||||||
debouncedSearchRef.current.cancel();
|
debouncedSearchRef.current.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🎯 追踪排序操作
|
||||||
|
if (trackingFunctions.trackNewsSorted) {
|
||||||
|
trackingFunctions.trackNewsSorted({
|
||||||
|
sortBy: value,
|
||||||
|
previousSortBy: sort,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 立即触发搜索
|
// 立即触发搜索
|
||||||
const params = buildFilterParams({ sort: value });
|
const params = buildFilterParams({ sort: value });
|
||||||
logger.debug('UnifiedSearchBox', '排序改变,立即触发搜索', params);
|
logger.debug('UnifiedSearchBox', '排序改变,立即触发搜索', params);
|
||||||
@@ -328,6 +357,15 @@ const UnifiedSearchBox = ({
|
|||||||
debouncedSearchRef.current.cancel();
|
debouncedSearchRef.current.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🎯 追踪行业筛选
|
||||||
|
if (trackingFunctions.trackNewsFilterApplied) {
|
||||||
|
trackingFunctions.trackNewsFilterApplied({
|
||||||
|
filterType: 'industry',
|
||||||
|
filterValue: value?.[value.length - 1] || '',
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 立即触发搜索
|
// 立即触发搜索
|
||||||
const params = buildFilterParams({
|
const params = buildFilterParams({
|
||||||
industry_code: value?.[value.length - 1] || ''
|
industry_code: value?.[value.length - 1] || ''
|
||||||
@@ -347,6 +385,15 @@ const UnifiedSearchBox = ({
|
|||||||
debouncedSearchRef.current.cancel();
|
debouncedSearchRef.current.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🎯 追踪热门关键词点击
|
||||||
|
if (trackingFunctions.trackNewsSearched) {
|
||||||
|
trackingFunctions.trackNewsSearched({
|
||||||
|
searchQuery: keyword,
|
||||||
|
searchType: 'popular_keyword',
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const params = buildFilterParams({
|
const params = buildFilterParams({
|
||||||
q: keyword,
|
q: keyword,
|
||||||
industry_code: ''
|
industry_code: ''
|
||||||
@@ -363,6 +410,16 @@ const UnifiedSearchBox = ({
|
|||||||
if (!timeConfig) {
|
if (!timeConfig) {
|
||||||
// 清空筛选
|
// 清空筛选
|
||||||
setTradingTimeRange(null);
|
setTradingTimeRange(null);
|
||||||
|
|
||||||
|
// 🎯 追踪时间筛选清空
|
||||||
|
if (trackingFunctions.trackNewsFilterApplied) {
|
||||||
|
trackingFunctions.trackNewsFilterApplied({
|
||||||
|
filterType: 'time_range',
|
||||||
|
filterValue: 'cleared',
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const params = buildFilterParams({
|
const params = buildFilterParams({
|
||||||
start_date: '',
|
start_date: '',
|
||||||
end_date: '',
|
end_date: '',
|
||||||
@@ -389,6 +446,16 @@ const UnifiedSearchBox = ({
|
|||||||
|
|
||||||
setTradingTimeRange({ ...params, label, key });
|
setTradingTimeRange({ ...params, label, key });
|
||||||
|
|
||||||
|
// 🎯 追踪时间筛选
|
||||||
|
if (trackingFunctions.trackNewsFilterApplied) {
|
||||||
|
trackingFunctions.trackNewsFilterApplied({
|
||||||
|
filterType: 'time_range',
|
||||||
|
filterValue: label,
|
||||||
|
timeRangeType: type,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 立即触发搜索
|
// 立即触发搜索
|
||||||
const searchParams = buildFilterParams({ ...params, mode });
|
const searchParams = buildFilterParams({ ...params, mode });
|
||||||
logger.debug('UnifiedSearchBox', '交易时段筛选变化,立即触发搜索', {
|
logger.debug('UnifiedSearchBox', '交易时段筛选变化,立即触发搜索', {
|
||||||
@@ -411,6 +478,16 @@ const UnifiedSearchBox = ({
|
|||||||
industry_code: ''
|
industry_code: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 🎯 追踪搜索操作
|
||||||
|
if (trackingFunctions.trackNewsSearched && inputValue) {
|
||||||
|
trackingFunctions.trackNewsSearched({
|
||||||
|
searchQuery: inputValue,
|
||||||
|
searchType: 'main_search',
|
||||||
|
filters: params,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
logger.debug('UnifiedSearchBox', '主搜索触发', {
|
logger.debug('UnifiedSearchBox', '主搜索触发', {
|
||||||
inputValue,
|
inputValue,
|
||||||
params
|
params
|
||||||
@@ -513,6 +590,15 @@ const UnifiedSearchBox = ({
|
|||||||
setImportance([]); // 改为空数组
|
setImportance([]); // 改为空数组
|
||||||
setTradingTimeRange(null); // 清空交易时段筛选
|
setTradingTimeRange(null); // 清空交易时段筛选
|
||||||
|
|
||||||
|
// 🎯 追踪筛选重置
|
||||||
|
if (trackingFunctions.trackNewsFilterApplied) {
|
||||||
|
trackingFunctions.trackNewsFilterApplied({
|
||||||
|
filterType: 'reset',
|
||||||
|
filterValue: 'all_filters_cleared',
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 输出重置后的完整参数
|
// 输出重置后的完整参数
|
||||||
const resetParams = {
|
const resetParams = {
|
||||||
q: '',
|
q: '',
|
||||||
|
|||||||
@@ -105,7 +105,10 @@ const Community = () => {
|
|||||||
{/* 主内容区域 */}
|
{/* 主内容区域 */}
|
||||||
<Container ref={containerRef} maxW="1600px" pt={6} pb={8}>
|
<Container ref={containerRef} maxW="1600px" pt={6} pb={8}>
|
||||||
{/* 热点事件区域 */}
|
{/* 热点事件区域 */}
|
||||||
<HotEventsSection events={hotEvents} />
|
<HotEventsSection
|
||||||
|
events={hotEvents}
|
||||||
|
onEventClick={communityEvents.trackNewsArticleClicked}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* 实时要闻·动态追踪 - 横向滚动 */}
|
{/* 实时要闻·动态追踪 - 横向滚动 */}
|
||||||
<DynamicNewsCard
|
<DynamicNewsCard
|
||||||
@@ -116,6 +119,14 @@ const Community = () => {
|
|||||||
onSearch={updateFilters}
|
onSearch={updateFilters}
|
||||||
onEventClick={handleEventClick}
|
onEventClick={handleEventClick}
|
||||||
onViewDetail={handleViewDetail}
|
onViewDetail={handleViewDetail}
|
||||||
|
trackingFunctions={{
|
||||||
|
trackNewsArticleClicked: communityEvents.trackNewsArticleClicked,
|
||||||
|
trackNewsDetailOpened: communityEvents.trackNewsDetailOpened,
|
||||||
|
trackNewsFilterApplied: communityEvents.trackNewsFilterApplied,
|
||||||
|
trackNewsSorted: communityEvents.trackNewsSorted,
|
||||||
|
trackNewsSearched: communityEvents.trackNewsSearched,
|
||||||
|
trackRelatedStockClicked: communityEvents.trackRelatedStockClicked,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Reference in New Issue
Block a user